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

📄 forumlistadmin.aspx.cs

📁 ASP.net网站开发四“酷”全书:新闻、论坛、电子商城、博客_源码
💻 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;
using BusObjectForum;
using SampleForum.SetData;
namespace SampleForum.SysManage
{
	/// <summary>
	/// ForumListAdmin 的摘要说明。
	/// </summary>
	public class ForumListAdmin : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DropDownList selFunction;
		protected System.Web.UI.WebControls.DataGrid dgrFourm;
		protected System.Web.UI.WebControls.CheckBoxList CheckBoxList1;
		protected System.Web.UI.WebControls.DropDownList selTopic;
		protected System.Web.UI.WebControls.Label labCurrentPage;
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if(!Page.IsPostBack)
			{
				ForumC oForum = new ForumC();
				string ErrDesc = "";
				DataSet oDataSet = oForum.getForumList(CONNSTRING,out ErrDesc);
				this.selFunction.DataSource = oDataSet;
				selFunction.DataMember = "T_Function";
				selFunction.DataValueField = "fchrFunctionID";
				selFunction.DataTextField = "fchrFunctionName";
				Page.DataBind();
				InitList("");
			}
			dgrFourm.Columns[0].Visible = false;
		}
		public static string CONNSTRING
		{
			get
			{
				connect_strings oConn = new connect_strings();
				return oConn.OLEDBConnectionString;
			}
		}
		public static string SQLCONNSTRING
		{
			get
			{
				connect_strings oConn = new connect_strings();
				return oConn.SqlConnectionString ;
			}
		}
		public void OnChangeFunction(object oSource, System.EventArgs e)
		{
			DropDownList oSel = (DropDownList)oSource;
			string strFunctionID=oSel.SelectedValue;
			string ErrDesc= "";
			ForumC oForum = new ForumC();
			DataSet oDataSet = oForum.getTopicByFunction(CONNSTRING,strFunctionID,false,out ErrDesc);
			if(ErrDesc=="")
			{
				this.selTopic.DataSource = oDataSet.Tables[0].DefaultView;
				selTopic.DataTextField = "fchrTopicCaption";
				selTopic.DataValueField = "fchrTopicID";
				selTopic.DataBind();
			}
			else
			{
				Response.Write("错误:"+ErrDesc);
			}
		}
		public void OnChangeTopic(object oSource, System.EventArgs e)
		{
			DropDownList oSel = (DropDownList)oSource;
			InitList(oSel.SelectedValue);
		}
		public void InitList(string strTopicID)
		{
			if(strTopicID=="")
				strTopicID="{00000000-0000-0000-0000-000000000000}";
			InnerFunction oFunction = new InnerFunction();
			string ErrDesc="";
			dgrFourm.PageSize =int.Parse(oFunction.getUserParaByName(CONNSTRING,"Forum_ListPageNO",out ErrDesc));
			dgrFourm.PagerStyle.Mode=PagerMode.NumericPages;
			ErrDesc = "";
			ForumC oForum = new ForumC();
			DataSet oDataSet = oForum.getForumByTopic(CONNSTRING,strTopicID,true,out ErrDesc);
			if(ErrDesc=="")
			{
				dgrFourm.DataSource = oDataSet.Tables[0].DefaultView;
				dgrFourm.DataBind();
			}
			else
			{
				Response.Write("错误:"+ErrDesc);
			}
		}
		public void DoGoToForum(Object oSource,DataGridCommandEventArgs oArgs)
		{
			this.dgrFourm.EditItemIndex = oArgs.Item.ItemIndex;
			InitList(this.selTopic.SelectedValue);
		}
		public void UpdateForumState(object oSource,DataGridCommandEventArgs oArgs)
		{
			string ErrDesc="";
			ForumC oForum = new ForumC();
			string strForumID = oArgs.Item.Cells[0].Text;
			DropDownList oIsNoUsed = (DropDownList)oArgs.Item.FindControl("selIsNoUsed");
			if(oForum.SetForumState(SQLCONNSTRING,strForumID,oIsNoUsed.SelectedValue,out ErrDesc))
			{
				Response.Write("更新状态成功!");
			}
			else
			{
				Response.Write ("发生错误:"+ErrDesc);
				Response.End();
			}
		}
		public void CancelFourm(object oSource,DataGridCommandEventArgs oArgs)
		{
			this.dgrFourm.EditItemIndex = -1;
			this.InitList(this.selTopic.SelectedValue);
		}
		public void ChangePage(object oSender,DataGridPageChangedEventArgs objArgs)
		{
			dgrFourm.CurrentPageIndex = objArgs.NewPageIndex;
			InitList(this.selTopic.SelectedValue);
			labCurrentPage.Text = (dgrFourm.CurrentPageIndex+1).ToString();
		}
		#region Web 窗体设计器生成的代码
		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
	}
}

⌨️ 快捷键说明

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