Exemplo n.º 1
0
        public T_UserLogin SetItem(T_Users _user)
        {
            T_UserLogin _obj = new T_UserLogin();

            _obj.ID               = 0;
            _obj.Login_Date       = DateTime.Now;
            _obj.Session_ID       = Session.SessionID.ToString();
            _obj.User_Ipaddress   = HttpContext.Current.Request.UserHostAddress.ToString();
            _obj.User_Name        = _user.UserName;
            _obj.LastMessage_Time = DateTime.Now;
            _obj.Full_Name        = _user.UserFullName;
            _obj.Loggedin         = true;
            return(_obj);
        }
Exemplo n.º 2
0
        public int InsertT_UserLogin(T_UserLogin obj)
        {
            int _insert = 0;

            try
            {
                _insert = HPCDataProvider.Instance().InsertObjectReturn(obj, "Chat_InsertT_UserLogin");
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(_insert);
        }
Exemplo n.º 3
0
        protected void btLogon_Click(object sender, EventArgs e)
        {
            if (_userDAL.Login(txtUsername.Text, txtPassword.Text))
            {
                if (Convert.ToInt32(Session["capchaimgvna"]) >= 3)
                {
                    if (Session["captcha"] != null)
                    {
                        if (Session["captcha"].ToString() != txtCaptcha.Text)
                        {
                            FuncAlert.AlertJS(this, "Mã bảo mật không đúng!");
                            return;
                        }
                    }
                }
                if (this.txtUsername.Text.Length > 0 && this.txtPassword.Text.Length > 0)
                {
                    user = _userDAL.GetUserByUserPass(txtUsername.Text, txtPassword.Text);
                }
                if (user.UserActive)
                {
                    FormsAuthentication.SetAuthCookie(user.UserName, false);
                    HttpCookie cookie = new HttpCookie("hpcinfomation");
                    cookie.Values.Add("hpcUserNames", txtUsername.Text.Trim());
                    cookie.Values.Add("hpcPassword", txtPassword.Text.Trim());
                    cookie.Expires = DateTime.Now.AddMinutes(60);
                    Response.Cookies.Add(cookie);
                    //Phan message
                    _userLog = SetItem(user);
                    _dalchat.InsertT_UserLogin(_userLog);
                    //end
                    UltilFunc.Log_Action(user.UserID, user.UserFullName, DateTime.Now, 0, "Đăng nhập hệ thống thành công");

                    Response.Redirect(Global.ApplicationPath + "/Dungchung/Commons.aspx");
                }
                else
                {
                    if (Session["capchaimgvna"] == null)
                    {
                        Session["capchaimgvna"] = "1";
                    }
                    else
                    {
                        Session["capchaimgvna"] = Convert.ToInt32(Session["capchaimgvna"]) + 1;
                        if (Convert.ToInt32(Session["capchaimgvna"]) >= 3)
                        {
                            pnlcapcha.Visible = true;
                        }
                    }
                    FuncAlert.AlertJS(this, "Tài khoản của bạn đang bị khóa. Liên hệ quản trị!");
                    FillCapctha();
                }
            }
            else
            {
                if (Session["capchaimgvna"] == null)
                {
                    Session["capchaimgvna"] = "1";
                }
                else
                {
                    Session["capchaimgvna"] = Convert.ToInt32(Session["capchaimgvna"]) + 1;
                    if (Convert.ToInt32(Session["capchaimgvna"]) >= 3)
                    {
                        this.pnlcapcha.Visible = true;
                    }
                }
                FuncAlert.AlertJS(this, "Đăng nhập không thành công");
                FillCapctha();
            }
        }