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

📄 showbranch.aspx.cs

📁 asp.net办公自动化实例导航——非常经典的OA源代码
💻 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 qminoa.DA; 
using qminoa.Common; 

namespace qminoa.Webs.FM
{
	public class ShowBranch : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.ImageButton cmdCancel;
		protected System.Web.UI.WebControls.ImageButton cmdFinish;
		protected System.Web.UI.WebControls.ImageButton cmdLast;
		protected System.Web.UI.WebControls.Button cmdDel;
		protected System.Web.UI.WebControls.Button cmdAdd;
		protected System.Web.UI.WebControls.Label Label5;
		protected System.Web.UI.WebControls.Label Label4;
		protected System.Web.UI.WebControls.ListBox lstSelBranch;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.DropDownList BranchDropList;
		protected System.Web.UI.WebControls.ListBox DepartmentDropList;
		protected System.Web.UI.WebControls.Label Label1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!this.IsPostBack)
			{
				AdminDB admin = new AdminDB();
				BranchDropList.DataSource=admin.GetAllBranch();
				BranchDropList.DataBind();
				BranchDropList.Items[0].Selected=true;

				DepartmentDropList.DataSource=admin.GetDepByBranch(Int32.Parse(BranchDropList.SelectedItem.Value));
				DepartmentDropList.DataBind();
				DepartmentDropList.Items[0].Selected=true;
			 }
		}

		#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.BranchDropList.SelectedIndexChanged += new System.EventHandler(this.BranchDropList_SelectedIndexChanged);
			this.cmdAdd.Click += new System.EventHandler(this.cmdAdd_Click);
			this.cmdDel.Click += new System.EventHandler(this.cmdDel_Click);
			this.cmdLast.Click += new System.Web.UI.ImageClickEventHandler(this.cmdLast_Click);
			this.cmdFinish.Click += new System.Web.UI.ImageClickEventHandler(this.cmdFinish_Click);
			this.cmdCancel.Click += new System.Web.UI.ImageClickEventHandler(this.cmdCancel_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void cmdLast_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			Response.Redirect("SetRightType.aspx?type=0",false);
		}

		private void cmdCancel_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			int righttype;
			int fid;
			int doc_id;
			righttype=Convert.ToInt32(Session["RightType"]);
			fid=Convert.ToInt32(Session["_FolderId"]);
			doc_id=Convert.ToInt32(Session["_docid"]);
			if(righttype==4)
			{ 
				Response.Redirect("fmNewFolder.aspx?docid="+doc_id+"&id="+fid+"&type=-3",false);
			}
			else if(righttype==5)
			{
			   Response.Redirect("fmNewFile.aspx?did="+doc_id+"&fid="+fid+"&type=-3",false);
			}
		}
		private void FillUnit()
		{
			DataSet resultsSet = null;
			
			try
			{
				resultsSet = (new FileRight()).GetAllUnitName();
			}
			catch (ApplicationException)
			{
			}
           
			DepartmentDropList.DataSource=resultsSet.Tables["unitname"].DefaultView;
			DepartmentDropList.DataValueField=resultsSet.Tables["unitname"].Columns["DepId"].ToString();
			DepartmentDropList.DataTextField=resultsSet.Tables["unitname"].Columns["DepName"].ToString();
			DataBind();
			DepartmentDropList.SelectedIndex=0; 
		}

		private void cmdAdd_Click(object sender, System.EventArgs e)
		{
			bool exist=false;
			
			foreach(ListItem li in lstSelBranch.Items)
			{
				if(li.Value==DepartmentDropList.SelectedItem.Value)
				{
					exist=true;
				}
			}
			if(exist==false)
			{
				lstSelBranch.Items.Add(new ListItem(DepartmentDropList.SelectedItem.Text,DepartmentDropList.SelectedItem.Value));
			}
		}

		private void cmdDel_Click(object sender, System.EventArgs e)
		{
			lstSelBranch.Items.Remove(lstSelBranch.SelectedItem);
		}

		private void cmdFinish_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			int righttype=Convert.ToInt32(Session["RightType"]);
			int num=lstSelBranch.Items.Count;
			for(int i=0;i<lstSelBranch.Items.Count;i++ )
			{
				FileRight fright =new FileRight();
				int depid=Convert.ToInt32(lstSelBranch.Items[i].Value);
				if(righttype==4)
				{
					fright.SaveDocFolderRight(GetSaveData(depid),5);
				}
				else
				{
					fright.SaveDocRight(GetSaveData_Doc(depid),5);
				}
			}
			int type=Convert.ToInt32(Session["Type"]);
			int doc_id=Convert.ToInt32(Session["_docid"]);
			int fid=Convert.ToInt32(Session["_FolderId"]);
			if(righttype==4)
			{
				if(type==-2)
				{
					Response.Redirect("fmNewFolder.aspx?righttype=4&type=-2&id="+fid,false); 
				}
				else
				{
					Response.Redirect("fmNewFolder.aspx?docid="+doc_id+"&id="+fid+"&type=-3",false);
				}
			}
			if(righttype==5)
			{
				if(type==-2)
				{
				     Response.Redirect("fmNewFile.aspx?righttype=5&type=-2&did="+doc_id,false);
				}
				else
				{
				      Response.Redirect("fmNewFile.aspx?did="+doc_id+"&fid="+fid+"&type=-3",false);
				}
			}
		}

		public FileData GetSaveData(int DepId)
		{
			int FolderId;
			int type=Convert.ToInt32(Session["type"].ToString(),10);
			if(type==-2)
			{
				FolderId=0; 
			}
			else
			{
				FolderId=Convert.ToInt32(Session["_FolderId"]);
			}
			FileData rightdata=new FileData();
			DataTable userdata =rightdata.Tables[FileData.FMDOCFOLDERCTR_TABLE];
			DataRow row =userdata.NewRow();  
			
			row[0]=0;
			row[1]=FolderId;
			row[2]=DepId;
			row[3]=0;
			row[4]=0;
			row[5]=0;	                           
			row[6]=1;
			row[7]=DepId;
			userdata.Rows.Add(row);
			userdata.AcceptChanges();
			rightdata.AcceptChanges();
			return rightdata;
		}

		public FileData GetSaveData_Doc(int DepId)
		{
			int DocId;
			int type=Convert.ToInt32(Session["type"].ToString(),10);
			if(type==-2)
			{
				DocId=0; 
			}
			else
			{
				DocId=Convert.ToInt32(Session["_docid"]);
			}
			FileData rightdata=new FileData();
			DataTable userdata =rightdata.Tables[FileData.FMDOCFOLDERCTR_TABLE];
			DataRow row =userdata.NewRow();  
			row[0]=0;
			row[1]=DocId;
			row[2]=DepId;
			row[3]=0;
			row[4]=0;
			row[5]=0;	                           
			row[6]=1;
			row[7]=DepId;
			userdata.Rows.Add(row);
			userdata.AcceptChanges();
			rightdata.AcceptChanges();
			return rightdata;
		}

		private void BranchDropList_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			AdminDB admin = new AdminDB();
			DepartmentDropList.DataSource=admin.GetDepByBranch(Int32.Parse(BranchDropList.SelectedItem.Value));
			DepartmentDropList.DataBind();
		}
	}
}

⌨️ 快捷键说明

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