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
| Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Click
Me.DataGridView2.ReadOnly = False
Dim nb As Integer = Me.DataGridView2.RowCount
Dim buffer1 As String = Me.DataGridView2.Rows(nb - 2).Cells(0).Value.ToString
Dim buffer2 As String = Me.DataGridView2.Rows(nb - 2).Cells(1).Value
Dim buffer3 As Date = Me.DataGridView2.Rows(nb - 2).Cells(2).Value
Dim buffer4 As Integer = Me.DataGridView2.Rows(nb - 2).Cells(4).Value
Dim ConnectionString As String = "Data Source=SM65CVDF;Initial Catalog=GESTION;Integrated Security=True"
Dim con As New SqlConnection(ConnectionString)
con.Open()
Dim sqlNum As String = "select * from amine_alerte_histo"
Dim cmd As New SqlCommand(sqlNum, con)
Dim reader As SqlDataReader = cmd.ExecuteReader()
Dim bool As Boolean = False
reader.Read()
'Me.Label1.Text = reader("NumeroOsmose").ToString()
Dim mohamed As String
mohamed = reader("NumeroOsmose").ToString
MsgBox(buffer1 + " " + reader("NumeroOsmose").ToString)
If (String.Compare(buffer1, mohamed) = 0) Then
MsgBox("youpi")
End If
While reader.Read()
If (String.Compare(buffer1, reader("NumeroOsmose").ToString) = 0) Then
bool = True
MsgBox("existe déjà")
GoTo m1
End If
End While
If (bool = False) Then
If Me.Validate Then
'Dim ConnectionString1 As String = "Data Source=SM65CVDF;Initial Catalog=GESTION;Integrated Security=True"
'Dim con As New SqlConnection(ConnectionString1)
'Dim cmd As SqlCommand = con.CreateCommand()
'cmd.CommandText = "select"
Me.AMINEALERTESBindingSource1.EndEdit()
Me.AMINE_ALERTESTableAdapter1.Update(Me.GESTIONDataSet5.AMINE_ALERTES)
Else
System.Windows.Forms.MessageBox.Show(Me, "Validation errors occurred.", "Save", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning)
End If
End If
m1: reader.Close()
MsgBox("confimez-vous avoir traité cette alerte")
End Sub |
Partager