// GET: /<controller>/ public IActionResult Index() { string json = HttpContext.Session.GetString("user_login"); if (json == null) { return(Redirect("/home/index")); } Model.user_login u_l = Gx.Json.StrToObj <Model.user_login>(json); Model.Userone u = Bll.Login.Get_User(u_l); if (u == null) { return(Redirect("/home/index")); } List <Model.V_bk> l = Bll.shengpi.UserList(u.id); ViewBag.list = l; ViewBag.name = u.name; u_l = Bll.Login.User_Login_Update(u_l); if (u_l != null) { HttpContext.Session.SetString("user_login", Gx.Json.ObjToStr(u_l)); } return(View()); }
// GET: /<controller>/ public IActionResult Index(int id = 0) { string json = HttpContext.Session.GetString("user_login"); if (json == null) { return(Redirect("/home/index")); } Model.user_login u_l = Gx.Json.StrToObj <Model.user_login>(json); Model.Userone u = Bll.Login.Get_User(u_l); if (u == null) { return(Redirect("/home/index")); } if (u.role != "管理员") { return(Redirect("/home/index")); } List <Model.V_bk> l = Bll.shengpi.SelectList(id); string n = ""; switch (id) { case -1: n = "未通过"; break; case 0: n = "未审核"; break; case 1: n = "已通过"; break; } ViewBag.type = n; ViewBag.list = l; ViewBag.name = u.name; return(View()); }
public static bool Update(Model.user_login m) { Gx.Sql s = new Gx.Sql("login=@login,token=@token,time=@time", "user_login", "where name=@name", m); if (s.Update() > 0) { return(true); } return(false); }
public static bool Delete(Model.user_login m) { Gx.Sql s = new Gx.Sql("", "user_login", "where name=@name", m); if (s.Delete() > 0) { return(true); } return(false); }
public static bool Insert(Model.user_login m) { Delete(m); Gx.Sql s = new Gx.Sql("(name,login,token,time)values(@name,@login,@token,@time)", "user_login", "", m); if (s.Insert() > 0) { return(true); } return(false); }
/// <summary> /// 修改登录凭证 /// </summary> /// <param name="u_l">登录凭证</param> /// <returns></returns> public static Model.user_login User_Login_Update(Model.user_login u_l) { Random ran = new Random(); u_l.token = ran.Next(1000000, 10000000).ToString(); u_l.time = DateTime.Now; if (!Dal.user_login.Update(u_l)) { return(null); } return(u_l); }
/// <summary> /// 获取用户信息 /// </summary> /// <param name="u_l">登录凭证</param> /// <returns></returns> public static Model.Userone Get_User(Model.user_login u_l) { if (!Dal.user_login.Exists(u_l)) { Dal.user_login.Delete(u_l); return(null); } Model.Userone user = new Model.Userone() { name = u_l.name }; return(Dal.Userone.Get_User(user)); }
public IActionResult Register(string username, string password) { Model.Userone u = Bll.Register.User_Insert(username, password); if (u == null) { return(Content("<script >alert('注册失败!用户名已被占用!');window.location.href='/home/index'</script >", "text/html")); } Model.user_login u_l = Bll.Login.User_Login(u.name, password); if (u_l == null) { return(Content("<script >alert('注册失败!用户名已被占用!');window.location.href='/home/index'</script >", "text/html")); } HttpContext.Session.SetString("user_login", Gx.Json.ObjToStr(u_l)); return(Redirect("/user/index")); }
public IActionResult sq(string reason, string name, string job, string address, string hobby) { string json = HttpContext.Session.GetString("user_login"); if (json == null) { return(Redirect("/home/index")); } Model.user_login u_l = Gx.Json.StrToObj <Model.user_login>(json); Model.Userone u = Bll.Login.Get_User(u_l); if (u == null) { return(Redirect("/home/index")); } /// Gx.AjaxMessage ajax = new Gx.AjaxMessage(); Model.bk b = new Model.bk() { uid = u.id, sqly = reason, name = name, zw = job, dw = address, jsxq = hobby, time = DateTime.Now, type = 0 }; if (Bll.shengpi.Insert(b)) { ajax.result = true; ajax.message = "申请成功请等待审核!"; } else { ajax.result = false; ajax.message = "不能多次申请!"; } /// u_l = Bll.Login.User_Login_Update(u_l); if (u_l != null) { HttpContext.Session.SetString("user_login", Gx.Json.ObjToStr(u_l)); } return(Content(ajax.ToString())); }
public IActionResult Login(string name, string pwd) { Gx.AjaxMessage ajax = new Gx.AjaxMessage(); Model.user_login u_l = Bll.Login.User_Login(name, pwd); if (u_l == null) { ajax.result = false; ajax.message = "失败!"; return(Content(ajax.ToString())); } Model.Userone u = Bll.Login.Get_User(u_l); if (u == null) { ajax.result = false; ajax.message = "失败!"; return(Content(ajax.ToString())); } HttpContext.Session.SetString("user_login", Gx.Json.ObjToStr(u_l)); ajax.result = true; ajax.message = (u.role == "管理员" ? "/admin/index" : "/user/index"); return(Content(ajax.ToString())); }
public IActionResult sp(int id, int type) { string json = HttpContext.Session.GetString("user_login"); if (json == null) { return(Redirect("/home/index")); } Model.user_login u_l = Gx.Json.StrToObj <Model.user_login>(json); Model.Userone u = Bll.Login.Get_User(u_l); if (u == null) { return(Redirect("/home/index")); } /// Gx.AjaxMessage ajax = new Gx.AjaxMessage(); Model.bk b = new Model.bk() { id = id, type = type }; if (Bll.shengpi.Update(b)) { ajax.result = true; ajax.message = "审批成功!"; } else { ajax.result = false; ajax.message = "审批失败!"; } /// u_l = Bll.Login.User_Login_Update(u_l); if (u_l != null) { HttpContext.Session.SetString("user_login", Gx.Json.ObjToStr(u_l)); } return(Content(ajax.ToString())); }
/// <summary> /// 用户登录 /// </summary> /// <param name="name">用户名</param> /// <param name="pwd">密码</param> /// <returns></returns> public static Model.user_login User_Login(string name, string pwd) { Model.Userone user = new Model.Userone() { name = name, pwd = Gx.DataCrypt.MD5(pwd) }; if (!Dal.Userone.Exists(user)) { return(null); } Random ran = new Random(); Model.user_login u_l = new Model.user_login(); u_l.name = user.name; u_l.login = ran.Next(1000000, 10000000).ToString(); u_l.token = ran.Next(1000000, 10000000).ToString(); u_l.time = DateTime.Now; if (!Dal.user_login.Insert(u_l)) { return(null); } return(u_l); }
public static bool Exists(Model.user_login m) { Gx.Sql s = new Gx.Sql("*", "user_login", "where name=@name and login=@login and token=@token", m); return(s.Exists <Model.user_login>()); }