Ejemplo n.º 1
0
        private void OnClick_Login(object sender, RoutedEventArgs e)
        {
            try
            {
                string username = txtUsername.Text;
                string password = boxPassword.Password;

                AssertValidUserCredentials(username, password);

                StudentInfoContext context = new StudentInfoContext();

                User user = DatabaseUtils.GetUserByUsername(username);

                if (UserRoles.ADMIN.Equals(user.Role))
                {
                    AdminWindow adminWindow = new AdminWindow();
                    adminWindow.Show();
                }
                else
                {
                    LoginUser();
                }
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show(String.Format("Потребител с име: {0} не беше намерен.", txtUsername.Text));
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Ejemplo n.º 2
0
 public void SaveChanges()
 {
     UserLogin.User user = UserLogin.UserData.IsUserPassCorrect(Login.Username, Login.Password);
     if (user != null)
     {
         if (user.Role == UserLogin.UserRoles.ADMIN)
         {
             AdminWindow adminWindow = new AdminWindow();
             adminWindow.Show();
         }
     }
 }