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
|
Dim existe As Boolean = False
con.ConnectionString = "Data Source=MEHDI-PC\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=eco"
d = CDate(MaskedTextBox1.Text)
con.Open()
cmd = New SqlCommand("select N_CPT_POS from COMPTEURS;", con)
da = cmd.ExecuteReader
While da.Read Or Not existe
If da(0) = Val(TextBox13.Text) Then
MsgBox("Un compteur avec le même numéro existe déja!", MsgBoxStyle.Critical)
existe = True
End If
End While
da.Close()
If Not existe Then
Try
com = New SqlCommand("insert into COMPTEURS(N_ORD_ECO,SOUS_QUART,CIL,QUART,NOM_CLT,AV_ACC,PORTE,RUE,N_CPT_DEPO,N_SERIE,DER_IND_LU,TP_CAL,MAR_DEPO,N_CPT_POS,IND_DEPO,DATE_DEPO,CAL_POS,MAR_POS) values('" & ComboBox1.SelectedItem.ToString & "','" & TextBox1.Text & "','" & Val(TextBox2.Text) & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & Val(TextBox6.Text) & "','" & TextBox7.Text & "','" & Val(TextBox8.Text) & "','" & Val(TextBox9.Text) & "','" & Val(TextBox10.Text) & "','" & Val(TextBox11.Text) & "','" & TextBox12.Text & "','" & Val(TextBox13.Text) & "','" & Val(TextBox14.Text) & "','" & d & "','" & Val(TextBox16.Text) & "','" & TextBox17.Text & "''" & RichTextBox1.Text & "');", con)
com.ExecuteNonQuery()
MsgBox("Compteur ajouté avec succés", MsgBoxStyle.OkOnly)
Catch ex As Exception
MsgBox("Erreur d'insertion des données:" & ex.ToString)
End Try
End If
con.Close() |
Partager