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.IO;

public partial class etwuser_maoyinfo : System.Web.UI.Page
{
    public int page = 1;
    public int userid = 0;
    public string website = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie GetCookie = Request.Cookies["cookEtwuser"];
        if (Request.Cookies["cookEtwuser"] == null)
        {
            Response.Redirect("../index.aspx");
        }
        DataSet ds1 = DbHelperSQL.Query("select u.userid,w.website from etw_user u inner join etw_web w on u.userid=w.usernameid where u.username='" + GetCookie["username"].ToString() + "'");
        if (ds1.Tables[0].Rows.Count > 0)
        {
            userid = Convert.ToInt32(ds1.Tables[0].Rows[0]["userid"]);
            Fun.Funrecord(Request.Url.AbsoluteUri,Page.Request.UserHostAddress, userid.ToString());
            for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
            {
                website = ds1.Tables[0].Rows[i]["website"].ToString();
                //createxml();
            }
        }
        if (!IsPostBack)
        {
            int totalOrders = (int)DbHelperSQL.GetSingle("select count(id) from etw_news where userid=" + userid + "");
            Cache["totalproduct"] = totalOrders;
            Pager1.RecordCount = totalOrders;
            Pager2.RecordCount = totalOrders;
        }
        Datanews();

    }
    protected void Pager1_PageChanging1(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        Pager1.CurrentPageIndex = e.NewPageIndex;
        page = Pager1.CurrentPageIndex;
        Datanews();
    }
    protected void Pager2_PageChanging1(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        Pager2.CurrentPageIndex = e.NewPageIndex;
        page = Pager2.CurrentPageIndex;
        Datanews();
    }
    public void Datanews()
    {
        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 trade_product where id not in(select top " + mun + " id from trade_product where userid=" + userid + " order by website asc,updatetime desc) and userid=" + userid + " order by website asc,updatetime desc");
        if (ds.Tables[0].Rows.Count > 0)
        {
            Repeater1.DataSource = ds.Tables[0].DefaultView;
            Repeater1.DataBind();
        }
    }
    public string getpic(string str)
    {
        string picture = string.Empty;
        if (str != null && str != "")
        {
            string[] al = str.Split(new string[] { ";" }, System.StringSplitOptions.RemoveEmptyEntries);
            if (al.Length > 0)
            {
                picture = al[0];
            }
        }
        else
        {
            picture = "nopic.jpg";
        }
        return picture;
    }
   
}
