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_FindPwd : System.Web.UI.Page
{
    BLL.UserInfo user = new BLL.UserInfo();
    protected void Page_Load(object sender, EventArgs e)
    {
        Title = "找回密码";
        if (!this.IsPostBack)
        {
            this.MultiView1.ActiveViewIndex = 0;

        }
    }
    /// <summary>
    /// 检查用户名是否存在
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void setup1bt_Click(object sender, EventArgs e)
    {
        if (user.IsExist(this.usernametb.Text.Trim()) == true)
        {
            DataTable table = user.getUser(this.usernametb.Text.Trim());
            ViewState["answer"] = table.Rows[0]["Answer"].ToString();
            this.questiontb.Text = table.Rows[0]["Question"].ToString();
            this.MultiView1.ActiveViewIndex += 1;
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('用户名不存在!')</script>", false);
        }
    }

    /// <summary>
    /// 回答问题
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void setup2bt_Click(object sender, EventArgs e)
    {
        if (this.answertb.Text.Trim() == ViewState["answer"].ToString())
        {
            this.passwordlabel.Text = "你的密码:<font color:rend>" + user.researchPassword(this.usernametb.Text.Trim(), this.questiontb.Text.Trim(), this.answertb.Text.Trim()) + "</font> 请妥善保管!";
            this.MultiView1.ActiveViewIndex += 1;
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('密码问题不正确!')</script>", false);
        }
    }
}
