Exemplo n.º 1
0
        private void btn_login_Click(object sender, RoutedEventArgs e)
        {
            //doing validation

            //if textboxes are not empty
            if (tb_username.Text.Length != 0 && tb_username.Text.Length != 0)
            {
                //validate user with a boolean method and open the appropriate window with the status of my user
                if (atm.Authentication(tb_username.Text, Passwrdbox_password.Password))
                {
                    switch (ATM.U.Status)
                    {
                    case "Admin":
                        WindowAdmin wa = new WindowAdmin();
                        wa.Show();
                        Hide();
                        break;

                    case "Customer":
                        WindowUsers wc = new WindowUsers();
                        wc.Show();
                        Hide();
                        break;

                    default:
                        MessageBox.Show("A problem just happened. Please try to log in again...");
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Your username and your password don't match. Please try again...");
                    ClearMethod();
                    tries++;
                    if (tries == 3)
                    {
                        MessageBox.Show("You have tried 3 times already, please try again later!");
                    }
                }
            }
            else
            {
                MessageBox.Show("Your username and your password cannot be empty. Please try again...");
                if (tb_username.Text.Length == 0)
                {
                    tb_username.Focus();
                }
                else
                {
                    Passwrdbox_password.Focus();
                }
            }
        }
Exemplo n.º 2
0
 private void ClearMethod()
 {
     tb_username.Clear();
     Passwrdbox_password.Clear();
     tb_username.Focus();
 }