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
| Try
con.Open()
Dim str2 As String
ds.Clear()
Dim str1 As String = " select * from personnel where "
If (Cservice.Text <> String.Empty) Then
str1 = str1 & " service = '" & Cservice.Text & "' and "
End If
If (Cgrade.Text <> String.Empty) Then
str1 = str1 & " grade = '" & Cgrade.Text & "' and "
End If
If (Cstatut.Text <> String.Empty) Then
str1 = str1 & " statut = '" & Cstatut.Text & "' and "
End If
If (Tcin.Text <> String.Empty) Then
str1 = str1 & " cin = '" & Tcin.Text & "' and "
End If
If (Tmlle.Text <> String.Empty) Then
str1 = str1 & " mlle_drpp = '" & Tmlle.Text & "' and "
End If
If (DTP1.Text <> String.Empty And DTP2.Text <> String.Empty) Then
str1 = str1 & " date_naiss between #" & DTP1.Text & "# and #" & DTP2.Text & "# and "
End If
If (DTP3.Text <> String.Empty And DTP4.Text <> String.Empty) Then
str1 = str1 & " date_recrut between #" & DTP3.Text & "# and #" & DTP4.Text & "# and "
End If
str2 = Mid(str1, 1, Len(str1) - 6)
cmd.CommandText = str2
dr = cmd.ExecuteReader
dt = New DataTable
dt.Load(dr)
DataGridView1.DataSource = dt
dr.Close()
con.Close()
'Dim i As Integer
'If i > dtt.Rows.Count - 1 Then
' MsgBox("Désolé pas de données")
'End If
Catch ex As Exception
MsgBox(ex.Message)
End Try |
Partager