forums_main_public.aspx.cs
来自「ASP.NET的一些开发实例,有论坛管理系统等」· CS 代码 · 共 346 行
CS
346 行
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;
namespace WhiteForum.forums
{
/// <summary>
/// forums_main_public 的摘要说明。
/// </summary>
public class forums_main_public : BDStudioBase.FormBase
{
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Label Label7;
protected System.Web.UI.WebControls.Label Label9;
protected System.Web.UI.WebControls.Panel PL1;
protected System.Web.UI.WebControls.Label Label10;
protected System.Web.UI.WebControls.Label Label11;
protected System.Web.UI.WebControls.Label Label12;
protected System.Web.UI.WebControls.Label Label14;
protected System.Web.UI.WebControls.HyperLink HyperLink14;
protected System.Web.UI.WebControls.Table Table2;
protected System.Web.UI.WebControls.Label L_people;
protected System.Web.UI.WebControls.Label L_topics;
string m_num="46";
private COM_ForumCategory COM_ForumCategory=new COM_ForumCategory();
string m_num1="79";
private COM_ForumForum COM_ForumForum=new COM_ForumForum();
int topic_count=0;
private COM_SystemAccount COM_SystemAccount=new COM_SystemAccount();
protected System.Web.UI.WebControls.Panel Panel1;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private COM_ForumTopics COM_ForumTopics=new COM_ForumTopics();
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
string[] str_FieldValue={};
DataSet n_ds=this.COM_SystemAccount.DsMainListForAll(str_FieldValue);
this.L_people.Text=n_ds.Tables[0].Rows.Count.ToString();
o_str_Pk1="forum_id";
TableInit();
Label12.Text=DateTime.Now.ToShortDateString();
//取论坛状态数据
DataSet dsStatus=this.COM_ForumTopics.DsForumStatus((string)Session["userid"]);
this.DataGrid1.DataSource=dsStatus;
this.DataGrid1.DataBind();
foreach(DataRow row in dsStatus.Tables[0].Rows)
{
if(row["status"].ToString()!="W")
{
System.Web.UI.HtmlControls.HtmlImage IMG= new System.Web.UI.HtmlControls.HtmlImage();
IMG.Src="../images/icon_folder_new.gif";
IMG.ID="IMG";
IMG.Width=16;
IMG.Height=16;
this.Panel1.Controls.Add(IMG);
System.Web.UI.WebControls.HyperLink hlk=new System.Web.UI.WebControls.HyperLink();
hlk.Text=row["status"].ToString();
hlk.CssClass="txt_box1";
hlk.NavigateUrl=row["url"].ToString();
this.Panel1.Controls.Add(hlk);
System.Web.UI.WebControls.Label lab=new System.Web.UI.WebControls.Label();
lab.Text="<br>";
this.Panel1.Controls.Add(lab);
}
}
}
#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.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private DataSet ForumVisibleInit(DataSet DsForum)
{
DataSet DsVisible=DsForum.Copy();
int j=0;
int k=0;
foreach (DataRow dr in DsForum.Tables[0].Rows)
{
bool isAuthorization=false;
string enableDepartment=dr["dep_res"].ToString();
string enableSchema=dr["sche_res"].ToString();
DataSet DsCurrentAccount=this.COMInterface.CreateDataSetFromSql("select dep_num,schema_num from system_account where acc_name='"+Session["userid"].ToString()+"'");
string attachDepartment=DsCurrentAccount.Tables[0].Rows[0]["dep_num"].ToString();
string attachSchema=DsCurrentAccount.Tables[0].Rows[0]["schema_num"].ToString();
string[] perDep=attachDepartment.Split(new char[]{','});
string[] perSch=attachSchema.Split(new char[]{','});
for(int i=0;i<(perDep.Length);i++)
{
if(enableDepartment.IndexOf(perDep[i])>-1)
{
isAuthorization=true;
break;
}
}
for(int i=0;i<(perSch.Length);i++)
{
if(enableSchema.IndexOf(perSch[i])>-1)
{
isAuthorization=true;
break;
}
}
if(isAuthorization==false)
{
//DsVisible.Tables[0].Rows.Remove(dr);
DsVisible.Tables[0].Rows.RemoveAt(k);
k--;
}
j++;
k++;
}
return DsVisible;
}
private void TableInit()
{
Table Tb;
TableRow tRow;
TableRow tRow1;
TableRow tRow2;
TableCell tCell;
string[] strFieldValue = {m_num,"dbGridMain1"};
DataSet ds=this.COM_ForumCategory.DsMainListForAll(strFieldValue);
this.DataGrid1.DataSource=ds;
this.DataBind();
if(ds.Tables.Count>0)
{
foreach(DataRow row in ds.Tables[0].Rows)
{
string[] strFieldValue1 = {m_num1,"dbGridMain2",row[0].ToString()};
DataSet ds1 = ForumVisibleInit(this.COM_ForumForum.DsMainListForAll(strFieldValue1));
if(ds1.Tables[0].Rows.Count>0)
{
Tb=new Table();
// Tb.CssClass="dbtable_title";
Tb.CellPadding=0;
Tb.CellSpacing=0;
//Tb.Width=new Unit(950);
tRow=new TableRow();
tRow.Height=25;
// tRow.Width=new Unit(950);
tCell=new TableCell();
tCell.Width=new Unit(15);
System.Web.UI.HtmlControls.HtmlImage IMG= new System.Web.UI.HtmlControls.HtmlImage();
IMG.Src="../images/tb_left.gif";
IMG.ID="IMG";
IMG.Width=40;
IMG.Height=25;
tCell.Controls.Add(IMG);
tRow.Cells.Add(tCell);
tCell=new TableCell();
tCell.ColumnSpan=2;
System.Web.UI.HtmlControls.HtmlImage IMG1= new System.Web.UI.HtmlControls.HtmlImage();
IMG1.Src="../images/tb_bg.gif";
IMG1.ID="IMG1";
IMG1.Width =720;
IMG1.Height=25;
tCell.Controls.Add(IMG1);
tRow.Cells.Add(tCell);
tCell=new TableCell();
System.Web.UI.HtmlControls.HtmlImage IMG2= new System.Web.UI.HtmlControls.HtmlImage();
IMG2.Src="../images/tb_right.gif";
IMG2.ID="IMG2";
IMG2.Width=185;
IMG2.Height=25;
tCell.Controls.Add(IMG2);
tRow.Cells.Add(tCell);
Tb.Rows.Add(tRow);
// string[] strFieldValue1 = {m_num1,"dbGridMain2",row[0].ToString()};
// DataSet ds1 = ForumVisibleInit(this.COM_ForumForum.DsMainListForAll(strFieldValue1));
foreach(DataRow row1 in ds1.Tables[0].Rows)
{
if(row1["f_topic_count"].ToString().Trim()!=string.Empty && row1["f_topic_count"]!=null)
{
topic_count+=(int)row1["f_topic_count"];
}
else
{
row1["f_topic_count"]=0;
}
for(int j=0;j<=2;j++)
{
tRow1=new TableRow();
if(j==0)
{
DataSet dsView = this.COMInterface.CreateDataSetFromSql("select * from forum_topics where forum_id='"+row1["forum_id"].ToString()+"'");
DataSet ds_new=this.COM_ForumTopics.DsView(ref dsView ,Session["userid"].ToString());
tCell=new TableCell();
tCell.RowSpan=3;
System.Web.UI.HtmlControls.HtmlImage pIMG= new System.Web.UI.HtmlControls.HtmlImage();
pIMG.Src="../images/forum_nnews.gif";
foreach(DataRow row2 in ds_new.Tables[0].Rows)
{
if(row2["view"].ToString()=="0")
{
pIMG.Src="../images/forum_news.gif";
break;
}
}
pIMG.ID="pIMG";
tCell.Controls.Add(pIMG);
tRow1.Cells.Add(tCell);
tCell=new TableCell();
tCell.ColumnSpan=2;
tCell.CssClass="txt_box3";
System.Web.UI.WebControls.HyperLink HPL=new System.Web.UI.WebControls.HyperLink();
HPL.Text=row1["f_subject"].ToString();
HPL.NavigateUrl="../forums/forums_main_topic.aspx?as_pk="+row1["forum_id"].ToString()+"&type=public"+"&saveValidity="+row1["save_validity"].ToString()+"&deleteTime="+row1["delete_time"].ToString();
// HPL.CssClass="txt_box3";
HPL.ID="HPL";
tCell.Controls.Add(HPL);
tRow1.Cells.Add(tCell);
Tb.Rows.Add(tRow1);
tCell=new TableCell();
// tCell.Text=row1[].ToString().Replace("\n","<br> ");
tRow1.Cells.Add(tCell);
Tb.Rows.Add(tRow1);
}
if(j==1)
{
tRow1.Height=10;
tCell=new TableCell();
tCell.ColumnSpan=2;
tCell.Text="<br>"+row1["f_description"].ToString().Replace("\n","<br> ");
tRow1.Cells.Add(tCell);
tCell=new TableCell();
// tCell.Text=row1[1].ToString().Replace("\n","<br> ")+"<br>"+row1[0].ToString().Replace("\n","<br> ");
tRow1.Cells.Add(tCell);
Tb.Rows.Add(tRow1);
}
if(j==2)
{
tRow1.Height=10;
tCell=new TableCell();
// tCell.Width=30;
tCell.CssClass="down_line";
// tCell.Text=row1[0].ToString().Replace("\n","<br> ");
tRow1.Cells.Add(tCell);
tCell=new TableCell();
tCell.CssClass="down_line";
// tCell.Text=row1[0].ToString().Replace("\n","<br> ");
tRow1.Cells.Add(tCell);
Tb.Rows.Add(tRow1);
tCell=new TableCell();
tCell.CssClass="down_line";
tCell.Text="文章:"+row1["f_topic_count"].ToString().Replace("\n","<br> ");
tRow1.Cells.Add(tCell);
Tb.Rows.Add(tRow1);
}
}
}
tRow2=new TableRow();
tRow2.Height=25;
// tRow2.Width=new Unit(950);
tCell=new TableCell();
System.Web.UI.HtmlControls.HtmlImage dIMG= new System.Web.UI.HtmlControls.HtmlImage();
dIMG.Src="../images/bb_left.gif";
dIMG.ID="dIMG";
dIMG.Width=40;
dIMG.Height=25;
tCell.Controls.Add(dIMG);
tRow2.Cells.Add(tCell);
tCell=new TableCell();
tCell.ColumnSpan=2;
System.Web.UI.HtmlControls.HtmlImage dIMG1= new System.Web.UI.HtmlControls.HtmlImage();
dIMG1.Src="../images/bb_bg.gif";
dIMG1.ID="dIMG1";
dIMG1.Width =720;
dIMG1.Height=25;
tCell.Controls.Add(dIMG1);
tRow2.Cells.Add(tCell);
tCell=new TableCell();
System.Web.UI.HtmlControls.HtmlImage dIMG2= new System.Web.UI.HtmlControls.HtmlImage();
dIMG2.Src="../images/bb_right.gif";
dIMG2.ID="IMG2";
dIMG2.Width=185;
dIMG2.Height=25;
tCell.Controls.Add(dIMG2);
tRow2.Cells.Add(tCell);
Tb.Rows.Add(tRow2);
this.PL1.Controls.Add(Tb);
System.Web.UI.WebControls.Label lab=new System.Web.UI.WebControls.Label();
lab.Text="<p>";
this.PL1.Controls.Add(lab);
}
}
this.L_topics.Text=this.topic_count.ToString();
}
//this.CommonButtonInit();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?