设为首页
联系我们
加入收藏
| 网络工具 | 系统工具 | 应用软件 | 多媒体类 | 联络聊天 | 行业软件 | 图形图像 | 安全相关 | 编程开发 | 教育教学 | 游戏娱乐 |
| 程序源码 | ASP 源码 | CGI 源码 | PHP 源码 | 驱动下载 | 字体下载 | 素材下载 | 桌面大全 | 闪客天地 | 外挂插件 | 考题下载 |

站内搜索:

您的位置:首页-> 资讯中心-> 技术开发-> ASP 学院-> ASP实例-> asp+的论坛列表程序---代码部分

ASP实例

ASP教程
ASP文摘
ASP实例
ASP FAQ
ASP安全
ASP组件
ASP其它

本类阅读TOP10

·一个功能完善的专栏管理的程序(二)
·ASP如何获取真实IP地址
·披著羊皮的大野狼 - Session
·用VB编写ActiveX DLL实现ASP编程
·开辟一条自由ASP快车道
·ASP编写完整的一个IP所在地搜索类
·插入Access记录后马上得到自动编号值的方法
·asp+版本简单的留言板的制作(一)
·一个简单的域名自动转向源代码
·用ASP发送邮件

精品推荐

asp+的论坛列表程序---代码部分

作者:未知 来源:未知 加入时间:2004-12-1

asp+的论坛列表程序---代码部分

--------------------------------------------------------------------------------
【bigeagle】 于 2000-11-13 15:38:57 加贴在 Joy ASP ↑:

///////////////////////////////////////////////////////////////////////////////
//
// File name: forum.cs
//
// Description: forum.aspx的后台代码
//
// date: 2000/10/13
//
// Programming: Bigeagle
//
// History: version 1.0
// start at 2000/10/13 16:45 finish
//
////////////////////////////////////////////////////////////////////////////////

using System;
using System.Collections ;
using System.Data;
using System.Data.SQL;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Drawing ;

public class Forum : Page
{

//public Image imgIfNew ;
public Label lblForumName ;
public HyperLink linkMaster ;
public Label lblForumName1 ;
public ImageButton btnPostNew ;
public ImageButton btnPostNew1 ;
public Label lblTopicCounts ;
public Label lblTopicCounts1 ;
public Label lblPerPage ;
public Label lblPosition ;
public HtmlImage imgOICQ ;
public HyperLink linkFirstPage ;
public HyperLink linkPrevPage ;
public HyperLink linkNextPage ;
public HyperLink linkLastPage ;
public HyperLink linkFirstPage1 ;
public HyperLink linkPrevPage1 ;
public HyperLink linkNextPage1 ;
public HyperLink linkLastPage1 ;
public DropDownList selChangeForum ; //转换版面下拉框

public Table tblTopic ;

public void Page_Load(Object sender , EventArgs e)
{
Int32 intForumID = new Int32();
Int32 intPageNo = new Int32() ;
int intPageSize = 20 ;
int intPageCount = 0 ;
int intTopicCounts = 0 ;


//--edit by bigeagle 2000/10/25------------------
// if (Session["LoginID"] == null )
// {
// Response.Redirect("login.aspx") ;
// }
//-----------------------------------------------

//接收论坛ID
try
{
intForumID = Request.QueryString["ID"].ToInt32() ;

}
catch(Exception exp)
{
Response.Write(exp.ToString()) ;
}

GetForumInfo(intForumID) ;

//接收页号
try
{
intPageNo = Request.QueryString["PageNo"].ToInt32() ;

}
catch(Exception exp)
{
intPageNo = 1 ;
}

//规范页号,页数
intTopicCounts = lblTopicCounts1.Text.ToInt32() ;
if (intTopicCounts <= intPageSize)
{
intPageCount = 1 ;
}
else if (intTopicCounts / intPageSize == 0)
{
intPageCount = intTopicCounts / intPageSize ;
}
else
{
intPageCount = (int)(intTopicCounts / intPageSize) + 1 ;
}

if (intPageNo < 1)
{
intPageNo = 1 ;
}
else if (intPageNo > intPageCount)
{
intPageNo = intPageCount ;
}

//初始化页面显示
lblTopicCounts.Text = intTopicCounts.ToString() ;
lblTopicCounts.ForeColor = Color.Green ;
lblPerPage.Text = intPageSize.ToString() ;
lblPerPage.ForeColor = Color.Green ;
lblPosition.Text = intPageNo.ToString() + "/" + intPageCount.ToString() ;
lblPosition.ForeColor = Color.Green ;


//更新导航栏

//首页
if (intPageNo != 1)
{
linkFirstPage.NavigateUrl = "forum.aspx?" + "ID=" + intForumID.ToString() ;
linkFirstPage.ToolTip = "回到首页" ;
linkFirstPage1.NavigateUrl = "forum.aspx?" + "ID=" + intForumID.ToString() ;
linkFirstPage1.ToolTip = "回到首页" ;
}
else
{
linkFirstPage.ToolTip = "你现在就在首页。" ;
linkFirstPage1.ToolTip = "你现在就在首页。" ;
}

//前页
if (intPageNo > 1 )
{
linkPrevPage.NavigateUrl = "forum.aspx?" + "ID=" + intForumID.ToString()
+ "&PageNo=" + (intPageNo - 1).ToString() ;
linkPrevPage.ToolTip = "回到上一页。" ;
linkPrevPage1.NavigateUrl = "forum.aspx?" + "ID=" + intForumID.ToString()
+ "&PageNo=" + (intPageNo - 1).ToString() ;
linkPrevPage1.ToolTip = "回到上一页。" ;
}
else
{
linkPrevPage.ToolTip = "你现在就位于第一页,你还想上哪儿?" ;
linkPrevPage1.ToolTip = "你现在就位于第一页,你还想上哪儿?" ;
}

//后页
if (intPageNo < intPageCount )
{
linkNextPage.NavigateUrl = "forum.aspx?" + "ID=" + intForumID.ToString()
+ "&PageNo=" + (intPageNo + 1).ToString() ;
linkNextPage.ToolTip = "到下一页。" ;
linkNextPage1.NavigateUrl = "forum.aspx?" + "ID=" + intForumID.ToString()
+ "&PageNo=" + (intPageNo + 1).ToString() ;
linkNextPage1.ToolTip = "到下一页。" ;
}
else
{
linkNextPage.ToolTip = "你现在就位于最后一页,你还想上哪
儿?" ;
linkNextPage1.ToolTip = "你现在就位于最后一页,你还想上哪
儿?" ;
}

//末页
if (intPageNo != intPageCount)
{
linkLastPage.NavigateUrl = "forum.aspx?" + "ID=" + intForumID.ToString()
+ "&PageNo=" + intPageCount.ToString() ;
linkLastPage.ToolTip = "到最后一页。" ;
linkLastPage1.NavigateUrl = "forum.aspx?" + "ID=" + intForumID.ToString()
+ "&PageNo=" + intPageCount.ToString() ;
linkLastPage1.ToolTip = "到最后一页。" ;
}
else
{
linkLastPage.ToolTip = "你现在就位于最后一页。" ;
linkLastPage1.ToolTip = "你现在就位于最后一页。" ;
}


//贴子列表
ShowTopicList(intForumID , 0 , intPageNo , intPageSize) ;

//显示转换版面下拉列表
ShowChangeForum(intForumID) ;
}

private void ShowTopicList(int a_intForumID , int a_intDays , int a_intPageNo , int a_intPageSize)
{

//读出纪录
SQLConnection myConnection = new SQLConnection("server=server1;uid=sa;pwd=;database=BBS");
SQLCommand myCommand = new SQLCommand("up_TopicsList" , myConnection);

myCommand.ActiveConnection = myConnection ;
myCommand.CommandType = CommandType.StoredProcedure;

SQLParameter workParam = null;

//论坛id
workParam = myCommand.Parameters.Add(new SQLParameter("@a_ForumID", SQLDataType.Int, 4));
workParam.Direction = ParameterDirection.Input;
workParam.Value = a_intForumID ;


//限定天数
workParam = myCommand.Parameters.Add(new SQLParameter("@a_intDays", SQLDataType.Int, 4));
workParam.Direction = ParameterDirection.Input;
workParam.Value = a_intDays ;

//页号
workParam = myCommand.Parameters.Add(new SQLParameter("@a_intPageNo", SQLDataType.Int, 4));
workParam.Direction = ParameterDirection.Input;
workParam.Value = a_intPageNo ;

//每页显示数
workParam = myCommand.Parameters.Add(new SQLParameter("@a_intPageSize", SQLDataType.Int, 4));
workParam.Direction = ParameterDirection.Input;
workParam.Value = a_intPageSize ;

SQLDataReader myReader ;

try
{
myConnection.Open();
myCommand.ute(out myReader);
//Response.Write(myReader.HasVal 橸?@@nbsp;
//取纪录
if (lblTopicCounts.Text.ToInt32() == 0) //如果没有发言
{
TableRow tr = new TableRow() ;
tr.BackColor = Color.White ;
TableCell td = new TableCell() ;
td.ColumnSpan = 6 ;
td.VerticalAlign = VerticalAlign.Middle ;
td.HorizontalAlign = HorizontalAlign.Center ;
td.Height =200 ;
td.Controls.Add(new LiteralControl("目前尚未有人发言!")) ;
tr.Cells.Add(td) ;
tblTopic.Rows.Add(tr) ;
}
else //否则,显示贴字列表
{

while (myReader.Read())
{
String strInnerHtml = "";
TableRow tr = new TableRow() ;
tr.BackColor = Color.White ;

//贴子状态图片
TableCell tdStatus = new TableCell() ;
if ((int)myReader["TotalChilds"] == 0)
{
strInnerHtml = "<img src='images/closed.gif' alt='没有新回复。'>" ;
}
else if((int)myReader["TotalChilds"] < 5)
{
strInnerHtml = "<img src='images/closedb.gif' alt='有新回复,不过不多。'>";
}
else if((int)myReader["TotalChilds"] >= 10)
{
strInnerHtml = "<img src='images/hotclosedb.gif' alt='太火了。'>";
}
else if((int)myReader["TotalChilds"] >= 5)
{
strInnerHtml = "<img src='images/hotclosed.gif' alt='回复不少。'>";
}
tdStatus.Controls.Add(new LiteralControl(strInnerHtml)) ;
tr.Cells.Add(tdStatus) ;

//表情图片
TableCell tdFace = new TableCell() ;
strInnerHtml = "<img src='images/icon"+myReader["FaceID"].ToString() +".gif'>" ;
//Response.Write(strInnerHtml) ;
tdFace.Controls.Add(new LiteralControl(strInnerHtml)) ;
tr.Cells.Add(tdFace) ;

//主题
TableCell tdTitle = new TableCell() ;
strInnerHtml = "<a href='ShowTopic.aspx?id=" + myReader["ID"].ToString() + "'>"
+ myReader["Title"].ToString() + "</a>";
tdTitle.Controls.Add(new LiteralControl(strInnerHtml)) ;
tr.Cells.Add(tdTitle) ;

//作者
TableCell tdAuthor = new TableCell() ;
strInnerHtml = myReader["UserName"].ToString() ;
tdAuthor.Controls.Add(new LiteralControl(strInnerHtml)) ;
tr.Cells.Add(tdAuthor) ;

//回复数
TableCell tdReply = new TableCell() ;
strInnerHtml = myReader["TotalChilds"].ToString() ;
tdReply.Controls.Add(new LiteralControl(strInnerHtml)) ;
tr.Cells.Add(tdReply) ;

//最后回复时间
TableCell tdReplyTime = new TableCell() ;
strInnerHtml = myReader["LastReplyTime"].ToString() ;
tdReplyTime.Controls.Add(new LiteralControl(strInnerHtml)) ;
tr.Cells.Add(tdReplyTime) ;

tblTopic.Rows.Add(tr) ;




}
}
}
catch(Exception exp)
{
Response.Write(exp.ToString() ) ;
//Response.Redirect("error.asp") ;
}
finally
{
myConnection.Close();
//Response.Redirect("default.aspx") ;
}


}

private void GetForumInfo(int a_intForumID)
{
SQLConnection myConnection = new SQLConnection("server=server1;uid=sa;pwd=;database=BBS");
SQLCommand myCommand = new SQLCommand("up_GetForum" , myConnection);

myCommand.ActiveConnection = myConnection ;
myCommand.CommandType = CommandType.StoredProcedure;

SQLParameter workParam = null;

//论坛id
workParam = myCommand.Parameters.Add(new SQLParameter("@a_ForumID", SQLDataType.Int, 4));
workParam.Direction = ParameterDirection.Input;
workParam.Value = a_intForumID ;


SQLDataReader myReader ;

try
{
myConnection.Open();
myCommand.Execute(out myReader);

myReader.Read() ;

//板块名称
lblForumName.Text = myReader["CategoryName"].ToString() ;
lblForumName.CssClass = "BigTitle" ;
lblForumName.ToolTip = myReader["Description"].ToString() ;
lblForumName1.Text = lblForumName.Text ;
lblForumName1.CssClass = "Title" ;
lblForumName1.ToolTip = myReader["Description"].ToString() ;

//贴子数
lblTopicCounts1.Text = myReader["NewTopicNumber"].ToString() ;
lblTopicCounts1.ToolTip = "当前贴子数:" + lblTopicCounts1.Text ;


//oicq
if (myReader["OICQ"].ToString() != "")
{
imgOICQ.Src = "http://infocenter.tencent.com/" + myReader["OICQ"].ToString() + "/s/00/99" ;
imgOICQ.Alt = "OICQ:" + myReader["OICQ"].ToString() ;
//imgOICQ.Src = "images/off.gif" ;
}
else
{
imgOICQ.Src = "" ;
imgOICQ.Alt = "没留OICQ。" ;
}

//版主
linkMaster.Text = myReader["UserName"].ToString() ;
linkMaster.NavigateUrl = (myReader["Email"].ToString() == "" ? "" :
"MailTo:" + myReader["Email"].ToString()) ;
linkMaster.ToolTip = (myReader["Email"].ToString() == "" ? "版主没留Email," :"写信给版主,");

}
catch(Exception exp)
{
Response.Write(exp.ToString()) ;
//Response.Redirect("error.asp") ;
}
finally
{
myConnection.Close();
//Response.Redirect("default.aspx") ;
}

}

//显示转换版面下拉列表
private void ShowChangeForum(int a_intForumID)
{
selChangeForum.Width = 200 ;

}
}

(出处:不详 )





相关文章
相关软件