private void DeleteUser(object sender, RoutedEventArgs e) { var usr = new UserList(_ds); usr.SelectUser(_user); usr.DeleteUser(); Close(); }
public FrmChangeUser(DataSet parent, string user) { InitializeComponent(); _usr = new UserList(parent); try { _usr.SelectUser(user); TbNewUsername.Text = user; } catch(ArgumentOutOfRangeException ex) { MessageBox.Show(ex.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Methode initiiert die Erstellung eines neuen Benutzers /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddUser(object sender, RoutedEventArgs e) { TbUsername.Background = Brushes.White; TbUsername.Foreground = Brushes.Black; TbPassword.Background = Brushes.White; TbPassword.Foreground = Brushes.Black; var usr = new UserList(_ds); if(TbPassword.Password == TbPasswordConfirm.Password) { try { usr.CreateUser(TbUsername.Text, TbPassword.Password); Close(); } catch(UserNameIsNullOrEmptyException ex) { MessageBox.Show(ex.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error); TbUsername.Background = Brushes.Red; TbUsername.Foreground = Brushes.White; TbUsername.Focus(); } catch(PasswordIsNullOrEmptyException ex) { MessageBox.Show(ex.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error); TbPassword.Background = Brushes.Red; TbPassword.Foreground = Brushes.White; TbPassword.Focus(); } catch(ArgumentException ex) { MessageBox.Show(ex.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error); TbUsername.Background = Brushes.Red; TbUsername.Foreground = Brushes.White; TbUsername.Focus(); } } else { MessageBox.Show("Das Passwort stimmt nicht mit der Passwortbestätigung überein.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error); TbPassword.Password = null; TbPasswordConfirm.Password = null; TbPassword.Focus(); } }