• ONE


    HOUTAI

    D

    public class UserDal
    {

    public int AddUser(User user)
    {
    SqlParameter[] parameters = new SqlParameter[]
    {
    new SqlParameter("@UserName",user.UserName),
    new SqlParameter("@UserPassword",user.UserPassword)
    };
    return DBhelper.SqlExecuteNonQuery("p_Add", CommandType.StoredProcedure, parameters);
    }

    public int UserLogin(string Name, string Password)
    {
    SqlParameter[] parameters = new SqlParameter[]
    {
    new SqlParameter("@UserName",Name),
    new SqlParameter("@UserPassword",Password)
    };
    var dt = DBhelper.GetTable("p_Login", CommandType.StoredProcedure, parameters);
    if (dt.Rows.Count > 0)
    {
    return (int)dt.Rows[0]["UserID"];
    }
    else {

    var ero = DBhelper.SqlExecuteNonQuery("p_Error", CommandType.StoredProcedure, new SqlParameter("@UserName", Name));
    }
    return 0;
    }

    public int UserUpdate(int ID, string Password)
    {
    SqlParameter[] parameters = new SqlParameter[]
    {
    new SqlParameter("@UserID",ID),
    new SqlParameter("@UserPassword",Password)
    };
    var result = DBhelper.SqlExecuteNonQuery("p_Update", CommandType.StoredProcedure, parameters);
    return result;
    }

    public List<User> GetUser()
    {
    var result = DBhelper.GetTable("p_Get", CommandType.StoredProcedure);
    var jar = JsonConvert.DeserializeObject<List<User>>(JsonConvert.SerializeObject(result));
    return jar;
    }
    }

    M

    public class LoginController : Controller
    {
    UserBll bll = new UserBll();

    public ActionResult Index()
    {
    ViewBag.Name = Session["UName"];
    return View();
    }
    public ActionResult Add()
    {
    return View();
    }

    public ActionResult Login()
    {
    ViewBag.Name = Session["UName"];
    return View();
    }
    [LoginFatier]
    public ActionResult Updata()
    {
    ViewBag.Name = Session["UName"];
    return View();
    }



    [HttpPost]
    public int GetUser(string Name)
    {
    var result = bll.GetUser().Where(m => m.UserName.Equals(Name)).ToList();

    if (result.Count() > 0)
    {
    return 1;
    }
    else {
    return 0;
    }
    }

    [HttpPost]
    public int Add(User user)
    {
    var result = bll.AddUser(user);
    return result;
    }

    public int UserLogin(string Name,string Password)
    {
    var result = bll.UserLogin(Name, Password);
    if (result > 0)
    {
    Session["UName"] = Name;
    Session["ID"] = result;

    }
    return result;
    }

    public int UserUpdata(string Password)
    {
    int Id = Convert.ToInt32(Session["ID"]);
    var result = bll.UserUpdate(Id,Password);
    return result;
    }
    }

  • 相关阅读:
    Luogu 3119 [USACO15JAN]草鉴定Grass Cownoisseur
    Luogu 4514 上帝造题的七分钟
    Luogu 1484 种树
    Luogu【P2904】跨河(DP)
    Luogu【P2065】贪心的果农(DP)
    Luogu【P1725】琪露诺(单调队列,DP)
    二分图匹配
    单调队列
    Tarjan的强联通分量
    手写堆
  • 原文地址:https://www.cnblogs.com/590-822/p/10001385.html
Copyright © 2020-2023  润新知