CODE
Private DbCommand As String = ""
Private bindingSrc As BindingSource
Private DbName As String = "auditor_db.db"
Private DbPath As String = Application.StartupPath & "\" & DbName
Private ConnString As String = "Data Source =" & DbPath & ";Version=3"
Private Connection As New SQLiteConnection(ConnString)
Private Command As New SQLiteCommand("", Connection)
Dim Pos As Point
2 - محتويات زر الدخول
CODE
If TextBox1.Text.Trim = "" Or TextBox2.Text.Trim = "" Then
MessageBox.Show("لا يمكن ترك صندوق النصوص الخاص باسم المستخدم او كلمة السر فارغا", "رسالة هامة", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign, False)
Exit Sub
End If
Connection.Open()
If Connection.State = ConnectionState.Open Then
Command.Connection = Connection
Command.CommandText = "Select * from user Where user_name ='" & TextBox1.Text & "'"
Dim reader As SQLiteDataReader = Command.ExecuteReader
Dim found As Boolean = False
Dim username As String
Dim userpassword As String
Dim userrole As String
Using reader
While (reader.Read())
username = reader.GetString(1)
userpassword = reader.GetString(2)
userrole = reader.GetString(3)
found = True
End While
End Using
If found = False Then
MessageBox.Show("اسم المستخدم غير موجود "
Connection.Close()
Exit Sub
End If
If TextBox2.Text <> userpassword Then
MessageBox.Show("كلمة السر خاطئة"
Connection.Close()
Exit Sub
End If
If userrole = "مدير" Then
main.Show()
main.Label2.Text = username
main.Label5.Text = userrole
Me.Hide()
End If
If userrole = "مستخدم" Then
main.Show()
main.Label2.Text = username
main.Label5.Text = userrole
Me.Hide()
End If
End If
Connection.Close()
3 - التنقل من صندوق نصوص لأخر
CODE
Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
TextBox2.Focus()
End If
End Sub
تحميل ملف العمل من هنا
