예제 #1
0
        private void GoToUserPanelButton_Click(object sender, RoutedEventArgs e)
        {
            UserPanel newWindow = new UserPanel();

            newWindow.Show();
            Close();
        }
예제 #2
0
        private async void LogInButton_Click(object sender, RoutedEventArgs e)
        {
            ProgressSpin.IsActive  = true;
            LoginFailed.Visibility = Visibility.Hidden;
            LogInButton.IsEnabled  = false;

            if (LoginBox.Text.Length > 0 && PasswordBox.Password.Length > 0)
            {
                using (IAuthenticationCore core = new AuthenticationCore())
                {
                    var loginModel = new LoginModel()
                    {
                        Login    = LoginBox.Text,
                        Password = PasswordBox.Password
                    };

                    if (core.AdminLogin(loginModel))
                    {
                        AdministratorPanel newAdministratorWindow = new AdministratorPanel();
                        newAdministratorWindow.Show();
                        Close();
                    }
                    else
                    {
                        if (await core.LoginAsync(loginModel))
                        {
                            LoginFailed.Visibility = Visibility.Hidden;
                            UserPanel newMainWindow = new UserPanel();
                            newMainWindow.Show();
                            Close();
                        }
                        else
                        {
                            LoginFailed.Visibility = Visibility.Visible;
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Invalid form");
            }
            ProgressSpin.IsActive = false;
            LogInButton.IsEnabled = true;
        }