private string GetModel(HttpContext context) { int id = ObjectConvertHelper.ConvertToInt(context.Request["id"]); StaffsBLL bll = new StaffsBLL(); var model = bll.GetModel(id); return(JsonConvert.SerializeObject(model)); }
private string ChangePwd(HttpContext context) { string oldPwd = context.Request["oldPwd"]; string newPwd = context.Request["newPwd"]; if (context.User != null) { Staffs model = ((FormsPrincipal)context.User).UserData; StaffsBLL bll = new StaffsBLL(); model = bll.GetModel(model.Id); if (model.UserPwd != oldPwd) { return(JsonConvert.SerializeObject(new { success = 1, msg = "原始密码不正确" })); } else { model.UserPwd = newPwd; if (bll.ChangePwd(model)) { return(JsonConvert.SerializeObject(new { success = 0, msg = "修改成功" })); } else { return(JsonConvert.SerializeObject(new { success = 2, msg = "修改失败" })); } } } else { return(JsonConvert.SerializeObject(new { success = 3, msg = "用户未登录" })); } }
private void LoginOper(HttpContext context) { context.Response.ContentType = "application/json"; string userName = context.Request["userName"].ToString(); string password = context.Request["password"].ToString(); string strWhere = " and StaffName='" + userName + "' "; StaffsBLL bll = new StaffsBLL(); Staffs model = bll.GetModel(strWhere); if (model != null) { if (model.UserPwd == password) { FormsPrincipal.SignIn(model.UserName, model, 30); LogHelper.Info(this.GetType(), model.UserName + "登录"); context.Response.Write(JsonConvert.SerializeObject(new { success = 0, result = "登录成功!" })); } else { context.Response.Write(JsonConvert.SerializeObject(new { success = 1, result = "密码输入不正确!" })); } } else { context.Response.Write(JsonConvert.SerializeObject(new { success = 2, result = "用户不存在!" })); } context.Response.End(); }
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 = "用户未登录" })); } }