Skip to content

Commit c695996

Browse files
committed
♻️ login event
1 parent 07db8db commit c695996

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

Login.vb

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,36 @@ Public Class Login
99
Dim username As String = UsernameTextBox.Text
1010
Dim password As String = PasswordTextBox.Text
1111

12-
' Check if password or username is empty give error
12+
'Check if password or username is empty give error
1313
If String.IsNullOrEmpty(username) Or String.IsNullOrEmpty(password) Then
1414
MessageBox.Show("Username or email can not be empty.")
15-
Else
16-
' Creates a query to select user.
17-
Dim query As String = "SELECT * FROM users_table WHERE username = '" + username + "' AND password = '" + password + "'"
15+
Return
16+
End If
1817

19-
Dim cmd As New SqlDataAdapter(query, con)
20-
Dim dt As New DataTable()
18+
'Creates a query to select user.
19+
Dim query As String = "SELECT * FROM users_table WHERE username = '" + username + "' AND password = '" + password + "'"
2120

22-
' Fill the data table with results from database
23-
cmd.Fill(dt)
21+
Dim cmd As New SqlDataAdapter(query, con)
22+
Dim dt As New DataTable()
2423

25-
' Check if user exist with given username and password
26-
If dt.Rows.Count > 0 Then
27-
' Hide the login form
28-
Me.Hide()
24+
'Fill the data table with results from database
25+
cmd.Fill(dt)
2926

30-
' Reset the username and password input.
31-
UsernameTextBox.Text = ""
32-
PasswordTextBox.Text = ""
27+
'Check if user exist with given username and password
28+
If dt.Rows.Count = 0 Then
29+
MessageBox.Show("Incorrect Username or password.")
30+
Return
31+
End If
3332

34-
' Show the dashboard form
35-
Dashboard.Show()
36-
Else
37-
MessageBox.Show("Username or password is incorrect")
38-
End If
33+
'Hide the login form
34+
Me.Hide()
35+
36+
'Reset the username and password input.
37+
UsernameTextBox.Text = ""
38+
PasswordTextBox.Text = ""
39+
40+
'Show the dashboard form
41+
Dashboard.Show()
3942

40-
End If
4143
End Sub
4244
End Class

0 commit comments

Comments
 (0)