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 etw_c_m_History : System.Web.UI.Page
{
    public string pagelist = string.Empty;
    public int page = 1;
    public string userid = string.Empty;
    public string company = string.Empty;
    public string ipaddress = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie GetCookie = Request.Cookies["cook_admin"];
        if (Request.Cookies["cook_admin"] == null)
        {
            Response.Redirect("index.aspx");
        }
        if (Request.QueryString["pagelist"] != null && Request.QueryString["userid"] != null && Request.QueryString["ipaddress"] != null)
        {
            pagelist = Request.QueryString["pagelist"].ToString();
            userid = Request.QueryString["userid"].ToString();
            ipaddress = Request.QueryString["ipaddress"].ToString();
            etw.etw_user lead = new etw.etw_user();
            lead.userid = Convert.ToInt32(userid);
            lead.GetModel();
            company = lead.company;
            if (!IsPostBack)
            {
                int totalOrders = (int)DbHelperSQL.GetSingle("select count(id) from etw_record where usernameid=" + userid + " and ip='" + ipaddress + "'");
                Cache["totalproduct"] = totalOrders;
                Pager1.RecordCount = totalOrders;
                Pager2.RecordCount = totalOrders;
            }
        }
        DataUser();
    }
    protected void Pager1_PageChanging1(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        Pager1.CurrentPageIndex = e.NewPageIndex;
        page = Pager1.CurrentPageIndex;
        DataUser();
    }
    protected void Pager2_PageChanging1(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        Pager2.CurrentPageIndex = e.NewPageIndex;
        page = Pager2.CurrentPageIndex;
        DataUser();
    }
    public void DataUser()
    {
        int i = 1;
        if (Request.QueryString["page"] != null)
        {
            i = Convert.ToInt32(Request.QueryString["page"].ToString());
        }
        int mun = (i - 1) * 20;
        DataSet ds = DbHelperSQL.Query("select top 20 * from etw_record where usernameid=" + userid + " and ip='" + ipaddress + "' and id not in(select top " + mun + " id  from etw_record where usernameid=" + userid + " and ip='" + ipaddress + "' order by id desc) order by id desc");
        if (ds.Tables[0].Rows.Count > 0)
        {
            Repeater1.DataSource = ds.Tables[0].DefaultView;
            Repeater1.DataBind();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        this.Response.Redirect("IPlist.aspx?pagelist=" + pagelist + "&userid="+userid+"");
    }
}
