コード例 #1
0
    private void login()
    {
        Dang_Nhap dn = new Dang_Nhap();                                              //Tạo một đối tượng mới cho lớp Dang_Nhap
        int       t  = dn.CheckLogin(username, Encrypt.EncryptText(password, true)); //gọi phương thức CheckLogin

        if (t > 0)
        {
            Session["UserName"] = username;
            Session["Role"]     = t;
            //Response.Redirect("Login_Success.aspx");
        }
        else
        {
            Response.Write("<script>alert('Đăng nhập tự động thất bại');</script>");
        }
    }
コード例 #2
0
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        Dang_Nhap dn = new Dang_Nhap();                                                      //Tạo một đối tượng mới cho lớp Dang_Nhap
        int       t  = dn.CheckLogin(txtuser.Text, Encrypt.EncryptText(txtpass.Text, true)); //gọi phương thức CheckLogin

        if (t > 0)
        {
            Session["UserName"] = txtuser.Text;
            Session["Role"]     = t;
            WriteCookie();
            Response.Redirect("Login_Success.aspx");
        }
        else
        {
            Response.Write("<script>alert('Đăng nhập thất bại');</script>");
        }
    }