コード例 #1
0
 /// <summary>
 /// 创建一个组织机构_角色部门范围权限
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="db">数据库上下文</param>
 /// <param name="entity">一个组织机构_角色部门范围权限</param>
 /// <returns></returns>
 public bool Create(ref ValidationErrors validationErrors, ORG_RoleDepartmenScopetAuthority entity)
 {
     try
     {
         repository.Create(entity);
         return(true);
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
コード例 #2
0
        /// <summary>
        /// 获取默认选中的菜单
        /// </summary>
        /// <param name="id">主键</param>
        /// <param name="type">类别(role;user)</param>
        /// <param name="tr"></param>
        private void GetChecked(int id, string type, ref SysMenu tr)
        {
            IBLL.IORG_MenuOpBLL MoBll = new BLL.ORG_MenuOpBLL();
            //获取菜单相关操作
            List <ORG_MenuOp> ListOpt = new List <ORG_MenuOp>();

            //ListOpt = MoBll.GetByParam("","ID","asc","XYBZ = 'Y' and Org_Menu_ID = '" + tr.id + "' order by Sort asc");
            ListOpt = MoBll.GetByParam("", "asc", "Sort", "XYBZDDL_String&Y^Org_Menu_IDDDL_Int&" + tr.id.ToString());
            string MenuOpIds = "";

            //获取菜单操作权限
            if (type == "role")
            {
                IBLL.IORG_RoleMenuOpAuthorityBLL RmoBll          = new BLL.ORG_RoleMenuOpAuthorityBLL();
                ORG_RoleMenuOpAuthority          MenuOpAuthority = new ORG_RoleMenuOpAuthority();
                //MenuOpAuthority = bll.GetByParam("", "asc", "Sort", string.Format("ORG_Role_ID = {0} and ORG_Menu_ID = '{1}'", id, tr.id)).FirstOrDefault();
                MenuOpAuthority = RmoBll.GetByParam("", "asc", "ID", string.Format("ORG_Role_IDDDL_Int&{0}^ORG_Menu_IDDDL_String&{1}", id, tr.id)).FirstOrDefault();

                if (MenuOpAuthority != null)
                {
                    MenuOpIds = MenuOpAuthority.ORG_MenuOp_ID_List ?? "";
                    //tr.DataScope = MenuOpAuthority.DataScope;
                    tr.IsChecked = true;
                }

                ORG_RoleDepartmenScopetAuthority          DepartmentScopet = new ORG_RoleDepartmenScopetAuthority();
                IBLL.IORG_RoleDepartmenScopetAuthorityBLL RdsBll           = new BLL.ORG_RoleDepartmenScopetAuthorityBLL();
                //DepartmentScopet = RdsBll.GetModel<ORG_RoleDepartmenScopetAuthority>(string.Format("ORG_Role_ID = {0} and ORG_Menu_ID = '{1}'", id, tr.id));
                DepartmentScopet = RdsBll.GetByParam("", "asc", "ID", string.Format("ORG_Role_IDDDL_Int&{0}^ORG_Menu_IDDDL_String&{1}", id, tr.id)).FirstOrDefault();
                if (DepartmentScopet != null)
                {
                    tr.DataScope = DepartmentScopet.DepartmentScope;
                }
            }
            else//user
            {
                IBLL.IORG_UserMenuOpAuthorityBLL UmoBll          = new BLL.ORG_UserMenuOpAuthorityBLL();
                ORG_UserMenuOpAuthority          MenuOpAuthority = new ORG_UserMenuOpAuthority();
                //MenuOpAuthority = bll.GetModel<ORG_UserMenuOpAuthority>(string.Format("ORG_User_ID = {0} and ORG_Menu_ID = '{1}'", id, tr.id));
                MenuOpAuthority = UmoBll.GetByParam("", "asc", "ID", string.Format("ORG_User_IDDDL_Int&{0}^ORG_Menu_IDDDL_String&{1}", id, tr.id)).FirstOrDefault();
                if (MenuOpAuthority != null)
                {
                    MenuOpIds = MenuOpAuthority.ORG_MenuOp_ID_List ?? "";
                    //tr.DataScope = MenuOpAuthority.DataScope;
                    tr.IsChecked = true;
                }

                ORG_UserDepartmenScopetAuthority          DepartmentScopet = new ORG_UserDepartmenScopetAuthority();
                IBLL.IORG_UserDepartmenScopetAuthorityBLL UdsBll           = new BLL.ORG_UserDepartmenScopetAuthorityBLL();
                //DepartmentScopet = bll.GetModel<ORG_UserDepartmenScopetAuthority>(string.Format("ORG_User_ID = {0} and ORG_Menu_ID = '{1}'", id, tr.id));
                DepartmentScopet = UdsBll.GetByParam("", "asc", "ID", string.Format("ORG_User_IDDDL_Int&{0}^ORG_Menu_IDDDL_String&{1}", id, tr.id)).FirstOrDefault();
                if (DepartmentScopet != null)
                {
                    tr.DataScope = DepartmentScopet.DepartmentScope;
                }
            }

            List <MenuOption> ListMenuOpt = new List <MenuOption>();
            MenuOption        Option      = new MenuOption();

            foreach (ORG_MenuOp model in ListOpt)
            {
                Option             = new MenuOption();
                Option.ID          = model.ID;
                Option.MenuOpName  = model.MenuOpName;
                Option.SYS_Menu_ID = model.ORG_Menu_ID;
                // 获取当前操作权限
                foreach (string MenuOpId in MenuOpIds.Split(','))
                {
                    if (MenuOpId == model.ID)
                    {
                        Option.IsChecked = true;
                        break;
                    }
                }
                tr.MenuOptions.Add(Option);
                tr.MenuOptIds += Option.ID + ",";
            }

            if (!string.IsNullOrEmpty(tr.MenuOptIds))
            {
                tr.MenuOptIds = tr.MenuOptIds.Substring(0, tr.MenuOptIds.LastIndexOf(','));
            }
        }