⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showboard.aspx.cs

📁 网上自动答疑系统(C#)
💻 CS
字号:
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 dayi
{
	/// <summary>
	/// showBoard 的摘要说明。
	/// </summary>
	public class showBoard : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Label lblAffiche;
		protected System.Web.UI.WebControls.Label lblHostList;
		protected System.Web.UI.WebControls.TextBox txtSearchWord;
		protected System.Web.UI.WebControls.DropDownList listLimite;
		protected System.Web.UI.WebControls.ImageButton btnSearch;
		protected System.Web.UI.WebControls.Label lblboardList;
		protected System.Web.UI.WebControls.Label lblHotSearchWord;
	
		dayi.controlDatabase cd=new controlDatabase();
		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!this.IsPostBack)
			{
				try
				{
					//显示最热搜索词
					this.lblHotSearchWord.Text=cd.hotSearchWord(5);

					//显示快速通道
					this.lblboardList.Text=cd.getMainBoardList(0);
					if(this.lblboardList.Text.Trim()=="")
					{
						this.lblboardList.Text="没有任何栏目";
					}

					//填充范围列表
					DataTable dt=cd.getDataTable("select * from [board] where rootID=0");
					this.listLimite.Items.Clear();//先清空列表
					this.listLimite.Items.Add(new ListItem("所有文章","0"));
					foreach(DataRow row in dt.Rows)
					{
						this.listLimite.Items.Add(new ListItem(row["boardName"].ToString().Trim(),row["boardID"].ToString()));
					}
					//显示栏目及相关文章标题列表
					int boardid=1;
					int page=1;
					if(Request.QueryString["boardID"]!=null)
					{
						boardid=Convert.ToInt32(Request.QueryString["boardID"]);
					}
					if(boardid<=0)
						boardid=1;
					//当前页
					if(Request.QueryString["page"]!=null)
					{
						page=Convert.ToInt32(Request.QueryString["page"]);
					}
					string path;
					int rootID=0;//根ID
					DataTable dataTable=cd.getDataTable("select * from [board] where boardID="+boardid);
					if(dataTable.Rows.Count>0)
					{
						DataRow dataRow=dataTable.Rows[0];
						path=dataRow["boardPath"].ToString().Trim()+","+boardid.ToString();

						this.Label1.Text=cd.pathToString(path,"showBoard.aspx")+"<br>";
						string questionList=cd.showBoard(boardid,"","",page);
						if(questionList=="")
						{
							questionList="&nbsp;<img src=images/l_y.gif>本栏目没有帖子";
						}
					
						this.Label1.Text+=questionList;

						rootID=Convert.ToInt32(dataRow["rootID"]);
						if(rootID==0)
							rootID=boardid;
						//显示本栏目热帖
						this.lblHostList.Text=cd.showHotRecord(rootID,"",20,"");
						if(this.lblHostList.Text.Trim()=="")
							this.lblHostList.Text="没有任何记录";

						//显示本栏目公告
						this.lblAffiche.Text="";
						string sql="select * from [affiche] where boardID="+rootID+" or boardID=0 order by id desc";
						dt=cd.getDataTable(sql);
						foreach(DataRow row in dt.Rows)
						{
							this.lblAffiche.Text+="<img src=images/l_y.gif><a href=# onClick=showAffiche('showAffiche.aspx?id="+row["id"].ToString()+"')>"+row["subject"].ToString().Trim()+"</a><br>";
						}
						if(this.lblAffiche.Text=="")
							this.lblAffiche.Text="&nbsp;&nbsp;没有公告";

					}
				}
				catch(Exception)
				{}
			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.btnSearch.Click += new System.Web.UI.ImageClickEventHandler(this.btnSearch_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void btnSearch_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			if(this.txtSearchWord.Text.Trim()!="")
			{
				Response.Redirect("search.aspx?keyword="+Server.UrlEncode(this.txtSearchWord.Text.Trim())+"&type="+this.listLimite.SelectedValue);
				//Response.Write(Server.UrlEncode(this.txtSearchWord.Text));
			}
			else
			{
				this.txtSearchWord.Text="请输入查询关键字";
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -