Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.Cookies["username"] != null)
     {
         b.Users userBll = new b.Users();
         m.Users user    = userBll.GetUserByName(Request.Cookies["username"].Value);
         if (user.LoginPwd == Request.Cookies["password"].Value)
         {
             Session["user"] = user;
         }
     }
 }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            url = Request["returnurl"];

            Response.ContentType = "text/html;charset=utf-8";
            if (Request.HttpMethod.ToLower() == "post")
            {
                string username = Request["username"];
                string password = Request["password"];
                if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
                {
                    b.Users usersBll = new b.Users();
                    m.Users user     = usersBll.GetUserByName(username);
                    if (user != null)
                    {
                        if (c.Md5Util.GetMd5(password) == user.LoginPwd)
                        {
                            Session["user"] = user;
                            if (!string.IsNullOrEmpty(Request["autoLogin"]))
                            {
                                HttpCookie cName = new HttpCookie("username");
                                HttpCookie cPwd  = new HttpCookie("password");
                                cName.Value   = user.LoginId;
                                cPwd.Value    = user.LoginPwd;
                                cName.Expires = DateTime.Now.AddDays(7);
                                cPwd.Expires  = DateTime.Now.AddDays(7);
                                Response.SetCookie(cName);
                                Response.SetCookie(cPwd);
                            }
                            if (url != null)
                            {
                                Response.Redirect(url);
                            }
                        }
                    }
                    else
                    {
                        Msg = "用户名或密码错误";
                    }
                }
                else
                {
                    Msg = "用户名或密码不能为空";
                }
            }
        }
Exemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         url = Request["returnurl"];
     }
     if (IsPostBack)
     {
         string txtName     = Request["txtName"];
         string txtRealName = Request["txtRealName"];
         string txtPwd      = Request["txtRealName"];
         url = Request["returnurl"];
         string  txtCode = Request["txtCode"];
         m.Users users   = new m.Users();
         b.Users bll     = new b.Users();
         int     count   = 0;
         if (bll.GetCountByName(txtName) != 0)
         {
             count++;
         }
         if (txtCode != (string)Session["validate"])
         {
             Session["validate"] = null;
             count++;
         }
         if (String.IsNullOrEmpty(txtPwd))
         {
             count++;
         }
         if (count == 0)
         {
             users.LoginId     = txtName;
             users.Name        = txtRealName;
             users.LoginPwd    = Md5Util.GetMd5(txtPwd);
             users.UserStateId = 1;
             bll.Add(users);
             Session["user"] = users;
             if (url != null)
             {
                 Response.Redirect(url);
             }
             Response.Redirect("default.aspx");
         }
     }
 }
Exemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string msg = context.Request["msg"];
            int    bookid;

            bool result = int.TryParse(context.Request["bookid"], out bookid);

            if (msg == null)
            {
                if (!result)
                {
                    System.Web.Script.Serialization.JavaScriptSerializer javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                    m.Users user = context.Session["user"] as m.Users;
                    if (context.Session["user"] == null)
                    {
                        if (context.Request["username"] != null)
                        {
                            b.Users bll      = new b.Users();
                            m.Users baseUser = bll.GetUserByName(context.Request["username"]);
                            if (baseUser.LoginPwd == context.Request["password"])
                            {
                                context.Response.Write(javaScriptSerializer.Serialize(baseUser));
                                context.Response.End();
                            }
                        }
                        context.Response.Write(javaScriptSerializer.Serialize(new { Msg = "no" }));
                        context.Response.End();
                    }
                    else
                    {
                        context.Response.Write(javaScriptSerializer.Serialize(user));
                    }
                }
                else
                {
                    context.Response.Write(LoadCommnet(bookid));
                }
            }
            else
            {
                context.Response.Write(AddComment(bookid, msg));
            }
        }
Exemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            b.Users bll     = new b.Users();
            string  address = context.Request["address"];

            m.Users user = bll.GetUserByMail(address);
            if (user != null)
            {
                string password = Guid.NewGuid().ToString().Substring(0, 8);
                SendMail(address, user.LoginId, "bookshop3密码修改", "您的新密码是" + password);
                user.LoginPwd = Md5Util.GetMd5(password);
                bll.Update(user);
                context.Response.Write("yes");
            }
            else
            {
                context.Response.Write("no");
            }
        }
Exemplo n.º 6
0
 protected void Page_Init(object sender, EventArgs e)
 {
     if (Session["user"] == null)
     {
         if (Request.Cookies["username"] != null)
         {
             b.Users userBll = new b.Users();
             m.Users user    = userBll.GetUserByName(Request.Cookies["username"].Value);
             if (user.LoginPwd == Request.Cookies["password"].Value)
             {
                 Session["user"] = user;
             }
             else
             {
                 Response.Redirect("/aspx/Login.aspx?returnurl=" + Request.Url.ToString());
             }
         }
         else
         {
             Response.Redirect("/aspx/Login.aspx?returnurl=" + Request.Url.ToString());
         }
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(cn.itcast.bookshop.Model.Users model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(cn.itcast.bookshop.Model.Users model)
 {
     return(dal.Add(model));
 }