private void SaveButton_Click(object sender, RoutedEventArgs e) { bool isPasswordDiff = OldPasswordBox.Password != PasswordBox.Password && OldPasswordBox.Password != RepeatPasswordBox.Password; bool isOldPassCorrect = _user.Password == OldPasswordBox.Password; bool isPasswordSame = PasswordBox.Password == RepeatPasswordBox.Password; if (isOldPassCorrect && isPasswordDiff && isPasswordSame) { using (var context = new ExpansesManagerContext()) { _user.Password = PasswordBox.Password; context.Users.AddOrUpdate(_user); context.SaveChanges(); } UsernameTextBox.Clear(); PasswordBox.Clear(); RepeatPasswordBox.Clear(); OldPasswordBox.Clear(); ErrorLabel.Content = "Successfully Changed Password !"; } else { ErrorLabel.Content = Checks.PasswordsDoNotMatch; } }
private void ChangePasswordButton_Click(object sender, RoutedEventArgs e) { if (0 == OldPasswordBox.Password.Length) { MessageBox.Show("请输入原密码!"); return; } if (0 == NewPasswordBox.Password.Length) { MessageBox.Show("请输入新密码!"); return; } if (0 == NewPasswordBox2.Password.Length) { MessageBox.Show("请输入密码确认!"); return; } if (NewPasswordBox.Password != NewPasswordBox2.Password) { MessageBox.Show("新密码与密码确认不一致!"); return; } string oldpw = OldPasswordBox.Password; string newpw = NewPasswordBox.Password; if (ChangeRootPassword(oldpw, newpw)) { MessageBox.Show("修改成功!"); OldPasswordBox.Clear(); NewPasswordBox.Clear(); NewPasswordBox2.Clear(); } else { MessageBox.Show("修改失败!"); } }
// clear texten i varje box private void OldPasswordBoxRemove(object sender, MouseButtonEventArgs e) { OldPasswordBox.Clear(); }
private void ClearPasswordBoxes() { OldPasswordBox.Clear(); NewPasswordBox.Clear(); NewPasswordBox_Retype.Clear(); }