using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using JXC_MIS.MyClass;
using JXC_MIS.DataTier;

namespace JXC_MIS.UserTier.BaseForm
{
	/// <summary>
	/// frmTreeWindows 的摘要说明。
	/// </summary>
	public class frmTreeWindows : System.Windows.Forms.Form
	{
		protected System.Windows.Forms.ToolBarButton t_Save;
		protected System.Windows.Forms.ComboBox cbo_SetupName;
		protected System.Windows.Forms.ToolBarButton t_Modify;
		protected System.Windows.Forms.StatusBar sbr_StatusBar;
		protected System.Windows.Forms.ToolBar tbr_Toolbar;
		private System.Windows.Forms.ToolBarButton t_s4;
		protected System.Windows.Forms.ToolBarButton t_Output;
		protected System.Windows.Forms.ToolBarButton t_new;
		protected System.Windows.Forms.ToolBarButton t_Cancel;
		private System.Windows.Forms.ToolBarButton t_S3;
		protected System.Windows.Forms.ToolBarButton t_Preview;
		private System.Windows.Forms.ToolBarButton t_Print;
		private System.Windows.Forms.ToolBarButton T_S1;
		protected System.Windows.Forms.ToolBarButton t_Refresh;
		protected System.Windows.Forms.ToolBarButton t_Find;
		private System.Windows.Forms.ToolBarButton t_S2;
		protected System.Windows.Forms.ToolBarButton t_Exit;
		private System.Windows.Forms.ImageList img_ImageList;
		protected System.Windows.Forms.Panel panel1;
		protected System.Windows.Forms.Splitter spt_H;
		protected System.Windows.Forms.DataGrid grd_Bottom;
		protected System.Windows.Forms.DataGrid grd_Top;
		protected System.Windows.Forms.Splitter spt_V;
		protected System.Windows.Forms.TreeView tv_Tree;
		private System.ComponentModel.IContainer components;

		private System.Windows.Forms.ComboBox cbo_Value;
		private System.Windows.Forms.DateTimePicker dt_Date;

		protected System.Windows.Forms.Panel pnl_Filter;
		private System.Windows.Forms.Button cmd_Close;
		private System.Windows.Forms.Label lblCaption;
		protected System.Windows.Forms.Button cmd_Cancel;
		protected System.Windows.Forms.Button cmd_ExeQuery;
		private string m_colCaption ="开始日期,D,1|终止日期,D,1|国标代码,C,SELECT DISTINCT fstrClassTeam  FROM InitClassTeam|国标型号,C,18|客户名称,C,18|业务员,C,18|部门,C,18|发票类型,C,18|开票单位,C,18" ;						 //列标题
		private string m_queryName  ;
		protected ljs.MyGrid grd_Filter;
		private string m_ReportName  ;				    //
				protected ClsInitData InitData=new ClsInitData();
		protected ClsDataBase newDb=new ClsDataBase();
//		private ClsReceiptAttrib newR_Attrib=new ClsReceiptAttrib();
		protected ClsDataBaseAccess newADO=new ClsDataBaseAccess();
/// <summary>
		/// 列标题
		/// </summary>
		public string ColCaption
		{ 
			get {return m_colCaption;} 
			set { m_colCaption=value;} 
		} 
		/// <summary>
		/// 查询语句的名称
		/// </summary>
		public string ReportName
		{ 
			get {return m_ReportName;} 
			set { m_ReportName=value;} 
		}
		/// <summary>
		/// 查询语句的名称
		/// </summary>
		public string QueryName
		{ 
			get {return m_queryName;} 
			set { m_queryName=value;} 
		}

		public frmTreeWindows()
		{
			//
			// 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(frmTreeWindows));
			this.t_Save = new System.Windows.Forms.ToolBarButton();
			this.cbo_SetupName = new System.Windows.Forms.ComboBox();
			this.t_Modify = new System.Windows.Forms.ToolBarButton();
			this.sbr_StatusBar = new System.Windows.Forms.StatusBar();
			this.tbr_Toolbar = new System.Windows.Forms.ToolBar();
			this.t_s4 = new System.Windows.Forms.ToolBarButton();
			this.t_Output = new System.Windows.Forms.ToolBarButton();
			this.t_new = new System.Windows.Forms.ToolBarButton();
			this.t_Cancel = new System.Windows.Forms.ToolBarButton();
			this.t_S3 = new System.Windows.Forms.ToolBarButton();
			this.t_Preview = new System.Windows.Forms.ToolBarButton();
			this.t_Print = new System.Windows.Forms.ToolBarButton();
			this.T_S1 = new System.Windows.Forms.ToolBarButton();
			this.t_Refresh = new System.Windows.Forms.ToolBarButton();
			this.t_Find = new System.Windows.Forms.ToolBarButton();
			this.t_S2 = new System.Windows.Forms.ToolBarButton();
			this.t_Exit = new System.Windows.Forms.ToolBarButton();
			this.img_ImageList = new System.Windows.Forms.ImageList(this.components);
			this.panel1 = new System.Windows.Forms.Panel();
			this.spt_H = new System.Windows.Forms.Splitter();
			this.grd_Bottom = new System.Windows.Forms.DataGrid();
			this.grd_Top = new System.Windows.Forms.DataGrid();
			this.spt_V = new System.Windows.Forms.Splitter();
			this.tv_Tree = new System.Windows.Forms.TreeView();
			this.pnl_Filter = new System.Windows.Forms.Panel();
			this.cbo_Value = new System.Windows.Forms.ComboBox();
			this.dt_Date = new System.Windows.Forms.DateTimePicker();
			this.cmd_Close = new System.Windows.Forms.Button();
			this.lblCaption = new System.Windows.Forms.Label();
			this.cmd_Cancel = new System.Windows.Forms.Button();
			this.cmd_ExeQuery = new System.Windows.Forms.Button();
			this.grd_Filter = new ljs.MyGrid();
			this.panel1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.grd_Bottom)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.grd_Top)).BeginInit();
			this.pnl_Filter.SuspendLayout();
			this.SuspendLayout();
			// 
			// t_Save
			// 
			this.t_Save.ImageIndex = 9;
			this.t_Save.Tag = "保存";
			this.t_Save.Text = "保存";
			this.t_Save.Visible = false;
			// 
			// cbo_SetupName
			// 
			this.cbo_SetupName.AccessibleDescription = "垂直";
			this.cbo_SetupName.Location = new System.Drawing.Point(0, 2);
			this.cbo_SetupName.Name = "cbo_SetupName";
			this.cbo_SetupName.Size = new System.Drawing.Size(124, 20);
			this.cbo_SetupName.TabIndex = 17;
			this.cbo_SetupName.Visible = false;
			// 
			// t_Modify
			// 
			this.t_Modify.ImageIndex = 7;
			this.t_Modify.Tag = "修改";
			this.t_Modify.Text = "修改";
			this.t_Modify.Visible = false;
			// 
			// sbr_StatusBar
			// 
			this.sbr_StatusBar.Location = new System.Drawing.Point(0, 428);
			this.sbr_StatusBar.Name = "sbr_StatusBar";
			this.sbr_StatusBar.ShowPanels = true;
			this.sbr_StatusBar.Size = new System.Drawing.Size(606, 25);
			this.sbr_StatusBar.TabIndex = 15;
			this.sbr_StatusBar.Text = "statusBar1";
			// 
			// tbr_Toolbar
			// 
			this.tbr_Toolbar.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
			this.tbr_Toolbar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						   this.t_s4,
																						   this.t_Output,
																						   this.t_new,
																						   this.t_Modify,
																						   this.t_Save,
																						   this.t_Cancel,
																						   this.t_S3,
																						   this.t_Preview,
																						   this.t_Print,
																						   this.T_S1,
																						   this.t_Refresh,
																						   this.t_Find,
																						   this.t_S2,
																						   this.t_Exit});
			this.tbr_Toolbar.DropDownArrows = true;
			this.tbr_Toolbar.ImageList = this.img_ImageList;
			this.tbr_Toolbar.Location = new System.Drawing.Point(0, 0);
			this.tbr_Toolbar.Name = "tbr_Toolbar";
			this.tbr_Toolbar.ShowToolTips = true;
			this.tbr_Toolbar.Size = new System.Drawing.Size(606, 41);
			this.tbr_Toolbar.TabIndex = 14;
			this.tbr_Toolbar.Wrappable = false;
			this.tbr_Toolbar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tbr_Toolbar_ButtonClick);
			// 
			// t_s4
			// 
			this.t_s4.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// t_Output
			// 
			this.t_Output.ImageIndex = 22;
			this.t_Output.Tag = "导出";
			this.t_Output.Text = "导出";
			// 
			// t_new
			// 
			this.t_new.ImageIndex = 19;
			this.t_new.Tag = "新增";
			this.t_new.Text = "新增";
			this.t_new.Visible = false;
			// 
			// t_Cancel
			// 
			this.t_Cancel.ImageIndex = 3;
			this.t_Cancel.Tag = "放弃";
			this.t_Cancel.Text = "放弃";
			this.t_Cancel.Visible = false;
			// 
			// t_S3
			// 
			this.t_S3.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// t_Preview
			// 
			this.t_Preview.ImageIndex = 15;
			this.t_Preview.Tag = "预览";
			this.t_Preview.Text = "预览";
			// 
			// t_Print
			// 
			this.t_Print.ImageIndex = 10;
			this.t_Print.Tag = "打印";
			this.t_Print.Text = "打印";
			// 
			// T_S1
			// 
			this.T_S1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// t_Refresh
			// 
			this.t_Refresh.ImageIndex = 9;
			this.t_Refresh.Tag = "刷新";
			this.t_Refresh.Text = "刷新";
			// 
			// t_Find
			// 
			this.t_Find.ImageIndex = 2;
			this.t_Find.Tag = "查询";
			this.t_Find.Text = "查询";
			// 
			// t_S2
			// 
			this.t_S2.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// t_Exit
			// 
			this.t_Exit.ImageIndex = 16;
			this.t_Exit.Tag = "退出";
			this.t_Exit.Text = "退出";
			// 
			// img_ImageList
			// 
			this.img_ImageList.ImageSize = new System.Drawing.Size(16, 16);
			this.img_ImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("img_ImageList.ImageStream")));
			this.img_ImageList.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this.spt_H);
			this.panel1.Controls.Add(this.grd_Bottom);
			this.panel1.Controls.Add(this.grd_Top);
			this.panel1.Controls.Add(this.spt_V);
			this.panel1.Controls.Add(this.tv_Tree);
			this.panel1.Controls.Add(this.cbo_SetupName);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panel1.Location = new System.Drawing.Point(0, 41);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(606, 387);
			this.panel1.TabIndex = 16;
			// 
			// spt_H
			// 
			this.spt_H.Dock = System.Windows.Forms.DockStyle.Top;
			this.spt_H.Location = new System.Drawing.Point(128, 178);
			this.spt_H.Name = "spt_H";
			this.spt_H.Size = new System.Drawing.Size(478, 4);
			this.spt_H.TabIndex = 4;
			this.spt_H.TabStop = false;
			this.spt_H.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.spt_H_SplitterMoved);
			// 
			// grd_Bottom
			// 
			this.grd_Bottom.AlternatingBackColor = System.Drawing.Color.Silver;
			this.grd_Bottom.BackColor = System.Drawing.Color.White;
			this.grd_Bottom.CaptionBackColor = System.Drawing.Color.Silver;
			this.grd_Bottom.CaptionFont = new System.Drawing.Font("Tahoma", 9F);
			this.grd_Bottom.CaptionForeColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(192)));
			this.grd_Bottom.CaptionText = "标题";
			this.grd_Bottom.DataMember = "";
			this.grd_Bottom.Font = new System.Drawing.Font("Tahoma", 8F);
			this.grd_Bottom.ForeColor = System.Drawing.Color.Black;
			this.grd_Bottom.GridLineColor = System.Drawing.Color.Silver;
			this.grd_Bottom.HeaderBackColor = System.Drawing.Color.Silver;
			this.grd_Bottom.HeaderFont = new System.Drawing.Font("Tahoma", 8F);
			this.grd_Bottom.HeaderForeColor = System.Drawing.Color.Black;
			this.grd_Bottom.LinkColor = System.Drawing.Color.Maroon;
			this.grd_Bottom.Location = new System.Drawing.Point(130, 182);
			this.grd_Bottom.Name = "grd_Bottom";
			this.grd_Bottom.ParentRowsBackColor = System.Drawing.Color.Silver;
			this.grd_Bottom.ParentRowsForeColor = System.Drawing.Color.Black;
			this.grd_Bottom.SelectionBackColor = System.Drawing.Color.Maroon;
			this.grd_Bottom.SelectionForeColor = System.Drawing.Color.White;
			this.grd_Bottom.Size = new System.Drawing.Size(584, 162);
			this.grd_Bottom.TabIndex = 2;
			// 
			// grd_Top
			// 
			this.grd_Top.CaptionBackColor = System.Drawing.Color.Silver;
			this.grd_Top.CaptionForeColor = System.Drawing.Color.Red;
			this.grd_Top.CaptionText = "主表";
			this.grd_Top.DataMember = "";
			this.grd_Top.Dock = System.Windows.Forms.DockStyle.Top;
			this.grd_Top.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.grd_Top.Location = new System.Drawing.Point(128, 0);
			this.grd_Top.Name = "grd_Top";
			this.grd_Top.Size = new System.Drawing.Size(478, 178);
			this.grd_Top.TabIndex = 3;
			this.grd_Top.Click += new System.EventHandler(this.grd_Top_Click);
			// 
			// spt_V
			// 
			this.spt_V.Location = new System.Drawing.Point(124, 0);
			this.spt_V.Name = "spt_V";
			this.spt_V.Size = new System.Drawing.Size(4, 387);
			this.spt_V.TabIndex = 1;
			this.spt_V.TabStop = false;
			this.spt_V.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.spt_V_SplitterMoved);
			// 
			// tv_Tree
			// 
			this.tv_Tree.Dock = System.Windows.Forms.DockStyle.Left;
			this.tv_Tree.ForeColor = System.Drawing.Color.Black;
			this.tv_Tree.ImageIndex = -1;
			this.tv_Tree.Location = new System.Drawing.Point(0, 0);
			this.tv_Tree.Name = "tv_Tree";
			this.tv_Tree.SelectedImageIndex = -1;
			this.tv_Tree.Size = new System.Drawing.Size(124, 387);
			this.tv_Tree.TabIndex = 0;
			this.tv_Tree.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tv_Tree_MouseDown);
			this.tv_Tree.Click += new System.EventHandler(this.tv_Tree_Click);
			// 
			// pnl_Filter
			// 
			this.pnl_Filter.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.pnl_Filter.Controls.Add(this.cbo_Value);
			this.pnl_Filter.Controls.Add(this.dt_Date);
			this.pnl_Filter.Controls.Add(this.cmd_Close);
			this.pnl_Filter.Controls.Add(this.lblCaption);
			this.pnl_Filter.Controls.Add(this.cmd_Cancel);
			this.pnl_Filter.Controls.Add(this.cmd_ExeQuery);
			this.pnl_Filter.Controls.Add(this.grd_Filter);
			this.pnl_Filter.Location = new System.Drawing.Point(232, 150);
			this.pnl_Filter.Name = "pnl_Filter";
			this.pnl_Filter.Size = new System.Drawing.Size(284, 196);
			this.pnl_Filter.TabIndex = 18;
			this.pnl_Filter.Visible = false;
			// 
			// cbo_Value
			// 
			this.cbo_Value.Location = new System.Drawing.Point(47, 97);
			this.cbo_Value.Name = "cbo_Value";
			this.cbo_Value.Size = new System.Drawing.Size(188, 20);
			this.cbo_Value.TabIndex = 5;
			this.cbo_Value.Visible = false;
			// 
			// dt_Date
			// 
			this.dt_Date.Location = new System.Drawing.Point(47, 77);
			this.dt_Date.Name = "dt_Date";
			this.dt_Date.Size = new System.Drawing.Size(188, 21);
			this.dt_Date.TabIndex = 4;
			this.dt_Date.Visible = false;
			// 
			// cmd_Close
			// 
			this.cmd_Close.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.cmd_Close.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.cmd_Close.Location = new System.Drawing.Point(262, 2);
			this.cmd_Close.Name = "cmd_Close";
			this.cmd_Close.Size = new System.Drawing.Size(18, 16);
			this.cmd_Close.TabIndex = 3;
			this.cmd_Close.Text = "x";
			this.cmd_Close.Click += new System.EventHandler(this.cmd_Close_Click);
			// 
			// lblCaption
			// 
			this.lblCaption.BackColor = System.Drawing.Color.RoyalBlue;
			this.lblCaption.Image = ((System.Drawing.Image)(resources.GetObject("lblCaption.Image")));
			this.lblCaption.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.lblCaption.Location = new System.Drawing.Point(-2, 0);
			this.lblCaption.Name = "lblCaption";
			this.lblCaption.Size = new System.Drawing.Size(488, 20);
			this.lblCaption.TabIndex = 2;
			this.lblCaption.Text = "   查询过滤";
			this.lblCaption.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// cmd_Cancel
			// 
			this.cmd_Cancel.Location = new System.Drawing.Point(74, 144);
			this.cmd_Cancel.Name = "cmd_Cancel";
			this.cmd_Cancel.Size = new System.Drawing.Size(70, 24);
			this.cmd_Cancel.TabIndex = 1;
			this.cmd_Cancel.Text = "关闭";
			this.cmd_Cancel.Click += new System.EventHandler(this.cmd_Cancel_Click);
			// 
			// cmd_ExeQuery
			// 
			this.cmd_ExeQuery.Location = new System.Drawing.Point(160, 144);
			this.cmd_ExeQuery.Name = "cmd_ExeQuery";
			this.cmd_ExeQuery.Size = new System.Drawing.Size(70, 24);
			this.cmd_ExeQuery.TabIndex = 0;
			this.cmd_ExeQuery.Text = "执行查询";
			this.cmd_ExeQuery.Click += new System.EventHandler(this.cmd_ExeQuery_Click);
			// 
			// grd_Filter
			// 
			this.grd_Filter.BackColor = System.Drawing.Color.White;
			this.grd_Filter.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("grd_Filter.BackgroundImage")));
			this.grd_Filter.BorderStyle = false;
			this.grd_Filter.BorderWidth = 0;
			this.grd_Filter.CellBackColor = System.Drawing.Color.White;
			this.grd_Filter.CellColLength = -1;
			this.grd_Filter.CellFontSize = 9F;
			this.grd_Filter.CellForeColor = System.Drawing.Color.Black;
			this.grd_Filter.CellHeight = 0;
			this.grd_Filter.CellRowLength = -1;
			this.grd_Filter.CellTag = null;
			this.grd_Filter.Col = 0;
			this.grd_Filter.Cols = 6;
			this.grd_Filter.EnterToTab = true;
			this.grd_Filter.GridStyle = true;
			this.grd_Filter.Location = new System.Drawing.Point(10, 28);
			this.grd_Filter.Name = "grd_Filter";
			this.grd_Filter.ReadCellBackColor = System.Drawing.Color.White;
			this.grd_Filter.ReadCellForeColor = System.Drawing.Color.Black;
			this.grd_Filter.Row = 0;
			this.grd_Filter.RowHeightMin = 20;
			this.grd_Filter.Rows = 2;
			this.grd_Filter.SetCellWidth = "100,100,100,100,100,100,100,100";
			this.grd_Filter.Size = new System.Drawing.Size(328, 102);
			this.grd_Filter.TabIndex = 6;
			// 
			// frmTreeWindows
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(606, 453);
			this.Controls.Add(this.pnl_Filter);
			this.Controls.Add(this.panel1);
			this.Controls.Add(this.sbr_StatusBar);
			this.Controls.Add(this.tbr_Toolbar);
			this.Name = "frmTreeWindows";
			this.Text = "frmTreeWindows";
			this.Resize += new System.EventHandler(this.frmTreeWindows_Resize);
			this.Load += new System.EventHandler(this.frmTreeWindows_Load);
			this.panel1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.grd_Bottom)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.grd_Top)).EndInit();
			this.pnl_Filter.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmTreeWindows_Load(object sender, System.EventArgs e)
		{
		
			tv_Tree.Width =140;
			ShowResize();
			tbr_Toolbar.SendToBack(); 
			//tv_Tree.BringToFront();
		}
		/// <summary>
		/// 设置是否可见树tv_Tree控件
		/// </summary>
		public void SetTreeVisible(bool p_TreeVisible)
		{
			tv_Tree.Visible =p_TreeVisible;
			spt_V.Visible =p_TreeVisible;	
			ShowResize();
		}
		/// <summary>
		/// 设置是否可见grd_Top控件
		/// </summary>
		public void SetGridVisible(bool p_GridTopVisible)
		{
			grd_Top.Visible =p_GridTopVisible;
			spt_H.Visible =p_GridTopVisible;	
			ShowResizeH();
		}

		protected virtual void tv_Tree_Click(object sender, System.EventArgs e)
		{
			TreeNode tn = new TreeNode();
			tn = tv_Tree.SelectedNode;
			
			if (tn != null)
			{
				cbo_SetupName.Text =tn.Text ;
			}
		}

		protected virtual void InitTreeData(string p_TreeDataSource)
		{
			if (p_TreeDataSource!=null && p_TreeDataSource!="")
			{
				InitData.InitTreeView (tv_Tree,newDb.GetDataArray(newADO.GetDataSet(p_TreeDataSource)));
			}

		}
		protected virtual void InitFilter(string p_colCaption)
		{
			string [] ArrSplit = null; //     临时数组变量
			string [] ArrSplit1 = null; //     临时数组变量
			//'设置行数，列数
			ArrSplit = p_colCaption.Split('|');
			int rs=ArrSplit.Length;				//总行数
			grd_Filter.Rows =rs    ;			//设置行数
			grd_Filter.Cols = 4 ;    //    
			//'设置列宽
			grd_Filter.SetCellWidth ="80,180,0,0"; 
			grd_Filter.RowHeightMin =20;//22;
			grd_Filter.ShowGrid() ;
			grd_Filter.SetColBackColor(SystemColors.Control  ,true);
			int m=0;
			for (int i=0;i<rs;i++)
			{
				ArrSplit1 = ArrSplit[i].Split(',');
				m=ArrSplit1.Length ;
				if (m > 0) {grd_Filter.CellText(i,0,ArrSplit1[0]);}
				if (m > 1) {grd_Filter.CellText(i,2,ArrSplit1[1]);}
				if (m > 2) {grd_Filter.CellText(i,3,ArrSplit1[2]);}
			}
			//			grd_Filter.Left =0;
//			this.pnl_Filter.Width =grd_Filter.Width +10;
			this.pnl_Filter.Height =grd_Filter.Height +100;//pnl_Bottom.Height*2+grd_Filter.Top  ;
			pnl_Filter.Visible =true;
			pnl_Filter.Left =(this.Width -pnl_Filter.Width )/2;
			pnl_Filter.Top =(this.Height -pnl_Filter.Height )/2;
			pnl_Filter.BringToFront();
			this.cmd_Cancel.Top =this.pnl_Filter.Height -this.cmd_Cancel.Height*2;
			this.cmd_ExeQuery.Top =this.cmd_Cancel.Top ;

		}
		private void grd_Filter_Click(object sender, System.EventArgs e)
		{
			TextBox control = (TextBox) sender ;

			if (grd_Filter.Col==1 && (grd_Filter.Row==0 || grd_Filter.Row==1))
			{
				dt_Date.Top  =control.Top+control.Parent.Top ;
				dt_Date.Left  =control.Left+control.Parent.Left+1  ;
				dt_Date.Height   =control.Height-1 ;
				dt_Date.Width =control.Width-3;
				dt_Date.Visible =true;
				dt_Date.BringToFront() ;
				dt_Date.Focus() ;
			}
			else
			{
				cbo_Value.Top  =control.Top+control.Parent.Top;
				cbo_Value.Left  =control.Left+control.Parent.Left+1  ;
				cbo_Value.Height   =control.Height-1 ;
				cbo_Value.Width =control.Width-3;
				cbo_Value.Visible =true;
				cbo_Value.BringToFront() ;
				cbo_Value.Focus() ;
			
			}


		}
		private void dt_Date_Leave(object sender, System.EventArgs e)
		{
			dt_Date.Visible =false;
		}

		private void cbo_Value_Leave(object sender, System.EventArgs e)
		{
			cbo_Value.Visible =false;
		}

		protected virtual void grd_Top_Click(object sender, System.EventArgs e)
		{
		}

		private void tv_Tree_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			try
			{
				tv_Tree.SelectedNode = tv_Tree.GetNodeAt(e.X,e.Y);	
			}
			catch
			{
				return;
			}
		}
		protected void  ShowResize()
		{
			if (grd_Top.Visible ==false){grd_Top.Width =0;spt_H.Visible =false;}
			if (spt_H.Visible ==false){spt_H.Height=0 ;spt_H.Top=0;}
			if (tv_Tree.Visible ==false){tv_Tree.Width =0;}
			if (spt_V.Visible ==false){spt_V.Width=0 ;spt_V.Left=0;}
			if (tv_Tree.Visible ==false)
			{
				grd_Bottom.Left =0 ;
			}
			else
			{
				grd_Bottom.Left =spt_V.Left +spt_V.Width ;
			}
			grd_Bottom.Width =this.Width -this.grd_Bottom.Left-6  ;
			ShowResizeH();
		}
		private void  ShowResizeH()
		{
			if (grd_Top.Visible ==false){grd_Top.Width =0;spt_H.Visible =false;}
			if (spt_H.Visible ==false){spt_H.Height=0 ;spt_H.Top=0;}
			if (grd_Top.Visible ==false)
			{
				this.grd_Bottom.Top  =0   ;
			}
			else
			{
				this.grd_Bottom.Top  =this.spt_H.Top+this.spt_H.Height   ;
			}
			this.grd_Bottom.Height =this.tv_Tree.Height-(this.spt_H.Top+this.spt_H.Height);//-this.grd_Bottom.Top;
		}
		private void spt_V_SplitterMoved(object sender, System.Windows.Forms.SplitterEventArgs e)
		{
			ShowResize();
		}


	
		protected virtual void tbr_Toolbar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			switch (e.Button.Tag.ToString())
			{
				case "新增":
					break;
				case "修改":
					//					if (grd_Bottom[grd_Bottom.CurrentCell.RowNumber ,0]==null){return;}
					try
					{
					}
					catch
					{}

					//					RecordModify();
					break;
				case "放弃":
					////					RecordCancel();
					break;
				case "预览":

					break;
				case "打印":
					//					ReceiptPrint();
					break;
				case "刷新":
					//					InitData(cbo_SetupName.Text);
					break;
				case "查询":
					//					ReceiptFind();
					InitFilter(m_colCaption);
					break;
				case "退出":
					this.Close();
					break;

				default:
 
					break;
			}
		}

		private void spt_H_SplitterMoved(object sender, System.Windows.Forms.SplitterEventArgs e)
		{
			ShowResizeH();
		}

		private void frmTreeWindows_Resize(object sender, System.EventArgs e)
		{
			ShowResize();
			ShowResizeH();

		}

		private void cmd_Close_Click(object sender, System.EventArgs e)
		{
			pnl_Filter.Visible =false;

		}

		protected virtual void cmd_Cancel_Click(object sender, System.EventArgs e)
		{
			pnl_Filter.Visible =false;

		}

		protected  virtual void cmd_ExeQuery_Click(object sender, System.EventArgs e)
		{
			pnl_Filter.Visible =false;
		}

	}
}
