I have to create a login page for an electronic library and for some reason there is a problem when logging in. The login successfully works for member and employee but after the a popup box shows "please register user name". Here's my code if that helps.
Public Class Login
Dim NumberOfRows As Integer
Dim NumberOfRowss As Integer
Dim RowData As Object
Dim Password As String = String.Empty
Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
'If the textbox for email or password is empty and user clicks enter then
'A pop up messagebox asks the user to "please enter your email and password"
'Member Login
If txtEmail.Text = String.Empty Or txtPassword.Text = String.Empty Then
MessageBox.Show("please enter your email and password")
txtEmail.Focus()
txtEmail.Clear()
txtPassword.Clear()
Else
End If
'Query searches for matching email provided by user and record in the Member table.
NumberOfRows = LibraryMembersTableAdapter.FillByMemberEmail(LibraryDatabaseDataSet.LibraryMembers, txtEmail.Text)
'If record with a matching email is located then
'Get that record and store it in an object for use later on
'The dataset's index names will match the names of the columns in the table.
'Thus RowData.Password points to the user's password
If NumberOfRows = 1 Then
RowData = LibraryMembersTableAdapter.GetDataByMemberEmail(txtEmail.Text)(0)
'Get the password from the stored record
'Determine if the userís given password matches the one in the saved record
Password = RowData.Password
'If the user given password matches the password stored in the table then
'Messagebox shows saying "Login successful", directs user to the member account page
If Password = txtPassword.Text Then
MessageBox.Show("Member Login successful")
'MemberAccount.Show()
Me.Hide()
Else
'If log in unsuccessful
'A pop up messagebox shows ìLogin unsuccessfulî
MessageBox.Show("Member Login unsuccessful")
txtPassword.Clear()
End If
Else
'Clear all the textboxes and shift focus to email
'Message the user "No user has registered with this email, please try a different email or register as a new userî
MessageBox.Show("No user has registered with this email, please try a different email or register as a new user")
txtEmail.Focus()
End If
'Employee Login
If txtEmail.Text = String.Empty Or txtPassword.Text = String.Empty Then
MessageBox.Show("please enter your email and password")
txtEmail.Focus()
txtEmail.Clear()
txtPassword.Clear()
Else
'Query searches for matching email provided by user and record in the Member table.
NumberOfRowss = EmployeeTableAdapter.FillByEmployeeEmail(LibraryDatabaseDataSet.Employee, txtEmail.Text)
'If record with a matching email is located then
'Get that record and store it in an object for use later on
'The dataset's index names will match the names of the columns in the table.
'Thus RowData.Password points to the user's password
If NumberOfRowss = 1 Then
RowData = EmployeeTableAdapter.GetDataByEmployeeEmail(txtEmail.Text)(0)
'Get the password from the stored record
'Determine if the userís given password matches the one in the saved record
Password = RowData.Password
'If the user given password matches the password stored in the table then
'Messagebox shows saying "Login successful", directs user to the member account page
If Password = txtPassword.Text Then
MessageBox.Show("Member Login successful")
'MemberAccount.Show()
Me.Hide()
Else
'If log in unsuccessful
'A pop up messagebox shows ìLogin unsuccessfulî
MessageBox.Show("Member Login unsuccessful")
txtPassword.Clear()
End If
Else
'Clear all the textboxes and shift focus to email
'Message the user "No user has registered with this email, please try a different email or register as a new userî
MessageBox.Show("No user has registered with this email, please try a different email or register as a new user")
txtEmail.Focus()
End If
End If
End Sub
Private Sub LibraryMembersBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
Me.Validate()
Me.LibraryMembersBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.LibraryDatabaseDataSet)
End Sub
Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
Me.Close()
End Sub
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
txtEmail.Focus()
txtEmail.Clear()
txtPassword.Clear()
End Sub
Private Sub EmployeeBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
Me.Validate()
Me.EmployeeBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.LibraryDatabaseDataSet)
End Sub
End Class