Example #1
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (Session["checkcode"].ToString().Equals(this.txt_checkcode.Value))
        {
            String password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txt_password.Value, "MD5");
            TPortalClass.JpUsers Users = new TPortalClass.JpUsers();
            if (Users.Login(this.txt_username.Value, password))
            {
                TPortalClass.JpUsers userinfo = new TPortalClass.JpUsers(this.txt_username.Value);
                Session["uid"] = userinfo.uid;
                Session["uname"] = userinfo.uname;
                TPortalClass.JpRoles roles = new TPortalClass.JpRoles();
                Session["role"] = roles.GetRolesListByUID(userinfo.uid);
                String aa = Session["role"].ToString();

                //写系统日志
                TPortalClass.JpCommon JpCommon = new TPortalClass.JpCommon();
                string userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                if (userip == null || userip == "")
                {
                    userip = Request.ServerVariables["REMOTE_ADDR"];
                }
                JpCommon.WriteLog(userip, "登录", "后台登录", Session["uid"].ToString(), Session["uname"].ToString());
                this.Response.Redirect(this.lblurl.Text);
            }
            else
            {
                Response.Write("<script>alert('输入的用户名或者密码不正确!');window.location.href = window.location.href;</script>");
                return;
            }
        }
        else
        {
            Response.Write("<script>alert('校验码不正确!');window.location.href = window.location.href;</script>");
            return;
        }
    }