using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Member_Update_Pwd : System.Web.UI.Page
{
    BLL.UserInfo user = new BLL.UserInfo();
    protected void Page_Load(object sender, EventArgs e)
    {
        Title = "修改密码";
        if (user.IsLogin() == true)
        {
            if (!this.IsPostBack)
            {
                this.usernamelb.Text = user.getUserName();
            }
        }
        else
        {
            this.Response.Redirect("Member_Login.aspx");
        }
    }

    /// <summary>
    /// 修改密码
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void updateBt_Click(object sender, EventArgs e)
    {
        if (user.validateUser(user.getUserName(), this.oldpasswordTb.Text.Trim(), 1) == true)
        {
            if (user.updateUserPassword(user.getUserID(), this.newpasswordTb.Text.Trim()) == 1)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('修改成功!')</script>", false);
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('修改失败!')</script>", false);
            }
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('旧密码错误!')</script>", false);
        }
    }
}
