コード例 #1
0
 private bool UpdateMenuForEmp()
 {
     try
     {
         List <PSMenuSecurity> lstMenuSecurity = new List <PSMenuSecurity>();
         for (int i = 0; i < lstMenu.Count; i++)
         {
             string         item         = lstMenu[i];
             string[]       items        = item.Split(',');
             PSMenuSecurity menuSecurity = new PSMenuSecurity
             {
                 MenuCode     = items[0],
                 MenuName     = items[1],
                 EmployeeCode = empCode,
                 CreateDate   = DateTime.Now
             };
             lstMenuSecurity.Add(menuSecurity);
         }
         return(BioBLL.UpdateMenuSercurity(lstMenuSecurity, empCode));
     }
     catch { return(false); }
 }
コード例 #2
0
ファイル: BioBLL.cs プロジェクト: ngoctuan29/BioCuaAnh
        public static void InsertItemMenuSercurity(PSMenuSecurity itemMenuSecurity)
        {
            var db = new BioDAL();

            db.InsertItemMenuSercurity(itemMenuSecurity);
        }
コード例 #3
0
ファイル: BioBLL.cs プロジェクト: ngoctuan29/BioCuaAnh
        public static void DeleteItemMenuSercurity(PSMenuSecurity itemMenuSecurity)
        {
            var db = new BioDAL();

            db.DeleteItemMenuSercurity(itemMenuSecurity);
        }
コード例 #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                lstMenu = new List <string>();
                FindItemToCheckByParent(treeAuthor.Nodes[0]);

                if (this.isGroup)
                {
                    if (this.positionCode == 0)
                    {
                        XtraMessageBox.Show("Chưa chọn nhân viên để thực hiện!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    int checkLevel = this.CheckLevelPositionWithPosCode(this.empLogin);
                    if (checkLevel == 0)
                    {
                        XtraMessageBox.Show("Bạn không thể chỉnh sửa nhóm nhân viên trên cấp!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (checkLevel == -1)
                    {
                        XtraMessageBox.Show("Bạn không thể chỉnh sửa nhóm nhân viên bằng cấp!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (checkLevel == -2)
                    {
                        XtraMessageBox.Show("Lỗi không thể sửa phẩn quyền!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (rdoDefault.Checked)
                    {
                        if (UpdateMenuForPosition())
                        {
                            XtraMessageBox.Show("Cập nhật phân quyền thành công!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            XtraMessageBox.Show("Cập nhật phân quyền thất bại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                    else if (rdoApplyForEmp.Checked)
                    {
                        UpdateMenuForPosition();

                        var           lstEmpPosition = BioBLL.GetEmployeeByPosition(this.positionCode);
                        List <string> menu           = CompareWithTwoList(lstMenuByPosition, lstMenuByPositionNew);

                        foreach (var empPosition in lstEmpPosition)
                        {
                            foreach (var emp in empPosition.Employee)
                            {
                                this.empCode = emp.EmployeeCode;
                                for (int i = 0; i < menu.Count; i++)
                                {
                                    string[]       items        = menu[i].Split(',');
                                    PSMenuSecurity menuSecurity = new PSMenuSecurity
                                    {
                                        MenuCode     = items[0],
                                        MenuName     = items[1],
                                        EmployeeCode = this.empCode,
                                        CreateDate   = DateTime.Now
                                    };
                                    if (items[2] == "Check")
                                    {
                                        BioBLL.InsertItemMenuSercurity(menuSecurity);
                                    }
                                    else
                                    {
                                        BioBLL.DeleteItemMenuSercurity(menuSecurity);
                                    }
                                }
                            }
                        }
                        XtraMessageBox.Show("Cập nhật phân quyền thành công!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (rdoApplyToDefault.Checked)
                    {
                        UpdateMenuForPosition();
                        var lstEmpPosition = BioBLL.GetEmployeeByPosition(this.positionCode);
                        foreach (var empPosition in lstEmpPosition)
                        {
                            foreach (var emp in empPosition.Employee)
                            {
                                this.empCode = emp.EmployeeCode;
                                UpdateMenuForEmp();
                            }
                        }
                        XtraMessageBox.Show("Cập nhật phân quyền thành công!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        XtraMessageBox.Show("Chưa chọn thiết lập phân quyền cho nhóm!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        rdoDefault.Focus();
                        return;
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(this.empCode))
                    {
                        XtraMessageBox.Show("Chưa chọn nhân viên để thực hiện!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    int checkLevel = this.CheckLevelPositionWithEmpCode(this.empLogin, this.empCode);
                    if (checkLevel == 0)
                    {
                        XtraMessageBox.Show("Bạn không thể chỉnh sửa nhân viên trên cấp!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (checkLevel == -1)
                    {
                        XtraMessageBox.Show("Bạn không thể chỉnh sửa nhân viên bằng cấp!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (checkLevel == -2)
                    {
                        XtraMessageBox.Show("Lỗi không thể sửa phẩn quyền!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (UpdateMenuForEmp())
                    {
                        XtraMessageBox.Show("Cập nhật phân quyền thành công!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        XtraMessageBox.Show("Cập nhật phân quyền thất bại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            catch
            {
                XtraMessageBox.Show("Cập nhật phân quyền thất bại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }