private void AsEmployeeExecute() { try { if (managerService.GetManagers().Count == 0) { string str = string.Format("You can't create emplooye account\n" + "There are no managers in database"); MessageBox.Show(str); return; } if (sectorService.GetSectors().Count == 0) { string str = string.Format("You can't create emplooye account\n" + "There are no sectors in database"); MessageBox.Show(str); return; } EmployeeRegisterView registerView = new EmployeeRegisterView(); registerView.ShowDialog(); view.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void AsManagerExecute() { string passwordFromFile = ReadPasswordFromFile(); int tryCounter = 3; try { ManagerRegisterView registerView = new ManagerRegisterView(); MessageBoxResult result = MessageBox.Show("Are you sure that you want to register as manager?" + "", "My App", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); switch (result) { case MessageBoxResult.Yes: for (int i = 0; i < 3; i++) { InputDialogSample inputDialog = new InputDialogSample("Please enter password from file " + "ManagerAccess.txt:", ""); if (inputDialog.ShowDialog() == true) { if (inputDialog.Answer.Equals(passwordFromFile)) { registerView.ShowDialog(); LoginView loginView = new LoginView(); loginView.Show(); view.Close(); return; } else { tryCounter--; if (tryCounter != 0) { MessageBox.Show("Wrong password. You have " + tryCounter + " more attempts"); } if (tryCounter == 0) { MessageBox.Show("You can't create manager account.\n" + "Create employee account."); if (managerService.GetManagers().Count == 0) { string str = string.Format("You can't create emplooye account\n" + "There are no managers in database"); MessageBox.Show(str); return; } canAsManager = false; EmployeeRegisterView employeeRegisterView = new EmployeeRegisterView(); employeeRegisterView.ShowDialog(); return; } } } } break; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }