/// <summary> /// Get playerName from user input /// </summary> /// <returns></returns> private string DialogPlayerNameInput() { string playerName = ""; try { playerName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; playerName = playerName.Substring(playerName.LastIndexOf("\\") + 1); } catch { playerName = "Anonymous"; } InputDialogSample inputDialog = new InputDialogSample("Great Score!\nPlease enter your name:", playerName); if (inputDialog.ShowDialog() == true) { if (inputDialog.Answer.Length > 10) { playerName = inputDialog.Answer.Substring(0, 10); } else if (inputDialog.Answer.Length == 0) { return(playerName); } else { playerName = inputDialog.Answer; } } return(playerName); }
void Submit(object obj) { string password = (obj as PasswordBox).Password; string encryptedString = EncryptionHelper.Encrypt(password); tblUser user = service.GetUserByUserNameAndPassword(UserName, encryptedString); if (user != null) { InputDialogSample inputDialog = new InputDialogSample("Enter children or adults to choose cake list:" + "", ""); if (inputDialog.ShowDialog() == true) { if (inputDialog.Answer.ToLower().Equals("children")) { UserMainView mainView = new UserMainView("children", user); mainView.Show(); view.Close(); return; } else if (inputDialog.Answer.ToLower().Equals("adults")) { UserMainView mainView = new UserMainView("adults", user); mainView.Show(); view.Close(); return; } else { MessageBox.Show("Wrong input"); } } } else { MessageBox.Show("Wrong username or password"); } }
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()); } }