Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Login
- Dim timeLeft As Integer
- Public loginAttempts As Integer = 1
- Public lockedUser As String = user
- Public user As String
- Public pass As String
- Private Sub uxBtnExit_Click(sender As Object, e As EventArgs) Handles uxBtnExit.Click
- Me.Close()
- End Sub
- Private Sub uxBtnLogin_Click(sender As Object, e As EventArgs) Handles uxBtnLogin.Click
- user = uxTxtUsername.Text
- pass = uxTxtPassword.Text
- If (Me.UsersTableAdapter.QueryLOGIN(user, pass, 0)) Then
- MessageBox.Show("Login Successful!")
- Me.UserProfileTableAdapter.QueryUserProfile(user, 1)
- Me.UsersTableAdapter.UpdateResetLoginAttempts(user)
- MainMenu.Show()
- Me.Visible = False
- ElseIf (Me.UsersTableAdapter.QueryLOGIN(user, pass, 1)) Then
- MessageBox.Show("Account is locked!")
- lockedUser = user
- lockedAccount()
- Else
- Me.UsersTableAdapter.UpdateLoginAttempts(user)
- loginAttempts += 1
- MessageBox.Show("Invalid Login")
- loginAttempts = Me.UsersTableAdapter.QueryLoginAttempts(user)
- Dim attemptsRemaining = (3 - loginAttempts)
- uxLblLocked.Text = attemptsRemaining.ToString() + " out of 3" + vbNewLine + "attempts remaining"
- If (loginAttempts = 3) Then
- MessageBox.Show("Too many incorrect login attempts")
- lockedUser = user
- lockedAccount()
- Me.UsersTableAdapter.QueryLOCKED(user, 1)
- End If
- End If
- End Sub
- Public Sub lockedAccount()
- timeLeft = 10
- Timer1.Start()
- End Sub
- Private Sub UsersBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles UsersBindingNavigatorSaveItem.Click
- Me.Validate()
- Me.UsersBindingSource.EndEdit()
- Me.TableAdapterManager.UpdateAll(Me.DataSet1)
- End Sub
- Private Sub Login_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- 'TODO: This line of code loads data into the 'DataSet1.UserProfile' table. You can move, or remove it, as needed.
- Me.UserProfileTableAdapter.Fill(Me.DataSet1.UserProfile)
- 'TODO: This line of code loads data into the 'DataSet1.Users' table. You can move, or remove it, as needed.
- Me.UsersTableAdapter.Fill(Me.DataSet1.Users)
- End Sub
- Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
- If timeLeft > 0 Then
- timeLeft -= 1
- uxLblLogin.Visible = True
- uxLblLocked.Visible = True
- uxLblLogin.Text = "Username " + vbNewLine + " Locked: " + lockedUser
- uxLblLocked.Text = timeLeft & " Seconds"
- Else
- Timer1.Stop()
- uxLblLogin.Text = "Account Unlocked!"
- uxLblLocked.Text = ""
- Me.UsersTableAdapter.QueryLOCKED(lockedUser, 0)
- Me.UsersTableAdapter.UpdateResetLoginAttempts(lockedUser)
- lockedUser = ""
- loginAttempts = 1
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement