private void Logout_Click(object sender, RoutedEventArgs e) { var next_window = new LoginWindow(); next_window.Show(); this.Close(); }
public void GoBackLogin_Click(object sender, RoutedEventArgs e) { var next_window = new LoginWindow(); next_window.Show(); this.Close(); }
private void Button_Loginwindow(object sender, RoutedEventArgs e) { LoginWindow loginw = new LoginWindow(); loginw.Show(); this.Close(); }
private void LoggOuteClick(object sender, RoutedEventArgs e) // Knappens funktion { var loginwindow = new LoginWindow(); // Stänger fönstret vid utloggning och tar en till inloggningsfönstret. loginwindow.Show(); this.Close(); }
// Hänvisar tillbaka till LoginWindow private void Cancel_Click(object sender, RoutedEventArgs e) { var next_windowTwo = new LoginWindow(); next_windowTwo.Show(); this.Close(); }
private void Create_account_click(object sender, RoutedEventArgs e) { string full_name = name_field.Text.Trim(); string email = email_field.Text.Trim(); string password = password_field.Password; string password_check = confirm_password_field.Password; if (password != password_check) { MessageBox.Show("Your passwords doesn't match"); } else { bool test = API.Create_account(full_name, email, password); if (test) { MessageBox.Show("Account successfully created!"); var next_window = new LoginWindow(); next_window.Show(); this.Close(); } else { MessageBox.Show("Email already in use!"); } } }
private void CreateNewAccountClick(object sender, RoutedEventArgs e) { using (var ctx = new Context()) { try { if (IsValidEmail(Email.Text) == true) { if (Password.Password == Password2.Password) { State.User = API.GetCustomerByName(Name.Text); if (State.User != null) { MessageBox.Show("Username already taken.", "Account creation Failed!", MessageBoxButton.OK, MessageBoxImage.Information); Name.Text = "..."; Password.Password = "******"; Email.Text = "..."; Age.Text = "..."; } else { ctx.Customers.Add(new Customer { Name = Name.Text, Password = Password.Password, Email = Email.Text, Age = Convert.ToInt32(Age.Text) }); ctx.SaveChanges(); MessageBox.Show("Account successful creation.", "Account creation Succeeded!", MessageBoxButton.OK, MessageBoxImage.Information); var next_window = new LoginWindow(); next_window.Show(); this.Close(); } } else { Password.Background = Brushes.Red; Password2.Background = Brushes.Red; MessageBox.Show("Password doesn't match.", "Password error.", MessageBoxButton.OK, MessageBoxImage.Information); } } else { Email.Background = Brushes.Red; MessageBox.Show("Incorrect email form", "Email error.", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (System.FormatException) { Age.Text = "..."; Age.Background = Brushes.Red; MessageBox.Show("Not correct input"); } } }
private void Exit_Click(object sender, RoutedEventArgs e) { State.User.FirstName = ""; State.User.LastName = ""; State.User.EmailAdress = ""; State.User.UserName = ""; State.User.Password = ""; var login = new LoginWindow(); login.Show(); this.Close(); }
private void Submit_Click(object sender, RoutedEventArgs e) { //Lägger till ny användare samt hänvisar tillbaka till LoginWindow. using (var ctx = new Context()) { if (FirstName.Text.Length == 0) { MessageBox.Show("Please enter your first name."); } else if (UserName.Text.Length == 0) { MessageBox.Show("Please enter a username."); } else if (PasswordField.Password.Length == 0) { MessageBox.Show("Please enter a password."); } else if (Email.Text.Length == 0) { MessageBox.Show("Please enter an e-mailadress."); } else { State.User = API.GetCustomerByName(Email.Text); if (State.User != null) { MessageBox.Show("Username already taken."); UserName.Clear(); } else { ctx.Customers.Add(new Customer { Name = FirstName.Text, UserName = UserName.Text, Password = PasswordField.Password, Email = Email.Text }); ctx.SaveChanges(); MessageBox.Show("You've made an account!"); var next_window = new LoginWindow(); next_window.Show(); this.Close(); } } } }
public void AccountCreate_Click(object sender, RoutedEventArgs e) { string username = CreateAccountUsernameField.Text; string password = CreateAccountPasswordField.Text; string passwordMatch = ConfirmPasswordField.Text; string mobile = PhoneNumberField.Text; string firstName = FirstNameField.Text; string lastName = LastNameField.Text; if (password == passwordMatch) { API.AddUser(username, password, mobile, firstName, lastName); var next_window = new LoginWindow(); next_window.Show(); this.Close(); } else { var new_window = new PassMissMatch(); new_window.Show(); this.Close(); } }
private void AddIn_Click(object sender, RoutedEventArgs e) { State.User = API.GetCustomerByName(UserField.Text.Trim(), PWField.Password); if (State.User != null) { MessageBox.Show("Användaren finns redan"); } else { int phonenummer = Convert.ToInt32(PField.Text.Trim()); API.AddCustomer(UserField.Text.Trim(), PWField.Password, AddressField.Text.Trim(), EmailField.Text.Trim(), phonenummer); State.User = API.GetCustomerByName(UserField.Text.Trim(), PWField.Password); String choosenGenre = GenreBox.SelectedItem.ToString(); API.SetFavoriteGenre(State.User, choosenGenre); // API.AddGenre() var new_window = new LoginWindow(); new_window.Show(); this.Close(); } }
private void RegisterButton_Click(object sender, RoutedEventArgs e) { using var ctx = new Context(); var validateUserInput = true; var cList = ctx.Customers.ToList(); if (rEmailAdressText.Text == null || string.IsNullOrWhiteSpace(rEmailAdressText.Text)) { MessageBox.Show("Email adress is required."); validateUserInput = false; } if (ruserNameText.Text == null || string.IsNullOrWhiteSpace(ruserNameText.Text)) { MessageBox.Show("Username is required."); validateUserInput = false; } if (rpasswordText.Password == null || string.IsNullOrWhiteSpace(rpasswordText.Password)) { MessageBox.Show("Password is required."); validateUserInput = false; } if (validateUserInput) { foreach (var customer in cList) { if (customer.EmailAdress == rEmailAdressText.Text) { MessageBox.Show("Email adress already exists."); validateUserInput = false; } if (customer.UserName == ruserNameText.Text) { MessageBox.Show("Username already exists."); validateUserInput = false; } } } if (validateUserInput) { var nCustomer = new Customer { FirstName = rFirstNameText.Text, LastName = rLastNameText.Text, EmailAdress = rEmailAdressText.Text, UserName = ruserNameText.Text, Password = rpasswordText.Password }; ctx.Add(nCustomer); ctx.SaveChanges(); MessageBox.Show("Your account is now registered. Welcome!"); var loginWindow = new LoginWindow(); loginWindow.Show(); this.Close(); } }