public ActionResult search() { try { string useID = Request.Cookies["username"].Value.ToString(); tb_teacher teacher = bll.search(useID); return(Json(teacher, JsonRequestBehavior.AllowGet)); } catch { return(RedirectToRoute("Default", new { controller = "Home", action = "Index" })); } }
public ActionResult Self(string inform) { try { Object datas = new Object(); string useID = Request.Cookies["username"].Value.ToString(); string useSESSION = Request.Cookies["ASPSESSION"].Value.ToString(); if (useID == null || useSESSION == null) { return(RedirectToRoute("Default", new { controller = "Home", action = "Index" })); } else { string re = con.yanzheng(useID); if (re != "false") { if (re != "1") { return(RedirectToRoute("Default", new { controller = "Home", action = "Index" })); } else { if (Request.RequestType == "GET") { return(View()); } else { tb_teacher tea = bll.Selfin(Convert.ToInt64(useID)); Selfinfom teaSelf = new Selfinfom { id = tea.id, name = tea.name, nplace = tea.nplace, sex = tea.sex, phone = tea.phone, education = tea.education, id_card = tea.id_card, position = tea.position, image = tea.image, bname = tea.bname }; return(Json(teaSelf, JsonRequestBehavior.AllowGet)); } } } else { return(RedirectToRoute("Default", new { controller = "Home", action = "Index" })); } } } catch { return(RedirectToRoute("Default", new { controller = "Home", action = "Index" })); } }
public bool UPpass(Int64 id, string oldpass, string newpass) { bool b = false; //查找出修改前的数据 tb_teacher uu = DB.tb_teacher.Where(a => a.id == id && a.password == oldpass).FirstOrDefault(); if (uu != null) { try { uu.password = newpass; DB.SubmitChanges(); b = true; } catch { } } return(b); }
public bool Teaupdata(Int64 id, string name, string nplace, string phone) { bool b = false; //查找出修改前的数据 tb_teacher uu = DB.tb_teacher.Where(a => a.id == id).FirstOrDefault(); if (uu != null) { try { uu.name = name; uu.nplace = nplace; uu.phone = phone; DB.SubmitChanges(); b = true; } catch { } } return(b); }
public tb_teacher Selfin(Int64 id) { tb_teacher Self = DB.tb_teacher.FirstOrDefault(a => a.id == id); return(Self); }
//public bool Insert() //{ // return true; //} public tb_teacher search(string id) { tb_teacher stu = DB.tb_teacher.FirstOrDefault(a => a.id == Convert.ToInt64(id)); return(stu); }
public ActionResult Index(string account, string password, string Role) { try { Int64 user = Convert.ToInt64(account); if (password == null || password == null || Role == null) { return(View()); } else { if (Role == "1") { tb_teacher tea = bll.Selfin(user); if (user == tea.id && password == tea.password) { object a = account; string jiami = md5slt.MD5Encoding(password, a); var data1 = getredis.GetDatabase(2); getredis.GetDatabase(1).StringSet(account, jiami, TimeSpan.FromMinutes(20)); getredis.GetDatabase(2).StringSet(account, Role, TimeSpan.FromMinutes(20)); Response.AddHeader("Set-Cookie", "ASPSESSION=" + jiami + "; HttpOnly"); Response.AddHeader("Set-Cookie", "username="******";HttpOnly"); Response.AddHeader("Set-Cookie", "name=" + tea.name); Response.Write("OK"); return(RedirectToRoute("Default", new { controller = "Home", action = "First" })); } else { return(View()); } } else { if (Role == "0") { tb_student stu = bll.StuSelf(user); if (user == stu.id && password == stu.password) { object a = account; string jiami = md5slt.MD5Encoding(password, a); var data1 = getredis.GetDatabase(2); getredis.GetDatabase(1).StringSet(account, jiami, TimeSpan.FromMinutes(20)); getredis.GetDatabase(2).StringSet(account, Role, TimeSpan.FromMinutes(20)); Response.AddHeader("Set-Cookie", "ASPSESSION=" + jiami + "; HttpOnly"); Response.AddHeader("Set-Cookie", "username="******";HttpOnly"); Response.AddHeader("Set-Cookie", "name=" + stu.name); Response.Write("OK"); return(RedirectToRoute("Default", new { controller = "StudentD", action = "Student", stuID = Convert.ToInt64(account), stuPwd = password })); } else { return(View()); } } return(View()); } } } catch { return(RedirectToRoute("Default", new { controller = "Home", action = "Index" })); } }