115 lines
3.2 KiB
C#
115 lines
3.2 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using DeiNiu.Utils;
|
|
using DeiNiu.wms.Logical;
|
|
|
|
public partial class index : Page
|
|
{
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
// if(!IsPostBack)
|
|
// Session[appScope.PagelevelObj] = this;
|
|
|
|
// if (!IsPostBack)
|
|
// bindData();
|
|
|
|
Response.Redirect("login.aspx");
|
|
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
void bindData()
|
|
{
|
|
LPublicNews logic = new LPublicNews();
|
|
DataView dv = logic.QueryTopCatagory().DefaultView;
|
|
RepeaterTop.DataSource = dv;
|
|
RepeaterTop.DataBind();
|
|
|
|
RepeaterMarquee.DataSource = logic.QueryMarqueen().DefaultView;
|
|
RepeaterMarquee.DataBind();
|
|
|
|
}
|
|
|
|
protected void RepeaterTop_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
|
|
{
|
|
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
|
|
{
|
|
Repeater rpColumnNews = (Repeater)e.Item.FindControl("RepeaterSecond");
|
|
//找到分类Repeater关联的数据项
|
|
DataRowView rowv = (DataRowView)e.Item.DataItem;
|
|
//提取分类ID
|
|
string authID = Convert.ToString(rowv["ID"]);
|
|
//里面的Repeater
|
|
LPublicNews logic = new LPublicNews();
|
|
DataView dv = logic.QueryPublicInfomation().DefaultView;
|
|
dv.RowFilter = "auth_uplevel='" + authID + "' and auth_marqueen=0 ";
|
|
rpColumnNews.DataSource = dv;
|
|
rpColumnNews.DataBind();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
protected void RepeaterSecond_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
|
|
{
|
|
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
|
|
{
|
|
Repeater rpColumnNews = (Repeater)e.Item.FindControl("RepeaterThird");
|
|
//找到分类Repeater关联的数据项
|
|
DataRowView rowv = (DataRowView)e.Item.DataItem;
|
|
//提取分类ID
|
|
string authID = Convert.ToString(rowv["ID"]);
|
|
//里面的Repeater
|
|
LPublicNews logic = new LPublicNews();
|
|
DataView dv = logic.QueryNews(Convert.ToInt32(authID)).DefaultView;
|
|
dv = GetTopDataViewRows(dv,3);
|
|
rpColumnNews.DataSource = dv;
|
|
rpColumnNews.DataBind();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
public string FormatShowContent(string titlecontent, int titlelength)
|
|
{
|
|
if (titlecontent.Length > titlelength)
|
|
{
|
|
return titlecontent.Substring(0, titlelength);
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < titlelength - titlecontent.Length;i++ )
|
|
titlecontent += " ";
|
|
|
|
return titlecontent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private DataView GetTopDataViewRows(DataView dv, int n)
|
|
{
|
|
DataTable dt = dv.Table.Clone();
|
|
|
|
for (int i = 0; i < n - 1; i++)
|
|
{
|
|
if (i >= dv.Count)
|
|
{
|
|
break;
|
|
}
|
|
dt.ImportRow(dv[i].Row);
|
|
}
|
|
return new DataView(dt, dv.RowFilter, dv.Sort, dv.RowStateFilter);
|
|
}
|
|
|
|
|
|
}
|