Esempio n. 1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string userName = txtUserName.Value.Trim();
        string userPwd  = txtPassword.Value.Trim();

        //判断登录信息
        userPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(userPwd, "MD5");
        //Response.Write(userPwd);
        //Response.End();
        if (tbl_admin.Exists(userName, userPwd))
        {
            tbl_admin myuser       = new tbl_admin();
            string    sqlGetUserID = "select  id  from [tbl_admin] where huiyuan_bianhao='" + userName + "'";
            int       userid       = Convert.ToInt16(DbHelperSQL.GetSingle(sqlGetUserID));
            myuser.GetModel(userid);

            //判断账号是否被禁用
            if (Convert.ToInt32(myuser.is_lock) == 1)
            {
                MessageBox.errorShow(this.Page, "您的账号被禁用,请联系客服!");
                return;
            }

            //写入登录日志
            tbl_login login_log = new tbl_login();
            login_log.huiyuan_bianhao = userName;
            login_log.huiyuan_name    = myuser.huiyuan_name;
            login_log.login_date      = DateTime.Now;
            login_log.login_flag      = 1;
            login_log.huiyuan_ip      = AXRequest.GetIP();
            login_log.Add();


            //写入Cookies
            Utils.WriteCookie("hy_id", myuser.huiyuan_id, 14400);
            Utils.WriteCookie("hy_bianhao", userName, 14400);
            Utils.WriteCookie("hy_name", myuser.huiyuan_name, 14400);
            Utils.WriteCookie("RoleID", myuser.role_id.ToString(), 14400);


            //写入Session
            Session["hy_id"]      = myuser.huiyuan_id;
            Session["hy_bianhao"] = userName;
            Session["hy_name"]    = myuser.huiyuan_name;
            Session["RoleID"]     = myuser.role_id.ToString();


            Session.Timeout = 45;

            Response.Redirect("index.aspx");
            return;
        }
        else
        {
            MessageBox.errorShow(this.Page, "账号或密码有误,请重试!");
            return;
        }
    }
Esempio n. 2
0
    /// <summary>
    /// 写入管理日志
    /// </summary>
    /// <param name="action_type"></param>
    /// <param name="remark"></param>
    /// <returns></returns>
    public bool AddAdminLog(string action_type, string remark)
    {
        //写入日志
        tbl_login mylog = new tbl_login();

        mylog.huiyuan_bianhao = Session["hy_bianhao"].ToString();
        mylog.huiyuan_name    = Session["hy_name"].ToString();
        mylog.login_date      = DateTime.Now;
        mylog.login_flag      = 1;
        mylog.huiyuan_ip      = AXRequest.GetIP();
        int newId = mylog.Add();

        if (newId > 0)
        {
            return(true);
        }

        return(false);
    }
Esempio n. 3
0
    protected void ibtnLogin_Click(object sender, EventArgs e)
    {
        TextBox txtname = (TextBox)((MasterPage)Master).FindControl("txtUserName");
        TextBox txtpwd  = (TextBox)((MasterPage)Master).FindControl("txtPassword");
        TextBox Txtcode = (TextBox)((MasterPage)Master).FindControl("Txtcode");

        if (Txtcode.Text == "")
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "alert('您未输入验证码。');", true);
            //lblTip.Text = "您输入的验证码不正确,请重新输入。";
            return;
        }

        if (Session["serverCode"] == null)
        {
            Response.Write("<script language=javascript>alert('验证码失效,刷新页面!');location.href='index.aspx';</script>");
            Response.End();
        }
        string sVCode = Session["serverCode"].ToString();

        if (txtname.Text == "")
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "alert('请输入用户名。');", true);
            //lblTip.Text = "您输入的验证码不正确,请重新输入。";
            return;
        }
        if (txtpwd.Text == "")
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "alert('请输入密码。');", true);
            //lblTip.Text = "您输入的验证码不正确,请重新输入。";
            return;
        }
        if (Txtcode.Text != sVCode)
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "alert('您输入的验证码不正确,请重新输入。');", true);
            //lblTip.Text = "您输入的验证码不正确,请重新输入。";
            return;
        }

        string sUserName = Utils.Filter(txtname.Text.Trim());

        string sPassWord = Utils.Filter(txtpwd.Text.Trim());

        if (tbl_huiyuan.Existshui(sUserName, sPassWord) || tbl_huiyuan.Exists(sUserName, sPassWord))
        {
            if (tbl_huiyuan.Existshui(sUserName, sPassWord))
            {
                tbl_huiyuan model1 = new tbl_huiyuan();
                model1.GetModel_hui_mob(sUserName);
                Session["hy_id1"]      = model1.huiyuan_id;
                Session["hy_bianhao1"] = model1.huiyuan_bianhao;
                Session["hy_name1"]    = model1.huiyuan_name;
                Session["hy_zm1"]      = model1.huiyuan_zhuanmai;
                Session["hy_jiebie1"]  = model1.huiyuan_jiebie;
                //Session["zhongyao1"] = 1;

                //写入登录日志
                tbl_login login_log = new tbl_login();
                login_log.huiyuan_bianhao = sUserName;
                login_log.huiyuan_name    = model1.huiyuan_name;
                login_log.login_date      = DateTime.Now;
                login_log.login_flag      = 2;
                login_log.huiyuan_ip      = AXRequest.GetIP();
                login_log.Add();
            }

            if (tbl_huiyuan.Exists(sUserName, sPassWord))
            {
                tbl_huiyuan model1 = new tbl_huiyuan();
                model1.GetModel_hui_bianhao(sUserName);
                Session["hy_id1"]      = model1.huiyuan_id;
                Session["hy_bianhao1"] = model1.huiyuan_bianhao;
                Session["hy_name1"]    = model1.huiyuan_name;
                Session["hy_zm1"]      = model1.huiyuan_zhuanmai;
                Session["hy_jiebie1"]  = model1.huiyuan_jiebie;
                //Session["zhongyao1"] = 1;

                //写入登录日志
                tbl_login login_log = new tbl_login();
                login_log.huiyuan_bianhao = sUserName;
                login_log.huiyuan_name    = model1.huiyuan_name;
                login_log.login_date      = DateTime.Now;
                login_log.login_flag      = 2;
                login_log.huiyuan_ip      = AXRequest.GetIP();
                login_log.Add();
            }



            Utils.WriteCookie("ps_cookie_shopping_cart", "AoXiang", -14400);
            Response.Redirect("huiyuan/index.aspx");
            return;
        }
        else
        {
            Response.Write("<script language=javascript>alert('账号或密码有误或被冻结,请重试!');location.href='login.aspx';</script>");
            Response.End();
        }
    }