Exemplo n.º 1
0
        private void UpdateEmployee(Employee employee)
        {
            employee.Passport          = txtPassport.Text;
            employee.FullName          = txtFullName.Text;
            employee.Phone             = txtPhone.Text;
            employee.Position          = (Position)ctlPosition.SelectedItem;
            employee.DrivingCategories = new List <DrivingCategory>();
            for (int i = 0; i < ctlDrivingCategories.Items.Count; i++)
            {
                if (ctlDrivingCategories.GetSelected(i))
                {
                    employee.DrivingCategories.Add((DrivingCategory)ctlDrivingCategories.Items[i]);
                }
            }

            if (!string.IsNullOrEmpty(txtLogin.Text))
            {
                if (employee.Account == null)
                {
                    employee.Account = new Account();
                }

                employee.Account.Login = txtLogin.Text;

                if (!string.IsNullOrEmpty(txtPassword.Text))
                {
                    employee.Account.Password = MD5Hasher.GetHash(txtPassword.Text);
                }
            }
        }
Exemplo n.º 2
0
        private void btnEnter_Click(object sender, EventArgs e)
        {
            Account account = new Account();

            account.Login    = txtLogin.Text.Trim();
            account.Password = MD5Hasher.GetHash(txtPassword.Text.Trim());

            if (account.Login == adminLogin && account.Password == adminPassword)
            {
                FmAdminMenu adminMenu = new FmAdminMenu();
                adminMenu.Show();
                this.Hide();

                return;
            }

            Employee employee = AccountDAO.SearchEmployee(account);


            if (employee != null)
            {
                FmMainMenu mainMenu = new FmMainMenu(employee);
                mainMenu.Show();
                this.Hide();

                return;
            }

            string loginErrorMessage = $"Ошибка входа в систему.{Environment.NewLine}Неверные имя пользователя или пароль.";

            MessageBox.Show(loginErrorMessage, "Ошибка входа.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }