예제 #1
0
 protected void btn_submit_Click(object sender, EventArgs e)
 {
     String pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(this.pwd.Text, "MD5");
     HyUser HyUser = new HyUser();
     HyCommon HyCommon = new HyCommon();
     if (Session["SESSION_CODE"].ToString().ToLower().Equals(this.txtCode.Text.ToLower()))
     {
         if (HyUser.Login(this.user.Text, pwd))
         {
             DataTable dt = HyUser.Getuserbyuserid(this.user.Text);
             if (dt.Rows.Count > 0)
             {
                 Session["uid"] = dt.Rows[0]["hy_userid"].ToString();
                 Session["uname"] = dt.Rows[0]["hy_username"].ToString();
                 Session["deptid"] = dt.Rows[0]["hy_deptid"].ToString();
             }
             //写系统日志
             string userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
             if (userip == null || userip == "")
             {
                 userip = Request.ServerVariables["REMOTE_ADDR"];
             }
             //写系统日志
             HyCommon.WriteLog("登录", "系统登录", Session["uid"].ToString(), Session["uname"].ToString());
             //跳转到首页
             Response.Redirect(lblurl.Text);
         }
         else
         {
             Response.Write("<script>alert('输入的用户名或者密码不正确!');window.location.href = window.location.href;</script>");
         }
     }
     else
     {
         Response.Write("<script>alert('输入的验证码不正确!');window.location.href = window.location.href;</script>");
     }
 }
예제 #2
0
    //保存
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        HyUser Users = new HyUser();
        String password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtoldpwd.Text, "MD5");
        if (!Users.Login(this.txtUid.Text, password))
        {
            this.Response.Write("<script language=javascript>alert('输入旧密码不正确!')</script>");
            return;
        }

        String newpwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtnewpwd.Text, "MD5");

        if (Users.DoChPwd(this.txtUid.Text, newpwd))
        {
            //写系统日志
            HyCommon HyCommon = new HyCommon();
            HyCommon.WriteLog("修改密码", "修改密码", this.txtUid.Text, this.txtUname.Text);
            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>");
        }
    }