public ActionResult UpdateEmployee(int id) { ViewData["Roles"] = Manage.GetRoles(0); var r = new UpdateOrganizationUserModel(); var data = YunClient.Instance.Execute(new GerPermissionUserRequest { Id = id, }, Member.Token).User; if (data != null) { r.DisplayName = data.DisplayName; r.Email = data.Email; r.Entry = data.EntryTime; r.IdCard = data.IdCard; r.IsFemale = data.IsFemale ? 1 : 0; r.JobNum = data.JobNum; r.OrgId = (int)data.OrganizationId; r.OtherName = data.OtherName; r.Phone = data.Phone; r.Plane = data.Plane; r.Remark = data.Description; r.Roleids = data.Roles; r.UserName = data.UserName; r.WorkPlace = data.WorkPlace; return View(r); } TempData["error"] = "该职员不存在,请重新选择"; return RedirectToAction("Employees"); }
/// <summary> /// 更新员工资料 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult UpdateEmployee(int id) { ViewData["Roles"] = Manage.GetRoles(0, CompanyId, ShopId, Token); var r = new UpdateOrganizationUserModel(); var data = YunClient.Instance.Execute(new GerPermissionUserRequest { Id = id, }, Token).User; if (data != null) { r.DisplayName = data.DisplayName; r.Email = data.Email; r.Entry = data.EntryTime == null ? "" : data.EntryTime.Substring(0, data.EntryTime.IndexOf(' ')); r.IdCard = data.IdCard; r.IsFemale = data.IsFemale ? 1 : 0; r.JobNum = data.JobNum; r.OrgId = (int) data.OrganizationId; r.OtherName = data.OtherName; r.Phone = data.Phone; r.Plane = data.Plane; r.Remark = data.Description; r.Roleids = (data.Roles != null && data.Roles.Any()) ? data.Roles.Select(e => (int)e.Key).ToList() : null; r.UserName = data.UserName; r.WorkPlace = data.WorkPlace; return View(r); } TempData["error"] = "该职员不存在,请重新选择"; return RedirectToAction("Employees"); }
public ActionResult UpdateEmployee(int id, UpdateOrganizationUserModel model, FormCollection collection) { if (ModelState.IsValid) { var r = Manage.UpdateUserOrganization(0, 0, model.IdCard, collection["Role"], collection["EntryTime"].Is<DateTime>() ? collection["EntryTime"] : null, model.JobNum, model.OtherName, model.Phone, model.Email, model.Plane, model.WorkPlace, model.IsFemale == 1, model.DisplayName, id); TempData["success"] = "已成功修改职员信息"; return Json(r); } return Json(0); }
public ActionResult UpdateEmployee(int id, UpdateOrganizationUserModel model, FormCollection collection) { if (ModelState.IsValid) { var r = YunClient.Instance.Execute(new UpdateEmployeeRequest { OrganizationId = 0, HigherUserId = 0, IdCard = model.IdCard, RoleIds = collection["Role"], EntryTime = collection["EntryTime"].Is<DateTime>() ? collection["EntryTime"] : null, JobNum = model.JobNum, OtherName = model.OtherName, Phone = model.Phone, Email = model.Email, Plane = model.Plane, WorkPlace = model.WorkPlace, DisplayName = model.DisplayName, IsFemale = model.IsFemale == 1, UserId = id, Description = model.Remark }, Token); if (r.Result > 0) { TempData["success"] = "已成功修改职员信息"; Manage.functionsCache.Clear(); return Json(1); } return Json(r.ErrMsg+";"+r.SubErrMsg); } return Json(0); }