forums_forum_setdepartment.aspx.cs

来自「ASP.NET的一些开发实例,有论坛管理系统等」· CS 代码 · 共 173 行

CS
173
字号
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_forum_setDepartment 的摘要说明。
	/// </summary>
	public class forums_forum_setDepartment : BDStudioBase.FormBase
	{
		protected System.Web.UI.WebControls.Label Label02;
		protected System.Web.UI.WebControls.Label Out_Label1;
		protected System.Web.UI.WebControls.TextBox txtForumName;
		protected System.Web.UI.WebControls.TextBox txtForumNum;
		protected System.Web.UI.WebControls.Table tableSche;
		protected System.Web.UI.WebControls.Label labMessage1;
		protected System.Web.UI.WebControls.Button cbSaveReturn;
		protected System.Web.UI.WebControls.Button cbReturn;
		protected System.Web.UI.WebControls.DataGrid DataGrid1;
	
		DataSet dsForAll;
		protected COM_ForumForum  COM_ForumForum=new  COM_ForumForum();
		protected COM_SystemDepartment COM_SystemDepartment=new COM_SystemDepartment();
		protected Gfunction Gfunction=new Gfunction();
		string sRole="";
		string[] sFieldName={"forum_id","dep_res"};
		string m_num="73";


		private void Page_Load(object sender, System.EventArgs e)
		{
			this.o_str_FormName="forums_forum_setDepartment";
			if (this.Param_check(this.o_str_FormName)==1)//该页是否需要接收值
			{
				this.txtForumNum.Text=this.Param_get("as_pk");
				this.txtForumName.Text=this.Param_get("as_forumname");
				sRole=this.Param_get("as_department");
			}
			// 在此处放置用户代码以初始化页面
			TableInit();
			if(sRole!=""&&sRole!=null)
			{
				string[] arr_Role=this.sRole.Split(new char[]{','});
				for(int i=0;i<arr_Role.Length;i++)
				{
					arr_Role[i]=arr_Role[i].Substring(1,arr_Role[i].Length-2);
					//Response.Write(arr_Role[i]);
					CheckBox chk = (CheckBox)this.tableSche.FindControl("chk_"+arr_Role[i]);
					chk.Checked=true;
				}
			}
		}

		private void TableInit()
		{
			TableRow tRow;
			TableCell tCell;
			string[] str_FieldValue = {m_num,"dbGridMain1"};
			dsForAll=COM_SystemDepartment.DsMainListForAll(str_FieldValue);
			DataGrid1.DataSource=dsForAll;
			DataGrid1.DataBind();
			int i=0;
			int k=0;
			tRow= new TableRow();
			foreach(DataRow currRow in dsForAll.Tables[0].Rows)
			{
				
				if(k<=dsForAll.Tables[0].Rows.Count)
				{
					if(i==0||i==4)
					{
						tRow= new TableRow();
						tRow.Height=20;
						tRow.CssClass="dbtable_title";
						tableSche.Rows.Add(tRow);
						if(i==4)
						{
							i=0;
						}
					}
					if(i<4)
					{
						tCell = new TableCell();
						System.Web.UI.WebControls.CheckBox chk = new System.Web.UI.WebControls.CheckBox();
						chk.Text=currRow["dep_name"].ToString();
						chk.ID="chk_"+currRow["dep_num"].ToString();
						chk.Width=new Unit(150);
						tCell.Controls.Add(chk);
						tRow.Cells.Add(tCell);
						i++;
						k++;
					}
				}
			}
		}
		
		



		#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.cbSaveReturn.Click += new System.EventHandler(this.cbSaveReturn_Click);
			this.cbReturn.Click += new System.EventHandler(this.cbReturn_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void cbSaveReturn_Click(object sender, System.EventArgs e)
		{
			string str_data="";
			foreach(DataRow row in dsForAll.Tables[0].Rows)
			{
				CheckBox chk = (CheckBox)this.tableSche.FindControl("chk_"+row["dep_num"].ToString());
				if((chk!=null)&(chk.Checked==true))
				{
					this.Gfunction.StringAdd(ref str_data,"","["+row["dep_num"].ToString()+"]",",");
				}
			}
			DataSet dsData=new DataSet();
			DataTable dtData=new DataTable();
			DataRow dr;
			for(int i=0;i<sFieldName.Length;i++)
			{
				dtData.Columns.Add(new DataColumn(sFieldName[i],typeof(string)));
			}

			dr=dtData.NewRow();
			dr[sFieldName[0]]=this.txtForumNum.Text;
			dr[sFieldName[1]]=str_data;

			dtData.Rows.Add(dr);
			dsData.Tables.Add(dtData);
			//			DataGrid1.DataSource=dsData;
			//			DataGrid1.DataBind();
			string sReturn = string.Empty;
			this.COM_ForumForum.EditData(dsData,"0",ref sReturn);
			this.labMessage1.Text = sReturn;
			this.labMessage1.Visible=true;
		}

		private void cbReturn_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("forums_forum.aspx");
		}
	
	}
}

⌨️ 快捷键说明

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