Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. Public Class Login
  2. Dim timeLeft As Integer
  3. Public loginAttempts As Integer = 1
  4. Public lockedUser As String = user
  5. Public user As String
  6. Public pass As String
  7.  
  8. Private Sub uxBtnExit_Click(sender As Object, e As EventArgs) Handles uxBtnExit.Click
  9. Me.Close()
  10. End Sub
  11.  
  12. Private Sub uxBtnLogin_Click(sender As Object, e As EventArgs) Handles uxBtnLogin.Click
  13. user = uxTxtUsername.Text
  14. pass = uxTxtPassword.Text
  15.  
  16. If (Me.UsersTableAdapter.QueryLOGIN(user, pass, 0)) Then
  17. MessageBox.Show("Login Successful!")
  18. Me.UserProfileTableAdapter.QueryUserProfile(user, 1)
  19. Me.UsersTableAdapter.UpdateResetLoginAttempts(user)
  20.  
  21. MainMenu.Show()
  22. Me.Visible = False
  23.  
  24. ElseIf (Me.UsersTableAdapter.QueryLOGIN(user, pass, 1)) Then
  25. MessageBox.Show("Account is locked!")
  26. lockedUser = user
  27. lockedAccount()
  28. Else
  29. Me.UsersTableAdapter.UpdateLoginAttempts(user)
  30. loginAttempts += 1
  31. MessageBox.Show("Invalid Login")
  32. loginAttempts = Me.UsersTableAdapter.QueryLoginAttempts(user)
  33. Dim attemptsRemaining = (3 - loginAttempts)
  34. uxLblLocked.Text = attemptsRemaining.ToString() + " out of 3" + vbNewLine + "attempts remaining"
  35. If (loginAttempts = 3) Then
  36. MessageBox.Show("Too many incorrect login attempts")
  37. lockedUser = user
  38. lockedAccount()
  39. Me.UsersTableAdapter.QueryLOCKED(user, 1)
  40. End If
  41. End If
  42. End Sub
  43.  
  44. Public Sub lockedAccount()
  45. timeLeft = 10
  46. Timer1.Start()
  47. End Sub
  48.  
  49. Private Sub UsersBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles UsersBindingNavigatorSaveItem.Click
  50. Me.Validate()
  51. Me.UsersBindingSource.EndEdit()
  52. Me.TableAdapterManager.UpdateAll(Me.DataSet1)
  53.  
  54. End Sub
  55.  
  56. Private Sub Login_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  57. 'TODO: This line of code loads data into the 'DataSet1.UserProfile' table. You can move, or remove it, as needed.
  58. Me.UserProfileTableAdapter.Fill(Me.DataSet1.UserProfile)
  59. 'TODO: This line of code loads data into the 'DataSet1.Users' table. You can move, or remove it, as needed.
  60. Me.UsersTableAdapter.Fill(Me.DataSet1.Users)
  61. End Sub
  62.  
  63. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  64. If timeLeft > 0 Then
  65. timeLeft -= 1
  66. uxLblLogin.Visible = True
  67. uxLblLocked.Visible = True
  68. uxLblLogin.Text = "Username " + vbNewLine + " Locked: " + lockedUser
  69. uxLblLocked.Text = timeLeft & " Seconds"
  70. Else
  71. Timer1.Stop()
  72. uxLblLogin.Text = "Account Unlocked!"
  73. uxLblLocked.Text = ""
  74. Me.UsersTableAdapter.QueryLOCKED(lockedUser, 0)
  75. Me.UsersTableAdapter.UpdateResetLoginAttempts(lockedUser)
  76. lockedUser = ""
  77. loginAttempts = 1
  78. End If
  79. End Sub
  80. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement