Asp + Forum list program --- Code Section

Source: Internet
Author: User

Asp + Forum list program --- Code Section

--------------------------------------------------------------------------------
[Bigeagle] is added to Joy ASP repository at 15:38:57, January 13:

//////////////////////////////////////// ///////////////////////////////////////
//
// File name: forum. cs
//
// Description: Background code of 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; // switch the layout drop-down list

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 ");
//}
//-----------------------------------------------

// Receives the Forum ID
Try
{
IntForumID = Request. QueryString ["ID"]. ToInt32 ();

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

GetForumInfo (intForumID );

// Receive page number
Try
{
IntPageNo = Request. QueryString ["PageNo"]. ToInt32 ();

}
Catch (Exception exp)
{
IntPageNo = 1;
}

// Standard page number, page number
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;
}

// Display the initialization page
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;


// Update the navigation bar

// Homepage
If (intPageNo! = 1)
{
LinkFirstPage. NavigateUrl = "forum. aspx? "+" ID = "+ intForumID. ToString ();
LinkFirstPage. ToolTip = "back to homepage ";
LinkFirstPage1.NavigateUrl = "forum. aspx? "+" ID = "+ intForumID. ToString ();
LinkFirstPage1.ToolTip = "back to homepage ";
}
Else
{
LinkFirstPage. ToolTip = "you are now on the homepage. ";
LinkFirstPage1.ToolTip = "you are now on the homepage. ";
}

// Previous Page
If (intPageNo> 1)
{
LinkPrevPage. NavigateUrl = "forum. aspx? "+" ID = "+ intForumID. ToString ()
+ "& PageNo =" + (intPageNo-1). ToString ();
LinkPrevPage. ToolTip = "back to the previous page. ";
LinkPrevPage1.NavigateUrl = "forum. aspx? "+" ID = "+ intForumID. ToString ()
+ "& PageNo =" + (intPageNo-1). ToString ();
LinkPrevPage1.ToolTip = "return to the previous page. ";
}
Else
{
LinkPrevPage. ToolTip = "you are now on the first page. Where do you want to go? ";
LinkPrevPage1.ToolTip = "you are now on the first page. Where do you want to go? ";
}

// Back page
If (intPageNo <intPageCount)
{
LinkNextPage. NavigateUrl = "forum. aspx? "+" ID = "+ intForumID. ToString ()
+ "& PageNo =" + (intPageNo + 1). ToString ();
LinkNextPage. ToolTip = "to the next page. ";
LinkNextPage1.NavigateUrl = "forum. aspx? "+" ID = "+ intForumID. ToString ()
+ "& PageNo =" + (intPageNo + 1). ToString ();
LinkNextPage1.ToolTip = "to the next page. ";
}
Else
{
LinkNextPage. ToolTip = "you are now on the last page.
? ";
LinkNextPage1.ToolTip = "you are now on the last page.
? ";
}

// Last page
If (intPageNo! = IntPageCount)
{
LinkLastPage. NavigateUrl = "forum. aspx? "+" ID = "+ intForumID. ToString ()
+ "& PageNo =" + intPageCount. ToString ();
LinkLastPage. ToolTip = "to the last page. ";
LinkLastPage1.NavigateUrl = "forum. aspx? "+" ID = "+ intForumID. ToString ()
+ "& PageNo =" + intPageCount. ToString ();
LinkLastPage1.ToolTip = "to the last page. ";
}
Else
{
LinkLastPage. ToolTip = "you are now on the last page. ";
LinkLastPage1.ToolTip = "you are now on the last page. ";
}


// Subscriber list
ShowTopicList (intForumID, 0, intPageNo, intPageSize );

// Display the conversion layout drop-down list
ShowChangeForum (intForumID );
}

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

// Read the record
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;

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


// Specify the number of days
WorkParam = myCommand. Parameters. Add (new SQLParameter ("@ a_intDays", SQLDataType. Int, 4 ));
WorkParam. Direction = ParameterDirection. Input;
WorkParam. Value = a_intDays;

// Page number
WorkParam = myCommand. Parameters. Add (new SQLParameter ("@ a_intPageNo", SQLDataType. Int, 4 ));
WorkParam. Direction = ParameterDirection. Input;
WorkParam. Value = a_intPageNo;

// Number of entries displayed on each page
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. Execute (out myReader );
// Response. Write (myReader. HasValue. ToString ());

// Obtain the record
If (lblTopicCounts. Text. ToInt32 () = 0) // if no
{
TableRow tr = new TableRow ();
Tr. BackColor = Color. White;
TableCell td = new TableCell ();
Td. ColumnSpan = 6;
Td. VerticalAlign = VerticalAlign. Middle;
Td. HorizontalAlign = HorizontalAlign. Center;
Td. width = 200;
Td. Controls. Add (new LiteralControl ("no one has spoken yet! "));
Tr. Cells. Add (td );
TblTopic. Rows. Add (tr );
}
Else // otherwise, the post list is displayed
{

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

// Post a status Image
TableCell tdStatus = new TableCell ();
If (int) myReader ["TotalChilds"] = 0)
{
StrInnerHtml = " ";
}
Else if (int) myReader ["TotalChilds"] <5)
{
StrInnerHtml = " ";
}
Else if (int) myReader ["TotalChilds"]> = 10)
{
StrInnerHtml = " ";
}
Else if (int) myReader ["TotalChilds"]> = 5)
{
StrInnerHtml = " ";
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.