forums_main_topic_display.aspx.cs
来自「ASP.NET的一些开发实例,有论坛管理系统等」· CS 代码 · 共 719 行 · 第 1/2 页
CS
719 行
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 WhiteForum.forums
{
/// <summary>
/// forums_main_topic_display 的摘要说明。
/// </summary>
public class forums_main_topic_display : BDStudioBase.FormBase
{
protected System.Web.UI.WebControls.Panel PL1;
protected System.Web.UI.WebControls.Label Label12;
protected System.Web.UI.WebControls.Label LbTitle;
protected System.Web.UI.WebControls.Table TB;
protected System.Web.UI.WebControls.Label labPage1;
protected System.Web.UI.WebControls.ImageButton ImageButton1;
protected System.Web.UI.WebControls.ImageButton ImageButton2;
protected System.Web.UI.WebControls.ImageButton ImageButton11;
protected System.Web.UI.WebControls.ImageButton ImageButton12;
protected System.Web.UI.WebControls.ImageButton ImageButton14;
protected System.Web.UI.WebControls.LinkButton LinkButton2;
protected System.Web.UI.WebControls.ImageButton ImageButton15;
protected System.Web.UI.WebControls.ImageButton ImageButton4;
protected System.Web.UI.WebControls.LinkButton LinkButton1;
protected System.Web.UI.WebControls.Image Image1;
protected System.Web.UI.WebControls.LinkButton linkbPrev1;
protected System.Web.UI.WebControls.LinkButton linkbNext1;
protected System.Web.UI.WebControls.LinkButton linkbJump1;
protected System.Web.UI.WebControls.TextBox txtPageNum1;
protected System.Web.UI.WebControls.Label labPage2;
protected System.Web.UI.WebControls.DataGrid dbGridMain1;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.Label labCurrentRow;
protected System.Web.UI.HtmlControls.HtmlAnchor other;//
string m_num="49";
protected COM_ForumTopics COM_ForumTopics=new COM_ForumTopics();
COM_ForumReply COM_ForumReply=new COM_ForumReply();
COM_ForumTopicsStow COM_ForumTopicsStow=new COM_ForumTopicsStow();
public string topicID="";
public string type="";
string forumID="";
DataSet ds;
string sReturn=string.Empty;
DataSet dsReplyData=new DataSet();
DataRow drReply;
DataTable dtReplyData=new DataTable();
private string sReceiveId="";//
private string[] arr_ReceiveId;//
// private int i_RowCount=0;
private int i_CurrentRow=0;
private string topicAuthor="";
private void Page_Load(object sender, System.EventArgs e)
{
this.o_str_FormUrl="forums_main_topic.aspx";
this.o_str_FormName="forums_main_topic";
this.o_str_InputFile1="forums_main_topic_input2.aspx";
this.o_str_InputFile2="forums_main_topic_input1.aspx";
this.o_str_InputFile3="forums_main_topic_edit.aspx";
// 在此处放置用户代码以初始化页面
sReceiveId=(string)Session["sSendId"];//
topicID=Request.QueryString["as_pk"];
type=Request.QueryString["type"];
Label12.Text=DateTime.Now.ToShortDateString();
if(this.sReceiveId!="W") //
{
arr_ReceiveId=this.sReceiveId.Split(new char[]{','});
// i_RowCount=arr_ReceiveId.Length;
} //
if(type=="favorite")
{
this.LinkButton2.Visible=false;
}
if(type=="primeArea")
{
this.LinkButton1.Visible=false;
}
if(type=="search")
{
this.ImageButton1.Visible=false;
}
if(type=="must")
{
this.ImageButton1.Visible=false;
}
TableInit();
if(dtReplyData.Columns.Count==0)
{
dtReplyData.Columns.Add(new DataColumn("r_author",typeof(string)));
dtReplyData.Columns.Add(new DataColumn("r_message",typeof(string)));
dtReplyData.Columns.Add(new DataColumn("r_date",typeof(string)));
dtReplyData.Columns.Add(new DataColumn("r_ip",typeof(string)));
}
if(!Page.IsPostBack)
{
Session["PageNum1"]=0;
Session["dv1"]=null;
if(this.sReceiveId!="W")//
{
i_CurrentRow=this.COMGfunction.GetNumFromArray(topicID,arr_ReceiveId)+1;
this.labCurrentRow.Text=i_CurrentRow.ToString();
}//
if((string)Session["Search"]!="1")
{
this.COM_ForumTopics.EditViewEmp(topicID,Session["userid"].ToString());
this.COM_ForumTopics.EditViewCount(topicID,Session["userid"].ToString());
this.COM_ForumReply.EditViewEmp(topicID,Session["userid"].ToString());
Session["Search"]="1";
}
this.o_ds_FormData=this.COM_ForumReply.DsMainFieldListForAll(m_num,"dbGridMain1",topicID);
this.dbGridMain1.DataSource=o_ds_FormData;
this.dbGridMain1.DataBind();
this.DataRead(this.o_ds_FormData,"dv1");
}
this.FormInit();
if(dtReplyData.Columns.Count>0)
{
dsReplyData.Tables.Add(dtReplyData);
this.TableInit1(dsReplyData);
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ImageButton4.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton4_Click);
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
this.LinkButton2.Click += new System.EventHandler(this.LinkButton2_Click);
this.ImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);
this.ImageButton2.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton2_Click);
this.ImageButton15.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton15_Click);
this.ImageButton11.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton11_Click);
this.ImageButton14.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton14_Click);
this.dbGridMain1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dbGridMain1_ItemDataBound);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void StrReplace(ref string strTopicNote)
{
// MyConn.Open();
// string sql="select * from face_image";
// SqlCommand Comm=new SqlCommand(sql,MyConn);
// SqlDataReader myReader;
// myReader=Comm.ExecuteReader();
// while(myReader.Read())
// {
// strTopicNote=strTopicNote.Replace(myReader["tag_value"].ToString(),myReader["tag_url"].ToString());
// }
// myReader.Close();
// MyConn.Close();
string SqlString="select * from face_image";
DataSet dsFace=this.COMInterface.CreateDataSetFromSql(SqlString);
foreach(DataRow row in dsFace.Tables[0].Rows)
{
strTopicNote=strTopicNote.Replace(row["tag_value"].ToString(),row["tag_url"].ToString());
}
}
private void TableInit()
{
TableRow tRow;
TableCell tCell;
string[] strFieldName={m_num,"dbGridMain1","topic_id"};
string[] strFieldValue = {topicID};
ds=this.COM_ForumTopics.GetTopics(strFieldName,strFieldValue,Session["userid"].ToString());
if(ds.Tables[0].Rows.Count==0)
{
return;
}
forumID=ds.Tables[0].Rows[0]["forum_id"].ToString();
DataSet Myds=this.COMInterface.CreateDataSetFromSql("select t_author from forum_topics where topic_id="+topicID.ToString());
topicAuthor=Myds.Tables[0].Rows[0]["t_author"].ToString();
if(ds.Tables[0].Rows[0]["t_level"].ToString()=="03")
{
this.other.Visible=false;
}
Session["p_table"]=ds.Tables[0].Rows[0]["t_place"].ToString();
if(Session["p_table"].ToString()=="02")
{
this.LinkButton1.Visible=false;
}
this.LbTitle.Text=ds.Tables[0].Rows[0]["t_subject"].ToString();
if(ds.Tables.Count>0)
{
for(int j=0;j<=1;j++)
{
tRow=new TableRow();
if(j==0)
{
tCell=new TableCell();
tCell.RowSpan=2;
tCell.Width=new Unit(50);
tCell.Text="<br> "+"发表人:"+"<br> "+ds.Tables[0].Rows[0]["t_author"].ToString().Replace("\n","<br> ");
//topicAuthor=tCell.Text;
tRow.Cells.Add(tCell);
tCell=new TableCell();
string str="<br> "+ds.Tables[0].Rows[0]["t_message"].ToString().Replace("\n","<br> ");
StrReplace(ref str);
tCell.Text=str;
tRow.Cells.Add(tCell);
this.TB.Rows.Add(tRow);
}
if(j==1)
{
tCell=new TableCell();
System.Web.UI.WebControls.Image IM1=new System.Web.UI.WebControls.Image();
IM1.ImageUrl="../images/posttime.gif";
tCell.Controls.Add(IM1);
System.Web.UI.WebControls.Label LB1=new System.Web.UI.WebControls.Label();
LB1.Text=ds.Tables[0].Rows[0]["t_date"].ToString();
tCell.Controls.Add(LB1);
System.Web.UI.WebControls.Image IM2=new System.Web.UI.WebControls.Image();
IM2.ImageUrl="../images/ip.gif";
tCell.Controls.Add(IM2);
System.Web.UI.WebControls.Label LB2=new System.Web.UI.WebControls.Label();
LB2.Text=ds.Tables[0].Rows[0]["t_ip"].ToString();
tCell.Controls.Add(LB2);
System.Web.UI.WebControls.ImageButton IM9=new System.Web.UI.WebControls.ImageButton();
IM9.ImageUrl="../images/fav.gif";
IM9.Click +=new System.Web.UI.ImageClickEventHandler(this.IM_Click);
IM9.ID="IM9";
tCell.Controls.Add(IM9);
System.Web.UI.WebControls.Label LB9=new System.Web.UI.WebControls.Label();
LB9.Text="修改";
LB9.ID="LB9";
tCell.Controls.Add(LB9);
System.Web.UI.WebControls.ImageButton IM10=new System.Web.UI.WebControls.ImageButton();
IM10.Attributes.Add("onClick", "return confirm('您确实删除这篇文章吗?');");
IM10.CommandName="delete";
IM10.Command+=new System.Web.UI.WebControls.CommandEventHandler(this.IM1_Command);
IM10.ImageUrl="../images/face8.gif";
IM10.ID="IM10";
tCell.Controls.Add(IM10);
System.Web.UI.WebControls.Label LB10=new System.Web.UI.WebControls.Label();
LB10.Text="删除";
LB10.ID="LB10";
tCell.Controls.Add(LB10);
tRow.Cells.Add(tCell);
this.TB.Rows.Add(tRow);
}
}
}
ButtonInit();
}
private void TableInit1(DataSet dsData)
{
TableRow tRow1;
TableCell tCell;
int i=0;
foreach(DataRow row in dsData.Tables[0].Rows)
{
if(i+1>this.dbGridMain1.Items.Count)
{
break;
}
for(int j=0;j<=1;j++)
{
tRow1=new TableRow();
if(i%2==0 || i==0)
{
if(j==0)
{
tCell=new TableCell();
tCell.RowSpan=2;
tCell.CssClass="down_line";
tCell.Width=new Unit(50);
tCell.Text="<br> "+"回复人:"+"<br> "+row["r_author"].ToString().Replace("\n","<br> ");
tRow1.Cells.Add(tCell);
tCell=new TableCell();
tCell.CssClass="down_line";
string str="<br> "+row["r_message"].ToString().Replace("\n","<br> ");
StrReplace(ref str);
tCell.Text=str;
tRow1.Cells.Add(tCell);
this.TB.Rows.Add(tRow1);
}
if(j==1)
{
tCell=new TableCell();
tCell.CssClass="down_line";
System.Web.UI.WebControls.Image IM3=new System.Web.UI.WebControls.Image();
IM3.ImageUrl="../images/posttime.gif";
tCell.Controls.Add(IM3);
System.Web.UI.WebControls.Label LB3=new System.Web.UI.WebControls.Label();
LB3.Text=row["r_date"].ToString();
tCell.Controls.Add(LB3);
System.Web.UI.WebControls.Image IM4=new System.Web.UI.WebControls.Image();
IM4.ImageUrl="../images/ip.gif";
tCell.Controls.Add(IM4);
System.Web.UI.WebControls.Label LB4=new System.Web.UI.WebControls.Label();
LB4.Text=row["r_ip"].ToString();
tCell.Controls.Add(LB4);
tRow1.Cells.Add(tCell);
this.TB.Rows.Add(tRow1);
}
}
else
{
if(j==0)
{
tCell=new TableCell();
tCell.RowSpan=2;
tCell.Width=new Unit(50);
tCell.Text="<br> "+"回复人:"+"<br> "+row["r_author"].ToString().Replace("\n","<br> ");
tRow1.Cells.Add(tCell);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?