Example #1
0
 public void Teardown()
 {
     _passwordForm.Dispose();
     while (_passwordForm.Disposing)
     {
     }
     _passwordForm = null;
 }
Example #2
0
    //*******************************************
    // event handling method for the idTextBox
    //
    public void IdTextBoxKeyUp(object source, KeyEventArgs e)
    {
        // We only want to act if the Enter key is pressed
        if (e.KeyCode == Keys.Enter)
        {
            // First, clear the fields reflecting the
            // previous student's information.
            ClearFields();

            // We'll try to construct a Student based on
            // the id we read, and if a file containing
            // Student's information cannot be found,
            // we have a problem.

            currentUser = new Student(idTextBox.Text + ".dat");
            currentUser.ReadStudentData(schedule);

            // Test to see if the Student fields were properly
            // initialized. If not, reset currentUser to null
            // and display a message box

            if (!currentUser.StudentSuccessfullyInitialized())
            {
                // Drat!  The ID was invalid.
                currentUser = null;

                // Let the user know that login failed,
                string message = "Invalid student ID; please try again.";
                MessageBox.Show(message, "Invalid Student ID",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                // Hooray!  We found one!  Now, we need
                // to request and validate the password.
                passwordDialog = new PasswordForm();
                passwordDialog.ShowDialog(this);

                string password = passwordDialog.Password;
                passwordDialog.Dispose();

                if (currentUser.ValidatePassword(password))
                {
                    // Let the user know that the
                    // login succeeded.
                    string message =
                        "Log in succeeded for " + currentUser.Name + ".";
                    MessageBox.Show(message, "Log In Succeeded",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);

                    // Load the data for the current user into the TextBox and
                    // ListBox components.
                    SetFields(currentUser);
                }
                else
                {
                    // The id was okay, but the password validation failed;
                    // notify the user of this.
                    string message = "Invalid password; please try again.";
                    MessageBox.Show(message, "Invalid Password",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            // Check states of the various buttons.
            ResetButtons();
        }
    }
Example #3
0
    //**********************************************
    // event handling method for "Log In" Button
    //
    public void LogInButtonClicked(object source, EventArgs e)
    {
        // First, clear the fields reflecting the
          // previous student's information.
          ClearFields();

          //  Display password dialog
          passwordDialog = new PasswordForm();
          passwordDialog.ShowDialog(this);

          string password = passwordDialog.Password;
          string id = passwordDialog.Id;
          passwordDialog.Dispose();

          // We'll try to construct a Student based on
          // the id we read, and if a file containing
          // Student's information cannot be found,
          // we have a problem.

          currentUser = new Student(id+".dat");
          currentUser.ReadStudentData(schedule);

          // Test to see if the Student fields were properly
          // initialized. If not, reset currentUser to null
          // and display a message box

          if (!currentUser.StudentSuccessfullyInitialized()) {
        // Drat!  The ID was invalid.
        currentUser = null;

        // Let the user know that login failed,
        string message = "Invalid student ID; please try again.";
        MessageBox.Show(message, "Invalid Student ID",
                 MessageBoxButtons.OK, MessageBoxIcon.Warning);
          }
          else {
        // We have a valid Student.  Now, we need
        // to validate the password.

        if (currentUser.ValidatePassword(password)) {

          // Let the user know that the login succeeded.
          string message =
               "Log in succeeded for " + currentUser.Name + ".";
          MessageBox.Show(message, "Log In Succeeded",
                 MessageBoxButtons.OK, MessageBoxIcon.Information);

          // Load the data for the current user into the TextBox and
          // ListBox components.
          SetFields(currentUser);
        }
        else {
          // The id was okay, but the password validation failed;
          // notify the user of this.
          currentUser = null;
          string message = "Invalid password; please try again.";
          MessageBox.Show(message, "Invalid Password",
                 MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
          }
          // Check states of the various buttons.
          ResetButtons();
    }