-
Notifications
You must be signed in to change notification settings - Fork 1
/
frmLogin.vb
executable file
·102 lines (68 loc) · 3.34 KB
/
frmLogin.vb
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
Imports System.Data.OleDb
Public Class frmlogin
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
Me.Hide()
frmChangePassword.Show()
End Sub
Private Sub login_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles login_button.Click
If Len(Trim(UserName.Text)) = 0 Then
MessageBox.Show("Please enter user name", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
UserName.Focus()
Exit Sub
End If
If Len(Trim(Password.Text)) = 0 Then
MessageBox.Show("Please enter password", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Password.Focus()
Exit Sub
End If
Try
Dim myConnection As oledbConnection
myConnection = New oledbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\PayrollManagerDB.accdb;Persist Security Info=False;")
Dim myCommand As oledbCommand
myCommand = New oledbCommand("SELECT username,password FROM Users WHERE username = @username AND password = @UserPassword", myConnection)
Dim uName As New oledbParameter("@username", oledbType.Varchar)
Dim uPassword As New oledbParameter("@UserPassword", oledbType.Varchar)
uName.Value = UserName.Text
uPassword.Value = Password.Text
myCommand.Parameters.Add(uName)
myCommand.Parameters.Add(uPassword)
myCommand.Connection.Open()
Dim myReader As oledbDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
Dim Login As Object = 0
If myReader.HasRows Then
myReader.Read()
Login = myReader(Login)
End If
If Login = Nothing Then
MsgBox("Login is Failed...Try again !", MsgBoxStyle.Critical, "Login Denied")
UserName.Clear()
Password.Clear()
UserName.Focus()
Else
ProgressBar1.Visible = True
ProgressBar1.Maximum = 5000
ProgressBar1.Minimum = 0
ProgressBar1.Value = 4
ProgressBar1.Step = 1
For i = 0 To 5000
ProgressBar1.PerformStep()
Next
frmMainMenu.ToolStripStatusLabel2.Text = UserName.Text
Me.Hide()
frmMainMenu.Show()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub Login_form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
UserName.Focus()
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
Close()
End Sub
Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
Me.Hide()
frmPasswordRecovery.Show()
End Sub
End Class