private void tile_ReviewerChangePassword_Click(object sender, EventArgs e) { this.Enabled = false; ChangePasswordWindow password_change = new ChangePasswordWindow(3, this); password_change.Show(); }
internal bool changePassword(int type, string username, string old_password, string new_password_1, string new_password_2, ChangePasswordWindow password_change_window) { if ((username.Equals("")) || (new_password_1.Equals("")) || (old_password.Equals("")) || (new_password_2.Equals(""))) { MetroFramework.MetroMessageBox.Show(password_change_window, "Incomplete form", "There are incomplete fields", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } else { string encryptedOldPassword = encrypter.Encrypt(old_password, ENCRYPT_KEY); encryptedOldPassword = encryptedOldPassword.Trim(); string encryptedNewPassword1 = encrypter.Encrypt(new_password_1, ENCRYPT_KEY); if (new_password_1.Equals(new_password_2)) { if (type == 1) { DataSet ds = dr.getAdmin(username, encryptedOldPassword); int count = ds.Tables[0].Rows.Count; if (count == 0) { MetroFramework.MetroMessageBox.Show(password_change_window, "Username or Password is incorrect", "Given Username or Password is incorrect", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { dr.changeAdminPassword(username,encryptedNewPassword1); MetroFramework.MetroMessageBox.Show(password_change_window, "Password was successfully changed", "Your account password was successfully chnaged", MessageBoxButtons.OK, MessageBoxIcon.Information); return true; } } else if (type == 2) { DataSet ds = dr.getAnalyser(username, encryptedOldPassword); int count = ds.Tables[0].Rows.Count; if (count == 0) { MetroFramework.MetroMessageBox.Show(password_change_window, "Username or Password is incorrect", "Given Username or Password is incorrect", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { dr.changeAnalysistPassword(username, encryptedNewPassword1); MetroFramework.MetroMessageBox.Show(password_change_window, "Password was successfully changed", "Your account password was successfully chnaged", MessageBoxButtons.OK, MessageBoxIcon.Information); return true; } } else { DataSet ds = dr.getReviewer(username, encryptedOldPassword); int count = ds.Tables[0].Rows.Count; if (count == 0) { MetroFramework.MetroMessageBox.Show(password_change_window, "Username or Password is incorrect", "Given Username or Password is incorrect", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { dr.changeReviewerPassword(username, encryptedNewPassword1); MetroFramework.MetroMessageBox.Show(password_change_window, "Password was successfully changed", "Your account password was successfully chnaged", MessageBoxButtons.OK, MessageBoxIcon.Information); return true; } } } else { MetroFramework.MetroMessageBox.Show(password_change_window, "Passwords do not match", "Two passwords do not match with each other", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } } return false; }