部门排行是在原有部门排行的基础上在加一个投稿总数(包括未审核的数量)。
现在的部门排行只有审核通过的数量。
现在部门排行代码为:
<% @ Page language="c#" Inherits="PageAdmin.custom_zdymodel"%>
<% @ Import NameSpace="System.Data"%>
<% @ Import NameSpace="System.Data.OleDb"%>
<%conn.Open();Read_Data(136);%><script language="c#" runat="server">
string TheTable,sql;
OleDbCommand comm;
private void Create_Date()
{
TheTable="article";
DataTable dt=new DataTable("default");
DataRow row;
dt.Columns.Add("id",Type.GetType("System.Int32"));
dt.Columns.Add("department",Type.GetType("System.String"));
dt.Columns.Add("tongji",Type.GetType("System.Int32"));
sql="select id,name from pa_department";
OleDbCommand comm=new OleDbCommand(sql,conn);
OleDbDataReader dr=comm.ExecuteReader();
while(dr.Read())
{
row = dt.NewRow();
row["id"]=int.Parse(dr["id"].ToString());
row["department"]=dr["name"].ToString();
row["tongji"]=TongJi(int.Parse(dr["id"].ToString()));
dt.Rows.Add(row);
}
dr.Close();
DataView dv=new DataView();
dv.Table=GetTable(dt,"tongji desc");
P1.DataSource=dv;
P1.DataBind();
}
private int TongJi(int dpid)
{
int rv=0;
sql="select count("+TheTable+".id) as co from "+TheTable+",pa_member where "+TheTable+".checked=1 and pa_member.department_id="+dpid+" and "+TheTable+".username=pa_member.username";
OleDbCommand comm=new OleDbCommand(sql,conn);
OleDbDataReader dr=comm.ExecuteReader();
if(dr.Read())
{
rv=int.Parse(dr["co"].ToString());
}
return rv;
}
private DataTable GetTable(DataTable sorucedt,string orderby)
{
sorucedt.DefaultView.Sort=orderby;
DataTable newdt = sorucedt.DefaultView.ToTable();
return newdt;
}
</script>
<%Create_Date();%>
<html>
<head>
<style type="text/css">
td{font:12px/1.7em Verdana,Tahoma,Helvetica,Arial,sans-serif;}
</style>
</head>
<body bgColor="transparent">
<div>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td>部门</td><td> 投稿数</td></tr>
<asp:Repeater id="P1" runat="server">
<ItemTemplate>
<tr><td><%#DataBinder.Eval(Container.DataItem,"department")%></td><td> <%#DataBinder.Eval(Container.DataItem,"tongji")%></td></tr>
</ItemTemplate>
</asp:Repeater>
</table>
</body>
</html><%conn.Close();
if(PageCount>1)
{
string PageHtml="<div id=\"sublanmu_page\" class=\"sublanmu_page\">";
if(CurrentPage>1)
{
if(APage_LinkText[0]!=""){PageHtml+="<a href=\""+GoPage(1)+"\">"+APage_LinkText[0]+"</a>";} //首页
if(APage_LinkText[1]!=""){PageHtml+=" <a href=\""+GoPage(CurrentPage-1)+"\">"+APage_LinkText[1]+"</a>";} //上一页
}
int p=8; //表示开始时显示的页码总数
int M=4; //超过p页后左右两边显示页码数
int LastPage=1;
if(CurrentPage<p)
{
LastPage=p;
if(LastPage>PageCount)
{
LastPage=PageCount;
}
for(int i=1;i<=LastPage;i++)
{
if(CurrentPage==i)
{
PageHtml+=" <span class=\"c\">"+i.ToString()+"</span>";
}
else
{
PageHtml+=" <a href=\""+GoPage(i)+"\">"+i.ToString()+"</a>";
}
}
}
else
{
//PageHtml+=" <a href=\""+GoPage(CurrentPage-1)+"\">1...</a>";
LastPage=CurrentPage+M;
if(LastPage>PageCount)
{
LastPage=PageCount;
}
for(int i=(CurrentPage-M);i<=LastPage;i++)
{
if(CurrentPage==i)
{
PageHtml+=" <span class=\"c\">"+i.ToString()+"</span>";
}
else
{
PageHtml+=" <a href=\""+GoPage(i)+"\">"+i.ToString()+"</a>";
}
}
}
if(CurrentPage<PageCount)
{
if(LastPage<PageCount)
{
PageHtml+=" <a href=\""+GoPage(LastPage+1)+"\">...</a>";
}
if(APage_LinkText[2]!=""){PageHtml+=" <a href=\""+GoPage(CurrentPage+1)+"\">"+APage_LinkText[2]+"</a>";} //下一页
if(APage_LinkText[3]!=""){PageHtml+=" <a href=\""+GoPage(PageCount)+"\">"+APage_LinkText[3]+"</a>";} //尾页
}
if(Page_LinkInfo!=""){PageHtml+=" <span>"+String.Format(Page_LinkInfo,CurrentPage,PageCount,RecordCount)+"</span>";} //记录页次
PageHtml+="</div>";
Response.Write(PageHtml);
}%>