コード例 #1
0
ファイル: EditUserWindow.xaml.cs プロジェクト: kejdajar/PASS
        private void btnSubmitGroup1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string newUsername = ValidateUser.ValidateUsername(tbUsername.Text, _selectedUser.username.Trim());

                Authentification.ChangeUsername(_userId, tbUsername.Text);

                Authentification.ChangeUserRole(_userId, cbRole.Text);

                DialogHelper.ShowInfo("Požadované změny byly úspěšně provedeny.");

                InitializeInterface();
            }
            catch (InvalidUsernameException ex)
            {
                DialogHelper.ShowWarning(ex.Message);
            }
            catch (UsernameAlreadyExistsException ex)
            {
                DialogHelper.ShowWarning(ex.Message);
            }
            catch
            {
                DialogHelper.ShowError("Kvůli neočekávané chybě operace selhala.");
            }
        }
コード例 #2
0
 private void btnSubmit_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string username      = ValidateUser.ValidateUsername(tbUsername.Text);
         string password      = ValidateUser.ValidateNewPassword(pbPassword.Password);
         string passwordAgain = pbPasswordAgain.Password;
         if (password == passwordAgain)
         {
             if (Authentification.NewUser(username, pbPassword.Password, comboBoxRoles.Text))
             {
                 DialogHelper.ShowInfo("Uživatel úspěšně přidán.");
                 this.Close();
             }
             else
             {
                 throw new NotImplementedException();
             }
         }
         else
         {
             DialogHelper.ShowWarning("Hesla se neshodují");
             pbPasswordAgain.Password = string.Empty;
         }
     }
     catch (InvalidUsernameException ex)
     {
         DialogHelper.ShowWarning(ex.Message);
     }
     catch (InvalidAuthPasswordException ex)
     {
         DialogHelper.ShowWarning(ex.Message);
     }
     catch
     {
         DialogHelper.ShowError("Uživatel nemohl být přidán.");
     }
 }