示例#1
0
        public JsonResult btnLogin(string playerID, string password)
        {
            int pID = 0;

            BLL.T_Match_Student          playerBll   = new BLL.T_Match_Student();
            Model.T_Match_Student        playerModel = new Model.T_Match_Student();
            List <Model.T_Match_Student> lst         = playerBll.GetModelList("SNO='" + playerID + "'");

            if (lst.Count > 0)
            {
                //判断密码正确?
                playerModel = lst[0];
                pID         = playerModel.SID;
                if (playerModel.SPwd == password)
                {
                    FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
                        1,
                        pID.ToString(),
                        DateTime.Now,
                        DateTime.Now.AddDays(365),
                        false,
                        "stu"   //写入用户角色
                        );

                    string encryptedTicket = FormsAuthentication.Encrypt(authTicket);

                    System.Web.HttpCookie authCookie = new System.Web.HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                    System.Web.HttpContext.Current.Response.Cookies.Add(authCookie);
                    return(Json(new { code = 1 }, JsonRequestBehavior.DenyGet));
                }
                else
                {
                    return(Json(new { code = 0, msg = "抱歉,账号或密码错误!" }, JsonRequestBehavior.DenyGet));
                }
            }
            else
            {
                return(Json(new { code = 0, msg = "抱歉,该用户不存在!" }, JsonRequestBehavior.DenyGet));
            }
        }
示例#2
0
        //Student页面展示
        public ActionResult SList()
        {
            BLL.T_Match_Student bll = new BLL.T_Match_Student();
            int    PageSize         = 10;//默认值
            int    PageIndex        = 1;
            string keywords         = Convert.ToString(Request.Form["keywords"]);

            if (Request.Form["pageNum"] != null)
            {
                PageSize  = Convert.ToInt32(Request.Form["numPerPage"]);
                PageIndex = Convert.ToInt32(Request.Form["pageNum"]);
            }
            //读取该页的数据
            DataSet ds = bll.GetListByPage("SName like '%" + keywords + "%'", "SID", (PageIndex - 1) * PageSize + 1, PageIndex * PageSize);
            List <Model.T_Match_Student> lst = bll.DataTableToList(ds.Tables[0]);
            int totalcount = bll.GetRecordCount("SName like '%" + keywords + "%'");

            ViewBag.pagesize   = PageSize;
            ViewBag.pageindex  = PageIndex;
            ViewBag.lst        = lst;
            ViewBag.totalcount = totalcount;
            return(View());
        }