using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SysCore;
using SysCore.Model;
using SysCore.DAL;


public partial class System_SystemFrame_ChangePassword : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btn_submit_Click(object sender, EventArgs e)
    {
        msg.ForeColor = System.Drawing.Color.Red;
        string old_pwd = txt_old_pwd.Text.Trim();
        string new_pwd = txt_new_pwd.Text.Trim();
        if (old_pwd.Equals(""))
        {
            msg.Text = "请输入原始密码!";
        }
        else if (new_pwd.Equals(""))
        {
            msg.Text = "请输入新密码!";
        }
        else
        {

            MemberDAL dal = new MemberDAL();
            int uid = new LoginInfo().uid;
            Member m = dal.Get(uid);

            if (!m.password.Equals(XTools.Encrypt(old_pwd)))
            {
                msg.Text = "原始密码不正确！";
            }
            else
            {
                m.password = XTools.Encrypt(new_pwd);
                dal.Update(m);
                msg.ForeColor = System.Drawing.Color.Green;
                msg.Text = "密码修改成功！";
            }
        }
    }
}