/// <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)); }
public string SubmitUserForm(CrmUserEntity entity) { string rtMsrg; int rtState; try { entity.Birthday = entity.Birthday.Year == 1 ? MinDate : entity.Birthday; var isAdd = string.IsNullOrEmpty(entity.Id); bool flag; if (isAdd) { entity.Password = DESHelper.ToDESEncrypt("123456", AppConst.EncryptKey); //初始默认密码123456 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 CrmUserBll().Add(entity) != null; } else { entity.Password = new CrmUserBll().Get(entity.Id).Password; //修改用户信息密码保持不变 entity.UpdateBy = CurrentUser.CrmUser.LoginName; entity.UpdateId = CurrentUser.CrmUser.Id; entity.UpdateOn = DateTime.Now; flag = new CrmUserBll().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)); }
public ActionResult ChatForm(string id) { ViewBag.ChatMessage = new ChatMessageBll().getLastMessage(10, CurrentUser.CrmUser.Id, id); CrmUserEntity user = cubll.Get(id); if (user.Portrait != "") { var fileEntity = new ComAttachmentBll().Get(user.Portrait); ViewBag.UserAvatar = !string.IsNullOrEmpty(fileEntity.FilePath) ? "/User/images/" + fileEntity.FilePath : "/User/images/avatar.png"; } else { ViewBag.UserAvatar = "/User/images/avatar.png"; } if (CurrentUser.CrmUser.Portrait != "") { var user2 = CurrentUser.CrmUser; var fileEntity = new ComAttachmentBll().Get(user2.Portrait); ViewBag.ToUserAvatar = !string.IsNullOrEmpty(fileEntity.FilePath) ? "/User/images/" + fileEntity.FilePath : "/User/images/avatar.png"; } else { ViewBag.ToUserAvatar = "/User/images/avatar.png"; } ViewData["Me"] = CurrentUser.CrmUser; if (user != null) { return(View(user)); } return(View(new CrmUserEntity())); }