private string AddData(HttpContext context) { string data = context.Request["model"]; Staffs model = JsonConvert.DeserializeObject <Staffs>(data); StaffsBLL bll = new StaffsBLL(); int success = 1; string msg = ""; if (model.Id == 0) { if (bll.GetCount(" and UserName='******' ") > 0) { msg = "账号已存在!"; } else { model.UserPwd = "888888"; if (bll.Add(model)) { success = 0; msg = "添加成功"; } else { msg = "添加失败"; } } } else { if (bll.Update(model)) { success = 0; msg = "Success"; } else { msg = "修改失败"; } } return(JsonConvert.SerializeObject(new { success = success, msg = msg })); }
private string UpdateUserMsg(HttpContext context) { string realName = context.Request["realName"]; Staffs model = new Staffs(); if (context.User != null) { StaffsBLL bll = new StaffsBLL(); model = ((FormsPrincipal)context.User).UserData; model = bll.GetModel(model.Id); model.StaffName = realName; if (bll.Update(model)) { return(JsonConvert.SerializeObject(new { success = 0, msg = "修改成功" })); } else { return(JsonConvert.SerializeObject(new { success = 1, msg = "修改失败" })); } } else { return(JsonConvert.SerializeObject(new { success = 2, msg = "用户未登录" })); } }