예제 #1
0
        private void login(Object sender, EventArgs e)
        {
            Services.EmployeeRepository repository = new Services.EmployeeRepository();

            Employee employee = repository.GetEmployeeByName(loginControl1.Username);

            if (employee == null)
            {
                MessageBox.Show("Username doesn't exists!");
            }
            else
            {
                if (employee.Password == loginControl1.Password)
                {
                    if (employee.Password.Equals(""))
                    {
                        if ((new FirstLoginDialog(ref employee)).ShowDialog() == DialogResult.OK)
                        {
                            if (employee.Administrator == true)
                            {
                                Hide();
                                new AdminForm(employee).Show();
                            }
                            else
                            {
                                Hide();
                                new EmployeeForm(employee).Show();
                            }
                        }
                    }
                    else
                    {
                        if (employee.Administrator == true)
                        {
                            Hide();
                            new AdminForm(employee).Show();
                        }
                        else
                        {
                            Hide();
                            new EmployeeForm(employee).Show();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Wrong password!");
                    loginControl1.Password = string.Empty;
                }
            }
        }