public string DeleteRole(string roleId) { string rtMsrg; int rtState; try { var flag = new CrmRoleBll().BatchDelete(roleId); rtMsrg = flag ? "删除成功" : "删除失败"; rtState = flag ? (int)OperationState.Success : (int)OperationState.Failure; } catch (Exception ex) { rtState = (int)OperationState.Error; rtMsrg = ex.Message; } var rtEntity = new StatusModel <DBNull> { rtData = null, rtMsrg = rtMsrg, rtState = rtState }; return(CommonMethod.ToJson(rtEntity)); }
/// <summary> /// 新增/编辑 /// </summary> /// <param name="companyId">单位ID</param> /// <param name="departmentId">部门主键编号</param> /// <param name="userId">用户ID</param> /// <returns></returns> public ActionResult Edit(string companyId, string departmentId, string userId) { var entity = new CrmUserEntity(); string roles = ""; if (!string.IsNullOrEmpty(userId)) { entity = new CrmUserBll().Get(userId); var userRole = new CrmUserRoleBll().GetSearchResult(new CrmUserRoleEntity() { UserId = userId }); if (userRole != null && userRole.Any()) { foreach (var crmUserRoleEntity in userRole) { var roleEntity = new CrmRoleBll().Get(crmUserRoleEntity.RoleId); if (roleEntity != null) { roles += roleEntity.FullName + ","; } } } } else if (!string.IsNullOrEmpty(companyId) && !string.IsNullOrEmpty(departmentId)) { entity.CompanyId = companyId; entity.DepartmentId = departmentId; } ViewBag.Roles = roles; return(View(entity)); }
/// <summary> /// 请求角色GridListJson /// </summary> /// <history> /// 修改描述:时间+作者+描述 /// </history> /// <param name="companyId">单位编号</param> /// <param name="rows">请求条数</param> /// <param name="page">请求页数</param> /// <returns></returns> public string GridListJson(string companyId, int rows, int page) { var departments = new CrmRoleBll().GetSearchResult(new CrmRoleEntity { CompanyId = companyId, PageIndex = page, PageSize = rows }); return(CommonMethod.PageToJson(departments)); }
/// <summary> /// 新增/编辑 /// </summary> /// <param name="companyId">单位编号</param> /// <param name="roleId">角色编号</param> /// <returns></returns> public ActionResult Edit(string companyId, string roleId) { var entity = new CrmRoleEntity(); if (!string.IsNullOrEmpty(roleId)) { entity = new CrmRoleBll().Get(roleId); } else if (!string.IsNullOrEmpty(companyId)) { entity.CompanyId = companyId; } return(View(entity)); }
public string SubmitRoleForm(CrmRoleEntity entity, FormCollection collection) { string rtMsrg; int rtState; try { var isAdd = string.IsNullOrEmpty(entity.Id); bool flag; if (isAdd) { entity.Id = Guid.NewGuid().ToString(); entity.RowStatus = (int)RowStatus.Normal; entity.CreateBy = CurrentUser.CrmUser.LoginName; entity.CreatorId = CurrentUser.CrmUser.Id; entity.CreateOn = DateTime.Now; entity.UpdateBy = CurrentUser.CrmUser.LoginName; entity.UpdateId = CurrentUser.CrmUser.Id; entity.UpdateOn = DateTime.Now; flag = new CrmRoleBll().Add(entity) != null; } else { entity.UpdateBy = CurrentUser.CrmUser.LoginName; entity.UpdateId = CurrentUser.CrmUser.Id; entity.UpdateOn = DateTime.Now; flag = new CrmRoleBll().Update(entity) > 0; } rtMsrg = flag ? "保存成功" : "保存失败"; rtState = flag ? (int)OperationState.Success : (int)OperationState.Failure; } catch (Exception ex) { rtState = (int)OperationState.Error; rtMsrg = ex.Message; } var rtEntity = new StatusModel <DBNull> { rtData = null, rtMsrg = rtMsrg, rtState = rtState }; return(CommonMethod.ToJson(rtEntity)); }
/// <summary> /// 单位与角色TreeJson /// </summary> /// <history> /// 修改描述:时间+作者+描述 /// </history> /// <returns></returns> public JsonResult ScopeRoleList() { var companys = new CrmCompanyBll().GetAllCompany(); var roles = new CrmRoleBll().GetAllRoles(); //企业 var topCompany = companys.Where(x => x.ParentId == "0").ToList(); var result = (from companyEntity in topCompany let childs = ChildCompany(companys, roles, companyEntity.Id) select new TreeNode() { id = companyEntity.Id, text = companyEntity.FullName, value = "company", img = "/Content/Images/Icon16/molecule.png", //tree.js处理路径 showcheck = false, isexpand = true, complete = true, hasChildren = childs.Count > 0, ChildNodes = childs }).ToList(); return(Json(result, JsonRequestBehavior.AllowGet)); }