//Verifies if the current password matches the password in database //verifies if the new password matches the verify password textboxes. //if old password matches the master password will be changed //All the account password in the database will be updated based on new master password private void BtnSave_Click(object sender, RoutedEventArgs e) { string newPwd = txtNewPwd.Password.ToString(); string verifyPwd = txtVerifyPwd.Password.ToString(); string oldPwd = txtOldPwd.Password.ToString(); string oldDbPwd = LoginInfo.MasterPwd; if (newPwd == verifyPwd) { if (oldPwd == oldDbPwd) { //Changes master password from old to new //Decrypts old accounts password and Encrypts with new accounts password ChangeMp(oldDbPwd, newPwd); MessageBox.Show("Your master password was changed successfully!", "Success!", MessageBoxButton.OK); //Refresh Grid hw.TextSearch(); this.Close(); } else { MessageBox.Show("Incorrect Current Password!", "Warning!", MessageBoxButton.OK); } } else if (txtNewPwd != txtVerifyPwd) { MessageBox.Show("Your new password and verify password doesn't match", "Warning!", MessageBoxButton.OK); } }
//Validates username and password field //Saves username and password to the database after valid username and password entered private void BtnOk_Click(object sender, RoutedEventArgs e) { string mp = LoginInfo.MasterPwd; int id = LoginInfo.UserId; if (txtAccountName.Text.ToString() == "" || txtPwd.Password.ToString() == "") { MessageBox.Show("Username or Password Field cannot be Empty", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } else { //calls AddPasswordDb() method to add username and password after validation string message = "Password Sucessfully Added"; AddPasswordDb(); MessageBox.Show(message, "Password Add", MessageBoxButton.OK); this.Close(); } //Refreshes the DataGrid in HomeWindow hw.TextSearch(); }