Пример #1
0
 protected void lbtnLogin_Click(object sender, EventArgs e)
 {
     //HttpCookie cookie = Request.Cookies["CheckCode"];
     //if (cookie.Value == this.txtCheckCode.Text.ToString())
     //{
     if (USER.CheckUser(txtUserName.Text.ToString(), txtPwd.Text.ToString()) == BLL.User.myLoginState.LOGINSUSCCESS)
     {
         //Response.Write("<script language='javascript'> alert( 'Success!'); </script> ");
         //Response.Redirect("Member/Default.aspx");
     }
     //}
 }
    protected void lbtnLogin_Click(object sender, EventArgs e)
    {
        panelCheckCode.Visible = false;
        panelLoginTime.Visible = false;
        panelPwd.Visible       = false;

        try//读取登录次数
        {
            HttpCookie cookieLogin = Request.Cookies["LoginTimes"];
            lbCountLogin.Text = cookieLogin.Values["Count"].ToString();
        }
        catch
        { lbCountLogin.Text = "1"; }

        if (int.Parse(lbCountLogin.Text) <= 3)//三次登录失败
        {
            HttpCookie cookie = Request.Cookies["CheckCode"];
            if (cookie.Value == this.txtCheckCode.Text.ToString())
            {
                if (USER.CheckUser(txtUserName.Text.ToString(), txtPwd.Text.ToString()) == BLL.User.myLoginState.LOGINSUSCCESS)
                {
                    Response.Write("<script language='javascript'> alert( 'Success!'); </script> ");
                    Response.Redirect("Member/Default.aspx");
                }
                else
                {
                    Response.Write("<script language=javascript> alert( '帐号或者密码错误!(第" + lbCountLogin.Text + "次错误!)'); </script> ");
                    panelPwd.Visible = true;
                    try//失败次数自增1
                    {
                        System.Web.HttpCookie cookieLogin = new System.Web.HttpCookie("LoginTimes");
                        cookieLogin.Values.Add("Count", (int.Parse(lbCountLogin.Text) + 1).ToString());
                        cookieLogin.Expires.AddHours(4);
                        System.Web.HttpContext.Current.Response.AppendCookie(cookieLogin);
                    }
                    catch { }
                }
            }
            else//Response.Write("<script language=javascript> alert( '验证码错误!'); </script> ");
            {
                panelCheckCode.Visible = true;
            }
        }
        else
        {
            panelLoginTime.Visible = true;
        }
    }
Пример #3
0
    //第二板块—登录
    #region
    /// <summary>
    /// 登录成功/失败
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void lbtnLogin_Click(object sender, EventArgs e)
    {
        if (USER.CheckUser(txtName.Text.ToString(), txtPwd.Text.ToString()) == BLL.User.myLoginState.LOGINSUSCCESS)
        {
            panelSelect.Visible  = false;
            panelLoging.Visible  = false;
            panelLogined.Visible = true;

            HttpCookie cookie = Request.Cookies["UserInfo"];
            lbNickName.Text     = cookie.Values["name"].ToString();
            Session["UID"]      = cookie.Values["UID"].ToString();
            Session["Name"]     = cookie.Values["name"].ToString();
            imgHeadImg.ImageUrl = "~/" + cookie.Values["vipImg"].ToString();
        }
        else
        {
            Response.Write("<script language=javascript> alert( '帐号或者密码错误!'); </script> ");
        }
    }