1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
Public jour, jour1, mois, mois1, annee, annee1 As String
Public dateformate, dateformate1 As String
Sub formatdate() 'Formate la date pour l'adapter au modèle de notre moteur MySQL
jour = Form1.DtpDebut.Value.Day
mois = Form1.DtpDebut.Value.Month
annee = Form1.DtpDebut.Value.Year
dateformate = annee & "/" & mois & "/" & jour
jour1 = Form1.DtpFin.Value.Day
mois1 = Form1.DtpFin.Value.Month
annee1 = Form1.DtpFin.Value.Year
dateformate1 = annee1 & "/" & mois1 & "/" & jour1
End Sub
Public Sub BD_Recherche(ByVal lstview As ListView)
WaitBar.ProgressBar1.Minimum = 0
Dim i As Integer
Dim myCommand1 As New MySqlCommand
Dim MyAdapter1 As New MySqlDataAdapter
Dim myDataTable1 As New DataTable
Dim strQuery1 As String
Dim strCountQuery1 As String
Dim cResulat1 As Integer = 0
Try
formatdate()
If Form1.CmbExpediteur.Text = "ALL" And Form1.CmbStatut.Text = "ALL" Then
strQuery1 = "select * from message where DateMsg >='" & Form1.DtpDebut.Text & "' and DateMsg <='" & Form1.DtpFin.Text & "';"
strCountQuery1 = "select count(*) from message where DateMsg >='" & Form1.DtpDebut.Text & "' and DateMsg <='" & Form1.DtpFin.Text & "';"
ElseIf Form1.CmbExpediteur.Text = "ALL" Then
strQuery1 = "select * from message where DateMsg <='" & Form1.DtpFin.Text & "' and DateMsg >='" & Form1.DtpDebut.Text _
& "' and DLR='" & Form1.CmbStatut.Text & "';"
strCountQuery1 = "select count(*) from message where DateMsg <='" & Form1.DtpFin.Text & "' and DateMsg >='" & Form1.DtpDebut.Text _
& "' and DLR='" & Form1.CmbStatut.Text & "';"
ElseIf Form1.CmbStatut.Text = "ALL" Then
strQuery1 = "select * from message where DateMsg <='" & Form1.DtpFin.Text & "' and DateMsg >='" & Form1.DtpDebut.Text _
& "' and Expediteur='" & Form1.CmbExpediteur.Text & "';"
strCountQuery1 = "select count(*) from message where DateMsg <='" & Form1.DtpFin.Text & "' and DateMsg >='" & Form1.DtpDebut.Text _
& "' and Expediteur='" & Form1.CmbExpediteur.Text & "';"
Else
strQuery1 = "select * from message where DateMsg <='" & Form1.DtpFin.Text & "' and DateMsg >='" & Form1.DtpDebut.Text _
& "' and Expediteur='" & Form1.CmbExpediteur.Text & "' and DLR='" & Form1.CmbStatut.Text & "';"
strCountQuery1 = "select count(*) from message where DateMsg <='" & Form1.DtpFin.Text & "' and DateMsg >='" & Form1.DtpDebut.Text _
& "' and Expediteur='" & Form1.CmbExpediteur.Text & "' and DLR='" & Form1.CmbStatut.Text & "';"
End If
myCommand1.Connection = conexion
myCommand1.CommandText = strQuery1
MyAdapter1.SelectCommand = myCommand1
Dim CountQuery1 As New MySqlCommand(strCountQuery1, conexion)
cResulat1 = CountQuery1.ExecuteScalar
WaitBar.ProgressBar1.Maximum = cResulat1
Dim myLine As ListViewItem
Dim j As Double = 0
MyAdapter1.Fill(myDataTable1)
If cResulat1 > 0 Then
'cResultat est la variable qui me retourne la valeur du compte que je fait avec CountQuery1.ExecuteScalar
For i = 0 To myDataTable1.Rows.Count - 1
WaitBar.Show()
WaitBar.Refresh()
myLine = lstview.Items.Insert(0, myDataTable1.Rows(i)("DateMsg"))
myLine.SubItems.AddRange(New String() {myDataTable1.Rows(i)("HeureMsg").ToString, "SMS", myDataTable1.Rows(i)("FID"), myDataTable1.Rows(i)("Expediteur"), _
myDataTable1.Rows(i)("Destinataire"), myDataTable1.Rows(i)("Taille"), myDataTable1.Rows(i)("DLR")})
WaitBar.ProgressBar1.Value = i
Thread.Sleep(10)
Next i
WaitBar.Close()
Else
MsgBox("Aucun enregistrement trouvé !", MsgBoxStyle.Information)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub |
Partager