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

📄 templatelist2.aspx.cs

📁 很不错的公文流转系统
💻 CS
字号:
using System; 
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
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 OI.DocTemplate.Template
{
	/// <summary>
	/// TemplateList 的摘要说明。
	/// </summary>
	/// 	bv
	public class TemplateList2 : OI.PageBase
	{
		protected System.Web.UI.WebControls.DropDownList DropDownListPrimay;
		protected System.Web.UI.WebControls.DropDownList DropDownListChild;
		protected System.Web.UI.WebControls.TextBox TextBoxTemplateName;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
		protected System.Web.UI.WebControls.TextBox TextBoxDescript;
		protected System.Web.UI.WebControls.ImageButton ImageButtonNext; 
		protected string FileType;
		protected string RecordID;
		private int departmentid;

		private OI.DatabaseOper.DatabaseConnect oConn = new OI.DatabaseOper.DatabaseConnect();

		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if (Session["userid"]==null)
			{
				Response.Write ("<script>alert('超时,请重新登录');top.location.href='../userpass.aspx';</script>");
				return ;
			}
			if(Request["FileType"]!=null)
			{
				FileType=Request["FileType"].ToString();
			}
			if(Request["RecordID"]!=null)
			{
				RecordID=Request["RecordID"].ToString();
			}

			try {
				departmentid=Convert.ToUInt16(Request["departmentid"].ToString());
			}
			catch{
				departmentid=1;
			}
			if(!Page.IsPostBack)
			{ 				
				if(RecordID!=null){
				BindEdit();//修改
				}
				else{
					bindPrimay();
				}
				DropDownListChild.Enabled=false;
			}
		}
		
		private void BindEdit()
		{
			if(RecordID!=null)
			{
				string sql="select t.[FileName],t.Descript,t.DocumentTypeID,v.PrimaryType from Template t "+
						" inner join VIEW_DocumentType  v on "+
						"t.DocumentTypeID=v.DocumentTypeID where t.RecordID="+RecordID;
				System.Collections.ArrayList al=oConn.getData(sql);
				if(al.Count>0){
					string a=al[0].ToString();
					if(a.Length>4) {
						TextBoxTemplateName.Text=a.Substring(0,a.Length-4);
					}
					else {
						TextBoxTemplateName.Text="";
					}
					TextBoxDescript.Text=al[1].ToString();
				
					bindPrimay();
					DropDownListPrimay.Items.FindByValue(al[3].ToString()).Selected=true;

					bindChild();
				
					DropDownListChild.Items.FindByValue(al[2].ToString()).Selected=true;
				}
				else {
					 bindPrimay();
					bindChild();
				}
			}
		}
		 
		/// <summary>
		/// 绑定主类别
		/// </summary>
		private void bindPrimay()
		{
			DataSet dsType=new DataSet();
			string szSql = "select DocumentTypeDescription,PrimaryType from VIEW_DocumentType group by PrimaryType,DocumentTypeDescription";
			dsType = oConn.getBinding(szSql,"Temp");				
			DropDownListPrimay.DataSource = dsType.Tables["Temp"];
			DropDownListPrimay.DataTextField ="DocumentTypeDescription";
			DropDownListPrimay.DataValueField ="PrimaryType";
			DropDownListPrimay.DataBind();
			ListItem li=new ListItem("请选择","000");
			DropDownListPrimay.Items.Insert (0,li);
		}


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

		}
		#endregion

		private void DropDownListPrimay_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			bindChild();
		}
		/// <summary>
		/// 绑定子类别
		/// </summary>
		private void bindChild()		
		{
			if(DropDownListPrimay.SelectedValue!="000")
			{
				string szSql = "select * from VIEW_DocumentType where PrimaryType=" + DropDownListPrimay.SelectedValue;
				DataSet dsTemp = oConn.getBinding(szSql,"Temp");

				DropDownListChild.DataSource = dsTemp.Tables["Temp"];
				DropDownListChild.DataTextField = "DocumentTypeName";
				DropDownListChild.DataValueField = "DocumentTypeID";
				DropDownListChild.DataBind();
				ListItem li = new ListItem("请选择","000");
				DropDownListChild.Items.Insert(0,li);

				DropDownListChild.Enabled = true;		
			}
		}

		private void ImageButtonNext_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			if(DropDownListChild.SelectedValue=="000")
				return;
			if(RecordID==null)
			{
				Response.Redirect("TemplateEdit.aspx?FileType="+FileType+"&DocTypeDetail="+DropDownListChild.SelectedValue+"&TemplateName="+TextBoxTemplateName.Text.Trim()+"&Descript="+TextBoxDescript.Text.Trim()+"&departmentid="+departmentid,true);
			}
			else
			{
				Response.Redirect("TemplateEdit.aspx?FileType="+FileType+"&RecordID="+RecordID+"&DocTypeDetail="+DropDownListChild.SelectedValue+"&TemplateName="+TextBoxTemplateName.Text.Trim()+"&Descript="+TextBoxDescript.Text.Trim()+"&departmentid="+departmentid,true);
			}
		}
		 
	}
}

⌨️ 快捷键说明

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