using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

//
using DotNet.FrameWork.Utils;
using DotNet.FrameWork.Data;
using DotNet.FrameWork.Common.Web;
using System.Data.SqlClient;
using System.Data;

namespace HteamDd.Web.Web.Dd_password
{
    public partial class Dd_psw_ret : System.Web.UI.Page
    {
        public string is_setuse="1";
        public string use_id = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                use_id=Fetch.Get("userguid");
                if (Fetch.Get("action") != "tdc%BDF%lhhy%ghdifs%dfgr" &&use_id != "")
                {
                   is_setuse= ActiveUser(Fetch.Get("userguid"), "/Dd_login.aspx", Fetch.Get("time"));
                }               
            }
        }

        public string ActiveUser(string user_id, string url, string time)
        {
            //SqlParameter ID = new SqlParameter("@ID",SqlDbType.Int);
            // SqlParameter create_time= new SqlParameter("@time",SqlDbType.DateTime);
            // ID.Value = user_id;
            // create_time.Value = time;
            // IDataParameter[] par = new IDataParameter[] { ID, create_time};
            //SqlDataReader sdr = DbHelperSQL.RunProcedure("SP_time", par);
            //string mes = string.Empty;
            //while (sdr.Read())
            //{
            //    mes = sdr.GetValue(0).ToString();
            //}

            int active_state = Convert.ToInt32(DbHelperSQL.GetSingle("select User_isSet from Dd_User  where User_ID=" + user_id + ""));
            if (active_state == 0)
            {
                Jscript.ShowAndRedirect(this, "您已使用过该链接或激活链接已过期！", url);
                return "1";
            }
            else
            {
                string strsql = "update Dd_User set User_isSet=0 where User_ID=" + user_id + "";
                DbHelperSQL.ExecuteSql(strsql);
                return "2";
            }

        }

        private bool Get_Uerguid(string ID)
        {
            string sql_guid = "select User_Guid from Dd_User where User_Email=@email";
            SqlParameter Parms = new SqlParameter("@email", SqlDbType.NVarChar, 50);
            Parms.Value = ID;
            return DbHelperSQL.GetExists(sql_guid, Parms);
        }
    }
}