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 DAL.Ad;
using WebSenPageNo;

public partial class Control_Default : System.Web.UI.Page
{
   // private int pageSize = 8;//这里设置分页尺寸
    #region
    public int Pageindex
    {
        //页下标属性
        set
        {
            this.ViewState["pgindex"] = value;
        }
        get
        {
            int index = 1;
            object o = this.ViewState["pgindex"];
            if (o != null)
            {
                index = (int)o;
            }
            return index;
        }
    }
    public int PageCount
    {
        //总页数
        set { this.ViewState["pagecount"] = value; }
        get
        {
            int pagecot = 1;
            object od = this.ViewState["pagecount"];
            if (od != null)
            {
                pagecot = (int)od;
            }
            return pagecot;
        }
    }
    #endregion
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //Control_PageNo C_pno = new Control_PageNo();
            string strURl = Request.RawUrl;
            strURl = strURl.Substring(0, strURl.IndexOf(".aspx"))+".aspx";
            PageNo1.Strurl = strURl;
            if (Request.QueryString["page"] != null)
            {
                PageNo1.Pageindex = Convert.ToInt32(Request.QueryString["page"].ToString());
                PageNo1.PageSize = 2;
                if (Session["strWhere"] != null)
                {
                    PageNo1.Where = Session["strWhere"].ToString();
                }
                else {
                    PageNo1.Where = "1=1";
                }
                PageNo1.Table = "(W_Ad_Table INNER JOIN W_Ad_MemberInfo ON W_Ad_Table.T_ID = W_Ad_MemberInfo.T_ID) LEFT JOIN U_UserInfo ON W_Ad_MemberInfo.[User_ID]=U_UserInfo.[UserID]";
                PageNo1.FldName = "W_Ad_Table.T_ID";
                PageNo1.StrGetFields = "W_Ad_Table.T_ID, W_Ad_Table.Ad_Type, W_Ad_Table.Ad_Name, W_Ad_Table.Ad_Page, W_Ad_Table.Ad_Height, W_Ad_Table.Ad_Width, W_Ad_Table.DayMoney, W_Ad_Table.Ad_StartDate,W_Ad_MemberInfo.Ad_MemberInfoName, W_Ad_MemberInfo.Ad_Adrees,W_Ad_MemberInfo.Ad_Leter,W_Ad_MemberInfo.Ad_ImageAdrees ,W_Ad_MemberInfo.Ad_Day,W_Ad_MemberInfo.M_ID,W_Ad_MemberInfo.[User_ID],W_Ad_MemberInfo.[Ad_RestrictTime],U_UserInfo.[LoginName],W_Ad_MemberInfo.[Ad_Auditing]";
                DataTable table = PageNo1.BindView();
                GridView1.DataSource = table.DefaultView;
                GridView1.DataBind();
            }
            else
            {
                PageNo1.Pageindex = Pageindex;
                PageNo1.PageSize = 2;
                PageNo1.Where = "1=1";
                PageNo1.Table = "(W_Ad_Table INNER JOIN W_Ad_MemberInfo ON W_Ad_Table.T_ID = W_Ad_MemberInfo.T_ID) LEFT JOIN U_UserInfo ON W_Ad_MemberInfo.[User_ID]=U_UserInfo.[UserID]";
                PageNo1.FldName = "W_Ad_Table.T_ID";
                PageNo1.StrGetFields = "W_Ad_Table.T_ID, W_Ad_Table.Ad_Type, W_Ad_Table.Ad_Name, W_Ad_Table.Ad_Page, W_Ad_Table.Ad_Height, W_Ad_Table.Ad_Width, W_Ad_Table.DayMoney, W_Ad_Table.Ad_StartDate,W_Ad_MemberInfo.Ad_MemberInfoName, W_Ad_MemberInfo.Ad_Adrees,W_Ad_MemberInfo.Ad_Leter,W_Ad_MemberInfo.Ad_ImageAdrees ,W_Ad_MemberInfo.Ad_Day,W_Ad_MemberInfo.M_ID,W_Ad_MemberInfo.[User_ID],W_Ad_MemberInfo.[Ad_RestrictTime],U_UserInfo.[LoginName],W_Ad_MemberInfo.[Ad_Auditing]";
                DataTable table = PageNo1.BindView();
                GridView1.DataSource = table.DefaultView;
                GridView1.DataBind();
            }
            
        }
        
    }
    protected void btnSeatch_Click(object sender, EventArgs e)
    {
        string strWhere = "1=1";
        if (this.txtWhere.Text != "" || this.txtWhere.Text != null)   //广告位名称
        {
            strWhere += " and Ad_Name like '%" + this.txtWhere.Text.ToString().Trim() + "%'";
        }
        Session["strWhere"] = strWhere;
        PageNo1.Pageindex = 1;
        PageNo1.PageSize = 2;
        PageNo1.Where = strWhere;
        PageNo1.Table = "(W_Ad_Table INNER JOIN W_Ad_MemberInfo ON W_Ad_Table.T_ID = W_Ad_MemberInfo.T_ID) LEFT JOIN U_UserInfo ON W_Ad_MemberInfo.[User_ID]=U_UserInfo.[UserID]";
        PageNo1.FldName = "W_Ad_Table.T_ID";
        PageNo1.StrGetFields = "W_Ad_Table.T_ID, W_Ad_Table.Ad_Type, W_Ad_Table.Ad_Name, W_Ad_Table.Ad_Page, W_Ad_Table.Ad_Height, W_Ad_Table.Ad_Width, W_Ad_Table.DayMoney, W_Ad_Table.Ad_StartDate,W_Ad_MemberInfo.Ad_MemberInfoName, W_Ad_MemberInfo.Ad_Adrees,W_Ad_MemberInfo.Ad_Leter,W_Ad_MemberInfo.Ad_ImageAdrees ,W_Ad_MemberInfo.Ad_Day,W_Ad_MemberInfo.M_ID,W_Ad_MemberInfo.[User_ID],W_Ad_MemberInfo.[Ad_RestrictTime],U_UserInfo.[LoginName],W_Ad_MemberInfo.[Ad_Auditing]";
        DataTable table = PageNo1.BindView();
        GridView1.DataSource = table.DefaultView;
        GridView1.DataBind();
    }
}
