Beispiel #1
0
        private void DeleteDepartment(DAL.Department department)
        {
            DialogResult dr = MessageBox.Show("Are you sure to delete department \"" + department.Name + "\"", "Confirm", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                EmloyeeDepartmentBLL emloyeeDepartmentBLL = new EmloyeeDepartmentBLL();
                EmployeeBLL          employeeBLL          = new EmployeeBLL();
                employeeBLL.DeleteByDepartment(emloyeeDepartmentBLL.ListEmployeeDepartmentByDepartment(department));
                DepartmentBLL departmentBLL = new DepartmentBLL();
                departmentBLL.DeleteDepartment(department);
                this.LoadData();
            }
        }
        private void addEmployee()
        {
            if (this.tvName.Text.Trim() == "")
            {
                MessageBox.Show("Please, enter the employee's full name!", "Warning", MessageBoxButtons.OK);
            }
            else
            {
                if (this.tvUserName.Text.Trim() == "")
                {
                    MessageBox.Show("Please, enter your full username!", "Warning", MessageBoxButtons.OK);
                }
                else
                {
                    if (this.tvPassword.Text == this.tvRetypePassword.Text)
                    {
                        EmployeeBLL          employeeBLL          = new EmployeeBLL();
                        EmloyeeDepartmentBLL emloyeeDepartmentBLL = new EmloyeeDepartmentBLL();

                        string mySalt       = BCrypt.Net.BCrypt.GenerateSalt();
                        string userPassWork = BCrypt.Net.BCrypt.HashPassword(this.tvRetypePassword.Text, mySalt);

                        Employee           employee           = employeeBLL.CreateEmployee(this.tvName.Text, this.tvUserName.Text, userPassWork);
                        EmployeeDepartment employeeDepartment = new EmployeeDepartment();
                        employeeDepartment.DepartmentID = department.ID;
                        employeeDepartment.EmployeeID   = employee.ID;
                        emloyeeDepartmentBLL.CreateEmployeeDepartment(employeeDepartment);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("The retype password you entered is incorrect!", "Warning", MessageBoxButtons.OK);
                    }
                }
            }
        }