/// <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)); }