10-09-18, 09:48 AM
كود :
Imports System.Data.OleDb
Public Class Form1
Dim Conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=|DataDirectory|db2.accdb; Persist Security Info=True")
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TxTUserName.Select()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SQLEmployees As String = "SELECT * FROM [Employees] WHERE Trim(LCase([EmployeeUser]))=Trim(LCase(@username)) AND [EmployeePass]=@password"
Dim DataAdapterEmployees As New OleDbDataAdapter(SQLEmployees, Conn)
DataAdapterEmployees.SelectCommand.Parameters.AddWithValue("@username", TxTUserName.Text)
DataAdapterEmployees.SelectCommand.Parameters.AddWithValue("@password", TxTPassword.Text)
Dim DataTableEmployees As New DataTable
If DataAdapterEmployees.Fill(DataTableEmployees) > 0 Then
Dim row As DataRow = DataTableEmployees.Rows(0)
Form2.Button1.Enabled = row("IsWarehouse")
Form2.Button1.Enabled = row("IsEmployees")
Form2.Button1.Enabled = row("IsEmplSales")
Form2.XN.Text = row("EmployeeName")
Form2.Show()
Else
MsgBox("خطأ في اسم المستخدم أو كلمة المرور")
End If
TxTPassword.Text = ""
End Sub
End Class