// When the Reset Passwors Button is clicked private void ResetPasswordButton_Click(object sender, EventArgs e) { // Validation if (PasswordETF.Text.Equals("")) // If no username has been entered { MessageBox.Show("Please enter a Password"); // Show a message box describing the error return; // Stop this method } else if (ReEnterPasswordETF.Text.Equals("")) // If no username has been entered { MessageBox.Show("Please Reenter the Password"); // Show a message box describing the error return; // Stop this method } if (!PasswordETF.Text.Equals(ReEnterPasswordETF.Text)) { // If the passwords entered do not match MessageBox.Show("Passwords to not match. Please try again."); // Show a messagebox displaying the error message return; // Stop the method } UserDatabase userDB = new UserDatabase(); // Create a new instance of a User Database. This can be read from and written to a file userDB.ChangeUserPassword(username, PasswordETF.Text); // Change the User's password (Details have been verified in the 'Start Display') userDB.SaveDatabase(); // Save the Database to a file this.Close(); // Close this form now that the password has been reset }
private void ResetPasswordButton_Click(object sender, EventArgs e) { if(!PasswordETF.Text.Equals(ReEnterPasswordETF.Text)){ MessageBox.Show("Passwords to not match. Please try again."); return; } UserDatabase userDB = new UserDatabase(); userDB.ChangeUserPassword(username, PasswordETF.Text); userDB.SaveDatabase(); }