public partial class forumindex : FunctionBase //继承
{
protected void Page_Load(object sender, EventArgs e) //页面加载事件触发
{ Page.Title = "交流园地"; //页面标题
newscontent.InnerHtml = ShowTopNews(); //新闻内容的HTML加载,要看后一个返回的是什么 string sql = "select forum.type,count(forum.forumid) as total,forumtype.title as typename,forumtype.forummanage,forumtype.description from forum " //查询数据库语句
+ "left join forumtype on forumtype.id=forum.type "
+ "group by forum.type,forumtype.title,forumtype.forummanage,forumtype.description";
DataSet ds = SQLBASE.FillDataSet(sql); //返回ds,一个表的集合,这里应该只是一个表
//接下来从数据库里面取出帖子的数据
//StringBuilder strHtmlCode = new StringBuilder(1000);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
DataRow row = ds.Tables[0].Rows[i];
/*---------------该类别的情况-总跟帖数-----------------------------------*/
string enlist_sql = "select count(enlistforum.id) as num from enlistforum "
+ "left join forum on enlistforum.forumid=forum.forumid "
+ "group by forum.type having forum.type=" + row["type"];
DataSet enlistds = SQLBASE.FillDataSet(enlist_sql);
int enlist_num = 0;//该类型帖子的总跟贴数
if (enlistds.Tables[0].Rows.Count>0)
{
DataRow enlistrow = enlistds.Tables[0].Rows[0];
enlist_num = (int)enlistrow["num"];
}
/*-------------------今日总发帖数------------------------------------------------*/
string today_sql = "select count(forumid) as todaynum from forum where DATEDIFF(day, createdate, getdate())=0 and type=" + row["type"];
DataSet todayds = SQLBASE.FillDataSet(today_sql);
int today_num = 0;//该类型帖子的总跟贴数
if (todayds.Tables[0].Rows.Count > 0)
{
DataRow todayrow = todayds.Tables[0].Rows[0];
today_num = (int)todayrow["todaynum"];
}
/*----------------------该项的最后发帖人----------------------------------------*/
string last_sql = "select top 1 forum.forumid,reguser.username,forum.createdate from reguser,forum where reguser.rid=forum.initiator order by forum.forumid desc";
DataSet lastds = SQLBASE.FillDataSet(last_sql);
string lastname = "无记录";
string lastdate = "";
if (lastds.Tables[0].Rows.Count > 0)
{
DataRow lastrow = lastds.Tables[0].Rows[0];
lastname = lastrow["username"].ToString();
lastdate = lastrow["createdate"].ToString();
}
forumlist.InnerHtml += " <br /> <table style='width: 800px; border: solid 1px #0096FF;background-color:#D6E0EF' cellpadding='1' cellspacing='1'>"
+" <tr>"
+ " <td style='width: 100%; height:25px; background-color:#00b0ff' align='left' valign='middle' colspan='7'>"
+ " <span style='padding-left:5px; color:White'> <strong> <a href='/code/forumlist.aspx?type=" + row["type"] + "' target='_blank'>" + row["typename"] + " </a> </strong> </span>"
+" </td>"
+" </tr>"
+ " <tr bgcolor='#EFEFEF'>"
+ " <td style='width: 6%; height:20px;' align='center' valign='middle'>"
+ " </td>"
+ " <td style='width: 44%; height:20px;' align='center' valign='middle'>论坛"
+ " </td>"
+ " <td style='width: 6%; height:20px;' align='center' valign='middle'>主题"
+ " </td>"
+ " <td style='width: 6%; height:20px;' align='center' valign='middle'>贴数"
+ " </td>"
+ " <td style='width: 6%; height:20px;' align='center' valign='middle'>今日"
+ " </td>"
+ " <td style='width: 20%; height:20px;' align='center' valign='middle'>最后发表"
+ " </td>"
+ " <td style='width: 12%; height:20px;' align='center' valign='middle'>版主"
+ " </td>"
+ " </tr>"
+ " <tr>"
+ " <td style='width: 6%; height:30px;background-color:#F8F8F8' align='center' valign='middle'>"
+" </td>"
+ " <td style='width: 44%; height:30px;background-color:#ffffff' align='left' valign='middle' onMouseOver=\"this.className='altbg1'\" onMouseOut=\"this.className='altbg2'\">"
+ " <a href='/code/forumlist.aspx?type=" + row["type"] + "' target='_blank'>" + row["description"] + " </a>"
+ " </td>"
+ " <td style='width: 6%; height:30px;background-color:#F8F8F8' align='center' valign='middle'>" + row["total"]
+ " </td>"
+ " <td style='width: 6%; height:30px;background-color:#ffffff' align='center' valign='middle'>" + enlist_num
+ " </td>"
+ " <td style='width: 6%; height:20px;background-color:#F8F8F8' align='center' valign='middle' >" + today_num
+ " </td>"
+ " <td style='width: 20%; height:20px;background-color:#ffffff' align='center' valign='middle'>" + lastdate+" by "+lastname
+ " </td>"
+ " <td style='width: 12%; height:30px;background-color:#F8F8F8' align='center' valign='middle'>" + row["forummanage"]
+ " </td>"
+" </tr>"
+" </table>"; }
//forumlist.InnerHtml = strHtmlCode;
}
{
protected void Page_Load(object sender, EventArgs e) //页面加载事件触发
{ Page.Title = "交流园地"; //页面标题
newscontent.InnerHtml = ShowTopNews(); //新闻内容的HTML加载,要看后一个返回的是什么 string sql = "select forum.type,count(forum.forumid) as total,forumtype.title as typename,forumtype.forummanage,forumtype.description from forum " //查询数据库语句
+ "left join forumtype on forumtype.id=forum.type "
+ "group by forum.type,forumtype.title,forumtype.forummanage,forumtype.description";
DataSet ds = SQLBASE.FillDataSet(sql); //返回ds,一个表的集合,这里应该只是一个表
//接下来从数据库里面取出帖子的数据
//StringBuilder strHtmlCode = new StringBuilder(1000);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
DataRow row = ds.Tables[0].Rows[i];
/*---------------该类别的情况-总跟帖数-----------------------------------*/
string enlist_sql = "select count(enlistforum.id) as num from enlistforum "
+ "left join forum on enlistforum.forumid=forum.forumid "
+ "group by forum.type having forum.type=" + row["type"];
DataSet enlistds = SQLBASE.FillDataSet(enlist_sql);
int enlist_num = 0;//该类型帖子的总跟贴数
if (enlistds.Tables[0].Rows.Count>0)
{
DataRow enlistrow = enlistds.Tables[0].Rows[0];
enlist_num = (int)enlistrow["num"];
}
/*-------------------今日总发帖数------------------------------------------------*/
string today_sql = "select count(forumid) as todaynum from forum where DATEDIFF(day, createdate, getdate())=0 and type=" + row["type"];
DataSet todayds = SQLBASE.FillDataSet(today_sql);
int today_num = 0;//该类型帖子的总跟贴数
if (todayds.Tables[0].Rows.Count > 0)
{
DataRow todayrow = todayds.Tables[0].Rows[0];
today_num = (int)todayrow["todaynum"];
}
/*----------------------该项的最后发帖人----------------------------------------*/
string last_sql = "select top 1 forum.forumid,reguser.username,forum.createdate from reguser,forum where reguser.rid=forum.initiator order by forum.forumid desc";
DataSet lastds = SQLBASE.FillDataSet(last_sql);
string lastname = "无记录";
string lastdate = "";
if (lastds.Tables[0].Rows.Count > 0)
{
DataRow lastrow = lastds.Tables[0].Rows[0];
lastname = lastrow["username"].ToString();
lastdate = lastrow["createdate"].ToString();
}
forumlist.InnerHtml += " <br /> <table style='width: 800px; border: solid 1px #0096FF;background-color:#D6E0EF' cellpadding='1' cellspacing='1'>"
+" <tr>"
+ " <td style='width: 100%; height:25px; background-color:#00b0ff' align='left' valign='middle' colspan='7'>"
+ " <span style='padding-left:5px; color:White'> <strong> <a href='/code/forumlist.aspx?type=" + row["type"] + "' target='_blank'>" + row["typename"] + " </a> </strong> </span>"
+" </td>"
+" </tr>"
+ " <tr bgcolor='#EFEFEF'>"
+ " <td style='width: 6%; height:20px;' align='center' valign='middle'>"
+ " </td>"
+ " <td style='width: 44%; height:20px;' align='center' valign='middle'>论坛"
+ " </td>"
+ " <td style='width: 6%; height:20px;' align='center' valign='middle'>主题"
+ " </td>"
+ " <td style='width: 6%; height:20px;' align='center' valign='middle'>贴数"
+ " </td>"
+ " <td style='width: 6%; height:20px;' align='center' valign='middle'>今日"
+ " </td>"
+ " <td style='width: 20%; height:20px;' align='center' valign='middle'>最后发表"
+ " </td>"
+ " <td style='width: 12%; height:20px;' align='center' valign='middle'>版主"
+ " </td>"
+ " </tr>"
+ " <tr>"
+ " <td style='width: 6%; height:30px;background-color:#F8F8F8' align='center' valign='middle'>"
+" </td>"
+ " <td style='width: 44%; height:30px;background-color:#ffffff' align='left' valign='middle' onMouseOver=\"this.className='altbg1'\" onMouseOut=\"this.className='altbg2'\">"
+ " <a href='/code/forumlist.aspx?type=" + row["type"] + "' target='_blank'>" + row["description"] + " </a>"
+ " </td>"
+ " <td style='width: 6%; height:30px;background-color:#F8F8F8' align='center' valign='middle'>" + row["total"]
+ " </td>"
+ " <td style='width: 6%; height:30px;background-color:#ffffff' align='center' valign='middle'>" + enlist_num
+ " </td>"
+ " <td style='width: 6%; height:20px;background-color:#F8F8F8' align='center' valign='middle' >" + today_num
+ " </td>"
+ " <td style='width: 20%; height:20px;background-color:#ffffff' align='center' valign='middle'>" + lastdate+" by "+lastname
+ " </td>"
+ " <td style='width: 12%; height:30px;background-color:#F8F8F8' align='center' valign='middle'>" + row["forummanage"]
+ " </td>"
+" </tr>"
+" </table>"; }
//forumlist.InnerHtml = strHtmlCode;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货