using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
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;
using System.Xml.Linq;
using LZBS.Model;
using LZBS.BLL;
using LZBS.Common;

namespace LZBS.Web
{
    public partial class Retrieve1 : System.Web.UI.Page
    {
        M_Member model = new M_Member();
        B_Member bll = new B_Member();
        M_SysLog mLog = new M_SysLog();
        B_SysLog bLog = new B_SysLog();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["Answer"] == null)
            {
                MyMessageBox.MessageBox("只有先输入账号并回答问题才能找回密码", this.Page,"Login.aspx");
            }
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            mLog.UserIP = ClientInfo.GetUserIP();
            mLog.URL = Request.Url.AbsoluteUri.ToString();
            mLog.Account = Request.Cookies["Answer"].Value;
            mLog.UserType = 1;

            model.MemberID = Request.Cookies["Answer"].Value;
            model.Password = txtNewPwd.Text.Trim();
            if (bll.ChangePassword(model) > 0)
            {
                mLog.OPInfo = "通过找回密码方式修改密码成功";
                MyMessageBox.MessageBox("密码修改成功", this.Page);
            }
            else
            {
                mLog.OPInfo = "通过找回密码方式修改密码失败";
                MyMessageBox.MessageBox("密码修改失败", this.Page);
            }
            bLog.AddLog(mLog);
        }
    }
}
