using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using System.Data;
namespace ComResProSystem
{
    public partial class UpdatePassword:BasePage
    {
        UserBll bll = new UserBll();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Ibt_Submit_Click(object sender, ImageClickEventArgs e)
        {
            DataTable dt = bll.gettable("SELECT ID FROM Users WHERE UserName='"+Session["UserName"].ToString()+"' AND [PassWord]='"+Tb_PassWord.Text+"'");
            if (dt.Rows.Count > 0)
            {
                if (bll.update("Users", "[PassWord]='" + Tb_New.Text + "'", "UserName='" + Session["UserName"].ToString() + "' AND [PassWord]='" + Tb_PassWord.Text + "'") == 0)
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('密码修改成功,请重新登录！');parent.parent.document.location='Login.aspx'", true);
                }
                else
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('密码修改失败！')", true);
                }
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('请输入正确的密码！')", true);
            }
        }
    }
}