public ActionResult Edit(AOWEN.Model.SysUserInfo model, string roleinfoName) { if (string.IsNullOrEmpty(model.Name)) { return(Content("<script>alert('名字不能为空');window.location.href='/UserInfoManage/Edit/@model.ID'</script>")); } //if (string.IsNullOrEmpty(model.Password)) //{ // return Content("<script>alert('密码不能为空';window.location.href='/UserInfoManage/Edit/@model.ID')</script>"); //} if (string.IsNullOrEmpty(model.Tel) && string.IsNullOrEmpty(model.Mobile)) { return(Content("<script>alert('电话和手机不能为空');window.location.href='/UserInfoManage/Edit/@model.ID'</script>")); } if (string.IsNullOrEmpty(model.Province.ToString()) || string.IsNullOrEmpty(model.City.ToString())) { return(Content("<script>alert('省份城市不能为空');window.location.href='/UserInfoManage/Add/'</script>")); } var userInfoModel = userinfoman.GetEntity(model.ID); #region 用户信息更新 userInfoModel.Name = model.Name; userInfoModel.UserCode = model.UserCode == null ? "" : model.UserCode; userInfoModel.Sex = model.Sex; userInfoModel.Birthday = model.Birthday; userInfoModel.Tel = model.Tel == null ? "" : model.Tel; userInfoModel.Province = model.Province; userInfoModel.City = model.City; userInfoModel.Mobile = model.Mobile == null ? "" : model.Mobile; userInfoModel.Email = model.Email == null ? "" : model.Email; userInfoModel.UserState = model.UserState; userInfoModel.Remark = model.Remark == null ? "" : model.Remark; if (model.Password != "") { userInfoModel.Password = model.Password; } userinfoman.Update(userInfoModel); #endregion #region 更新用户角色关联表 SysUserRoleMan userroleman = new SysUserRoleMan(); var userroleModel = userroleman.GetModelByUserId(model.ID); userroleModel.RoleId = Convert.ToInt32(roleinfoName); userroleModel.UserId = model.ID; userroleModel.UpdateTime = DateTime.Now; userroleman.Update(userroleModel); #endregion return(Content("<script>alert('更新成功');window.location.href='/UserInfoManage/Index/'</script>")); }
public ActionResult Edit(int ID) { var userinfoModel = userinfoman.GetEntity(ID); #region 省市数据 SysCityMan cityMan = new SysCityMan(); var provinceList = cityMan.GetProvinceByCityLevel(1).ToList(); var cityList = cityMan.GetCityByProvinceIdAndCityLevel(2, userinfoModel.Province).ToList(); ViewBag.province = provinceList; ViewBag.city = cityList; #endregion #region 用户角色关联表数据 SysUserRoleMan userroleman = new SysUserRoleMan(); var userrole = userroleman.GetModelByUserId(ID); ViewBag.UserRole = userrole; #endregion #region 角色数据 SysRoleInfoMan roleinfoman = new SysRoleInfoMan(); var roleinfoList = roleinfoman.GetAllRolesInfo().ToList(); ViewBag.RoleInfoList = roleinfoList; #endregion return(View(userinfoModel)); }