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
| import System.Data.SqlClient
Public Class ENREGISTREMENTS_DES_VISITEUR
Public con As SqlConnection
Public Sub connexion()
Dim g As String = "Data Source=STLDB3\STLDB;Initial Catalog=VISITEURS;Integrated Security=True"
con = New SqlConnection(g)
con.Open()
End Sub
Public Sub exection(ByVal sql As String)
Dim e As SqlCommand = New SqlCommand
connexion()
e.Connection = con
e.CommandType = CommandType.Text
e.CommandText = sql
e.ExecuteNonQuery()
e.Dispose()
con.Close()
MsgBox("opération effectué avec succeés")
End Sub
Private Sub charger()
connexion()
Dim table As New DataTable
Dim dtr3 As New SqlDataAdapter("select * FROM visiteur", con)
dtr3.Fill(table)
DataGridView1.DataSource = table
End Sub
Private Sub couleurdatagrid()
With Me.DataGridView1
.RowsDefaultCellStyle.BackColor = Color.DeepSkyBlue
.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige
End With
End Sub
Private Sub enregistrer()
Dim enregistrer As String
enregistrer = "INSERT INTO visiteur (Numéro,Noms,Organisation ,Sexe,Télephone,Nature_Pièce,Numéro_Carte) VALUES ('" & TextBox5.Text.ToString & "','" & TextBox1.Text.ToString & "','" & TextBox2.Text.ToString & "','" & ComboBox1.Text.ToString & "','" & TextBox3.Text.ToString & "','" & ComboBox2.Text.ToString & "','" & TextBox4.Text.ToString & "')"
exection(enregistrer)
MsgBox("visiteur Enregistrer")
TextBox5.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
ComboBox1.Text = ""
TextBox3.Text = ""
TextBox2.Text = ""
TextBox4.Text = ""
End Sub
Private Sub modification()
Dim modif As String
modif = " Update visiteur SET Numéro ='" & TextBox5.Text.ToString & "',Noms ='" & TextBox1.Text.ToString & "',Organisation ='" & TextBox2.Text.ToString & "',Sexe ='" & ComboBox1.Text.ToString & "',Télephone ='" & TextBox3.Text.ToString & "',Nature Pièce ='" & ComboBox2.Text.ToString & "' ,Numéro Carte ='" & TextBox4.Text.ToString & "' WHERE Numéro ='" & TextBox5.Text.ToString & "'"
exection(modif)
MsgBox("la modification est effectuer avec succes")
End Sub
Private Sub surprimer()
Dim sup As String
sup = "DELETE FROM WHERE Numéro ='" & TextBox5.Text & "'"
exection(sup)
TextBox5.Text = ""
End Sub
Private Sub rechercher()
If TextBox5.Text = "" Then
MsgBox("le zone de recherche est vide")
Else
connexion()
Dim table As New DataTable
Dim dtr2 As New SqlDataAdapter("Select * FROM visiteur where Numéro ='" + TextBox5.Text + "'", con)
dtr2.Fill(table)
DataGridView1.DataSource = table
'se deconnecter()
End If |
Partager