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;
using System.Data.OleDb;
public partial class usercontrol_findpwd : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            OleDbConnection conn = DB.connstr();
            conn.Open();
            OleDbCommand findcmd = new OleDbCommand("select Question from user_info where userName='" + this.username.Text + "'", conn);
            OleDbDataReader findread = findcmd.ExecuteReader();
            if (findread.Read())
            {
                if (findread["Question"].ToString().Length != 0)
                {
                    this.lbu.Text = "";
                    this.quest.Text = findread["Question"].ToString();
                }
                else
                {
                    this.lbu.Text = "您没有提供保密信息,不能找回密码！";
                    this.username.Text = "";
                    this.quest.Text = "";
                    this.useremail.Text = "";
                    this.ans.Text = "";
                    //this.nore.Visible = true;
                    //this.Panel1.Visible = false;
                    //this.re.Visible = false;
                }
            }
            else
            {
                this.lbu.Text = "用户名不存在！";
                this.username.Text = "";
                this.quest.Text = "";
                this.useremail.Text = "";
                this.ans.Text = "";
            }
            findread.Close();
            conn.Close();
        }

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string OleDb = "select * from user_info where userName='" + this.username.Text + "'and email='" + this.useremail.Text + "'";
        OleDbConnection conn = DB.connstr();
        conn.Open();
        OleDbCommand tocmd = new OleDbCommand(OleDb, conn);
        OleDbDataReader userread = tocmd.ExecuteReader();
        if (userread.Read())
        {
            this.labuid.Text = userread["userName"].ToString();
            this.labpwd.Text = userread["userPwd"].ToString();
            this.re.Visible = true;
            this.Panel1.Visible = false;
            this.nore.Visible = false;
            userread.Close();
            conn.Close();
        }
        else
        {
            this.nore.Visible = true;
            this.Panel1.Visible = false;
            this.re.Visible = false;
            userread.Close();
            conn.Close();
        }
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Session["user"] = this.labuid.Text;
        Response.Redirect("userinfo.aspx");
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        Session["user"] = this.labuid.Text;
        Response.Redirect("modpwd.aspx");
    }
}
