selectemp.aspx.cs

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

CS
211
字号
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 BDStudioBase
{
	/// <summary>
	/// SelectEmp 的摘要说明。
	/// </summary>
	public class SelectEmp : FormBase
	{
		protected System.Web.UI.WebControls.Label Label02;
		protected System.Web.UI.WebControls.Button cb_save;
		protected System.Web.UI.WebControls.CheckBoxList Check_select;
        protected COM_DropDs COM_DropDs=new COM_DropDs();
		protected COM_ForumTopics COM_ForumTopics=new COM_ForumTopics(); 
		protected Gfunction Gfunction=new Gfunction();

		public string sObjectData="";
		public string sObjectName="";
		protected System.Web.UI.WebControls.DropDownList listDep;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.CheckBox CheckBox1;
		protected COM_SystemAccount COM_SystemAccount=new COM_SystemAccount();
		//protected System.Web.UI.WebControls.DataGrid DataGrid1;
		public string sSendWindow="";

		private void Page_Load(object sender, System.EventArgs e)
		{
			sSendWindow=Request.QueryString["as_window"];
			if((sSendWindow=="system_work_plan11_input1")||(sSendWindow=="system_work_plan11_edit1"))
			{
				if(!Page.IsPostBack)
				{
					//string[] strFieldValue={Session["userid"].ToString()};
					//string sReturn="";
					//DataSet ds=this.COM_DropDs.DsAccount("acc_name='"+Session["userid"].ToString()+"'","");
					//DataGrid1.DataSource=ds;
					//DataGrid1.DataBind();
					DataSet ds=this.COMInterface.CreateDataSetFromSql("select under_res from system_account where acc_name='"+(string)Session["userid"]+"'");
					if(ds.Tables[0].Rows[0]["under_res"].ToString()!="[ALL]")
					{
						Label1.Visible=false;
						CheckBox1.Visible=false;
						this.listDep.Visible=false;
						this.Check_select.DataSource=this.COM_SystemAccount.DsAccUnderRes(Session["userid"].ToString(),"");
						this.Check_select.DataTextField="acc_emp";
						this.Check_select.DataValueField="acc_name";
						this.Check_select.DataBind();

					}
					else
					{


						this.listDep.DataSource=this.COM_DropDs.DsDepartment("","");
						this.listDep.DataTextField="dep_name";
						this.listDep.DataValueField="dep_num";
						this.listDep.DataBind();
						this.listDep.SelectedIndex=0;
						//string strWhere=Session["userid"].ToString();
						//string strWhere1=Session["userid"].ToString();
						Session["list"]=this.listDep.SelectedIndex;
						//string[] strFieldValue={Session["userid"].ToString(),this.listDep.SelectedItem.Value};
						this.Check_select.DataSource=this.COM_SystemAccount.DsAccUnderRes(Session["userid"].ToString(),this.listDep.SelectedItem.Value);
						
						this.Check_select.DataTextField="acc_emp";
						this.Check_select.DataValueField="acc_name";
						this.Check_select.DataBind();
					}
				}
				if(listDep.Visible)
				{
					if(Session["list"].ToString()!=this.listDep.SelectedIndex.ToString())
					{
						//string[] strFieldValue={Session["userid"].ToString(),this.listDep.SelectedItem.Value};
						this.Check_select.DataSource=this.COM_SystemAccount.DsAccUnderRes(Session["userid"].ToString(),this.listDep.SelectedItem.Value);
						this.Check_select.DataTextField="acc_emp";
						this.Check_select.DataValueField="acc_name";
						this.Check_select.DataBind();
						Session["list"]=Session["list"]=this.listDep.SelectedIndex;
						//DataGrid1.DataSource=this.COM_SystemAccount.DsAccUnderRes(Session["userid"].ToString(),this.listDep.SelectedItem.Value);;
						//DataGrid1.DataBind();
					}
				}

			}
			else
			{

				if(!Page.IsPostBack)
				{
					this.listDep.DataSource=this.COM_DropDs.DsDepartment("","");
					this.listDep.DataTextField="dep_name";
					this.listDep.DataValueField="dep_num";
					this.listDep.DataBind();
					this.listDep.SelectedIndex=0;
					//DataGrid1.DataSource=this.COM_DropDs.DsDepartment("","");
					//DataGrid1.DataBind();
					Session["list1"]=this.listDep.SelectedIndex;
					string strWhere="dep_num='"+this.listDep.SelectedItem.Value.ToString()+"'";
					this.Check_select.DataSource=this.COM_DropDs.DsAccount(strWhere,"");
					this.Check_select.DataTextField="acc_emp";
					this.Check_select.DataValueField="acc_name";
					this.Check_select.DataBind();
				
				}
				if(Session["list1"].ToString()!=this.listDep.SelectedIndex.ToString())
				{
					string strWhere="dep_num="+"'"+this.listDep.SelectedItem.Value.ToString()+"'";
					this.Check_select.DataSource=this.COM_DropDs.DsAccount(strWhere,"");
					this.Check_select.DataTextField="acc_emp";
					this.Check_select.DataValueField="acc_name";
					this.Check_select.DataBind();
					Session["list1"]=Session["list1"]=this.listDep.SelectedIndex;
				}
			}
		}

		#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.cb_save.Click += new System.EventHandler(this.cb_save_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		//返回人员代码数据
		private string ObjectData()
		{
			string DataValue="";
			for (int i=0; i<Check_select.Items.Count; i++)
			{
				if (Check_select.Items[i].Selected)
				{
					this.Gfunction.StringAdd(ref DataValue,"","["+Check_select.Items[i].Value+"]",",");
				}
			}
			return DataValue;
		}
		//返回人员名称数据
		private string ObjectName()
		{
			string DataValue="";
			for (int i=0; i<Check_select.Items.Count; i++)
			{
				if (Check_select.Items[i].Selected)
				{
					this.Gfunction.StringAdd(ref DataValue,"","["+Check_select.Items[i].Text+"]",",");
				}
			}
			return DataValue;
		}

		private void cb_save_Click(object sender, System.EventArgs e)
		{
			if(sSendWindow=="forums_main_topic_display")
			{
				string topicID=Request.QueryString["as_topicID"];
				DataSet ds=this.COMInterface.CreateDataSetFromSql("select topic_id,worning_emp from forum_topics where topic_id='"+topicID+"'");
				sObjectData=this.ObjectData();
				ds.Tables[0].Rows[0]["worning_emp"]=ds.Tables[0].Rows[0]["worning_emp"]+sObjectData;
				string sReturn="";
				COM_ForumTopics.EditData(ds,"0",ref sReturn);
			}
			else
			{
				if(CheckBox1.Visible)
				{
					if(CheckBox1.Checked)
					{
						sObjectData="[ALL]";
						sObjectName="[ALL]";
					}
					else
					{
						sObjectData=this.ObjectData();
						sObjectName=this.ObjectName();
					}
				}
				else
				{
					sObjectData=this.ObjectData();
					sObjectName=this.ObjectName();
				}
			}
		}
	}
}

⌨️ 快捷键说明

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