Пример #1
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            var username = txtUsername.Text;
            var password = txtPassword.Password;
            var usrMgr   = new UserManager();

            if (admin == null)
            {
                try
                {
                    admin = usrMgr.AuthenticateAdmin(username, password);
                    MessageBox.Show(admin.AdministratorID + " " + admin.Username + " has successfully logged in...");
                    AdminUI adminUi = new AdminUI();
                    Close();
                    adminUi.ShowDialog();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    txtPassword.Clear();
                    txtPassword.Focus();
                }
            }
            else
            {
                admin = null;
                txtUsername.Focus();
            }
        }
        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            AdminUI adminUI = new AdminUI();

            Close();
            adminUI.ShowDialog();
        }