private void btnSubmit_Click(object sender, EventArgs e) { if (PasswordDB.Authenticate(txtOldPass.Text) == true) { checkOPC = true; if (txtNewPass1.Text.Equals(txtNewPass2.Text) == true) { checkNPM = true; if (PasswordDB.HasPasswordAlreadyBeenUsed(txtNewPass1.Text) == false) { checkNPU = true; if (txtNewPass1.Text.Length >= 8) { checkNPLE = true; string hint; if (string.IsNullOrEmpty(txtHint.Text) == true) { hint = "******No hint available******"; } else { hint = txtHint.Text; } UpdatePassword(txtNewPass1.Text, hint); } else { checkNPLE = false; MessageBox.Show("Please enter a longer password.", "Error: password too short"); } } else { checkNPU = false; MessageBox.Show("You have used this password in the past. Please try a different password.", "Error: already used password"); } } else { checkNPM = false; MessageBox.Show("New passwords do not match. Please re-enter and try again. System is case sensitive.", "Error: passwords don't match"); } } else { checkOPC = false; MessageBox.Show("Please enter your current password correctly. System is case sensitive.", "Error: current password"); } }
private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtPassword.Text) == false) { if (PasswordDB.Authenticate(txtPassword.Text)) { isAuthenticated = true; DialogResult = DialogResult.OK; } else { lblIncorrectPassword.Visible = true; } } }