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
| Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Dim lg As String = Me.UsernameTextBox.Text()
Dim psw As String = Me.PasswordTextBox.Text()
Dim DBA As String = Environment.GetEnvironmentVariable("DB_PRESSING_ENV")
' Déclaration Objet Connexion
Dim MyConnexion As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data source=" & DBA & "\P13PRESSING_DB.accdb")
' Déclaration Objet Commande
Dim MyCommand As OleDbCommand = MyConnexion.CreateCommand()
MyCommand.CommandText = "SELECT * FROM [User] where login ='" & lg & "';"
MyConnexion.Open()
Dim MyReader As OleDbDataReader = MyCommand.ExecuteReader()
If MyReader.Read() Then
If MyReader.GetString(o) = lg Then
If MyReader.GetString(1) = psw Then
If MyReader.GetBoolean(5) = True Then
adminAccueil.Show()
Else
userAccueil.Show()
End If
' Modification de l'état de l'utilisateur (connecté ou non)
Dim MyCommandmaj As OleDbCommand = MyConnexion.CreateCommand()
MyCommandmaj.CommandText = "UPDATE [User] Set etat = True WHERE login ='" & lg & "';"
Dim MyReaderMaj As OleDbDataReader = MyCommandmaj.ExecuteReader()
MyReaderMaj.Close()
Me.Hide()
Else
MsgBox("Mot de passe incorrecte!", MsgBoxStyle.Information, "Invalid Input")
End If
Else
MsgBox("Nom de l'utilisateur non reconnu!")
End If
Else
MsgBox("Erreur! Utilisateur non reconnu!", MsgBoxStyle.Critical, "Echec Connexion")
End If
MyReader.Close()
MyConnexion.Close()
End Sub |