国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

asp+的論壇列表程序---代碼部分

2019-11-18 21:53:59
字體:
來源:轉載
供稿:網友
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.Execute(out myReader);
          //Response.Write(myReader.HasValue.ToString());
          
          //取紀錄
          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 ;
     
   }  
}   


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 灌南县| 抚松县| 英吉沙县| 琼结县| 华亭县| 蓝山县| 新营市| 鹤山市| 台中县| 洪雅县| 临西县| 定陶县| 大埔县| 航空| 东乌珠穆沁旗| 建水县| 峨边| 柳林县| 阜新市| 新巴尔虎右旗| 驻马店市| 南雄市| 西藏| 碌曲县| 英吉沙县| 绿春县| 保靖县| 金门县| 景宁| 巴彦淖尔市| 文安县| 普宁市| 乐至县| 赣州市| 霍山县| 古交市| 石柱| 德保县| 洪泽县| 神农架林区| 牡丹江市|