private void BackButton_Click(object sender, RoutedEventArgs e) { Login_window login_Window = new Login_window(this.Left, this.Top); login_Window.Show(); Close(); }
private void RegisterButton_Click(object sender, RoutedEventArgs e) { string inputUsername = username.Text; string inputPassword = password.Password; string inputConfirmPassword = confirm_password.Password; string inputBirthday = ""; Regex reg = new Regex("(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#]).*$"); Match match = reg.Match(inputPassword); if (string.IsNullOrEmpty(inputUsername)) { System.Windows.MessageBox.Show("Username box is empty"); return; } else if (string.IsNullOrEmpty(inputPassword)) { System.Windows.MessageBox.Show("Password box is empty"); return; } else if (string.IsNullOrEmpty(inputConfirmPassword)) { System.Windows.MessageBox.Show("Confirm Password box is empty"); return; } else if (!inputPassword.Equals(inputConfirmPassword)) { System.Windows.MessageBox.Show("Confirm Password does not match password"); return; } else if (UserList.isUsernameTaken(inputUsername)) { System.Windows.MessageBox.Show("Username is already taken, choose another one"); return; } else if (UserList.isOnTheList(inputUsername, inputPassword)) { System.Windows.MessageBox.Show("User is already on the list"); return; } else if (!match.Success) { System.Windows.MessageBox.Show("Password must have at least: one special character(!@#), one lower case letter, one upper case letter, one number"); return; } else { try { DateTime inputDateTimeBirthday = (DateTime)birthday.SelectedDate; inputBirthday = inputDateTimeBirthday.ToShortDateString(); } catch (Exception) { System.Windows.MessageBox.Show("Missing box birthday or invalid data format\n(correct one is: DD.MM.RRRR)"); return; } } User newUser = new User(inputUsername, inputPassword, inputBirthday); UserList.userList.Add(newUser); System.Windows.MessageBox.Show("Success! You can now log in."); Login_window login_Window = new Login_window(this.Left, this.Top); login_Window.Show(); Close(); }