コード例 #1
0
 /// <summary>
 /// This handler verifies login credentials and continues the program.
 /// </summary>
 private void LoginButton_Click(object sender, EventArgs e)
 {
     if (FailedLoginAttempts >= 3)
     {
         // begin lockout
         LoginButton.Enabled = false;
         LockoutTimer.Start();
         FailedLoginAttempts = 0;
         MessageBox.Show("Too many login attempts.  Try again in 3 minutes.", "Lockout");
     }
     else
     {
         if (Connection.QueryDatabase("select * from Account where Username = '******' and Password = '******'").Rows.Count > 0)
         {
             FailedLoginAttempts       = 0;
             Program.mainMenu.Username = UsernameTextBox.Text;
             UsernameTextBox.Text      = "";
             PasswordTextBox.Text      = "";
             this.Hide();
             Program.mainMenu.Show();
         }
         else
         {
             FailedLoginAttempts++;
             MessageBox.Show("Incorrect login credentials.", "Login Failed");
         }
     }
 }
コード例 #2
0
        // EVENT HANDLERS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        /// <summary>
        /// This handler disables lockout after 3 minutes.
        /// </summary>
        private void LockoutTimer_Tick(object sender, EventArgs e)
        {
            LockoutTimer.Stop();
            LoginButton.Enabled = true;
        }