private void RepeatPasswordTextBox_GotFocus(object sender, RoutedEventArgs e)
        {
            RepeatPasswordTextBox.Visibility = Visibility.Hidden;

            RepeatPasswordBox.Visibility = Visibility.Visible;

            RepeatPasswordBox.Focus();
        }
Ejemplo n.º 2
0
 private void ConfirmButton_Click(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrEmpty(UsernameBox.Text.Trim()))
     {
         NotificationLabel.ShowError("Please fill in username !");
         UsernameBox.Focus();
     }
     else if (string.IsNullOrEmpty(PasswordBox.Password))
     {
         NotificationLabel.ShowError("Please type in new Password !");
         PasswordBox.Focus();
     }
     else if (string.IsNullOrEmpty(RepeatPasswordBox.Password) ||
              !RepeatPasswordBox.Password.Equals(PasswordBox.Password))
     {
         NotificationLabel.ShowError("Please Confirm new Password");
         RepeatPasswordBox.Focus();
     }
     else
     {
         UserDAO dao = new UserDAO();
         try
         {
             User user = dao.GetUsers(username: UsernameBox.Text.Trim()).First();
             user.Password = PasswordBox.Password;
             dao.Update(user);
             NotificationLabel.ShowSuccess("Password changed successfully");
         }
         catch (System.InvalidOperationException ie)
         {
             DebugLog.WriteLine(ie);
             NotificationLabel.ShowError("Username does not exist !");
         }
         catch (Exception ex)
         {
             DebugLog.WriteLine(ex);
             NotificationLabel.ShowError("Could not update user !");
         }
     }
 }