private void AddData(HttpContext context) { var sysUserModel = new Models.SysUser(); sysUserModel.UserId = Guid.NewGuid(); SetModelValue(sysUserModel, context); sysUserModel.CreateTime = DateTime.Now; var sysUserBll = new BLL.SysUser(); var result = false; var msg = ""; try { if (sysUserBll.GetAccountExsist(sysUserModel.UserAccount, sysUserModel.UserId)) { msg = "该账号已存在,请修改!"; } else { result = sysUserBll.Add(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); }
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; } }