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

namespace JXC_MIS.UserTier.BaseForm
{
	/// <summary>
	/// frmTreeFlexGrid 的摘要说明。
	/// </summary>
	public class frmTreeFlexGrid : System.Windows.Forms.Form
	{
		protected System.Windows.Forms.Panel panel1;
		protected System.Windows.Forms.Splitter spt_H;
		protected System.Windows.Forms.Splitter spt_V;
		protected System.Windows.Forms.TreeView tv_Tree;
		protected System.Windows.Forms.ComboBox cbo_SetupName;
		protected System.Windows.Forms.ToolBarButton t_S2;
		protected System.Windows.Forms.ToolBarButton t_Find;
		protected System.Windows.Forms.ToolBarButton t_Exit;
		protected System.Windows.Forms.Panel pnl_Filter;
		private System.Windows.Forms.ComboBox cbo_Value;
		private System.Windows.Forms.DateTimePicker dt_Date;
		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;
		protected System.Windows.Forms.StatusBar sbr_StatusBar;
		protected System.Windows.Forms.ToolBarButton t_Modify;
		protected System.Windows.Forms.ToolBarButton t_s4;
		protected System.Windows.Forms.ToolBar tbr_Toolbar;
		protected System.Windows.Forms.ToolBarButton t_new;
		protected System.Windows.Forms.ToolBarButton t_Save;
		protected System.Windows.Forms.ToolBarButton t_Cancel;
		protected System.Windows.Forms.ToolBarButton t_S3;
		protected System.Windows.Forms.ToolBarButton t_Preview;
		protected System.Windows.Forms.ToolBarButton t_Print;
		protected System.Windows.Forms.ToolBarButton T_S1;
		protected System.Windows.Forms.ToolBarButton t_Refresh;
		protected ljs.MyGrid grd_Filter;
		protected ljs.MyFlexGrid grd_Top;
		protected ljs.MyFlexGrid grd_Bottom;
		protected TextBox TxtTemp=new TextBox() ;
		protected string m_ConnectReceipt  ;			    //参照返回列值
		protected string m_ConnectNextQuery  ;		    //目标列对应列
		protected string m_QueryName  ;				    //代码转换{表名，代码字段，名称字段}
		protected string m_QueryDesc  ;				    //计算表达式
		protected string m_ColCaption1  ;					//对齐方式折行标识
		protected string m_ColCaption2  ;				    //单元格显示格式
		protected string m_ParameterList;
		//		private JXC_MIS.Interface.IReferto  m_IRefertoForm;
		private System.ComponentModel.IContainer components;
		//								{标题，类型，默认值，参照类型，参照数据源}
		private string m_colCaption ="开始日期,D,@date,1|终止日期,D,@date,1|国标代码,C,,0,SELECT DISTINCT fcName  FROM I_Customer|国标型号,C,,0,18|客户名称,C,18|业务员,C,18|部门,C,18|发票类型,C,18|开票单位,C,18" ;						 //列标题
		private string m_queryName  ;
		private string m_ReportName  ;	
		protected string m_FilterString  ;	
		protected string m_SQL  ;	
		protected ClsInitData InitData=new ClsInitData();
		protected ClsDataBase newDb=new ClsDataBase();
		protected System.Windows.Forms.ToolBarButton t_Menu;
		protected System.Windows.Forms.ContextMenu ctm_Menu;
		protected ClsReceiptMethod newR_Method=new ClsReceiptMethod();
		protected System.Windows.Forms.ToolBarButton t_Delete;
		protected System.Windows.Forms.ImageList img_ImageList;
		private System.Windows.Forms.StatusBarPanel statusBarPanel1;
		protected System.Windows.Forms.Button btnDown;
		private System.Windows.Forms.StatusBar stb_Bar;
		private System.Windows.Forms.StatusBarPanel statusBarPanel3;
		protected ClsDataBaseAccess newADO=new ClsDataBaseAccess();
		protected ClsQueryAttrib newQueryAttrib=new ClsQueryAttrib();

		/// <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 frmTreeFlexGrid()
		{
			//
			// 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(frmTreeFlexGrid));
			this.panel1 = new System.Windows.Forms.Panel();
			this.spt_H = new System.Windows.Forms.Splitter();
			this.grd_Top = new ljs.MyFlexGrid();
			this.grd_Bottom = new ljs.MyFlexGrid();
			this.spt_V = new System.Windows.Forms.Splitter();
			this.cbo_SetupName = new System.Windows.Forms.ComboBox();
			this.tv_Tree = new System.Windows.Forms.TreeView();
			this.t_S2 = new System.Windows.Forms.ToolBarButton();
			this.t_Find = new System.Windows.Forms.ToolBarButton();
			this.t_Exit = new System.Windows.Forms.ToolBarButton();
			this.pnl_Filter = new System.Windows.Forms.Panel();
			this.btnDown = new System.Windows.Forms.Button();
			this.stb_Bar = new System.Windows.Forms.StatusBar();
			this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
			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.sbr_StatusBar = new System.Windows.Forms.StatusBar();
			this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel();
			this.t_Modify = new System.Windows.Forms.ToolBarButton();
			this.t_s4 = new System.Windows.Forms.ToolBarButton();
			this.tbr_Toolbar = new System.Windows.Forms.ToolBar();
			this.t_Menu = new System.Windows.Forms.ToolBarButton();
			this.ctm_Menu = new System.Windows.Forms.ContextMenu();
			this.t_new = new System.Windows.Forms.ToolBarButton();
			this.t_Save = new System.Windows.Forms.ToolBarButton();
			this.t_Cancel = new System.Windows.Forms.ToolBarButton();
			this.t_Delete = 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.img_ImageList = new System.Windows.Forms.ImageList(this.components);
			this.panel1.SuspendLayout();
			this.pnl_Filter.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit();
			this.SuspendLayout();
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this.spt_H);
			this.panel1.Controls.Add(this.grd_Top);
			this.panel1.Controls.Add(this.spt_V);
			this.panel1.Controls.Add(this.cbo_SetupName);
			this.panel1.Controls.Add(this.grd_Bottom);
			this.panel1.Controls.Add(this.tv_Tree);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panel1.Location = new System.Drawing.Point(0, 28);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(704, 446);
			this.panel1.TabIndex = 21;
			this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
			// 
			// spt_H
			// 
			this.spt_H.Dock = System.Windows.Forms.DockStyle.Top;
			this.spt_H.Location = new System.Drawing.Point(128, 198);
			this.spt_H.Name = "spt_H";
			this.spt_H.Size = new System.Drawing.Size(576, 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_Top
			// 
			this.grd_Top.BackColorSel = System.Drawing.SystemColors.Highlight;
			this.grd_Top.BorderStyle = false;
			this.grd_Top.CellBackColor = System.Drawing.Color.White;
			this.grd_Top.CellColLength = 0;
			this.grd_Top.CellForeColor = System.Drawing.SystemColors.ControlText;
			this.grd_Top.CellMultiLine = false;
			this.grd_Top.CellRowLength = 0;
			this.grd_Top.CellTag = null;
			this.grd_Top.Col = 1;
			this.grd_Top.ColCommanFormat = null;
			this.grd_Top.ColLocked = false;
			this.grd_Top.Cols = 2;
			this.grd_Top.ColSel = 1;
			this.grd_Top.DetailFormat = "NO|主表数据";
			this.grd_Top.Dock = System.Windows.Forms.DockStyle.Top;
			this.grd_Top.EnterToTab = true;
			this.grd_Top.FixedBackColor = System.Drawing.SystemColors.Control;
			this.grd_Top.FixedCols = 1;
			this.grd_Top.FormatString = null;
			this.grd_Top.FormatString1 = null;
			this.grd_Top.GridColor = System.Drawing.Color.FromArgb(((System.Byte)(183)), ((System.Byte)(183)), ((System.Byte)(183)));
			this.grd_Top.GridStyle = true;
			this.grd_Top.Location = new System.Drawing.Point(128, 0);
			this.grd_Top.MultiHead = false;
			this.grd_Top.Name = "grd_Top";
			this.grd_Top.OnlyRead = false;
			this.grd_Top.Row = 1;
			this.grd_Top.Rows = 2;
			this.grd_Top.RowSel = 1;
			this.grd_Top.SetCellWidth = null;
			this.grd_Top.Size = new System.Drawing.Size(576, 198);
			this.grd_Top.TabIndex = 18;
			// 
			// 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, 446);
			this.spt_V.TabIndex = 1;
			this.spt_V.TabStop = false;
			this.spt_V.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.spt_V_SplitterMoved);
			// 
			// 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;
			// 
			// grd_Bottom
			// 
			this.grd_Bottom.BackColorSel = System.Drawing.SystemColors.Highlight;
			this.grd_Bottom.BorderStyle = false;
			this.grd_Bottom.CellBackColor = System.Drawing.Color.White;
			this.grd_Bottom.CellColLength = 0;
			this.grd_Bottom.CellForeColor = System.Drawing.SystemColors.ControlText;
			this.grd_Bottom.CellMultiLine = false;
			this.grd_Bottom.CellRowLength = 0;
			this.grd_Bottom.CellTag = null;
			this.grd_Bottom.Col = 1;
			this.grd_Bottom.ColCommanFormat = null;
			this.grd_Bottom.ColLocked = false;
			this.grd_Bottom.Cols = 2;
			this.grd_Bottom.ColSel = 1;
			this.grd_Bottom.DetailFormat = "NO|数据明细";
			this.grd_Bottom.EnterToTab = true;
			this.grd_Bottom.FixedBackColor = System.Drawing.SystemColors.Control;
			this.grd_Bottom.FixedCols = 1;
			this.grd_Bottom.FormatString = null;
			this.grd_Bottom.FormatString1 = null;
			this.grd_Bottom.GridColor = System.Drawing.Color.FromArgb(((System.Byte)(183)), ((System.Byte)(183)), ((System.Byte)(183)));
			this.grd_Bottom.GridStyle = true;
			this.grd_Bottom.Location = new System.Drawing.Point(130, 204);
			this.grd_Bottom.MultiHead = false;
			this.grd_Bottom.Name = "grd_Bottom";
			this.grd_Bottom.OnlyRead = false;
			this.grd_Bottom.Row = 1;
			this.grd_Bottom.Rows = 2;
			this.grd_Bottom.RowSel = 1;
			this.grd_Bottom.SetCellWidth = null;
			this.grd_Bottom.Size = new System.Drawing.Size(460, 194);
			this.grd_Bottom.TabIndex = 19;
			// 
			// tv_Tree
			// 
			this.tv_Tree.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			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, 446);
			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);
			this.tv_Tree.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tv_Tree_AfterSelect);
			// 
			// t_S2
			// 
			this.t_S2.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			this.t_S2.Tag = "";
			// 
			// t_Find
			// 
			this.t_Find.ImageIndex = 33;
			this.t_Find.Tag = "查询";
			this.t_Find.ToolTipText = "查询";
			// 
			// t_Exit
			// 
			this.t_Exit.ImageIndex = 13;
			this.t_Exit.Tag = "退出";
			this.t_Exit.ToolTipText = "退出";
			// 
			// pnl_Filter
			// 
			this.pnl_Filter.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.pnl_Filter.Controls.Add(this.btnDown);
			this.pnl_Filter.Controls.Add(this.stb_Bar);
			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(326, 142);
			this.pnl_Filter.TabIndex = 22;
			this.pnl_Filter.Visible = false;
			// 
			// btnDown
			// 
			this.btnDown.BackColor = System.Drawing.Color.Transparent;
			this.btnDown.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnDown.BackgroundImage")));
			this.btnDown.Font = new System.Drawing.Font("Marlett", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(2)));
			this.btnDown.Location = new System.Drawing.Point(254, 84);
			this.btnDown.Name = "btnDown";
			this.btnDown.Size = new System.Drawing.Size(16, 18);
			this.btnDown.TabIndex = 62;
			this.btnDown.Visible = false;
			this.btnDown.Click += new System.EventHandler(this.btnDown_Click);
			// 
			// stb_Bar
			// 
			this.stb_Bar.Location = new System.Drawing.Point(0, 114);
			this.stb_Bar.Name = "stb_Bar";
			this.stb_Bar.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
																					   this.statusBarPanel1});
			this.stb_Bar.ShowPanels = true;
			this.stb_Bar.Size = new System.Drawing.Size(324, 26);
			this.stb_Bar.TabIndex = 7;
			// 
			// statusBarPanel1
			// 
			this.statusBarPanel1.Text = "正在加载数据.....";
			this.statusBarPanel1.Width = 500;
			// 
			// cbo_Value
			// 
			this.cbo_Value.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cbo_Value.DropDownWidth = 200;
			this.cbo_Value.ItemHeight = 12;
			this.cbo_Value.Location = new System.Drawing.Point(54, 62);
			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(56, 38);
			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(302, 4);
			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.Dock = System.Windows.Forms.DockStyle.Top;
			this.lblCaption.Image = ((System.Drawing.Image)(resources.GetObject("lblCaption.Image")));
			this.lblCaption.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.lblCaption.Location = new System.Drawing.Point(0, 0);
			this.lblCaption.Name = "lblCaption";
			this.lblCaption.Size = new System.Drawing.Size(324, 24);
			this.lblCaption.TabIndex = 2;
			this.lblCaption.Text = "   查询过滤";
			this.lblCaption.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// cmd_Cancel
			// 
			this.cmd_Cancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.cmd_Cancel.Location = new System.Drawing.Point(94, 88);
			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_Close_Click);
			// 
			// cmd_ExeQuery
			// 
			this.cmd_ExeQuery.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.cmd_ExeQuery.Location = new System.Drawing.Point(174, 88);
			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(12, 30);
			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,100,100,100,100,100,100,100,100";
			this.grd_Filter.Size = new System.Drawing.Size(328, 52);
			this.grd_Filter.TabIndex = 6;
			this.grd_Filter.Cell_KeyDown += new ljs.GridCell_KeyDown(this.grd_Filter_Cell_KeyDown);
			this.grd_Filter.Cell_Enter += new ljs.GridCell_Enter(this.grd_Filter_Cell_Enter);
			// 
			// sbr_StatusBar
			// 
			this.sbr_StatusBar.Location = new System.Drawing.Point(0, 474);
			this.sbr_StatusBar.Name = "sbr_StatusBar";
			this.sbr_StatusBar.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
																							 this.statusBarPanel3});
			this.sbr_StatusBar.ShowPanels = true;
			this.sbr_StatusBar.Size = new System.Drawing.Size(704, 25);
			this.sbr_StatusBar.TabIndex = 20;
			// 
			// statusBarPanel3
			// 
			this.statusBarPanel3.Text = "statusBarPanel3";
			this.statusBarPanel3.Width = 1000;
			// 
			// t_Modify
			// 
			this.t_Modify.ImageIndex = 15;
			this.t_Modify.Tag = "修改";
			this.t_Modify.ToolTipText = "修改";
			this.t_Modify.Visible = false;
			// 
			// t_s4
			// 
			this.t_s4.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			this.t_s4.Tag = "";
			// 
			// 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_Menu,
																						   this.t_new,
																						   this.t_Modify,
																						   this.t_Save,
																						   this.t_Cancel,
																						   this.t_Delete,
																						   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(704, 28);
			this.tbr_Toolbar.TabIndex = 19;
			this.tbr_Toolbar.Wrappable = false;
			this.tbr_Toolbar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tbr_Toolbar_ButtonClick);
			// 
			// t_Menu
			// 
			this.t_Menu.DropDownMenu = this.ctm_Menu;
			this.t_Menu.ImageIndex = 29;
			this.t_Menu.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
			this.t_Menu.Tag = "菜单";
			this.t_Menu.ToolTipText = "菜单";
			// 
			// t_new
			// 
			this.t_new.ImageIndex = 32;
			this.t_new.Tag = "新增";
			this.t_new.ToolTipText = "新增";
			this.t_new.Visible = false;
			// 
			// t_Save
			// 
			this.t_Save.ImageIndex = 6;
			this.t_Save.Tag = "保存";
			this.t_Save.ToolTipText = "保存";
			this.t_Save.Visible = false;
			// 
			// t_Cancel
			// 
			this.t_Cancel.ImageIndex = 25;
			this.t_Cancel.Tag = "放弃";
			this.t_Cancel.ToolTipText = "放弃";
			this.t_Cancel.Visible = false;
			// 
			// t_Delete
			// 
			this.t_Delete.ImageIndex = 25;
			this.t_Delete.Tag = "删除";
			this.t_Delete.ToolTipText = "删除";
			this.t_Delete.Visible = false;
			// 
			// t_S3
			// 
			this.t_S3.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			this.t_S3.Tag = "";
			// 
			// t_Preview
			// 
			this.t_Preview.ImageIndex = 18;
			this.t_Preview.Tag = "预览";
			this.t_Preview.ToolTipText = "预览";
			// 
			// t_Print
			// 
			this.t_Print.ImageIndex = 7;
			this.t_Print.Tag = "打印";
			this.t_Print.ToolTipText = "打印";
			// 
			// T_S1
			// 
			this.T_S1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			this.T_S1.Tag = "";
			// 
			// t_Refresh
			// 
			this.t_Refresh.ImageIndex = 20;
			this.t_Refresh.Tag = "刷新";
			this.t_Refresh.ToolTipText = "刷新";
			// 
			// 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;
			// 
			// frmTreeFlexGrid
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(704, 499);
			this.Controls.Add(this.pnl_Filter);
			this.Controls.Add(this.panel1);
			this.Controls.Add(this.tbr_Toolbar);
			this.Controls.Add(this.sbr_StatusBar);
			this.Name = "frmTreeFlexGrid";
			this.Text = "frmTreeFlexGrid";
			this.Resize += new System.EventHandler(this.frmTreeWindows_Resize);
			this.Load += new System.EventHandler(this.frmTreeFlexGrid_Load);
			this.panel1.ResumeLayout(false);
			this.pnl_Filter.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
		{
		
		}

		private void frmTreeFlexGrid_Load(object sender, System.EventArgs e)
		{
		
			tv_Tree.Width =140;
			ShowResize();
			tbr_Toolbar.SendToBack(); 
			//tv_Tree.BringToFront();
//			InitData.ShowGridData(grd_Top,"ljs_Customer");
//			InitData.ShowGridData(grd_Bottom,"ljs_Customer");
		}
		/// <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 OpenFilter(string p_Name)
		{
			newQueryAttrib.LoadQueryDesc(p_Name);
			m_QueryName=newQueryAttrib.QueryName  ;
			m_ConnectReceipt=newQueryAttrib.ConnectReceipt   ;			    // 
			m_ConnectNextQuery=newQueryAttrib.ConnectNextQuery    ;		        // 
			m_ConnectNextQuery=newQueryAttrib.ConnectNextQuery    ;		        // 
			m_QueryDesc=newQueryAttrib.QueryDesc   ;				    // 
			m_ColCaption1=newQueryAttrib.ColCaption1   ;					// 
			m_ColCaption2=newQueryAttrib.ColCaption2   ;				    // 
			m_ParameterList=newQueryAttrib.ParameterList   ;
			InitFilter(m_ParameterList);


		}
		protected virtual void InitFilter(string p_colCaption)
		{
			string [] ArrSplit = null; //     临时数组变量
			//'设置行数，列数
			ArrSplit = p_colCaption.Split('|');
			int rs=ArrSplit.Length;				//总行数
			grd_Filter.Rows =rs    ;			//设置行数
			grd_Filter.Cols = 3 ;    //    
			//'设置列宽
			grd_Filter.SetCellWidth ="80,220,0"; 
			grd_Filter.RowHeightMin =20;;
			grd_Filter.ShowGrid() ;
			grd_Filter.SetColBackColor(SystemColors.Control  ,true);
			for (int i=0;i<rs;i++)
			{
				grd_Filter.CellText(i,0,newQueryAttrib.SplitChar(ArrSplit[i]).RowCaption );//行标题
				grd_Filter.CellText(i,1,newQueryAttrib.SplitChar(ArrSplit[i]).TextDefault);//默认值
				grd_Filter.CellText(i,2,ArrSplit[i]);                                      //过滤参数属性字符串
                 //默认变量转换默认值
				if (grd_Filter.CellText(i,1).ToLower()=="@sysdate")   {grd_Filter.CellText(i,1,System.DateTime.Today.ToShortDateString() );}
				if (grd_Filter.CellText(i,1).ToLower()=="@operator")   {grd_Filter.CellText(i,1,GlobalData.Operator );}
				if (grd_Filter.CellText(i,1).ToLower()=="")    {grd_Filter.CellText(i,1,"<全部>");}
				if (newQueryAttrib.SplitChar(ArrSplit[i]).ReadOnly==true) {this.grd_Filter.GridCell(i,1).Enabled=false;}
				this.grd_Filter.GridCell(i,2).Enabled=false;//最后一列不可用
			}
				this.pnl_Filter.Height =grd_Filter.Height +stb_Bar.Height+lblCaption.Height*3 ;//pnl_Bottom.Height*2+grd_Filter.Top  ;
				this.pnl_Filter.Visible =true;
				this.pnl_Filter.Left =(this.Width -pnl_Filter.Width )/2;
				this.pnl_Filter.Top =(this.Height -pnl_Filter.Height )/2;
				this.pnl_Filter.BringToFront();
				this.cmd_Cancel.Top =stb_Bar.Top -this.cmd_Cancel.Height -5  ;//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 ;
				grd_Bottom.Width =this.Width-10  ;

			}
			else
			{
				grd_Bottom.Left =spt_V.Left +spt_V.Width ;
				grd_Bottom.Width =this.Width -this.grd_Bottom.Left-10  ;

			}
			ShowResizeH();
		}
		private void  ShowResizeH()
		{
			if (grd_Top.Visible ==false){grd_Top.Height =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   ;
				this.grd_Bottom.Height =this.tv_Tree.Height;
			}
			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);

			}
		}
		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;
			}
		}
		/// <summary>
		/// 工具条外观样式  p_Type=true 带文字显示   p_Type=false不带文字显示 只有图标
		/// </summary>
		/// <param name="p_Type"></param>
		public void ToolBarType(bool p_Type)
		{
			this.newR_Method.ToolBarType(this.tbr_Toolbar, p_Type); 
		}
		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;
			int j=grd_Filter.Rows ;
			m_FilterString="";
			m_SQL=m_QueryName+" ";
			for (int i=0;i<j;i++)
			{
				m_FilterString=m_FilterString+grd_Filter.CellText(i,0)+":"+grd_Filter.CellText(i,1)+" ";
				m_SQL=m_SQL+ "'"+grd_Filter.CellText(i,1)+"',";
			}
			    this.sbr_StatusBar.Panels[0].Text =m_FilterString; 
                m_SQL=m_SQL.Substring(0,m_SQL.Length-1); 
				grd_Bottom.Clear();
				InitData.ShowGridData(grd_Bottom,this.m_SQL );

		}

		protected virtual void grd_Filter_Cell_Enter(object sender, System.EventArgs e)
		{
			if (grd_Filter.Col==1)
			{
				TextBox control = (TextBox) sender ; 
				TxtTemp =control;
				btnDown.Top  =control.Top+control.Parent.Top+1 ;
				btnDown.Left  =control.Left+control.Parent.Left +control.Width -btnDown.Width  ;
				btnDown.Height   =control.Height-1 ;
				btnDown.Visible =true;
				btnDown.BringToFront() ;
			}

		}
		protected virtual void grd_Filter_Cell_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode ==Keys.Down || e.KeyCode ==Keys.Up )
			{
				if (btnDown.Visible ==true) ShowReferto();
			}

		}

		private void btnDown_Click(object sender, System.EventArgs e)
		{
			ShowReferto();
		}
		/// <summary>
		/// 显示参照
		/// </summary>
		protected virtual void ShowReferto()
		{  
			IReferto f=null; 
			f= new frmReferto();
			f.DataSource =newQueryAttrib.SplitChar(grd_Filter.CellText(grd_Filter.Row,2)).RefertoDataSource;//newCellAttrib.RefertoDataSource ;
			f.OtherFilter="";//m_OtherFilter;//参照其他过滤条件
				
			f.Location = new Point(this.Parent.Left +this.btnDown.Parent.Left + this.btnDown.Left + this.Left+this.btnDown.Width-TxtTemp.Width ,this.Parent.Top +this.grd_Filter.Top +this.btnDown.Parent.Top +this.btnDown.Height*2+this.tbr_Toolbar.Height +this.btnDown.Top + this.Top);
			f.DefaultValue=TxtTemp.Text ;
			f.RefertoType =int.Parse(newQueryAttrib.SplitChar(grd_Filter.CellText(grd_Filter.Row,2)).RefertoType ) ;
			f.ShowDialog();
			System.Collections.Hashtable ReturnValues= f.GetReturnHashtable();
			if (ReturnValues==null  || ReturnValues.Count==0) return;
			TxtTemp.Text =ReturnValues[0].ToString().Trim() ;
			TxtTemp.Focus();

		}
		private void FindReceipt(string p_Item,string p_ReceiptNO)
		{
			Form f=new Form();
			string strFormName ="";  //JXC_MIS.UserTier.ToolForm.frmReceiptSetup
			System.Data.DataSet dst = new System.Data.DataSet();
			ClsDataBaseAccess AdoDB=new ClsDataBaseAccess();
			dst =AdoDB.GetDataSet("SELECT fcLoadFormName FROM S_MenuItem  Where fcMenuCaption='"+p_Item+"'");
			int rs=dst.Tables[0].Rows.Count ;
			System.Data.DataRow dr =null;
			if (rs>0)
			{
				dr = dst.Tables[0].Rows[0];
				strFormName =dr[0].ToString();
			}
			if (strFormName=="")
			{
				MessageBox.Show("没有找到可运行的窗体！", "提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
				return;
			}
			f=(Form)InitData.LoadForm(strFormName);
			f.MdiParent = this;
			f.Text= p_Item;
			f.Show();
//			f.InitReceiptData(p_ReceiptNO);



		}
		private void tv_Tree_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
		{
		
		}

	



	}
}
