예제 #1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            DataTable newdt  = new DataTable();
            string    sqlCmd = "select * from APILogin where Acount='" + userid.Value + "'";

            SqlSel.GetSqlSel(ref newdt, sqlCmd);
            if (newdt.Rows.Count == 0)
            {
                Response.Write("<script>alert('您输入的用户名不存在!')</script>");
                return;
            }
            if (newdt.Rows[0]["Pwd"].ToString() == BPEycrypt.EncryptAdmin(txtpwd.Value))
            {
                HttpCookie cookieName = new HttpCookie("UserName");
                cookieName.Value = userid.Value;
                Response.AppendCookie(cookieName);
                HttpCookie cookieName2 = new HttpCookie("Pwd");
                cookieName2.Value = txtpwd.Value;
                Response.AppendCookie(cookieName2);
                string strsql = " update APILogin set IPAddress='" + IPHelp.ClientIP
                                + "',LoginTime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                                + "' where Acount='" + userid.Value + "' ";
                int execounts = SqlSel.ExeSql(strsql);
                Response.Redirect("Default.aspx");
            }
            else
            {
                Response.Write("<script>alert('您输入的密码有误!')</script>");
            }
        }
예제 #2
0
        protected void btnCon_Click(object sender, EventArgs e)
        {
            string relpwd = this.txtrelpwd.Value.Trim();
            string newpwd = this.txtnewpwd.Value.Trim();
            string chkpwd = this.txtchkpwd.Value.Trim();

            if (string.IsNullOrEmpty(relpwd) || string.IsNullOrEmpty(newpwd) || string.IsNullOrEmpty(chkpwd))
            {
                Response.Write("<script>alert('输入不完整或网络错误!');window.location='EditPwd.aspx'</script>");
            }
            if (newpwd != chkpwd)
            {
                Response.Write("<script>alert('新密码两次输入不一致!');window.location='EditPwd.aspx'</script>");
            }
            if (newpwd.Length < 6 || newpwd.Length > 16)
            {
                Response.Write("<script>alert('新密码长度与要求不符!');window.location='EditPwd.aspx'</script>");
            }
            string username = Request.Cookies["UserName"].Value.ToString();
            string strsql   = " update APILogin set Pwd='" + BPEycrypt.EncryptAdmin(newpwd)
                              + "' where Acount='" + username + "' and Pwd='" + BPEycrypt.EncryptAdmin(relpwd) + "' ";
            int execounts = SqlSel.ExeSql(strsql);

            if (execounts > 0)
            {
                lblMeassge.Visible = true;
                lblMeassge.Text    = "修改成功!";
            }
            else
            {
                lblMeassge.Visible = false;
                Response.Write("<script>alert('修改失败!');window.location='EditPwd.aspx'</script>");
            }
        }