Пример #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!");
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //lbTruyCap.Text = Application.Contents["SoNguoiTruyCap"].ToString();
            //lbTongTruyCap.Text = Application.Contents["TongTruyCap"].ToString();
            if (!IsPostBack)
            {
                lbTitle.Text = CGlobal.GetTitleAdmin();
                int num = objMyContest.GetCountNotAcceptedByCreated();
                if (num > 0)
                {
                    lbXinVaoLop.Text = " (" + num + ")";
                }
                //checkAdmin();
                //lbname.Text
            }
            long id = CGlobal.GetUserID();

            try
            {
                DataTable dt    = objUser.LoadByID(id);
                DataRow   dtRow = dt.Rows[0];
                lbUserFullName.Text     = dtRow["FullName"].ToString();
                lbUserName.Text         = dtRow["UserName"].ToString();
                lbUserCode.Text         = dtRow["UserCode"].ToString();
                imgAvatar.ImageUrl      = (dtRow["Avatar"].ToString());
                imgAvatarSlide.ImageUrl = (dtRow["Avatar"].ToString());

                if (!objUser.CheckIsAdmin(id))
                {
                    logOut();
                }
            }
            catch (Exception)
            {
                logOut();
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lbTruyCap.Text     = Application.Contents["SoNguoiTruyCap"].ToString();
            lbTongTruyCap.Text = Application.Contents["TongTruyCap"].ToString();
            getNoti();

            if (!IsPostBack)
            {
                lbTitle.Text = CGlobal.GetTitleUser();
            }
            long id = CGlobal.GetUserID();

            try
            {
                DataTable dt    = objUser.LoadByID(id);
                DataRow   dtRow = dt.Rows[0];
                lbUserFullName.Text     = dtRow["FullName"].ToString();
                lbUserName.Text         = dtRow["UserName"].ToString();
                lbUserCode.Text         = dtRow["UserCode"].ToString();
                imgAvatar.ImageUrl      = (dtRow["Avatar"].ToString());
                imgAvatarSlide.ImageUrl = (dtRow["Avatar"].ToString());

                if (objUser.CheckIsAdmin(id))
                {
                    liGoToAdmin.Visible = true;
                }
                else
                {
                    liGoToAdmin.Visible = false;
                }
            }
            catch
            {
                logOut();
            }
        }
Пример #4
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
            //{
            //
            //}
        }