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; } }
public ChangePasswordDialog() { InitializeComponent(); OldPasswordBox.Focus(); // If password is default password, set it to oldpasswordbox and disable it if (Session.CurrentUser.IsDefaultPassword()) { OldPasswordBox.Password = Session.DefaultPassword; OldPasswordBox.IsEnabled = false; } }
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 FocusPasswordBox() { OldPasswordBox.Focus(); }
private void SettingUserControl_OnLoaded(object sender, RoutedEventArgs e) { OldPasswordBox.Focus(); }
private void ClearPasswordBoxes() { OldPasswordBox.Clear(); NewPasswordBox.Clear(); NewPasswordBox_Retype.Clear(); }
private void ChangePasswordView_Loaded(object sender, RoutedEventArgs e) { Loaded -= ChangePasswordView_Loaded; this.MakeCloseable(); OldPasswordBox.Focus(); }
private void FakeOldPasswordBox_GotFocus(object sender, RoutedEventArgs e) { OldPasswordBox.Visibility = System.Windows.Visibility.Visible; FakeOldPasswordBox.Visibility = System.Windows.Visibility.Collapsed; OldPasswordBox.Focus(); }