public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; //GET方式获取传递的数据 //string username = context.Request.QueryString["username"]; //string password = context.Request.QueryString["password"]; //POST方式获取传递的数据 string username = context.Request.Form["username"]; string password = context.Request.Form["password"]; String certainPS = ""; String zhiwu = ""; string message = null; if (string.IsNullOrEmpty(username)) { message = "用户名不能为空"; context.Response.Write("{\"success\":0,\"message\":\"" + message + "\"}");//此JSON格式非常重要,否则会执行jquery的的error函数 context.Response.End(); } if (string.IsNullOrEmpty(password)) { message = "密码不能为空"; context.Response.Write("{\"success\":1,\"message\":\"" + message + "\"}"); context.Response.End(); } if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { Maticsoft.BLL.登录表 SQLConect = new Maticsoft.BLL.登录表(); bool IdOrPsCertain = false; IdOrPsCertain = SQLConect.Exists(username); if (IdOrPsCertain) { Maticsoft.Model.登录表 loginModel = SQLConect.GetModel(username); certainPS = loginModel.密码; if (certainPS == password) { message = "登录成功"; zhiwu = loginModel.职务; String reV = "{\"success\":2,\"message\":\"" + message + "\",\"zhiwu\":\"" + zhiwu + "\"}"; context.Response.Write(reV); } else { message = "用户名或密码错误"; context.Response.Write("{\"success\":3,\"message\":\"" + message + "\"}"); } } else { message = "用户名或密码错误"; context.Response.Write("{\"success\":3,\"message\":\"" + message + "\"}"); } //if (username.ToUpper() == "ADMIN" && password == "123") //{ // message = "登录成功"; // context.Response.Write("{\"success\":2,\"message\":\"" + message + "\"}"); //} //else //{ // message = "用户名或密码错误"; // context.Response.Write("{\"success\":3,\"message\":\"" + message + "\"}"); //} } context.Response.End(); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.登录表 model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.登录表 model) { return(dal.Update(model)); }
//学生注册信息 public JObject SingupInfo(JObject info) { JObject reV = new JObject(); bool StuAdd = false; bool SignUpExit = true; Maticsoft.BLL.学生表 StuSQL = new Maticsoft.BLL.学生表(); Maticsoft.Model.学生表 newStu = new Maticsoft.Model.学生表(); Maticsoft.BLL.登录表 SignupSQL = new Maticsoft.BLL.登录表(); Maticsoft.Model.登录表 newSign = new Maticsoft.Model.登录表(); newStu.班级 = info["banji"].ToString(); newStu.生日 = DateTime.ParseExact(info["stuBirth"].ToString(), "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture); newStu.性别 = info["stuGender"].ToString(); newStu.姓名 = info["stuName"].ToString(); newStu.学号 = info["stuId"].ToString(); newStu.学院 = info["xueyuan"].ToString(); newStu.专业 = info["zhuanye"].ToString(); newStu.邮箱 = info["stuEmail"].ToString(); newSign.账号 = info["stuId"].ToString(); newSign.密码 = info["stuPs"].ToString(); newSign.职务 = "学生"; SignupSQL.Add(newSign); if (SignupSQL.Exists(newSign.账号)) { if (!StuSQL.Exists(newStu.学号, newStu.邮箱)) { StuAdd = StuSQL.Add(newStu); //添加学生信息状态 } else { reV.Add("success", "false"); reV.Add("message", "学号已经注册"); return(reV); } } else { SignUpExit = false; //登录表不存在信息 reV.Add("success", "false"); reV.Add("message", "学号尚未录入无法注册"); return(reV); } if (StuAdd) { reV.Add("success", "true"); reV.Add("message", "注册成功"); } else { reV.Add("success", "false"); reV.Add("message", "注册失败"); } return(reV); }