using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using JY.Model;
using JY.BLL;
using Maticsoft.DBUtility;

public partial class PasswordUpdate : System.Web.UI.Page
{
    JY.BLL.Member bll = new JY.BLL.Member();
    JY.Model.Member model = new JY.Model.Member();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) 
        {
            if (Session["MemberName"] != null)
            {
                txtMemberName.Text = Session["MemberName"].ToString();
            }
        }
    }

    protected void tijiao_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            if (Session["MemberID"] != null)
            {
                EnCode encode = new EnCode();
                model = bll.GetModel(Convert.ToInt64(Session["MemberID"]));
                if (model.Password == encode.md5(txtOldPassword.Text.Trim()))                
                {
                    if (txtPassword.Text.Trim() != "")
                    {
                        model.Password = encode.md5(txtPassword.Text.Trim());

                        if (bll.Update(model))
                        {
                             Session["MemberID"] = null;
                             Session["MemberName"] = null;
                             Session["MemberRankId"] = null;

                             Response.Write("<script language=\"javascript\" >alert('您的登录密码修改成功，请使用新密码重新登录！');javascript:location='../Login.aspx';</script>");
                            // publicHandle.ShowMessage(this.Page, "'您的登录密码修改成功，请使用新密码重新登录！", "../Login.aspx");
                        }
                        else
                        {
                            publicHandle.ShowMessage(this.Page, "修改失败！");
                        }                       
                    }                   
                }
                else
                {
                    publicHandle.ShowMessage(this.Page, "原密码错误！");
                }
            }
        }
        catch (Exception ex)
        {
            publicHandle.ShowMessage(this, ex.Message);
        }
    }
}
