/// <summary> /// 创建一个组织机构_角色部门业务权限 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据库上下文</param> /// <param name="entity">一个组织机构_角色部门业务权限</param> /// <returns></returns> public bool Create(ref ValidationErrors validationErrors, ORG_RoleDepartmentAuthority entity) { try { repository.Create(entity); return(true); } catch (Exception ex) { validationErrors.Add(ex.Message); ExceptionsHander.WriteExceptions(ex); } return(false); }
/// <summary> /// 获取部门树 /// </summary> /// <param name="id">主键</param> /// <param name="type">类别(role;user)</param> /// <returns></returns> public ActionResult GetDepTree(int id, string type) { //CommonBLL bll = new CommonBLL(); IBLL.IORG_DepartmentBLL bll = new BLL.ORG_DepartmentBLL(); //获取页面参数 string strDptID = Request["menuDpt"] ?? ""; //页面选中的部门 //string strRoleID = Request["roleID"] ?? "0";//当前角色 string strMenuId = Request["menuId"] ?? "0"; //页面选中的菜单 //页面是否曾经加载过,若未加载过,需选中的菜单以数据库数据为准,否则以页面参数为准 string strWindow = Request["isWindow"] ?? "0"; List <DepTree> list = new List <DepTree>(); //获取所有部门 List <ORG_Department> dt = bll.GetByParam("", "asc", "Sort", "XYBZDDL_String&Y"); if (dt.Count > 0) { foreach (ORG_Department dr in dt) { DepTree tree = new DepTree(); tree.ID = dr.ID; tree.DepartmentName = dr.DepartmentName; tree.ParentID = dr.ParentID == null ? 0 : Convert.ToInt32(dr.ParentID); tree.open = true; if (strWindow == "0") { if (type == "role") { IBLL.IORG_RoleDepartmentAuthorityBLL RoleDepBll = new BLL.ORG_RoleDepartmentAuthorityBLL(); ORG_RoleDepartmentAuthority RoleDep = new ORG_RoleDepartmentAuthority(); RoleDep = RoleDepBll.GetByParam("", "asc", "ID", string.Format("ORG_Role_IDDDL_Int&{0}^ORG_Menu_IDDDL_String&{1}", id, strMenuId)).FirstOrDefault();; if (RoleDep != null && !string.IsNullOrEmpty(RoleDep.ORG_Department_ID_List)) { foreach (string opt in RoleDep.ORG_Department_ID_List.Split(',')) { if (opt == tree.ID.ToString()) { tree.Checked = true; break; } } } } else//user { IBLL.IORG_UserDepartmentAuthorityBLL UserDepBll = new BLL.ORG_UserDepartmentAuthorityBLL(); ORG_UserDepartmentAuthority UserDep = new ORG_UserDepartmentAuthority(); UserDep = UserDepBll.GetByParam("", "asc", "ID", string.Format("ORG_User_IDDDL_Int&{0}^ORG_Menu_IDDDL_String&{1}", id, strMenuId)).FirstOrDefault(); if (UserDep != null && !string.IsNullOrEmpty(UserDep.ORG_Department_ID_List)) { foreach (string opt in UserDep.ORG_Department_ID_List.Split(',')) { if (opt == tree.ID.ToString()) { tree.Checked = true; break; } } } } } else { foreach (string opt in strDptID.Split(',')) { if (opt == tree.ID.ToString()) { tree.Checked = true; break; } } } list.Add(tree); } string content = Newtonsoft.Json.JsonConvert.SerializeObject(list); content = content.Replace("Checked", "checked"); return(Content(content)); } else { return(null); } }