Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EmployeeUC"/> class.
 /// </summary>
 /// <param name="theGrid">The grid.</param>
 public EmployeeUC(DataGridView theGrid)
 {
     UserControlType = UserControls.Employee;
     DataGrid = theGrid;
     this.InitializeComponent();
     this.theController = new EmployeeController();
     this.loadEmployees();
 }
Ejemplo n.º 2
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            var theController = new EmployeeController();
            var id = 0;

            int.TryParse(this.usernameTextBox.Text, out id);

            DialogResult = DialogResult.None;

            if (id != 0)
            {
                var theUser = new LoginSession();
                try
                {
                    theUser = theController.ValidateUserOnNetwork(id, this.passwordTextBox.Text);
                }
                catch (Exception exception)
                {
                    ErrorHandler.DisplayErrorMessageToUserAndLog("Network Error",
                        "Unable to connect to SQL Database. Please try again.", exception);
                }

                if (theUser.IsAuthenticated)
                {
                    Tag = theUser;
                    DialogResult = DialogResult.OK;
                    Close();
                }
                else
                {
                    ErrorHandler.DisplayErrorBox("Login Error", "Invalid login information. Please try again.");
                }
            }
            else
            {
                ErrorHandler.DisplayErrorBox("Login Error", "Invalid login information. Please try again.");
            }
        }