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 UserInfo;

public partial class login_HelpKey : Base.BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnSubmit1_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["UserID"] != null && Request.QueryString["UserID"] != "")
        {
            int userid = int.Parse(Request.QueryString["UserID"].ToString());
            //找密码过程中验证此用户是否注册或密码答案是否正确
            if (txtAnswer.Text.Trim() == "")
            {
                lblcode.Text = "密码答案不能为空!";
                return;
            }
            //判断Cookie是否为空如果为空说明浏览器禁用了Cookie
            if (Request.Cookies["CheckCode"] == null)
            {
                lblcode.Text = "您的浏览器设置已被禁用Cookies,请设置浏览器允许使用Cookies后使用本系统";
            }
            //判断验证码与用户输入的是否相同
            if (string.Compare(Request.Cookies["CheckCode"].Value.ToLower(), txtCheckCode.Text.ToLower()) != 0)
            {
                lblcode.Text = "验证码错误！";
                return;
            }
            string where = "where UserID='" + userid + "'";
            IUserInfo user = new RUserInfo();
            DataTable dt = user.GetDataTable(where);
            string Answer = dt.Rows[0]["Answer"].ToString();
            string Question = dt.Rows[0]["Question"].ToString();
            if (Question != dropQuestion.SelectedValue)
            {
                lblcode.Text = "您的提示问题不正确！";
                return;
            }
            if (Answer.ToLower() != txtAnswer.Text.Trim().ToLower())
            {
                lblcode.Text = "您的提示答案不正确！";
                return;
            }
            else
            {
                Response.Redirect("FindPwd.aspx?UserID=" + userid);
            }

        }


    }
}
