Exemplo n.º 1
0
    //保存
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (this.Session["uid"].ToString() == "")
            this.Response.Redirect("../login.aspx");

        if (this.txtoldpwd.Text == "")
        {
            this.Response.Write("<script language=javascript>alert('请输入旧密码!')</script>");
            return;
        }
        if (this.txtnewpwd.Text == "")
        {
            this.Response.Write("<script language=javascript>alert('请输入新密码!')</script>");
            return;
        }
        if (this.txtcomfig.Text == "")
        {
            this.Response.Write("<script language=javascript>alert('请输入确认密码!')</script>");
            return;
        }
        if (this.txtnewpwd.Text != this.txtcomfig.Text)
        {
            this.Response.Write("<script language=javascript>alert('输入的新密码和确认密码不一致!')</script>");
            return;
        }

        TPortalClass.JpUsers Users = new TPortalClass.JpUsers();

        String password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtoldpwd.Text, "MD5");
        if (!Users.Login(Session["uid"].ToString(), password))
        {
            this.Response.Write("<script language=javascript>alert('输入旧密码不正确!')</script>");
            return;
        }
        if (Users.DoChPwd(Session["uid"].ToString(), this.txtnewpwd.Text))
        {
            //写系统日志
            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.Write("<script language=javascript>alert('修改密码成功!');window.location='main_xgmm.aspx?rnd=" + System.Guid.NewGuid().ToString() + "';</script>");
        }
        else
        {
            this.Response.Write("<script language=javascript>alert('修改密码失败!');window.location='main_xgmm.aspx?rnd=" + System.Guid.NewGuid().ToString() + "';</script>");
        }
    }
Exemplo n.º 2
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;
        }
    }