示例#1
0
        /// <summary>
        /// Обработка нажатия кнопки Login
        /// Открывает следующее окно основываясь на роли пользователя либо выводит ошибку
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnLogin_OnClick(object sender, RoutedEventArgs e)
        {
            var user = AuthenticateUser(TbUsername.Text, TbPassword.Password);

            if (user == null)
            {
                return;
            }
            if (!user.Active)
            {
                MessageBox.Show("Ваш профиль был заблокирован администратором.");
            }
            var logger = new AuthLogger(user);

            switch (user.RoleId)
            {
            case 1:
                var adminWindow = new AdminWindow(this, user, logger);
                adminWindow.Show();
                Hide();
                break;

            case 2:
                var userWindow = new UserWindow(this, user, logger);
                userWindow.Show();
                Hide();
                break;

            default:
                break;
            }
        }
示例#2
0
 public UserWindow(Window previousWindow, User user, AuthLogger logger)
 {
     _previousWindow = previousWindow;
     _logger         = logger;
     InitializeComponent();
     _sessionStartTime = _logger.SessionStartTime;
     _clockTimer       = new DispatcherTimer();
     _clockTimer.Tick += UpdateClock;
     _clockTimer.Start();
     LblGreeting.Content = $"Hi {user.FirstName}, Welcome to AMONIC Airlines";
 }
示例#3
0
        public AdminWindow(Window previousWindow, User user, AuthLogger logger)
        {
            _previousWindow = previousWindow;
            _db             = new DataContext();
            _logger         = logger;
            InitializeComponent();
            LoadUsersTable();
            _user = user;
            var officesList = _db.Offices.ToList();

            CbOfficesList.ItemsSource       = officesList;
            CbOfficesList.DisplayMemberPath = "Title";
        }