private string ModifyUser(HttpContext context) { try { var result = ""; var userId = new Guid(context.Request["uid"]); var userBll = new BLL.SysUser(); if (userBll.GetAccountExsist(context.Request["UserAccount"], userId)) //登录账户不能重复 { return "该账号已存在!"; } var userModel = userBll.GetModel(userId); if (userModel.UserRole == (int) EnumUserRole.Student) { var stubll = new BLL.Student(); var stuModel = stubll.GetModel(userModel.UserId); if (!string.IsNullOrEmpty(context.Request["Gender"])) { stuModel.Gender = Convert.ToInt32(context.Request["Gender"]); } stuModel.TelNo = context.Request["TelNo"]; stuModel.JobTitle = context.Request["Title"]; stuModel.StuName = context.Request["UserName"]; stuModel.School = context.Request["School"]; stuModel.LastModifyTime = DateTime.Now; stuModel.IdentityNo = context.Request["IdentityNo"]; stubll.Update(stuModel); userModel.UserAccount = context.Request["UserAccount"]; userModel.UserName = context.Request["UserName"]; userModel.UserPassWord = context.Request["UserPassWord"]; userModel.CreateTime = DateTime.Now; userBll.Update(userModel); } else { userModel.UserAccount = context.Request["UserAccount"]; userModel.UserName = context.Request["UserName"]; userModel.UserPassWord = context.Request["UserPassWord"]; userModel.CreateTime = DateTime.Now; userBll.Update(userModel); } return result; } catch (Exception ex) { LogHelper.WriteLogofExceptioin(ex); return ex.Message; } }
private void EditData(string id, HttpContext context) { var sysUserBll = new BLL.SysUser(); var sysUserModel = sysUserBll.GetModel(new Guid(id)); // sysUserModel.LastModifyTime = DateTime.Now; var result = false; var msg = ""; try { SetModelValue(sysUserModel, context); if (sysUserBll.GetAccountExsist(sysUserModel.UserAccount, sysUserModel.UserId)) { msg = "该账号已存在,请修改!"; } else { result = sysUserBll.Update(sysUserModel); if (!result) { msg = "保存失败!"; } } } catch (Exception ex) { LogHelper.WriteLogofExceptioin(ex); result = false; msg = ex.Message; } // var str = JsonConvert.SerializeObject(new { success = result, errorMsg = msg}); context.Response.Write(msg); }