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
| Public Class NewClient
Public Const chainedeconnexion As String = "Provider=SQLNCLI10;Data Source=BADR;Integrated Security=SSPI;Initial Catalog=TPSMI6"
Public DBConnexion As New System.Data.OleDb.OleDbConnection(chainedeconnexion)
Dim InsertCommand As New OleDb.OleDbCommand()
Private Sub NewClient_Load(sender As Object, e As EventArgs) Handles MyBase.Load
InsertCommand.Connection = DBConnexion
End Sub
'Boutton Ajouter
Private Sub BtnNewClient_Click(sender As Object, e As EventArgs) Handles BtnNewClient.Click
If TxtNomClient.Text <> "" And TxtAdrClient.Text <> "" And TxtVilClient.Text <> "" And TxtTelClient.Text <> "" Then
If Len(TxtTelClient.Text) <> 10 Or Mid(TxtTelClient.Text, 1, 2) <> "06" Then
MessageBox.Show("Veuillez entrer un numéro de téléphone valide !", "ERREUR", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
DBConnexion.Open()
InsertCommand.CommandText = "insert into Tclient(NumCli,NomCli,AdrCli,VilCli,TelCli) select count(*)+1,'" + TxtNomClient.Text + "','" + TxtAdrClient.Text + "','" + TxtVilClient.Text + "','" + TxtTelClient.Text + "' from Tclient"
InsertCommand.ExecuteNonQuery()
MessageBox.Show("Nouveau Client Ajouté !", "Nouveau Client", MessageBoxButtons.OK, MessageBoxIcon.Information)
DBConnexion.Close()
Me.Close()
End If
End Sub |
Partager