Exemplo n.º 1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string uname = txtUserName.Text;
            string pas   = txtPass.Text;

            long userID = user.GetID(uname, pas);

            if (userID >= 1)
            {
                Session[HELPER.CGlobal.USER_ID] = userID;
                if (user.CheckIsAdmin(userID))
                {
                    //HELPER.Client.Alert(this, "Đăng nhập thành công!");
                    Response.Redirect("~/Admin/Index.aspx");
                }
                else
                {
                    // HELPER.Client.Alert(this, "Bạn không có quyền Admin!");
                    Response.Redirect("~/Pages/Home.aspx");
                }
            }
            else
            {
                HELPER.Client.Alert(this, "Sai thông tin đăng nhập!");
            }
        }
Exemplo n.º 2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            String tenNguoiDung = txtUserName.Text;
            String matKhau      = txtPassword.Text;

            //Validate
            if (String.IsNullOrEmpty(tenNguoiDung))
            {
                error_div.Attributes.CssStyle["display"] = "block";
                lblError.Text = "Tên đăng nhập không được bỏ trống";
                txtUserName.Focus();
                return;
            }
            if (String.IsNullOrEmpty(matKhau))
            {
                error_div.Attributes.CssStyle["display"] = "block";
                lblError.Text = "Mật khẩu không được bỏ trống";
                txtPassword.Focus();
                return;
            }

            long userID = user.GetID(tenNguoiDung, matKhau);

            if (userID >= 1)
            {
                Session[HELPER.CGlobal.USER_ID] = userID;
                if (user.CheckIsAdmin(userID))
                {
                    //HELPER.Client.Alert(this, "Đăng nhập thành công!");
                    Response.Redirect("~/Admin/Index.aspx");
                }
                else
                {
                    // HELPER.Client.Alert(this, "Bạn không có quyền Admin!");
                    Response.Redirect("~/Pages/Home.aspx");
                }
            }
            else
            {
                error_div.Attributes.CssStyle["display"] = "block";
                lblError.Text = "Tên đăng nhập hoặc mật khẩu không đúng";
            }

            //AccessControl.SignOut();
            //AccessControl.SignIn(tenNguoiDung, matKhau);

            //if (AccessControl.IsLoggedIn)
            //{
            //    //Remember user
            //    HttpCookie cookieUsername = new HttpCookie("uname", tenNguoiDung);
            //    cookieUsername.Expires = DateTime.Now.AddDays(30);
            //    HttpCookie cookiePassword = new HttpCookie("upass", matKhau);
            //    cookiePassword.Expires = DateTime.Now.AddDays(30);
            //    Response.Cookies.Add(cookieUsername);
            //    Response.Cookies.Add(cookiePassword);

            //    Response.Redirect("~");
            //}
            //else
            //{
            //
            //}
        }