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

📄 frmplatfclass.cs

📁 Oracle源码:Oracle 数据库管理与应用系统开发代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OracleClient;
using System.Threading;
using GlobleUtility;



namespace PlatF
{
	/// <summary>
	/// 学校地址的查询界面。
	/// </summary>
	public class CfrmPlatFClass : System.Windows.Forms.Form
	{
		private System.Windows.Forms.ListView lvClass;//ListView控件显示选定部门下班级信息
		private System.Windows.Forms.ImageList imageListtbr;
		private System.Windows.Forms.ToolBar tbrClass;
		private System.Windows.Forms.ToolBarButton toolBarButton8;
		private System.Windows.Forms.ToolBarButton tbrButtonAdd;//工具栏上"新增"按钮
		private System.Windows.Forms.ToolBarButton tbrButtonDel;//工具栏上"删除"按钮
		private System.Windows.Forms.ToolBarButton tbrButtonExit;//工具栏上"退出"按钮
		private System.Windows.Forms.Label labview;
		private System.ComponentModel.IContainer components;
		private System.Windows.Forms.TreeView trvDept;//TreeView控件以树形结构显示部门及部门间关系
		private System.Windows.Forms.ImageList imgDeptList;
		
		
		private ArrayList arrayPipe;  
	 
		
		public CfrmPlatFClass()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(CfrmPlatFClass));
			this.lvClass = new System.Windows.Forms.ListView();
			this.imageListtbr = new System.Windows.Forms.ImageList(this.components);
			this.tbrClass = new System.Windows.Forms.ToolBar();
			this.toolBarButton8 = new System.Windows.Forms.ToolBarButton();
			this.tbrButtonAdd = new System.Windows.Forms.ToolBarButton();
			this.tbrButtonDel = new System.Windows.Forms.ToolBarButton();
			this.tbrButtonExit = new System.Windows.Forms.ToolBarButton();
			this.labview = new System.Windows.Forms.Label();
			this.trvDept = new System.Windows.Forms.TreeView();
			this.imgDeptList = new System.Windows.Forms.ImageList(this.components);
			this.SuspendLayout();
			// 
			// lvClass
			// 
			this.lvClass.BackColor = System.Drawing.SystemColors.Info;
			this.lvClass.Location = new System.Drawing.Point(232, 104);
			this.lvClass.Name = "lvClass";
			this.lvClass.Size = new System.Drawing.Size(560, 368);
			this.lvClass.TabIndex = 0;
			this.lvClass.DoubleClick += new System.EventHandler(this.lvClass_DoubleClick);
			this.lvClass.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lvClass_ColumnClick);
			// 
			// imageListtbr
			// 
			this.imageListtbr.ImageSize = new System.Drawing.Size(32, 32);
			this.imageListtbr.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListtbr.ImageStream")));
			this.imageListtbr.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// tbrClass
			// 
			this.tbrClass.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						this.toolBarButton8,
																						this.tbrButtonAdd,
																						this.tbrButtonDel,
																						this.tbrButtonExit});
			this.tbrClass.ButtonSize = new System.Drawing.Size(52, 52);
			this.tbrClass.DropDownArrows = true;
			this.tbrClass.ImageList = this.imageListtbr;
			this.tbrClass.Location = new System.Drawing.Point(0, 0);
			this.tbrClass.Name = "tbrClass";
			this.tbrClass.ShowToolTips = true;
			this.tbrClass.Size = new System.Drawing.Size(802, 58);
			this.tbrClass.TabIndex = 8;
			this.tbrClass.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tbrClass_ButtonClick);
			// 
			// toolBarButton8
			// 
			this.toolBarButton8.Enabled = false;
			this.toolBarButton8.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// tbrButtonAdd
			// 
			this.tbrButtonAdd.ImageIndex = 0;
			this.tbrButtonAdd.Text = "新增";
			this.tbrButtonAdd.ToolTipText = "新增";
			// 
			// tbrButtonDel
			// 
			this.tbrButtonDel.ImageIndex = 3;
			this.tbrButtonDel.Text = "删除";
			this.tbrButtonDel.ToolTipText = "删除";
			// 
			// tbrButtonExit
			// 
			this.tbrButtonExit.ImageIndex = 6;
			this.tbrButtonExit.Text = "退出";
			this.tbrButtonExit.ToolTipText = "退出";
			// 
			// labview
			// 
			this.labview.Font = new System.Drawing.Font("黑体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.labview.Location = new System.Drawing.Point(8, 64);
			this.labview.Name = "labview";
			this.labview.Size = new System.Drawing.Size(696, 32);
			this.labview.TabIndex = 9;
			this.labview.Text = "班级信息:";
			// 
			// trvDept
			// 
			this.trvDept.HideSelection = false;
			this.trvDept.ImageList = this.imgDeptList;
			this.trvDept.Location = new System.Drawing.Point(0, 104);
			this.trvDept.Name = "trvDept";
			this.trvDept.Size = new System.Drawing.Size(224, 368);
			this.trvDept.TabIndex = 11;
			this.trvDept.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.trvDept_AfterSelect);
			// 
			// imgDeptList
			// 
			this.imgDeptList.ImageSize = new System.Drawing.Size(16, 16);
			this.imgDeptList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imgDeptList.ImageStream")));
			this.imgDeptList.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// CfrmPlatFClass
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(802, 495);
			this.Controls.Add(this.trvDept);
			this.Controls.Add(this.labview);
			this.Controls.Add(this.tbrClass);
			this.Controls.Add(this.lvClass);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "CfrmPlatFClass";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "班级信息维护";
			this.Load += new System.EventHandler(this.CfrmPlatFClass_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void CfrmPlatFClass_Load(object sender, System.EventArgs e)
		{
			//窗体初始化
			Classview();
		}

	
		/***************************************************************************************************************
		 * 功能:将listview与数据库记录集绑定,并在listview中显示出来,数据库记录集使用OracleDataReader
		 * 
		 * 输入参数:1、lvDataReader,使用OracleDataReader生成的记录集,将其绑定在sLV上
		 *           2、sLV,要绑定的listview名称
		 * 输出参数:无
		 * 
		 * 最后修改时间:04-08-12   by cellz
		 * ************************************************************************************************************/
		private void BindingsListView(OracleDataReader lvDataReader,ListView sLV)
		{
			sLV.View=View.Details;  
			sLV.GridLines=true; 
			sLV.ListViewItemSorter=null;
			for(int i=0;i<lvDataReader.FieldCount;i++)
			{
				//生成listview列头标,调用CaseName函数以中文显示列头
				sLV.Columns.Add ( lvDataReader.GetName(i),80,HorizontalAlignment.Center);
			}
			sLV.Columns.RemoveAt(0);    //因为首列标是无意义的id字段,所以删除首列标
			lvTagTemp TagTemp= new lvTagTemp();//为结构lvTagTemp分配内存
			while (lvDataReader.Read ())
			{
				ListViewItem cmicItem=new ListViewItem(); 
				//将第一个id字段以结构的形式赋给viewitem的tag属性				
				TagTemp.temp_id  = lvDataReader.GetValue(0).ToString().Trim();
				cmicItem.Tag = TagTemp;
				//(cmicItem.Tag as lvTagTemp).temp_id ; //tag属性的使用方法
				//将第二个字段赋给viewitem的第一列
				cmicItem.Text= lvDataReader.GetValue(1).ToString().Trim();
				//从第三个字段开始依次从viewitem的第二列开始显示
				for(int i=2;i<lvDataReader.FieldCount;i++)
				{
					cmicItem.SubItems.Add(lvDataReader.GetValue(i).ToString().Trim());   
				}
				sLV.Items.Add(cmicItem); 
				

			}
			
		}


		/***************************************************************************************************************
		 * 功能:将listview与数据库记录集绑定,并在listview中显示出来,数据库记录集使用DataSet
		 * 
		 *输入参数:1、sDs,使用DataSet生成的记录集,将其绑定在sLV上
		 *           2、sLV,要绑定的listview名称
		 * 输出参数:无 
		 * 
		 * 最后修改时间:04-08-12   by cellz
		 * ************************************************************************************************************/
		private void BindingsListView(DataSet sDs,ListView sLV)
		{
			sLV.View=View.Details;  
			sLV.GridLines=true; 
			sLV.ListViewItemSorter=null;
			if(sDs.Tables.Count!=0)
			{
				DataTable cmicDt=sDs.Tables[0];
				foreach(DataColumn sDc in cmicDt.Columns)
				{
					//生成listview列头标,调用CaseName函数以中文显示列头
					sLV.Columns.Add(sDc.ColumnName,80,HorizontalAlignment.Center);    
				}
				sLV.Columns.RemoveAt(0);    //因为首列标是无意义的id字段,所以删除首列标
				lvTagTemp TagTemp= new lvTagTemp();//为结构lvTagTemp分配内存
				for(int i=0;i<cmicDt.Rows.Count;i++)   
				{
					ListViewItem cmicItem=new ListViewItem(); 
					//将第一个id字段以结构的形式赋给viewitem的tag属性					
					TagTemp.temp_id  = cmicDt.Rows[i][0].ToString().Trim();
					cmicItem.Tag = TagTemp;					
					//将第二个字段赋给viewitem的第一列
					cmicItem.Text= cmicDt.Rows[i][1].ToString().Trim();
					//从第三个字段开始依次从viewitem的第二列开始显示
					for(int j=2;j<cmicDt.Columns.Count;j++)
					{
						cmicItem.SubItems.Add(cmicDt.Rows[i][j].ToString().Trim());   
					}
					sLV.Items.Add(cmicItem); 
				}
			}
			else
			{
				return;
			}
		}

		/***************************************************************************************************************
		 * 功能:初始化班级维护界面,在listview中显示全部记录
		 * 
		 * 输入参数:无
		 * 输出参数:无
		 * 
		 * 最后修改时间:04-08-12   by cellz
		 * ************************************************************************************************************/
		private void Classview()
		{
			//窗体初始化设置
			//toolbar初始化设置
			tbrButtonAdd.Enabled = true;
			tbrButtonDel.Enabled = true;
            //设置ListView控件显示属性
            lvClass.FullRowSelect =true;  //整行选择
			lvClass.HideSelection = false; //当listview没有焦点时,选定项是否仍然突出显示
			lvClass.View=View.Details;  
			lvClass.GridLines=true; 
			lvClass.Clear();
			string[] UserFieldInfo = {"班级名称","所属部门","班级描述"};
			for (int i = 0; i <= 2; i++)
			{
				lvClass.Columns.Add(UserFieldInfo[i], 80, HorizontalAlignment.Center);
			}			
			lvClass.Columns[0].Width =150;
			lvClass.Columns[1].Width =150;
			lvClass.Columns[2].Width =200;
			//数据库查询操作,listview中按照名称顺序显示记录
			System.Data.OracleClient.OracleConnection Org_myConn = Connection.DBConnection;
			if (Org_myConn == null)
			{
				return;	
			}
			//检验有无学校信息,如无则窗体关闭
			string Org_mySql = "SELECT OrgName FROM Charge_School_Info";
			OracleCommand selCommand = new OracleCommand(Org_mySql,Org_myConn);
			
			OracleDataReader trvDataReader = null;
			try
			{
				trvDataReader = selCommand.ExecuteReader();
			}
			catch(Exception ee)
			{
				MessageBox.Show("数据库查询出错,消息如下:\r\n"+ee.Message,"消息:",MessageBoxButtons.OK,MessageBoxIcon.Warning);
				return;
			}
			if (!trvDataReader.HasRows)
			{


				MessageBox.Show("必须先建立学校信息!");
				this.Close();
				return;
			}
			trvTagTemp TagTemp= new trvTagTemp();//为结构trvTagTemp分配内存
			TreeNode rootNode = new TreeNode();
			//将学校设为部门树最高节点
			while (trvDataReader.Read ())
			{
				
				rootNode =trvDept.Nodes.Add(trvDataReader.GetValue(0).ToString().Trim());
				rootNode.ImageIndex = 2;
				rootNode.SelectedImageIndex = 2;
				TagTemp.temp_id = "0";   //在部门部门关系表中将一级部门的上级部门ID设为0
				TagTemp.temp_isexpand = 2; //表示根节点已展开过
                //该值为0代表此节点是最高节点,该值为1代表此节点是部门类型,该值为2代表此节点是班级类型
				TagTemp.temp_type = 0; 
				rootNode.Tag = TagTemp;

			}	
			GetDepttree(rootNode);
			trvDept.CollapseAll(); //折叠所有树节点
			

		}

		/****************************************************************************
				Function Description:
					获得下属部门列表
				Arguments:
					Type_ID		查找类别	1—查下属有学生的部门
											2—查下属有老师

		的部门
											3—查所有部门
					Node		当前点击的树结点,即当前部门
				Return Value:
					NONE
				History:
					Modified on 07/23/2004 by may-fly@tom.com
					Modified on 08/02/2004 by may-fly@tom.com
					Modified on 08/14/2004 by cellz
		
		

		*****************************************************************************/
		private void GetDepttree(TreeNode Node)//ok
		{
			string strDtName = "dtDept";

⌨️ 快捷键说明

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