?? myzhuti.aspx.cs
字號(hào):
//===========================================================================
// 此文件是作為 ASP.NET 2.0 Web 項(xiàng)目轉(zhuǎn)換的一部分修改的。
// 類名已更改,且類已修改為從文件“App_Code\Migrated\Stub_myzhuti_aspx_cs.cs”的抽象基類
// 繼承。
// 在運(yùn)行時(shí),此項(xiàng)允許您的 Web 應(yīng)用程序中的其他類使用該抽象基類綁定和訪問
// 代碼隱藏頁(yè)。
// 關(guān)聯(lián)的內(nèi)容頁(yè)“myzhuti.aspx”也已修改,以引用新的類名。
// 有關(guān)此代碼模式的更多信息,請(qǐng)參考 http://go.microsoft.com/fwlink/?LinkId=46995
//===========================================================================
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace free.bbs
{
/// <summary>
/// Summary description for myzhuti.
/// </summary>
public partial class Migrated_myzhuti : myzhuti
{
protected const int Record_Per_Page=40; //'定義每一頁(yè)顯示的記錄數(shù)
protected int nRecCount ; //保存記錄總數(shù)
protected int nPageCount; //保存總共的數(shù)據(jù)頁(yè)面數(shù)目
protected int nPage; //存放要瀏覽當(dāng)前數(shù)據(jù)頁(yè)面號(hào)
protected int nStart ; // 存放當(dāng)前頁(yè)面的起始記錄序號(hào)
protected int nEnd; //存放當(dāng)前頁(yè)面的終止記錄序號(hào)
protected int nPageEnd; //存儲(chǔ)當(dāng)前頁(yè)面的最后一面的序號(hào)
protected System.Data.SqlClient.SqlConnection myconn;
protected System.Data.SqlClient.SqlCommand mycomm;
protected System.Data.SqlClient.SqlDataReader reader;
protected System.Data.SqlClient.SqlDataAdapter mydda;
HtmlTableRow myrow;
HtmlTableCell mycell;
string h_yonghuming,h_shijian;
protected void Page_Load(object sender, System.EventArgs e)
{
try
{
string yonghuming=Request.Cookies["free_huiyuan"].Value.ToString();
if(yonghuming=="dengchu")
{
Response.Redirect("error.aspx");
}
}
catch
{
Response.Redirect("error.aspx");
}
myconn=new SqlConnection(Session["str_connection"].ToString());
string sqlselect="SELECT islock,isceam, isfix, zhuti, yonghuming, postid, neirong, shijian,ancestor_id FROM posts WHERE (yonghuming ='"+Request.Cookies["free_huiyuan"].Value.ToString()+"') ORDER BY isfix desc ,postid desc";
mydda=new SqlDataAdapter(sqlselect,myconn);
myconn.Open();
DataSet ds=new DataSet();
mydda.Fill(ds,"myzhuti");
nPage = Convert.ToInt32 ( Request.Params[ "Page"] );//得到當(dāng)前頁(yè)號(hào)
try
{
nRecCount=ds.Tables["myzhuti"].Rows.Count;//得到數(shù)據(jù)記錄總數(shù)
}
catch
{
nRecCount = 0;
}
if (nRecCount > 0)
// 確定數(shù)據(jù)記錄要顯示的頁(yè)面數(shù)
nPageCount = nRecCount/Record_Per_Page;
if (nRecCount%Record_Per_Page> 0 )
nPageCount += 1;
//確認(rèn)瀏覽命令中的頁(yè)面參數(shù)是否越界,如果越界則重置頁(yè)面序號(hào)
if( nPage<1 )nPage = 1 ;
if ( nPage > nPageCount) nPage = nPageCount ;
//確認(rèn)當(dāng)前頁(yè)面的開始記錄和終止記錄
nStart = Record_Per_Page * ( nPage - 1 );
nEnd = nStart + Record_Per_Page - 1;
if (nEnd > nRecCount - 1 ) nEnd = nRecCount - 1;
//////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
if(ds.Tables["myzhuti"].Rows.Count>0)
{
for (int i=nStart;i<=nEnd;i++)
{
myrow=new HtmlTableRow();
mycell=new HtmlTableCell();
mycell.Align="center";
mycell.Height="25px";
string addcell=null;
if(int.Parse(ds.Tables["myzhuti"].Rows[i]["islock"].ToString())==1)
addcell="<TD class='tablebody1'Align='center' height='20'><IMG align='absmiddle' alt='鎖定主題' src='./images/lockfolder.gif'></td>";
else if(int.Parse(ds.Tables["myzhuti"].Rows[i]["isceam"].ToString())==1)
addcell="<TD class='tablebody1'Align='center' height='20'><IMG align='absmiddle' alt='回復(fù)數(shù)超過1000的主題' src='./images/hotfolder.gif'></td>";
else if(int.Parse(ds.Tables["myzhuti"].Rows[i]["isceam"].ToString())==2)
addcell="<TD class='tablebody1'Align='center' height='20'><IMG align='absmiddle' alt='精華帖子' src='./images/isbest.gif'></td>";
else if(int.Parse(ds.Tables["myzhuti"].Rows[i]["isceam"].ToString())==3)
addcell="<TD class='tablebody1'Align='center' height='20'><IMG align='absmiddle' alt='投票帖子' src='./images/closedb.gif'></td>";
else if(int.Parse(ds.Tables["myzhuti"].Rows[i]["isfix"].ToString())==1)
addcell="<TD class='tablebody1'Align='center' height='20'><IMG align='absmiddle' alt='固頂主題' src='./images/istop.gif'></td>";
else if(int.Parse(ds.Tables["myzhuti"].Rows[i]["isfix"].ToString())==2)
addcell="<TD class='tablebody1'Align='center' height='20'><IMG align='absmiddle' alt='總固頂主題' src='./images/ztop.gif'></td>";
else
addcell="<TD class='tablebody1'Align='center' height='20'><IMG align='absmiddle'alt='開放主題' src='./images/folder.gif'></td>";
////////////////////////////////////////////////////////////////////////////////
addcell=addcell+"<TD class='tablebody2' height='20'><IMG runat='sever' style='CURSOR: hand' src='./images/plus.gif'>"+
"<A BgColor='#ffffff ' href='huifu.aspx?post_id="+int.Parse(ds.Tables["myzhuti"].Rows[i]["postid"].ToString())+"&ancestor_id="+ds.Tables["myzhuti"].Rows[i]["ancestor_id"]+"&Page=1'><font face='宋體'>"+ds.Tables["myzhuti"].Rows[i]["zhuti"].ToString()+"</font></A></td>";
addcell=addcell+"<TD class='tablebody1'Align='center' height='20'>"+ds.Tables["myzhuti"].Rows[i]["yonghuming"].ToString()+"</td>";
//
sqlselect="SELECT count(*)as huifushu FROM huifu where post_id="+int.Parse(ds.Tables["myzhuti"].Rows[i]["postid"].ToString())+" ";
mydda= new System.Data.SqlClient.SqlDataAdapter(sqlselect,myconn);
DataTable mytable=new DataTable();
mydda.Fill(mytable);
mytable.TableName="huifushu";
addcell=addcell+"<TD Align='center' class='tablebody2' height='20'>"+mytable.Rows[0]["huifushu"]+"</td>";
///////////////////////////////////////////////////////////////////////////////////
sqlselect="SELECT top 1 yonghuming, shijian FROM huifu where post_id="+int.Parse(ds.Tables["myzhuti"].Rows[i]["postid"].ToString())+" order by huifu_id desc";
mydda= new System.Data.SqlClient.SqlDataAdapter(sqlselect,myconn);
DataTable mytable1=new DataTable();
mydda.Fill(mytable1);
mytable1.TableName="huifu";
try
{
h_yonghuming=mytable1.Rows[0]["yonghuming"].ToString();
h_shijian=mytable1.Rows[0]["shijian"].ToString();
}
catch
{
h_yonghuming=null;
h_shijian=null;
}
addcell=addcell+"<TD class='tablebody1'Align='center' height='20'><A Align='center'>"+h_shijian+"</A>"+
" <FONT color='#ff0000'>|</FONT> <A Align='center' href='hyziliaochakan.aspx?UserId="+h_yonghuming+"' target'_blank'>"+h_yonghuming+"</A></td>";
mycell.Controls.Add(new LiteralControl (""+addcell+""));
myrow.Cells.Add(mycell);
table_1.Rows.Add(myrow);
}
}
else
{
myrow=new HtmlTableRow();
mycell=new HtmlTableCell();
mycell.Align="center";
mycell.Height="25px";
//mycell.Visible=false;
mycell.Controls.Add(new LiteralControl ("<TD class='tablebody1' ColSpan=5 Align='center' height='20'>您還未發(fā)表主題</td>"));
myrow.Cells.Add(mycell);
table_1.Rows.Add(myrow);
}
/////////////////////////////////
Session["npage"]=nPage;
Session["nPageCount"]=nPageCount;
Session["Record_Per_Page"]=Record_Per_Page;
Session["nRecCount"]=nRecCount;
string daohang2;
string daohang3;
daohang2=" <A href='myzhuti.aspx?name="+Request.Cookies["free_huiyuan"].Value.ToString()+" Page="+(nPage-1)+"'><FONT color='#0000ff'>上一頁(yè)</FONT> </A>";
daohang3=" <A href='myzhuti.aspx?name="+Request.Cookies["free_huiyuan"].Value.ToString()+" Page="+(nPage+1)+"'><FONT color='#0000ff'>下一頁(yè)</FONT></A> ";
if( nPage==1 || nPage==0)
{
daohang2="上一頁(yè)";
}
if(nPage==nPageCount)
{
daohang3=" 下一頁(yè)";
}
Session["fenye"]=daohang2+daohang3;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -