private void ConfirmCommandExecute(object obj) { try { string password = (obj as PasswordBox).Password; string filePassword = RandomPasswordGenerator.ReadManagerPassword(); if (password.Equals(filePassword)) { AddManagerView managerView = new AddManagerView(); managerPasswordEnterView.Close(); registration.Close(); managerView.Show(); return; } else { if (retryCounter == 0) { MessageBox.Show("You have exeeded maximum number of tries.\nReturning to registration screen."); RegistrationView registrationView = new RegistrationView(retryCounter); managerPasswordEnterView.Close(); registration.Close(); registrationView.Show(); } else { MessageBox.Show($"Wrong password. Remaining number of tries: {--retryCounter}"); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void SaveExecute() { try { user.GivenName = GivenName; user.Surname = Surname; user.Password = SecurePasswordHasher.Hash(Password); user.Username = Username; //adding new institution to database IsAddedNewUser = db.TryAddNewUserData(user); if (!IsAddedNewUser) { MessageBox.Show("Something went wrong. The new useris not created."); MainWindow login = new MainWindow(); login.Show(); registrationView.Close(); return; } else { var newUser = db.LoadUserByUsername(Username); MessageBox.Show("The new user is sucessfully created."); UserView userView = new UserView(newUser); registrationView.Close(); userView.Show(); return; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void SaveExecute() { try { //adding new user to database user.Username = Username; user.Email = Email; user.DateOfBirth = dateOfBirthValue; user.Password = SecurePasswordHasher.Hash(user.Password); IsAddedNewUser = db.TryAddNewUser(user); if (IsAddedNewUser == false) { MessageBox.Show("Something went wrong. New user is not created."); } else { MessageBox.Show("The new user is sucessfully created."); } MainWindow loginWindow = new MainWindow(); loginWindow.Show(); registrationView.Close(); return; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void AddNewEmployeeExecute() { try { AddNewEmployeeView addNewEmployeeView = new AddNewEmployeeView(); addNewEmployeeView.ShowDialog(); view.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void SaveExecute(object password) { User.Password = (password as PasswordBox).Password; if (String.IsNullOrEmpty(User.FirstName) || String.IsNullOrEmpty(User.LastName) || String.IsNullOrEmpty(User.Username) || String.IsNullOrEmpty(User.Password) || String.IsNullOrEmpty(User.Gender) || String.IsNullOrEmpty(User.DateOfBirth.ToString())) { MessageBox.Show("Please fill all required fields.", "Notification"); } else { try { MessageBoxResult result = MessageBox.Show("Are you sure you want to register?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { bool isCreated = users.CreateUser(User, out int id); User.UserId = id; if (isCreated == true) { MessageBox.Show("Successful registration!", "Notification", MessageBoxButton.OK); LoginView login = new LoginView(); registrationView.Close(); login.ShowDialog(); } else { MessageBox.Show("Registration cannot be performed.", "Notification", MessageBoxButton.OK); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
private void RegistrationExecute() { AvtorisationProxy avtorisationProxy = new AvtorisationProxy(); if (_registrationView.tbLogin.Text == string.Empty || _registrationView.tbPass.Password == string.Empty) { new MsgBox("Не всі поля заповнені").ShowDialog(); return; } if (avtorisationProxy.Registration(_registrationView.tbLogin.Text, _registrationView.tbPass.Password)) { new MsgBox("Ви вдало зареєстровані").ShowDialog(); _registrationView.Close(); } else { _registrationView.tbEror.Visibility = System.Windows.Visibility.Visible; _registrationView.tbLogin.Background = Brushes.Red; } }
public void Logout() { try { MessageBoxResult result = MessageBox.Show("Are you sure you want to logout?", "Confirmation", MessageBoxButton.OKCancel); switch (result) { case MessageBoxResult.OK: LoginView loginView = new LoginView(); Thread.Sleep(1000); registration.Close(); loginView.Show(); return; case MessageBoxResult.Cancel: break; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public static void OpenLoginFromRegister() { loginView.Show(); regView.Close(); }