forums_main_topic_display.aspx.cs
来自「ASP.NET的一些开发实例,有论坛管理系统等」· CS 代码 · 共 719 行 · 第 1/2 页
CS
719 行
tCell=new TableCell();
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();
System.Web.UI.WebControls.Image IM5=new System.Web.UI.WebControls.Image();
IM5.ImageUrl="../images/posttime.gif";
tCell.Controls.Add(IM5);
System.Web.UI.WebControls.Label LB5=new System.Web.UI.WebControls.Label();
LB5.Text=row["r_date"].ToString();
tCell.Controls.Add(LB5);
System.Web.UI.WebControls.Image IM6=new System.Web.UI.WebControls.Image();
IM6.ImageUrl="../images/ip.gif";
tCell.Controls.Add(IM6);
System.Web.UI.WebControls.Label LB6=new System.Web.UI.WebControls.Label();
LB6.Text=row["r_ip"].ToString();
tCell.Controls.Add(LB6);
tRow1.Cells.Add(tCell);
this.TB.Rows.Add(tRow1);
}
}
}
i++;
}
}
private void ImageButton2_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
this.CreatUserLogParentWindow("forums_main_topic_input2","forums_main_topic_display.aspx");//建立子窗口的父窗口数据值
this.Param_Open("forums_main_topic_input2");
this.Param_set("as_topicID",topicID);
this.Param_set("type",type);
Response.Redirect(this.o_str_InputFile1);
}
private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
this.CreatUserLogParentWindow("forums_main_topic_input1",this.o_str_FormUrl);//建立子窗口的父窗口数据值
this.Param_Open("forums_main_topic_input1");
this.Param_set("as_forumID",forumID);
this.Param_set("as_save_validity","10");
this.Param_set("as_delTime","5:00");
Response.Redirect(this.o_str_InputFile2);
}
private void IM_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
this.CreatUserLogParentWindow("forums_main_topic_edit","forums_main_topic_display.aspx");//建立子窗口的父窗口数据值
this.Param_Open("forums_main_topic_edit");
this.Param_set("as_topicID",topicID);
this.Param_set("type",type);
Response.Redirect(this.o_str_InputFile3);
}
private void IM1_Command(object sender, System.Web.UI.WebControls.CommandEventArgs e)
{
if(e.CommandName=="delete")
{
this.COM_ForumTopics.DeleteData(topicID,ref sReturn);
if(sReturn=="删除成功")
{
Response.Redirect("forums_main_topic.aspx");
}
}
}
private void ImageButton15_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
Response.Redirect("forums_main_topic.aspx");
}
private void ImageButton4_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
DataSet dsTop = this.COM_ForumTopics.DsTopicTop(Session["userid"].ToString());
if(dsTop.Tables[0].Rows.Count==0)
{
if(this.type=="must")
{
Response.Redirect("../index.aspx");
}
else
{
Response.Redirect("../forums/forums_main_public.aspx");
}
}
}
private void LinkButton1_Click(object sender, System.EventArgs e)
{
if(Session["p_table"].ToString()=="01")
{
Session["p_table"]="02";
ds.Tables[0].Rows[0]["t_place"]="02";
this.COM_ForumTopics.EditData(ds,"0",ref sReturn);
}
if(sReturn=="修改成功")
{
this.LinkButton1.Visible=false;
}
}
private void LinkButton2_Click(object sender, System.EventArgs e)
{
DataSet dsData=new DataSet();
DataTable dtData=new DataTable();
DataRow dr;
dtData.Columns.Add(new DataColumn("stow_id",typeof(string)));
dtData.Columns.Add(new DataColumn("topic_id",typeof(string)));
dtData.Columns.Add(new DataColumn("stow_emp",typeof(string)));
dr=dtData.NewRow();
dr["stow_id"]="自动增长";
dr["topic_id"]=topicID;
dr["stow_emp"]=Session["userid"].ToString();
dtData.Rows.Add(dr);
dsData.Tables.Add(dtData);
this.COM_ForumTopicsStow.InsertData(dsData,"0",ref sReturn);
if(sReturn=="增加成功")
{
this.LinkButton2.Visible=false;
}
}
/*翻页按钮事件*/
protected void PagerButtonClick(object sender, System.EventArgs e)
{
int PageNum=this.dbGridMain1.CurrentPageIndex;
string arg=((LinkButton)sender).CommandArgument;
switch(arg)
{
case("prev"):
if(PageNum>0)
PageNum--;
break;
case("next"):
if(PageNum<(this.dbGridMain1.PageCount-1))
PageNum++;
break;
}
//记录当前页
Session["PageNum1"]=PageNum;
this.dbGridMain1.CurrentPageIndex = PageNum;
this.dbGridMain1.DataBind();
this.PageShow();
this.FormInit();
}
private void PageShow()
{
if(dbGridMain1.PageCount>1)
{
this.linkbNext1.Visible=true;
this.linkbPrev1.Visible=true;
this.labPage1.Visible=true;
this.labPage2.Visible = true;
this.txtPageNum1.Visible = true;
this.linkbJump1.Visible = true;
this.PageLabelShow(ref this.labPage1,this.dbGridMain1.CurrentPageIndex+1,this.dbGridMain1.PageCount);
}
else
{
this.linkbNext1.Visible=false;
this.linkbPrev1.Visible=false;
this.labPage1.Visible=false;
this.labPage2.Visible = false;
this.txtPageNum1.Visible = false;
this.linkbJump1.Visible = false;
}
}
private void FormInit()
{
DataView dvdata;
if(Session["dv1"]!=null)
{
/*表格页数初始化*/
this.o_int_PageNum=(int)Session["PageNum1"];
dvdata=(DataView)Session["dv1"];
/*参数说明:主表格控件名称、表头数据集、空间固定列数量、主键名称、数据集*/
//this.DbGridInit(this.dbGridMain1,this.COMInterface.DsInterfaceTitle(m_num,"dbGridMain1"),ColumnCount,o_str_Pk1,ref dvdata);
this.dbGridMain1.DataSource=dvdata;
this.dbGridMain1.DataBind();
this.PageShow();
}
}
private void linkbJump1_Click(object sender, System.EventArgs e)
{
if (this.txtPageNum1.Text != string.Empty && this.txtPageNum1.Text != null)
{
int pagenum = (Int32.Parse(this.txtPageNum1.Text)-1);
if ( pagenum > (this.dbGridMain1.PageCount-1))
{
this.dbGridMain1.CurrentPageIndex = (this.dbGridMain1.PageCount-1);
}
else
{
this.dbGridMain1.CurrentPageIndex = pagenum;
}
Session["PageNum1"]=this.dbGridMain1.CurrentPageIndex;
// this.dbGridMain1.DataBind();
// this.PageShow();
this.FormInit();
}
}
private void ImageButton11_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
i_CurrentRow=Int32.Parse(this.labCurrentRow.Text);
i_CurrentRow--;
if(this.i_CurrentRow==0)
{
this.i_CurrentRow=1;
}
string[] str_FieldValue = {m_num,"DisplayFace",arr_ReceiveId[i_CurrentRow-1]};
this.labCurrentRow.Text=i_CurrentRow.ToString();
DataSet dsData=this.COM_ForumTopics.DsSelectSingleData(str_FieldValue,"0",ref sReturn);
topicID=dsData.Tables[0].Rows[0]["topic_id"].ToString();
this.TB.Rows.Clear();
this.TableInit();
this.o_ds_FormData=this.COM_ForumReply.DsMainFieldListForAll(m_num,"DisplayFace2",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);
}
}
private void dbGridMain1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemIndex!=-1)
{
drReply=dtReplyData.NewRow();
drReply["r_author"]=e.Item.Cells[2].Text;
drReply["r_message"]=e.Item.Cells[3].Text;
drReply["r_date"]=e.Item.Cells[4].Text;
drReply["r_ip"]=e.Item.Cells[5].Text;
dtReplyData.Rows.Add(drReply);
}
}
private void ImageButton14_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
i_CurrentRow=Int32.Parse(this.labCurrentRow.Text);
i_CurrentRow++;
if(this.arr_ReceiveId.Length<this.i_CurrentRow)
{
this.i_CurrentRow=this.arr_ReceiveId.Length;
}
string[] str_FieldValue = {m_num,"DisplayFace",arr_ReceiveId[i_CurrentRow-1]};
this.labCurrentRow.Text=i_CurrentRow.ToString();
DataSet dsData=this.COM_ForumTopics.DsSelectSingleData(str_FieldValue,"0",ref sReturn);
topicID=dsData.Tables[0].Rows[0]["topic_id"].ToString();
this.TB.Rows.Clear();
this.TableInit();
this.o_ds_FormData=this.COM_ForumReply.DsMainFieldListForAll(m_num,"DisplayFace2",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);
}
}
private void ButtonInit()
{
string thisPageUrl="forums/forums_main_topic_display.aspx";
string sqlquery="select * from system_module where m_type='3' and m_up=(select m_num from system_module where m_url='"+thisPageUrl+"')";
DataSet DsmapRole=this.COMInterface.CreateDataSetFromSql(sqlquery);
foreach(DataRow mapRoleRow in DsmapRole.Tables[0].Rows)
{
ImageButton imageButton=null;
Label label=null;
string enableRole=mapRoleRow["enable_role"].ToString();
string rolePoint=mapRoleRow["m_name"].ToString();
//string type=this.TB.FindControl(rolePoint).GetType().ToString();
//Response.Write(type);
object obj=this.Page.FindControl(rolePoint);//this.TB.FindControl(rolePoint);
string type=obj.GetType().ToString();
// if(type=="System.Web.UI.WebControls.ImageButton")
// {
//
// imageButton=(ImageButton)obj;
// imageButton.Visible=false;
// }
// if(type=="System.Web.UI.WebControls.Label")
// {
// label=(Label)obj;
// label.Visible=false;
// }
this.Page.FindControl(rolePoint).Visible=false;
DataSet DsuserRole=(DataSet)Session["DsUserRole"];
foreach(DataRow userRoleRow in DsuserRole.Tables[0].Rows)
{
if(enableRole.IndexOf(userRoleRow["role_num"].ToString())>-1)
{
this.Page.FindControl(rolePoint).Visible=true;
if(topicAuthor!=Session["userid"].ToString())
{
if(this.Page.FindControl(rolePoint).ID=="IM9" || this.Page.FindControl(rolePoint).ID=="IM10")
{
imageButton=(ImageButton)obj;
imageButton.Visible=false;
}
else if(this.Page.FindControl(rolePoint).ID=="LB9" || this.Page.FindControl(rolePoint).ID=="LB10")
{
label=(Label)obj;
label.Visible=false;
}
}
if((userRoleRow["role_num"].ToString()=="'R0031'")||(userRoleRow["role_num"].ToString()=="'R0033'"))
{
if(this.Page.FindControl(rolePoint).ID=="IM9" || this.Page.FindControl(rolePoint).ID=="IM10")
{
imageButton=(ImageButton)obj;
imageButton.Visible=true;
}
else if(this.Page.FindControl(rolePoint).ID=="LB9" || this.Page.FindControl(rolePoint).ID=="LB10")
{
label=(Label)obj;
label.Visible=true;
}
}
}
}
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?