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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
Imports accées_métier
Public Class Gestion_comptes
Dim a As accées_métier.admin
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
'Chaîne de connexion
Dim connectString As String = "Data Source=SARA\GMAO;Initial Catalog=GMAO;User ID=sa; password = 21009324"
'Objet connection
Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection(connectString)
'Ouverture
connection.Open()
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand("SELECT nom,service,login,mdp,tel,fax,email FROM administrateur where id_admin ='" & TextBox1.Text & "'", connection)
Dim reader As SqlClient.SqlDataReader = command.ExecuteReader
While reader.Read
TextBox2.Text = reader.GetString(0)
TextBox3.Text = reader.GetString(1)
TextBox4.Text = reader.GetString(2)
TextBox5.Text = reader.GetString(3)
TextBox6.Text = reader.GetInt32(4)
TextBox7.Text = reader.GetInt32(5)
TextBox8.Text = reader.GetString(6)
End While
MsgBox("id_administrateur introuvable", MsgBoxStyle.Exclamation)
reader.Close()
'-------------------------------------------------------------------------------------
' Fermeture()
Catch ex As Exception
System.Diagnostics.Debug.WriteLine("erreur")
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
'Chaîne de connexion
Dim connectString As String = "Data Source=SARA\GMAO;Initial Catalog=GMAO;User ID=sa; password = 21009324"
'Objet connection
Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection(connectString)
'--------------------------------------------------------------------------------------
'Ouverture
connection.Open()
'--------------------------------------------------------------------------------------
Dim strRequete As String = "INSERT INTO administrateur VALUES ('" & TextBox9.Text & " ',' " & TextBox10.Text & " ' , ' " & TextBox11.Text & " ' ,' " & TextBox12.Text & " ' , ' " & TextBox13.Text & " ', " & TextBox14.Text & ", " & TextBox15.Text & ", ' " & TextBox16.Text & " ' )"
Dim Command As New SqlClient.SqlCommand(strRequete, connection)
Dim affectedrows As Integer = Command.ExecuteNonQuery()
MsgBox("Nombre de lignes affectées {0}", affectedrows)
'Fermeture
connection.Close()
Catch ex As Exception
MsgBox("données non ajoutées", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Try
'Chaîne de connexion
Dim connectString As String = "Data Source=SARA\GMAO;Initial Catalog=GMAO;User ID=sa; password = 21009324"
'Objet connection
Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection(connectString)
'--------------------------------------------------------------------------------------
'Ouverture
connection.Open()
'--------------------------------------------------------------------------------------
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand("SELECT nom,service,login,mdp,tel,fax,email FROM administrateur where id_admin ='" & TextBox17.Text & "'", connection)
Dim reader As SqlClient.SqlDataReader = command.ExecuteReader
If reader.Read Then
TextBox18.Text = reader.GetString(0)
TextBox19.Text = reader.GetString(1)
TextBox20.Text = reader.GetString(2)
TextBox21.Text = reader.GetString(3)
TextBox22.Text = reader.GetInt32(4)
TextBox23.Text = reader.GetInt32(5)
TextBox24.Text = reader.GetString(6)
Else
MsgBox("id_administrateur introuvable", MsgBoxStyle.Exclamation)
End If
reader.Close()
'-------------------------------------------------------------------------------------
'Fermeture
connection.Close()
Catch ex As Exception
System.Diagnostics.Debug.WriteLine("erreur")
End Try
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Try
'Chaîne de connexion
Dim connectString As String = "Data Source=SARA\GMAO;Initial Catalog=GMAO;User ID=sa; password = 21009324"
'Objet connection
Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection(connectString)
'--------------------------------------------------------------------------------------
'Ouverture
connection.Open()
'--------------------------------------------------------------------------------------
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand("UPDATE administrateur SET nom = '" & TextBox31.Text & "',service='" & TextBox30.Text & "' ,login='" & TextBox29.Text & "' ,mdp='" & TextBox28.Text & "' ,tel=" & TextBox27.Text & " ,fax= " & TextBox26.Text & ",email= '" & TextBox25.Text & "' where id_admin ='" & TextBox17.Text & "' ", connection)
Dim reader As SqlClient.SqlDataReader = command.ExecuteReader
MsgBox(" la modification a été effectuée", MsgBoxStyle.OkOnly)
'Fermeture
connection.Close()
Catch ex As Exception
MsgBox(" la modification n'a pas été efectuée", MsgBoxStyle.Information)
End Try
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Try
'Chaîne de connexion
Dim connectString As String = "Data Source=SARA\GMAO;Initial Catalog=GMAO;User ID=sa; password = 21009324"
'Objet connection
Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection(connectString)
'--------------------------------------------------------------------------------------
'Ouverture
connection.Open()
'--------------------------------------------------------------------------------------
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand("DELETE FROM administrateur where id_admin ='" & TextBox33.Text & "' ", connection)
Dim reader As SqlClient.SqlDataReader = command.ExecuteReader
'Fermeture
connection.Close()
Catch ex As Exception
System.Diagnostics.Debug.WriteLine("erreur")
End Try
End Sub
End Class |
Partager