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

public partial class ad_widthAD : System.Web.UI.UserControl
{
    private string adID;
    public string adW = "680";
    public string adH = "250";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            XabaraCom xc = new XabaraCom();
            dbDataFunction db = new dbDataFunction();
            DateTime t = DateTime.Now;

            if (!string.IsNullOrEmpty(adID as string))
            {
                string[] ids = adID.Split(new char[] { '|' });  //分类，宽度，高度
                if (ids.GetUpperBound(0) == 2)
                {
                    adW = xc.SafeNum(ids[1]).ToString();
                    adH = xc.SafeNum(ids[2]).ToString();

                    string strSql = "select * from ads where starDate<'" + t.ToString() + "' and stopDate>'" + t.ToString() + "' and classID=" + xc.SafeNum(ids[0]) + " order by starDate DESC,aID DESC";
                    //Response.Write(strSql);
                    //Response.End();
                    DataTable dt = db.getDataTable(strSql);
                    int c = dt.Rows.Count;

                    if (c > 0)
                    {
                        for (int i = 0; i < c; i++)
                        {
                            divImg.Text += "<li>" + dt.Rows[i]["adCode"].ToString().Replace("\"", "\'") + "</li>";
                            divCount.Text += "<li>" + (i + 1).ToString() + "</li>";
                        }
                    }

                    dt.Dispose();
                }
            }
        }
    }

    public string ClassID   //得到参数
    {
        get { return adID; }
        set { adID = value; }
    }
}
