Exemplo n.º 1
0
 public static void OpenLoginWindow()
 {
     View.LoginWindow loginWindow = new View.LoginWindow();
     loginWindow.Show();
     Application.Current.MainWindow.Close();
     Application.Current.MainWindow = loginWindow;
 }
Exemplo n.º 2
0
 private void SwitchUser()
 {
     if (MessageBox.Show("Do you want to change user?", "Log out", MessageBoxButton.YesNo,
                         MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
     {
         View.LoginWindow view = new View.LoginWindow();
         MW.Close();
         view.Show();
     }
 }
 private void RegisterAccount(object sender, RoutedEventArgs e)
 {
     try
     {
         if (!string.IsNullOrEmpty(usernameBox.Text) && !string.IsNullOrWhiteSpace(usernameBox.Text))
         {
             if (newPasswordBox.Password == verifyPasswordBox.Password)
             {
                 if (!string.IsNullOrEmpty(newPasswordBox.Password) && !string.IsNullOrWhiteSpace(newPasswordBox.Password))
                 {
                     if (newPasswordBox.Password.ToString().Trim().Length > 5)
                     {
                         IAdminService admin = new AdminService();
                         admin.Insert(new Admin()
                         {
                             username = usernameBox.Text.ToString().Trim(), password = newPasswordBox.Password.ToString().Trim()
                         });
                         MessageBox.Show("User added to the database.", "Registration", MessageBoxButton.OK, MessageBoxImage.Information);
                         View.LoginWindow eenView = new View.LoginWindow();
                         eenView.Show();
                         this.Close();
                     }
                     else
                     {
                         MessageBox.Show("Password must contain at least 6 characters!", "Password Error", MessageBoxButton.OK, MessageBoxImage.Error);
                     }
                 }
                 else
                 {
                     MessageBox.Show("Password cannot be empty or whitespace!", "Password Error", MessageBoxButton.OK, MessageBoxImage.Error);
                 }
             }
             else
             {
                 MessageBox.Show("Passwords do not match!", "Password Error", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
         else
         {
             MessageBox.Show("Username cannot be empty or whitespace!", "Password Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void Cancel(object sender, RoutedEventArgs e)
 {
     View.LoginWindow eenView = new View.LoginWindow();
     eenView.Show();
     this.Close();
 }