Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click
Dim conn As New OleDbConnection
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Programing\Project_Final\Stores_management_system\Stores_management_system\bin\Database_Access\Database_shop.accdb"
conn.Open()
Try
If Me.txtnamelogin.Text = "" Or Me.txtpwdlogin.Text = "" Then
MsgBox("กรุณากรอกชื่อผู้ใช้งานและรหัสผ่าน", MsgBoxStyle.Exclamation, "Error")
txtnamelogin.Clear()
txtpwdlogin.Clear()
Me.txtnamelogin.Focus()
End If
If txtnamelogin.Text <> "" And txtpwdlogin.Text <> "" Then
Dim cm As New OleDbCommand("select * from login where Username=" & "'" & txtnamelogin.Text & "' and Pwd=" & "'" & txtpwdlogin.Text & "'", conn)
*** Dim insert As String = "INSERT INTO Checkuser (Status,Username,Firstname,Lastname) " & "SELECT (Status,Username,Firstname,Lastname) FROM Login WHERE Status = 'User' "
Dim Rd As OleDbDataReader
Dim User As String
Dim Pass As String
Rd = cm.ExecuteReader
Rd.Read()
User = Rd.Item("Username")
Pass = Rd.Item("Pwd")
If txtnamelogin.Text = User And txtpwdlogin.Text = Pass Then
form_shop.Show()
txtnamelogin.Text = ""
txtpwdlogin.Text = ""
Me.Hide()
End If
conn.Close()
End If
Catch ex As Exception
MsgBox("กรุณากรอกข้อมูลให้ถูกต้อง")
Exit Sub
End Try
End Sub