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_country_list : System.Web.UI.Page
{
    public int page = 1;
    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 (!IsPostBack)
        {
            int totalOrders = (int)DbHelperSQL.GetSingle("select count(id) from etw_country");
            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 c.*,a.name from etw_country c inner join etw_Address a on c.zid=a.id where c.id not in(select top " + mun + " id from etw_country order by id) order by c.id");
        if (ds.Tables[0].Rows.Count > 0)
        {
            Repeater1.DataSource = ds.Tables[0].DefaultView;
            Repeater1.DataBind();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (search.Text.ToString() != "")
        {
            DataSet ds = DbHelperSQL.Query("select c.*,a.name from etw_country c inner join etw_Address a on c.zid=a.id  where country_en like N'%" + search.Text.Trim() + "%' or country_cn  like N'%" + search.Text.Trim() + "%' or shortname  like N'%" + search.Text.Trim() + "%'");
            if (ds.Tables[0].Rows.Count > 0)
            {
                Pager1.Visible = false;
                Pager2.Visible = false;
                Repeater1.DataSource = ds.Tables[0].DefaultView;
                Repeater1.DataBind();
            }
        }
    }
}
