private void AdminButtonClick(object sender, RoutedEventArgs e)
        {
            Window AdminWindow = new AdminMainWindow();

            AdminWindow.Show();
            this.Close();
        }
        private void Back_Click(object sender, RoutedEventArgs e)
        {
            Window MainAdmin = new AdminMainWindow();

            MainAdmin.Show();
            this.Close();
        }
Esempio n. 3
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            User   user;
            string userName = this.UserName.Text;
            string password = this.UserPassword.Password;

            try
            {
                user = myIBL.GetUser(userName);
                if (password == user.Password)
                {
                    if (user.Type == UserType.Guest)
                    {
                        Window guestMainWindow = new GuestMainWindow(myIBL.GetGuestByUserName(user.UserName));
                        guestMainWindow.Show();
                        this.Close();
                    }
                    else if (user.Type == UserType.Host)
                    {
                        Window hostMainWindow = new HostMainWindow(myIBL.GetHostByUserName(user.UserName));
                        hostMainWindow.Show();
                        this.Close();
                        //}
                    }
                    else if (user.Type == UserType.Admin)
                    {
                        Window adminMainWindow = new AdminMainWindow();
                        adminMainWindow.Show();
                        this.Close();
                    }
                }
                else
                {
                    throw new NotExsitingUserException();
                }
            }
            catch (NotExsitingUserException)
            {
                UserPassword.Focus();
                MessageBox.Show("The Password you entered are incorrect.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (NotExistingKeyException)
            {
                UserName.Focus();
                MessageBox.Show("The UserName you entered doesn't exist", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }