using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using ljs;
using JXC_MIS.MyClass;
using JXC_MIS.DataTier;
namespace JXC_MIS.UserTier.BaseForm
{
	/// <summary>
	/// frmVoucherBase 的摘要说明。
	/// </summary>
	public class frmVoucherBase : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label lbl_Title1;
		private System.Windows.Forms.Label lbl_Title2;
		private System.Windows.Forms.Button btnDown;
		private System.Windows.Forms.Label lblBorder;
		ClsVoucherBase newReceipt=new ClsVoucherBase();
		ClsCellDesc newCellDesc=new ClsCellDesc();

		ClsDataBase newDB=new ClsDataBase() ;
		ClsDataBaseAccess newADO=new ClsDataBaseAccess();
		//		类的属性所对应的变量，采用属性名前加“m_”(我为_)前缀的形式
		private string m_FirstChar="" ;				//               单据编号开头字符如"XS"+2004-09-0001
		private bool m_EditFlag=true ;				//               标志单据是添加还是修改状态
		private string m_StabarText ;			    //                   保存状态提示

		private int m_WriteYesNo=1  ;			    //                   单据状态是否只读(0-只读 1-可编辑)

		private string m_MasterTableName="I_InLib" ;		//                   主表表名
		private string m_MasterFeildName="FcInLibNo, FcInLibType, FcCustomerCode, FdMakeDate, fcOperatror, FcLibDesc, fcDepartment, FcWorkMen, FcLibMen, FcChecker, fcMemo"  ;		//                   主表字段名称
		private string m_DetailTableName  ;		//                   明细表表名
		private string m_DetailFeildName  ;		//                   明细表字段名称
		private string m_KeyFieldName  ;    	//                   主表和明细表关联的主键（一般是单据编号）

		private string m_MasterViewName  ;		//                   主视图名
		private string m_MasterViewFeildName  ; //                   主视图字段名称
		private string m_DetailViewName  ;		//                   明细视图名
		private string m_DetailViewFeildName  ; //                   明细视图字段名称
		private string m_KeyViewFieldName ;     //                   主表和明细表关联的主键（一般是单据编号）

//		private string m_Operator ;									//  操作人员，一般为了控制单据权限时用到，只能看到，该操作员自己的单据
//		private string m_MakeDateField ;									// 制单日期字段（ 能够看到的日期范围的单据）
		private string m_QueryWhere ;									// 一般为了控制单据权限时用到,传递过滤条件
		private string m_FileNO ="文件号：OR/28936489" ;							//  文件号
		private string m_ReceiptName ="单据名称" ;									//  单据名称
		private string m_ReceiptTitle1="单据标题（主标题）"  ;						//  单据标题
		private string m_ReceiptTitle2="北京XX科技有限责任公司（副标题）"  ;		//  副标题
		private int m_detailHeight=230  ;											// 单据高
		private int m_ReceiptWidth=750  ;											// 单据宽
		//		private double m_ReceiptFontSize  ;		//                   单据字体大小
		//		private double m_TitleFontSize  ;		//                   单据标题字体大小
		
		private string m_PageTopFormat="制单人：|>|日期：|<;2004-01-01;T;0;|单据编号：|<;XS200401001;f;2"  ;		//                   新单据页顶内容标题      [对齐方式;是否编辑; 默认值;参照类型;参照数据源]
		private string m_PageHeaderFormat="页头标题1|>;北京;;1;|页头标题2|<;刘金山;F;3|页头标题3|$|页头标题4|>|^;页头标题5||^;页头标题6|"  ;	//                   新单据标题内容标题
		private string m_PageFooterFormat="1.质量要求：||2.交货地点：||3.运费负担：||4.交付方式：|$|5.付款方式：||6.交收提出异议期限：||7.其他事项：|| 合同评审人：|";
		private string m_PageOtherFormat="合计大写金额|<;F;;;;False|小写|";//$|^;页脚标题||页脚标题|<;刘;;;;false"  ;	//                   新单据标题内容标题
//		private string m_PageBottomFormat="页底标题1：|<;刘;;;;false|页底标题2：|<;刘;;;;false|页底标题3：|<;刘;;;;false"    ;	//                   新单据明细内容标题
		private string m_PageBottomFormat="备货人：||仓库主管：|| 产品核对：||发货人：|$|交(发)货日期：||运单号码：||运费金额||用户提货未付款签字：|";
//		private string m_PageBottomFormat="1.质量要求：||2.交货地点：||3.运费负担：||4.交付方式：|$|5.付款方式：||6.交收提出异议期限：||7.其他事项：|| 合同评审人：|$|备货人：||仓库主管：|| 产品核对：||发货人：|$|交(发)货日期：||运单号码：||运费金额||用户提货未付款签字：|$|日期：|";

		private string m_PageCaptionFormat1;//="0序号|1产品代码|2产品名称|3产品型号|4需方型号|5包装形式|6最小包装量|7单位|8仓库|入库|入库|入库|入库|出库|出库|出库|16库存数量|17平均单价|18金额|19列|20备注|21列|22列|23列|24列|25列|26列|27列";	//                   新单据内容标题
		private string m_PageCaptionFormat2="0序号|1产品代码|2产品名称|3产品型号|4需方型号|5包装形式|6最小包装量|7单位|8仓库|9入库日期|10入库数量|11入库单价|12入库金额|13出库数量|14出库单价|15出库金额|16库存数量|17平均单价|18金额|19列|20列|21列|22列|23列|24列|25列|26列|27列"  ;	//                   新单据内容标题
		//[对齐方式; 默认值;是否编辑;参照类型;参照数据源;是否保存;是否代码转换{表名，代码字段，名称字段};数据保存时数据验证（0或空=可以为空，1=不为空，2=日期验证，3=数值验证)；该列是否列合计（sum）]
		private string m_PageDetailFormat="0序号|<;;;1|<;;;2|<;;;3|<;;;4|<;;;5|6|7列|列|列|列|列|<列|<列|<列|<15列|16列|17列|18列|19列|20列|21列|22列|23列|24列|25列|26列|27列"  ;    //                   新单据明细内容标题
	
		private string m_PageDetailColWidth  ;								 //                   明细表格列宽
		private string m_PageTopColWidth="50,220,50,250,80,100"  ;			 //                   页顶表格列宽
		private string m_PageHeaderColWidth="100,80,100,170,100,200"  ;		  //               页头表格列宽
		private string m_PageFooterColWidth ="100,100,80,100,80,100,90,100" ;//"100,400,100,150" ;			  //               页脚表格列宽
		private string m_PageOtherColWidth ="100,460,90,100" ;			  //               页脚表格列宽

		private string m_PageBottomColWidth ="100,100,80,100,80,100,90,100" ;		  //               页底表格列宽

		TextBox [] ArrCell=null;
		TextBox TxtTemp=new TextBox() ;
		private System.Windows.Forms.StatusBarPanel statusBarPanel1;
		private System.Windows.Forms.StatusBarPanel statusBarPanel2;
		private System.Windows.Forms.StatusBarPanel statusBarPanel5;
		private System.Windows.Forms.StatusBarPanel statusBarPanel6;
		private ljs.MyGrid grd_Top;
		private ljs.MyGrid grd_Header;
		private ljs.MyGrid grd_Footer;
		private ljs.MyGrid grd_Bottom;
		private System.Windows.Forms.StatusBar sbr_statusBar;
		private System.Windows.Forms.ImageList img_ImageList;
		private System.Windows.Forms.PictureBox pictureBox1;
		private System.Windows.Forms.Label lbl_FlieNo;
		private ljs.MyFlexGrid grd_Detail;
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.ToolBar tbr_Toolbar;
		private System.Windows.Forms.ToolBarButton t_Menu;
		private System.Windows.Forms.ToolBarButton t_new;
		private System.Windows.Forms.ToolBarButton t_Modify;
		private System.Windows.Forms.ToolBarButton t_Save;
		private System.Windows.Forms.ToolBarButton t_Cancel;
		private System.Windows.Forms.ToolBarButton t_S3;
		private System.Windows.Forms.ToolBarButton t_Preview;
		private System.Windows.Forms.ToolBarButton t_Print;
		private System.Windows.Forms.ToolBarButton T_S1;
		private System.Windows.Forms.ToolBarButton t_Refresh;
		private System.Windows.Forms.ToolBarButton t_Find;
		private System.Windows.Forms.ToolBarButton t_First;
		private System.Windows.Forms.ToolBarButton t_Up;
		private System.Windows.Forms.ToolBarButton t_Down;
		private System.Windows.Forms.ToolBarButton t_Last;
		private System.Windows.Forms.ToolBarButton t_S2;
		private System.Windows.Forms.ToolBarButton t_Exit;
		private System.Windows.Forms.ComboBox CboReceiptNo;
		private ljs.MyGrid grd_Other;
		private System.Windows.Forms.Panel pnl_Face;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.StatusBarPanel page;
		private System.Windows.Forms.ComboBox comboBox1;
		private System.ComponentModel.IContainer components;//null;
		//      设置属性值
		/// <summary>
		/// 单据状态是否只读(0-只读 1-可编辑)
		/// </summary>
		public int WriteYesNo
		{ 
			get {return m_WriteYesNo;} 
			set { m_WriteYesNo=value;} 
		} 

		/// <summary>
		/// 单据编号开头字符如"XS"+2004-09-0001
		/// </summary>
		public string FirstChar
		{ 
			get {return m_FirstChar;} 
			set { m_FirstChar=value;} 
		} 

		/// <summary>
		/// 文件号
		/// </summary>
		public string FileNO
		{ 
			set { m_FileNO=value;} 
		} 

		/// <summary>
		/// 设置单据名称
		/// </summary>
		public string ReceiptName
		{ 
			get {return m_ReceiptName;} 
			set { m_ReceiptName=value;} 
		} 

		/// <summary>
		/// 设置单据标题1
		/// </summary>
		public string ReceiptTitle1
		{ 
			get {return m_ReceiptTitle1;} 
			set { m_ReceiptTitle1=value;} 
		} 
		/// <summary>
		/// 设置单据标题2
		/// </summary>
		public string ReceiptTitle2
		{ 
			get {return m_ReceiptTitle2;} 
			set { m_ReceiptTitle2=value;} 
		} 

		/// <summary>
		/// 设置单据高
		/// </summary>
		public int DetailHeight
		{ 
			get {return m_detailHeight;} 
			set { m_detailHeight=value;} 
		} 

		/// <summary>
		/// 设置单据宽
		/// </summary>
		public int ReceiptWidth
		{ 
			get {return m_ReceiptWidth;} 
			set { m_ReceiptWidth=value;} 
		} 

		/// <summary>
		/// 设置主表表名
		/// </summary>
		public string MasterTableName
		{ 
			get {return m_MasterTableName;} 
			set { m_MasterTableName=value;} 
		} 

		/// <summary>
		/// 设置主表字段名称
		/// </summary>
		public string MasterFeildName
		{ 
			get {return m_MasterFeildName;} 
			set { m_MasterFeildName=value;} 
		} 

		/// <summary>
		/// 设置明细表表名
		/// </summary>
		public string DetailTableName
		{ 
			get {return m_DetailTableName;} 
			set { m_DetailTableName=value;} 
		} 

		/// <summary>
		/// 设置明细表字段名称
		/// </summary>
		public string DetailFeildName
		{ 
			get {return m_DetailFeildName;} 
			set { m_DetailFeildName=value;} 
		} 

		/// <summary>
		/// 设置主表和明细表关联的主键（一般是单据编号）
		/// </summary>
		public string KeyFieldName
		{ 
			get {return m_KeyFieldName;} 
			set { m_KeyFieldName=value;} 
		} 


		
			/// <summary>
			/// 设置主视图名称
			/// </summary>
			public string MasterViewName
			{ 
				get {return m_MasterViewName;} 
				set { m_MasterViewName=value;} 
			} 

		/// <summary>
		/// 设置主视图字段名称
		/// </summary>
		public string MasterViewFeildName
		{ 
			get {return m_MasterViewFeildName;} 
			set { m_MasterViewFeildName=value;} 
		} 

		/// <summary>
		/// 设置明细视图名
		/// </summary>
		public string DetailViewName
		{ 
			get {return m_DetailViewName;} 
			set { m_DetailViewName=value;} 
		} 

		/// <summary>
		/// 设置明细视图字段名称
		/// </summary>
		public string DetailViewFeildName
		{ 
			get {return m_DetailViewFeildName;} 
			set { m_DetailViewFeildName=value;} 
		} 

		/// <summary>
		/// 设置视图主表和明细表关联的主键（一般是单据编号）
		/// </summary>
		public string KeyViewFieldName
		{ 
			get {return m_KeyViewFieldName;} 
			set { m_KeyViewFieldName=value;} 
		} 
		/// <summary>
		/// 设置页顶表标题
		/// </summary>
		public string PageTopFormat
		{ 
			get {return m_PageTopFormat;} 
			set { m_PageTopFormat=value;} 
		} 

		/// <summary>
		/// 设置页顶表格列宽
		/// </summary>
		public string PageTopColWidth
		{ 
			get {return m_PageTopColWidth;} 
			set { m_PageTopColWidth=value;} 
		} 

		
		/// <summary>
		/// 设置页头表标题
		/// </summary>
		public string PageHeaderFormat
		{ 
			get {return m_PageHeaderFormat;} 
			set { m_PageHeaderFormat=value;} 
		} 

		/// <summary>
		/// 设置页头表格列宽
		/// </summary>
		public string PageHeaderColWidth
		{ 
			get {return m_PageHeaderColWidth;} 
			set { m_PageHeaderColWidth=value;} 
		} 
		/// <summary>
		/// 设置明细列标题1
		/// </summary>
		public string PageCaptionFormat1
		{ 
			get {return m_PageCaptionFormat1;} 
			set { m_PageCaptionFormat1=value;} 
		} 
		/// <summary>
		/// 设置明细列标题2
		/// </summary>
		public string PageCaptionFormat2
		{ 
			get {return m_PageCaptionFormat2;} 
			set { m_PageCaptionFormat2=value;} 
		} 
		/// <summary>
		/// 设置明细列标题
		/// </summary>
		public string PageDetailFormat
		{ 
			get {return m_PageDetailFormat;} 
			set { m_PageDetailFormat=value;} 
		} 
		/// <summary>
		/// 设置明细列宽
		/// </summary>
		public string PageDetailColWidth
		{ 
			get {return m_PageDetailColWidth;} 
			set { m_PageDetailColWidth=value;} 
		} 
		/// <summary>
		/// 设置页脚
		/// </summary>
		public string PageFooterFormat
		{ 
			get {return m_PageFooterFormat;} 
			set { m_PageFooterFormat=value;} 
		} 


		/// <summary>
		/// 设置页脚表格列宽
		/// </summary>
		public string PageFooterColWidth
		{ 
			get {return m_PageFooterColWidth;} 
			set { m_PageFooterColWidth=value;} 
		} 

		
		/// <summary>
		/// 设置页底
		/// </summary>
		public string PageBottomFormat
		{ 
			get {return m_PageBottomFormat;} 
			set { m_PageBottomFormat=value;} 
		} 

		/// <summary>
		/// 设置页底表格列宽
		/// </summary>
		public string PageBottomColWidth
		{ 
			get {return m_PageBottomColWidth;} 
			set { m_PageBottomColWidth=value;} 
		} 
		/// <summary>
		/// 设置其他
		/// </summary>
		public string PageOtherFormat
		{ 
			get {return m_PageOtherFormat;} 
			set { m_PageOtherFormat=value;} 
		} 

		/// <summary>
		/// 设置其他表格列宽
		/// </summary>
		public string PageOtherColWidth
		{ 
			get {return m_PageOtherColWidth;} 
			set { m_PageOtherColWidth=value;} 
		} 

		/// <summary>
		/// 设置明细表格列宽
		/// </summary>
		public string DetailColWidth
		{ 
			get {return m_PageDetailColWidth;} 
			set { m_PageDetailColWidth=value;} 
		}

		public frmVoucherBase()
		{
			//
			// 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(frmVoucherBase));
			this.img_ImageList = new System.Windows.Forms.ImageList(this.components);
			this.lbl_Title1 = new System.Windows.Forms.Label();
			this.lbl_Title2 = new System.Windows.Forms.Label();
			this.btnDown = new System.Windows.Forms.Button();
			this.lblBorder = new System.Windows.Forms.Label();
			this.sbr_statusBar = new System.Windows.Forms.StatusBar();
			this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
			this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
			this.page = new System.Windows.Forms.StatusBarPanel();
			this.statusBarPanel5 = new System.Windows.Forms.StatusBarPanel();
			this.statusBarPanel6 = new System.Windows.Forms.StatusBarPanel();
			this.grd_Top = new ljs.MyGrid();
			this.grd_Header = new ljs.MyGrid();
			this.grd_Footer = new ljs.MyGrid();
			this.grd_Bottom = new ljs.MyGrid();
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.lbl_FlieNo = new System.Windows.Forms.Label();
			this.grd_Detail = new ljs.MyFlexGrid();
			this.panel1 = new System.Windows.Forms.Panel();
			this.comboBox1 = new System.Windows.Forms.ComboBox();
			this.CboReceiptNo = new System.Windows.Forms.ComboBox();
			this.label1 = new System.Windows.Forms.Label();
			this.tbr_Toolbar = new System.Windows.Forms.ToolBar();
			this.t_Menu = new System.Windows.Forms.ToolBarButton();
			this.t_new = new System.Windows.Forms.ToolBarButton();
			this.t_Modify = new System.Windows.Forms.ToolBarButton();
			this.t_Save = 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_First = new System.Windows.Forms.ToolBarButton();
			this.t_Up = new System.Windows.Forms.ToolBarButton();
			this.t_Down = new System.Windows.Forms.ToolBarButton();
			this.t_Last = new System.Windows.Forms.ToolBarButton();
			this.t_S2 = new System.Windows.Forms.ToolBarButton();
			this.t_Exit = new System.Windows.Forms.ToolBarButton();
			this.grd_Other = new ljs.MyGrid();
			this.pnl_Face = new System.Windows.Forms.Panel();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.page)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel5)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel6)).BeginInit();
			this.panel1.SuspendLayout();
			this.SuspendLayout();
			// 
			// 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;
			// 
			// lbl_Title1
			// 
			this.lbl_Title1.Font = new System.Drawing.Font("宋体", 20F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lbl_Title1.ForeColor = System.Drawing.Color.Navy;
			this.lbl_Title1.Location = new System.Drawing.Point(26, 55);
			this.lbl_Title1.Name = "lbl_Title1";
			this.lbl_Title1.Size = new System.Drawing.Size(750, 30);
			this.lbl_Title1.TabIndex = 3;
			this.lbl_Title1.Text = "销售单（主标题）";
			this.lbl_Title1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// lbl_Title2
			// 
			this.lbl_Title2.ForeColor = System.Drawing.Color.Red;
			this.lbl_Title2.Location = new System.Drawing.Point(26, 81);
			this.lbl_Title2.Name = "lbl_Title2";
			this.lbl_Title2.Size = new System.Drawing.Size(750, 17);
			this.lbl_Title2.TabIndex = 4;
			this.lbl_Title2.Text = "北京XX科技有限公司（副标题）";
			this.lbl_Title2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// btnDown
			// 
			this.btnDown.BackColor = System.Drawing.Color.Transparent;
			this.btnDown.Font = new System.Drawing.Font("Marlett", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(2)));
			this.btnDown.Image = ((System.Drawing.Image)(resources.GetObject("btnDown.Image")));
			this.btnDown.Location = new System.Drawing.Point(32, 54);
			this.btnDown.Name = "btnDown";
			this.btnDown.Size = new System.Drawing.Size(20, 20);
			this.btnDown.TabIndex = 28;
			this.btnDown.Visible = false;
			this.btnDown.Click += new System.EventHandler(this.btnDown_Click);
			// 
			// lblBorder
			// 
			this.lblBorder.BackColor = System.Drawing.Color.Transparent;
			this.lblBorder.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.lblBorder.Location = new System.Drawing.Point(62, 56);
			this.lblBorder.Name = "lblBorder";
			this.lblBorder.Size = new System.Drawing.Size(196, 26);
			this.lblBorder.TabIndex = 34;
			this.lblBorder.Text = "label1";
			// 
			// sbr_statusBar
			// 
			this.sbr_statusBar.Location = new System.Drawing.Point(0, 510);
			this.sbr_statusBar.Name = "sbr_statusBar";
			this.sbr_statusBar.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
																							 this.statusBarPanel1,
																							 this.statusBarPanel2,
																							 this.page,
																							 this.statusBarPanel5,
																							 this.statusBarPanel6});
			this.sbr_statusBar.ShowPanels = true;
			this.sbr_statusBar.Size = new System.Drawing.Size(788, 26);
			this.sbr_statusBar.TabIndex = 41;
			this.sbr_statusBar.Text = "就绪...";
			// 
			// statusBarPanel1
			// 
			this.statusBarPanel1.Icon = ((System.Drawing.Icon)(resources.GetObject("statusBarPanel1.Icon")));
			this.statusBarPanel1.Width = 400;
			// 
			// page
			// 
			this.page.Text = "第 1 页/共 1 页";
			// 
			// statusBarPanel5
			// 
			this.statusBarPanel5.Text = "帐期:2004/09/01--2004/10/01";
			this.statusBarPanel5.Width = 400;
			// 
			// statusBarPanel6
			// 
			this.statusBarPanel6.Style = System.Windows.Forms.StatusBarPanelStyle.OwnerDraw;
			// 
			// grd_Top
			// 
			this.grd_Top.BackColor = System.Drawing.Color.White;
			this.grd_Top.BorderStyle = false;
			this.grd_Top.BorderWidth = 0;
			this.grd_Top.CellBackColor = System.Drawing.Color.White;
			this.grd_Top.CellColLength = -1;
			this.grd_Top.CellFontSize = 9F;
			this.grd_Top.CellForeColor = System.Drawing.Color.Black;
			this.grd_Top.CellHeight = 0;
			this.grd_Top.CellRowLength = -1;
			this.grd_Top.CellTag = null;
			this.grd_Top.Col = 0;
			this.grd_Top.Cols = 6;
			this.grd_Top.EnterToTab = true;
			this.grd_Top.GridStyle = true;
			this.grd_Top.Location = new System.Drawing.Point(24, 104);
			this.grd_Top.Name = "grd_Top";
			this.grd_Top.ReadCellBackColor = System.Drawing.Color.White;
			this.grd_Top.ReadCellForeColor = System.Drawing.Color.Black;
			this.grd_Top.Row = 0;
			this.grd_Top.RowHeightMin = 20;
			this.grd_Top.Rows = 2;
			this.grd_Top.SetCellWidth = "100,100,100,100,100,100,100,100";
			this.grd_Top.Size = new System.Drawing.Size(754, 26);
			this.grd_Top.TabIndex = 42;
			this.grd_Top.Cell_Enter += new ljs.GridCell_Enter(this.grd_Top_Cell_Enter);
			// 
			// grd_Header
			// 
			this.grd_Header.BackColor = System.Drawing.Color.White;
			this.grd_Header.BorderStyle = false;
			this.grd_Header.BorderWidth = 0;
			this.grd_Header.CellBackColor = System.Drawing.Color.White;
			this.grd_Header.CellColLength = -1;
			this.grd_Header.CellFontSize = 9F;
			this.grd_Header.CellForeColor = System.Drawing.Color.Black;
			this.grd_Header.CellHeight = 0;
			this.grd_Header.CellRowLength = -1;
			this.grd_Header.CellTag = null;
			this.grd_Header.Col = 0;
			this.grd_Header.Cols = 6;
			this.grd_Header.EnterToTab = true;
			this.grd_Header.GridStyle = true;
			this.grd_Header.Location = new System.Drawing.Point(26, 132);
			this.grd_Header.Name = "grd_Header";
			this.grd_Header.ReadCellBackColor = System.Drawing.Color.White;
			this.grd_Header.ReadCellForeColor = System.Drawing.Color.Black;
			this.grd_Header.Row = 0;
			this.grd_Header.RowHeightMin = 20;
			this.grd_Header.Rows = 2;
			this.grd_Header.SetCellWidth = "100,100,100,100,100,100,100,100";
			this.grd_Header.Size = new System.Drawing.Size(262, 28);
			this.grd_Header.TabIndex = 44;
			this.grd_Header.Load += new System.EventHandler(this.grd_Header_Load);
			this.grd_Header.Cell_Enter += new ljs.GridCell_Enter(this.grd_Top_Cell_Enter);
			// 
			// grd_Footer
			// 
			this.grd_Footer.BackColor = System.Drawing.Color.White;
			this.grd_Footer.BorderStyle = false;
			this.grd_Footer.BorderWidth = 0;
			this.grd_Footer.CellBackColor = System.Drawing.Color.White;
			this.grd_Footer.CellColLength = -1;
			this.grd_Footer.CellFontSize = 9F;
			this.grd_Footer.CellForeColor = System.Drawing.Color.Black;
			this.grd_Footer.CellHeight = 0;
			this.grd_Footer.CellRowLength = -1;
			this.grd_Footer.CellTag = null;
			this.grd_Footer.Col = 0;
			this.grd_Footer.Cols = 6;
			this.grd_Footer.EnterToTab = true;
			this.grd_Footer.GridStyle = true;
			this.grd_Footer.Location = new System.Drawing.Point(28, 434);
			this.grd_Footer.Name = "grd_Footer";
			this.grd_Footer.ReadCellBackColor = System.Drawing.Color.White;
			this.grd_Footer.ReadCellForeColor = System.Drawing.Color.Black;
			this.grd_Footer.Row = 0;
			this.grd_Footer.RowHeightMin = 20;
			this.grd_Footer.Rows = 2;
			this.grd_Footer.SetCellWidth = "100,100,100,100,100,100,100,100";
			this.grd_Footer.Size = new System.Drawing.Size(118, 14);
			this.grd_Footer.TabIndex = 45;
			this.grd_Footer.Cell_Enter += new ljs.GridCell_Enter(this.grd_Top_Cell_Enter);
			// 
			// grd_Bottom
			// 
			this.grd_Bottom.BackColor = System.Drawing.Color.White;
			this.grd_Bottom.BorderStyle = false;
			this.grd_Bottom.BorderWidth = 0;
			this.grd_Bottom.CellBackColor = System.Drawing.Color.White;
			this.grd_Bottom.CellColLength = -1;
			this.grd_Bottom.CellFontSize = 9F;
			this.grd_Bottom.CellForeColor = System.Drawing.Color.Black;
			this.grd_Bottom.CellHeight = 0;
			this.grd_Bottom.CellRowLength = -1;
			this.grd_Bottom.CellTag = null;
			this.grd_Bottom.Col = 0;
			this.grd_Bottom.Cols = 6;
			this.grd_Bottom.EnterToTab = true;
			this.grd_Bottom.GridStyle = true;
			this.grd_Bottom.Location = new System.Drawing.Point(28, 452);
			this.grd_Bottom.Name = "grd_Bottom";
			this.grd_Bottom.ReadCellBackColor = System.Drawing.Color.White;
			this.grd_Bottom.ReadCellForeColor = System.Drawing.Color.Black;
			this.grd_Bottom.Row = 0;
			this.grd_Bottom.RowHeightMin = 20;
			this.grd_Bottom.Rows = 2;
			this.grd_Bottom.SetCellWidth = "100,100,100,100,100,100,100,100";
			this.grd_Bottom.Size = new System.Drawing.Size(92, 58);
			this.grd_Bottom.TabIndex = 46;
			this.grd_Bottom.Cell_Enter += new ljs.GridCell_Enter(this.grd_Top_Cell_Enter);
			// 
			// pictureBox1
			// 
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(26, 54);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(44, 36);
			this.pictureBox1.TabIndex = 48;
			this.pictureBox1.TabStop = false;
			// 
			// lbl_FlieNo
			// 
			this.lbl_FlieNo.ForeColor = System.Drawing.Color.Navy;
			this.lbl_FlieNo.Location = new System.Drawing.Point(626, 54);
			this.lbl_FlieNo.Name = "lbl_FlieNo";
			this.lbl_FlieNo.Size = new System.Drawing.Size(136, 20);
			this.lbl_FlieNo.TabIndex = 49;
			this.lbl_FlieNo.Text = "文件号：OR/39840934";
			// 
			// grd_Detail
			// 
			this.grd_Detail.BorderStyle = false;
			this.grd_Detail.CellBackColor = System.Drawing.Color.White;
			this.grd_Detail.CellColLength = 0;
			this.grd_Detail.CellForeColor = System.Drawing.Color.Black;
			this.grd_Detail.CellLocked = false;
			this.grd_Detail.CellRowLength = 0;
			this.grd_Detail.CellTag = null;
			this.grd_Detail.Col = 0;
			this.grd_Detail.Cols = 2;
			this.grd_Detail.DetailFormat = null;
			this.grd_Detail.EnterToTab = true;
			this.grd_Detail.FixedBackColor = System.Drawing.Color.Empty;
			this.grd_Detail.FixedCols = 1;
			this.grd_Detail.FormatString = null;
			this.grd_Detail.FormatString1 = null;
			this.grd_Detail.GridStyle = true;
			this.grd_Detail.Location = new System.Drawing.Point(26, 162);
			this.grd_Detail.Name = "grd_Detail";
			this.grd_Detail.Row = 0;
			this.grd_Detail.Rows = 2;
			this.grd_Detail.SetCellWidth = null;
			this.grd_Detail.Size = new System.Drawing.Size(752, 248);
			this.grd_Detail.TabIndex = 50;
			this.grd_Detail.Scroll += new ljs.FlexGrid_Scroll(this.grd_Detail_Scroll);
			this.grd_Detail.Cell_Enter += new ljs.FlexGridCell_Enter(this.grd_Detail_Cell_Enter);
			// 
			// panel1
			// 
			this.panel1.BackColor = System.Drawing.Color.Transparent;
			this.panel1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel1.BackgroundImage")));
			this.panel1.Controls.Add(this.comboBox1);
			this.panel1.Controls.Add(this.CboReceiptNo);
			this.panel1.Controls.Add(this.label1);
			this.panel1.Controls.Add(this.tbr_Toolbar);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
			this.panel1.Location = new System.Drawing.Point(0, 0);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(788, 42);
			this.panel1.TabIndex = 51;
			// 
			// comboBox1
			// 
			this.comboBox1.BackColor = System.Drawing.Color.DodgerBlue;
			this.comboBox1.Items.AddRange(new object[] {
														   "1",
														   "2",
														   "3",
														   "4",
														   "5",
														   "6",
														   "7",
														   "8",
														   "9",
														   "10",
														   "11",
														   "12"});
			this.comboBox1.Location = new System.Drawing.Point(584, 16);
			this.comboBox1.Name = "comboBox1";
			this.comboBox1.Size = new System.Drawing.Size(38, 20);
			this.comboBox1.TabIndex = 54;
			this.comboBox1.Text = "10";
			// 
			// CboReceiptNo
			// 
			this.CboReceiptNo.BackColor = System.Drawing.Color.DodgerBlue;
			this.CboReceiptNo.Location = new System.Drawing.Point(674, 16);
			this.CboReceiptNo.Name = "CboReceiptNo";
			this.CboReceiptNo.Size = new System.Drawing.Size(106, 20);
			this.CboReceiptNo.TabIndex = 52;
			this.CboReceiptNo.Click += new System.EventHandler(this.CboReceiptNo_Click);
			this.CboReceiptNo.SelectedIndexChanged += new System.EventHandler(this.CboReceiptNo_SelectedIndexChanged);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(556, 20);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(180, 14);
			this.label1.TabIndex = 53;
			this.label1.Text = "月份       快速定位";
			// 
			// tbr_Toolbar
			// 
			this.tbr_Toolbar.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
			this.tbr_Toolbar.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.tbr_Toolbar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						   this.t_Menu,
																						   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_First,
																						   this.t_Up,
																						   this.t_Down,
																						   this.t_Last,
																						   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(788, 42);
			this.tbr_Toolbar.TabIndex = 1;
			this.tbr_Toolbar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tbr_Toolbar_ButtonClick);
			// 
			// t_Menu
			// 
			this.t_Menu.ImageIndex = 8;
			this.t_Menu.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
			this.t_Menu.Text = "菜单";
			// 
			// t_new
			// 
			this.t_new.ImageIndex = 19;
			this.t_new.Text = "新增";
			// 
			// t_Modify
			// 
			this.t_Modify.ImageIndex = 7;
			this.t_Modify.Text = "修改";
			// 
			// t_Save
			// 
			this.t_Save.ImageIndex = 9;
			this.t_Save.Text = "保存";
			// 
			// t_Cancel
			// 
			this.t_Cancel.ImageIndex = 3;
			this.t_Cancel.Text = "放弃";
			// 
			// t_S3
			// 
			this.t_S3.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// t_Preview
			// 
			this.t_Preview.ImageIndex = 15;
			this.t_Preview.Text = "预览";
			// 
			// t_Print
			// 
			this.t_Print.ImageIndex = 10;
			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.Text = "刷新";
			// 
			// t_Find
			// 
			this.t_Find.ImageIndex = 2;
			this.t_Find.Text = "查询";
			// 
			// t_First
			// 
			this.t_First.ImageIndex = 11;
			this.t_First.Text = "首页";
			// 
			// t_Up
			// 
			this.t_Up.ImageIndex = 12;
			this.t_Up.Text = "上页";
			// 
			// t_Down
			// 
			this.t_Down.ImageIndex = 13;
			this.t_Down.Text = "下页";
			// 
			// t_Last
			// 
			this.t_Last.ImageIndex = 14;
			this.t_Last.Text = "末页";
			// 
			// t_S2
			// 
			this.t_S2.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// t_Exit
			// 
			this.t_Exit.ImageIndex = 16;
			this.t_Exit.Text = "退出";
			// 
			// grd_Other
			// 
			this.grd_Other.BackColor = System.Drawing.Color.White;
			this.grd_Other.BorderStyle = false;
			this.grd_Other.BorderWidth = 0;
			this.grd_Other.CellBackColor = System.Drawing.Color.White;
			this.grd_Other.CellColLength = -1;
			this.grd_Other.CellFontSize = 9F;
			this.grd_Other.CellForeColor = System.Drawing.Color.Black;
			this.grd_Other.CellHeight = 0;
			this.grd_Other.CellRowLength = -1;
			this.grd_Other.CellTag = null;
			this.grd_Other.Col = 0;
			this.grd_Other.Cols = 6;
			this.grd_Other.EnterToTab = true;
			this.grd_Other.GridStyle = true;
			this.grd_Other.Location = new System.Drawing.Point(28, 416);
			this.grd_Other.Name = "grd_Other";
			this.grd_Other.ReadCellBackColor = System.Drawing.Color.White;
			this.grd_Other.ReadCellForeColor = System.Drawing.Color.Black;
			this.grd_Other.Row = 0;
			this.grd_Other.RowHeightMin = 20;
			this.grd_Other.Rows = 2;
			this.grd_Other.SetCellWidth = "100,100,100,100,100,100,100,100";
			this.grd_Other.Size = new System.Drawing.Size(118, 14);
			this.grd_Other.TabIndex = 53;
			// 
			// pnl_Face
			// 
			this.pnl_Face.Location = new System.Drawing.Point(0, 2);
			this.pnl_Face.Name = "pnl_Face";
			this.pnl_Face.Size = new System.Drawing.Size(788, 10);
			this.pnl_Face.TabIndex = 54;
			// 
			// frmVoucherBase
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.AutoScroll = true;
			this.BackColor = System.Drawing.Color.White;
			this.ClientSize = new System.Drawing.Size(746, 485);
			this.Controls.Add(this.lbl_FlieNo);
			this.Controls.Add(this.pnl_Face);
			this.Controls.Add(this.grd_Footer);
			this.Controls.Add(this.grd_Other);
			this.Controls.Add(this.grd_Detail);
			this.Controls.Add(this.btnDown);
			this.Controls.Add(this.pictureBox1);
			this.Controls.Add(this.grd_Header);
			this.Controls.Add(this.sbr_statusBar);
			this.Controls.Add(this.lbl_Title2);
			this.Controls.Add(this.lbl_Title1);
			this.Controls.Add(this.lblBorder);
			this.Controls.Add(this.panel1);
			this.Controls.Add(this.grd_Bottom);
			this.Controls.Add(this.grd_Top);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Location = new System.Drawing.Point(170, 0);
			this.Name = "frmVoucherBase";
			this.Text = "frmVoucherBase";
			this.Resize += new System.EventHandler(this.frmVoucherBase_Resize);
			this.Closing += new System.ComponentModel.CancelEventHandler(this.frmVoucherBase_Closing);
			this.Load += new System.EventHandler(this.frmVoucherBase_Load);
			this.Activated += new System.EventHandler(this.frmVoucherBase_Activated);
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.page)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel5)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel6)).EndInit();
			this.panel1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion
		
		private void frmVoucherBase_Load(object sender, System.EventArgs e)
		{

			frmProgressShow f= new frmProgressShow();
			f.ShowDialog (this);
//			InitInterface();
			if (m_WriteYesNo==1)
			{
				ToolEnabled(false,true);
			}
			else
			{
				ToolEnabled(false,false);
			}
//			newReceipt.ReceiptPageMove (this,this.CboReceiptNo);
           f.Close();
			int j=this.Height ;
			this.Height=20;
			for (int i=0;i<j;i++)
			{
				if (this.Height>j)
				{ 
					this.Height=j;
					this.pnl_Face.Visible =false;
					this.pnl_Face.SendToBack();

					return;
				}
				this.Height=this.Height+10;
			
			}
			this.pnl_Face.Visible =false;
			this.pnl_Face.SendToBack();


		}
		
		/// <summary>
		/// 将界面中指定网格单元格对象添加到控件数组中。
		/// </summary>
		private int ArrayIndex(MyGrid p_Grid ,int p_Index)
		{
			int rows;
			int cols;
			if (p_Grid.Visible ==true)
			{
				rows=p_Grid.Rows ;
				cols=p_Grid.Cols;
				for (int r=0;r<rows;r++)
				{
					for (int c=0;c<cols;c++)
					{
						//将单元格对象添加到控件数组中
						ArrCell[p_Index]=p_Grid.GridCell(r,c);
						p_Index++;
					}
				}
			}
			return p_Index;

		}
		/// <summary>
		/// 将界面中所有单元格对象添加到控件数组中。
		/// </summary>
		private void AddArray()
		{
			int j=0;
			if (grd_Top.Visible ==true)
			{
				j+=grd_Top.Cols*grd_Top.Rows;
			}
			if (grd_Header.Visible ==true)
			{
				j+=grd_Header.Cols*grd_Header.Rows;
			}
			if (grd_Other.Visible ==true)
			{
				j+=grd_Other.Cols*grd_Other.Rows;
			}

			if (grd_Footer.Visible ==true)
			{
				j+=grd_Footer.Cols*grd_Footer.Rows;
			}
			if (grd_Bottom.Visible ==true)
			{
				j+=grd_Bottom.Cols*grd_Bottom.Rows;
			}
			ArrCell=new TextBox[j];

			int i=0;
			int k=0;
			i=ArrayIndex(grd_Top,i);
			k=ArrayIndex(grd_Header,i);
			i=ArrayIndex(grd_Other,k);
			k=ArrayIndex(grd_Footer,i);
			i=ArrayIndex(grd_Bottom,k);
//			i=ArrayIndex(grd_Top,i);
//			k=ArrayIndex(grd_Header,i);
//			i=ArrayIndex(grd_Footer,k);
//			k=ArrayIndex(grd_Bottom,i);

		}
		/// <summary>
		/// 单据界面初始化
		/// </summary>
		public void InitInterface()
		{
//			this.Left =170;
			this.Text =m_ReceiptName;
			lbl_Title1.Text =m_ReceiptTitle1;
			lbl_Title2.Text =m_ReceiptTitle2;

			newReceipt.SetInterface(grd_Top,m_PageTopFormat,m_PageTopColWidth,false,false);
			newReceipt.SetInterface(grd_Header,m_PageHeaderFormat,m_PageHeaderColWidth,true,true);
			newReceipt.SetInterface(grd_Other,m_PageOtherFormat,m_PageOtherColWidth,true,true);
			newReceipt.SetInterface(grd_Footer,m_PageFooterFormat,m_PageFooterColWidth,true,true);
			newReceipt.SetInterface(grd_Bottom,m_PageBottomFormat,m_PageBottomColWidth,false,true);
			CboReceiptNo.Text=grd_Top.CellText(0,grd_Top.Cols-1);
			grd_Detail.Rows=15;
			//			//			myFlexGrid1.CellLocked =true;
			if (m_PageCaptionFormat1==null || m_PageCaptionFormat1=="")
			{
				grd_Detail.Visible =false;
				grd_Detail.Height =0;
			}
			else
			{
				grd_Detail.FormatString =m_PageCaptionFormat1;//"0序号|1产品代码|2产品名称|3产品型号|4需方型号|5包装形式|6最小包装量|7单位|8仓库|入库|入库|入库|入库|出库|出库|出库|库存数量|17平均单价|18金额|19备注|20备注|21备注|22备注|23备注|24备注|25备注|26备注|27备注";
				grd_Detail.FormatString1 =m_PageCaptionFormat2;//"0序号|1产品代码|2产品名称|3产品型号|4需方型号|5包装形式|6最小包装量|7单位|8仓库|9入库日期|10入库数量|11入库单价|12入库金额|13出库数量|14出库单价|15出库金额|16库存数量|17平均单价|18金额|19备注|20备注|21备注|22备注|23备注|24备注|25备注|26备注|27备注";
				grd_Detail.DetailFormat =m_PageDetailFormat;
				grd_Detail.Height =m_detailHeight;
				grd_Detail.Visible =true;
				grd_Detail.SetRowNo();

			}
				AddArray();//把grd_Top、grd_Header、grd_Bottom、grd_Footer网格控件统一加入数组等同数组控件

				grd_Detail.Width=m_ReceiptWidth;
				lbl_Title1.Width =m_ReceiptWidth ;
				lbl_Title2.Width=m_ReceiptWidth ;
				grd_Header.Width=m_ReceiptWidth ;
				grd_Bottom.Width=m_ReceiptWidth ;
				grd_Footer.Width=m_ReceiptWidth ;
				lbl_FlieNo.Left =lbl_Title1.Left+lbl_Title1.Width-lbl_FlieNo.Width ;
				lblBorder.Left =grd_Top.Left-2 ;
				lblBorder.Width=grd_Detail.Width+4;

				grd_Header.Left =grd_Top.Left ;
				grd_Detail.Left=grd_Top.Left ;
				grd_Bottom.Left=grd_Top.Left ;
				grd_Footer.Left=grd_Top.Left ;
				lbl_Title1.Left=grd_Top.Left ;
				lbl_Title2.Left=grd_Top.Left ;

			grd_Header.Top=grd_Top.Top +grd_Top.Height+2 ;//
			if (grd_Header.Visible ==true)
			{
				grd_Detail.Top=grd_Header.Top +grd_Header.Height+1 ;
				grd_Detail.Top=grd_Header.Top +grd_Header.Height+1 ;
				lblBorder.Top=grd_Header.Top -2 ;
			}
			else
			{
				grd_Detail.Top=grd_Top.Top +grd_Top.Height+1 ;
				lblBorder.Top=grd_Detail.Top -2 ;
			}
			if (grd_Detail.Visible ==false)
			{
				grd_Detail.Top=grd_Header.Top +grd_Header.Height ;
			}


			if (grd_Other.Visible ==true)
			{
				grd_Other.Top=grd_Detail.Top +grd_Detail.Height+1 ;
				grd_Footer.Top=grd_Other.Top +grd_Other.Height-2;//+1 ;
				grd_Bottom.Top=grd_Footer.Top +grd_Footer.Height+4 ;
				lblBorder.Height=grd_Footer.Top-lblBorder.Top+4 ;
				grd_Other.Left=grd_Top.Left ;

			}
			else
			{
				grd_Other.Top=grd_Detail.Top +grd_Detail.Height+1 ;
				grd_Footer.Top=grd_Detail.Top +grd_Detail.Height+1 ;
				grd_Bottom.Top=grd_Footer.Top +grd_Footer.Height+4 ;
				lblBorder.Height=grd_Footer.Top-lblBorder.Top+4 ;
			}
			if (grd_Footer.Visible ==true)
			{
				lblBorder.Height=grd_Footer.Top+grd_Footer.Height -lblBorder.Top+2 ;
			}
			else
			{
				grd_Bottom.Top=grd_Footer.Top+4 ;
				lblBorder.Height=grd_Bottom.Top-lblBorder.Top ;
			}			
			if (grd_Other.Visible ==false && grd_Footer.Visible ==false)
			{
				lblBorder.Height=grd_Detail.Height +grd_Detail.Top-lblBorder.Top+2 ;
			}
			if (grd_Bottom.Visible ==false)
			{
				grd_Bottom.Top =grd_Footer.Top ;
			}


			this.Height =grd_Bottom.Top+grd_Bottom.Height +this.sbr_statusBar.Height*3;
			this.Width =lblBorder.Width +lblBorder.Left*2+10;
			grd_Detail.FixedBackColor =Color.White ;
			//单据编号列表初始
			InitReceiptList();

		}

		/// <summary>
		/// 单据数据初始
		/// </summary>
		public void InitReceiptData(string strReceiptNO) 
		{
			string[,] sArrary;//=new string [10,10];
			int rs=0;
			int cs=0;
			//			this.mouse
			//			 Me.MousePointer = vbHourglass
//			Screen
//			string sSql;
			//'判断首尾
						ReceiptPageMove(CboReceiptNo);
			//			sSql = "SELECT " + strMasterFeildName + " FROM " + strMasterTableName & " Where " & strReceiptNoFieldName & "='" + strReceiptNO & "'" ;
			//			sSql = sSql + " Order by " + strReceiptNoFieldName;
			//Set rstDB = OpenRst(sSql)
			//With rstDB
			//'填充主表
				sArrary= newDB.GetDataArray("Select "+m_MasterFeildName+" From "+m_MasterTableName+" Where "+m_KeyFieldName+"='"+strReceiptNO+"'");
			if (sArrary!=null)
			{
				 rs=sArrary.GetUpperBound(0)+1;
				 cs=sArrary.GetUpperBound(1)+1;
				int j=0;
				for (int i=0;i<cs*2;i++)
				{
					if (i%2!=0)
					{
						ArrCell[i].Text =sArrary[0,j];
						j++;
					}
				}
			}
			sArrary=null;
			//'填充明细表
			sArrary= newDB.GetDataArray("Select "+m_DetailFeildName+" From "+m_DetailTableName+" Where "+m_KeyFieldName+"='"+strReceiptNO+"'");
			if (sArrary!=null)
			{
				 rs=sArrary.GetUpperBound(0)+1;
				 cs=sArrary.GetUpperBound(1)+1;
				grd_Detail.Rows=rs+2;
				for (int r=0;r<rs;r++)
				{
					for (int c=0;c<cs;c++)
					{
						grd_Detail.SetCellText(r+1,c,sArrary[r,c]);
					}
				}
			}
	
		}
		/// <summary>
		/// 单据数据新增
		/// </summary>
		public void ReceiptAdd() 
		{

			//初始默认值
			int j=ArrCell.GetUpperBound(0)+1;
			for (int i=0 ;i<j;i++)
			{
				if (i%2!=0)
				{

					newCellDesc.FormatString =ArrCell[i].Tag.ToString();
					string v=newCellDesc.TextDefault ; 
					if (v!=null)
					{
						ArrCell[i].Text ="";

							//判断动态始默认值 当前日期 当前操作员
							if (v.ToLower()=="date")
							{
								ArrCell[i].Text =ClsGlobalData.GetDate();//"Date";
							}
							if (v.ToLower()=="operator")
							{
								ArrCell[i].Text =ClsGlobalData.GetOperator();;//JXC_MIS.UserTier.BaseForm.frmMain.ActiveForm  "Operator";
							}
					//其他静态默认值
					}
					else
					{
						ArrCell[i].Text =v;
					}
				}
			}

			ToolEnabled(true,false);
			m_EditFlag=true;
			grd_Detail.Clear();
			CboReceiptNo.Text =newReceipt.GetReceiptNo(m_MasterTableName,m_KeyFieldName,m_FirstChar);
			grd_Top.CellText(0,grd_Top.Cols-1,CboReceiptNo.Text);

		}
		/// <summary>
		/// 单据数据保存
		/// </summary>
		public void ReceiptSave() 
		{
			string [,] TempArrCell=null;
			string sReceiptNo;
			if (ReceiptCheck()==false) {return ;}
			newADO.BeginTrans(); 

			if (m_EditFlag==true)
			{
				sReceiptNo=CboReceiptNo.Text;
				newADO.ExeSql("Delete From "+m_MasterTableName+" Where "+m_KeyFieldName+"='"+CboReceiptNo.Text +"'"); 
				newADO.ExeSql("Delete From "+m_DetailTableName+" Where "+m_KeyFieldName+"='"+CboReceiptNo.Text +"'"); 
			}
			else
			{
				CboReceiptNo.Text =newReceipt.GetReceiptNo(m_MasterTableName,m_KeyFieldName,m_FirstChar);
				sReceiptNo=CboReceiptNo.Text;
				grd_Top.CellText(0,grd_Top.Cols-1,sReceiptNo);
			}

			int j=ArrCell.GetUpperBound(0)+1;
			//主表数据保存
			TempArrCell=new string[j/2,2];
			for (int i=0;i<j;i++)
			{
				if (i%2!=0)
				{
					TempArrCell[i/2,0]=ArrCell[i].Text;
					TempArrCell[i/2,1]=ArrCell[i].Tag.ToString();
				}
			}
			string sSQL=newReceipt.GetInsertSQL(m_MasterTableName,m_MasterFeildName,TempArrCell);
			if (newADO.ExeSql(sSQL)<0)
			{
				newADO.Rollback() ;
				return ;
			}

			//明细表数据保存
			TempArrCell=null;
			string sSQL1="";
			int cs=grd_Detail.Cols;
			int rs=grd_Detail.Rows;
			TempArrCell=new string[cs+1,2];

			for (int r=1;r<rs;r++)
			{
				if (grd_Detail.GetCellText(r,1)!="")
				{
					TempArrCell[0,0]=sReceiptNo;
					TempArrCell[0,1] ="";

					for (int c=0;c<cs;c++)
					{
						TempArrCell[c+1,0]=grd_Detail.GetCellText(r,c);
						TempArrCell[c+1,1] =grd_Detail.GetCellText(0,c);
					}
					sSQL1=newReceipt.GetInsertSQL(m_DetailTableName,m_KeyFieldName+","+m_DetailFeildName,TempArrCell);
					if (newADO.ExeSql(sSQL1)<0)
					{
						newADO.Rollback() ;
						return ;
					}
				}

			}
			newADO.Commit(); 
			TempArrCell=null;
        	ToolEnabled(false,false);
			//单据编号列表初始
		    InitReceiptList();
		}


		/// <summary>
		/// 单据数据修改
		/// </summary>
		public void ReceiptModify() 
		{
		  ToolEnabled(true,false);
		  m_EditFlag=true;

		}
		/// <summary>
		/// 单据删除
		/// </summary>
		public void ReceiptDel() 
		{
		
		}
		/// <summary>
		/// 单据取消放弃
		/// </summary>
		public void ReceiptCancel() 
		{
			ToolEnabled(false,false);
		}
		/// <summary>
		/// 单据刷新
		/// </summary>
		public void ReceiptRefresh() 
		{
			ToolEnabled(false,false);
			InitReceiptData(CboReceiptNo.Text);
		}
		/// <summary>
		/// 单据查询
		/// </summary>
		public void ReceiptFind() 
		{
			frmReceiptFind f=new frmReceiptFind();
			f.ShowDialog() ;
		}
		/// <summary>
		/// 单据首页
		/// </summary>
		public void FirstPage() 
		{
			if (CboReceiptNo.Items.Count >0 )
			{
				this.CboReceiptNo.SelectedIndex=0;
			}
			ReceiptPageMove(this.CboReceiptNo);	
		}
		/// <summary>
		/// 单据上一页
		/// </summary>
		public void UpPage() 
		{
			if (CboReceiptNo.SelectedIndex > 0 )
			{
				this.CboReceiptNo.SelectedIndex=this.CboReceiptNo.SelectedIndex-1;
			}
			ReceiptPageMove(this.CboReceiptNo);	
		}

		/// <summary>
		/// 单据下一页
		/// </summary>
		public void DownPage() 
		{
			if (CboReceiptNo.SelectedIndex < CboReceiptNo.Items.Count -1 )
			{
				this.CboReceiptNo.SelectedIndex=this.CboReceiptNo.SelectedIndex+1;
			}
			ReceiptPageMove(this.CboReceiptNo);	
		}

		/// <summary>
		/// 单据末页
		/// </summary>
		public void LastPage() 
		{
			if (CboReceiptNo.SelectedIndex < CboReceiptNo.Items.Count -1 )
			{
				this.CboReceiptNo.SelectedIndex=this.CboReceiptNo.Items.Count -1;
			}
			ReceiptPageMove(this.CboReceiptNo);
		}

		/// <summary>
		/// 单据完整性验证
		/// </summary>
		public bool ReceiptCheck() 
		{
			bool returnValue;
			string sCheckType;
			int j=ArrCell.GetUpperBound(0)+1;
			for (int i=0 ;i<j;i++)
			{
				if (i%2!=0)
				{
					newCellDesc.FormatString =ArrCell[i].Tag.ToString();
					sCheckType=newCellDesc.CheckType ; 
					returnValue=newReceipt.ReceiptCheck(ArrCell[i-1].Text.ToString(),ArrCell[i].Text.ToString(),sCheckType);
					if (returnValue==false)
					{return returnValue;}
				}
			}
		return true;

		}
		/// <summary>
		/// 单据打印
		/// </summary>
		public void ReceiptPrint() 
		{
		
		}
		/// <summary>
		/// 打印预览
		/// </summary>
		public void ReceiptPreview() 
		{
		
		}
		private void CboReceiptNo_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			ReceiptRefresh();
		}
		private void CboReceiptNo_Click(object sender, System.EventArgs e)
		{
		}
		/// <summary>
		/// 单据编号列表初始
		/// </summary>
		public void InitReceiptList()//System.Windows.Forms.ComboBox p_ComboBox 
		{
			string Sql;
				  Sql="Select "+m_KeyFieldName+" From "+m_MasterTableName;
            if (m_QueryWhere!="" && m_QueryWhere!=null)
			{
				Sql=Sql+" Where "+m_QueryWhere;
			}
				Sql=Sql+" Order By "+m_KeyFieldName;
			newDB.InitComboBox(CboReceiptNo,Sql);
            CboReceiptNo.SelectedIndex =CboReceiptNo.Items.Count-1;
			GetReceiptPage(CboReceiptNo);
		}


		/// <summary>
		/// 功能： 在报表窗体中前、后、首、末单击事件  (通用)
		/// </summary>
		public void ReceiptPageMove(ComboBox CboNo)
		{
			try
			{
				sbr_statusBar.Panels[2].Text =GetReceiptPage(CboReceiptNo);

				//没有数据记录
				if (CboNo.SelectedIndex <= 0 )
				{
					this.t_First.Enabled =false;
					this.t_Up.Enabled =false;
					this.t_Down.Enabled =false;
					this.t_Last.Enabled =false;
					return;
				}
				//判断记录首尾位置,控制是否按钮可用
				if (CboNo.SelectedIndex > 0 && CboNo.SelectedIndex < CboNo.Items.Count -1 )
				{
					this.t_First.Enabled =true;
					this.t_Up.Enabled =true;
					this.t_Down.Enabled =true;
					this.t_Last.Enabled =true;
					return;
				}
				if (CboNo.SelectedIndex == 0 )
				{
					this.t_First.Enabled =false;
					this.t_Up.Enabled =false;
					this.t_Down.Enabled =true;
					this.t_Last.Enabled =true;
					return;
				}
				if (CboNo.SelectedIndex == CboNo.Items.Count -1 )
				{
					this.t_First.Enabled =true;
					this.t_Up.Enabled =true;
					this.t_Down.Enabled =false;
					this.t_Last.Enabled =false;
					return;
				}

				if (CboNo.Items.Count <= 0 )
				{
					this.t_First.Enabled =false;
					this.t_Up.Enabled =false;
					this.t_Down.Enabled =true;
					this.t_Last.Enabled =false;
					return;
				}

			}
			catch
			{
			
			}

		}
		/// <summary>
		/// 功能： 判断工具条项目是否可用 BlnQueryTag:控制工具条 添加、修改、等功能不可用
		/// </summary>
		public void ToolEnabled(bool YesNo ,bool BlnQueryTag)
		{
			try
			{

				this.t_Menu.Enabled =! YesNo;
				this.t_new.Enabled =! YesNo;
				this.t_Modify.Enabled =! YesNo;
				this.t_Save.Enabled = YesNo;
				this.t_Cancel.Enabled = YesNo;
				this.t_Preview.Enabled =! YesNo;
				this.t_Print.Enabled =! YesNo;
				this.t_Refresh.Enabled =! YesNo;
				this.t_Find.Enabled =! YesNo;
				this.t_First.Enabled =! YesNo;
				this.t_Up.Enabled =! YesNo;
				this.t_Down.Enabled =! YesNo;
				this.t_Last.Enabled =! YesNo;
				this.t_Exit.Enabled =! YesNo;
				if (BlnQueryTag ==true) 
				{
					//单据查询时控制工具条 添加、修改、等功能不可用
					this.t_new.Enabled = YesNo;
					this.t_Modify.Enabled = YesNo;
				}
				else
				{
					this.t_new.Enabled =! YesNo;
					this.t_Modify.Enabled =! YesNo;
				}
			}
			catch
			{
			
			}
		}
		//
		//			'-----------------自动设置当前单据的页数以及所在页码-----------------------------
		public string GetReceiptPage(ComboBox CboReceiptNo )
		{
			int i=CboReceiptNo.SelectedIndex  + 1;
			int j=CboReceiptNo.Items.Count ;
			string p = "第" + i.ToString() + "页/共" + j.ToString()+ "页";
			return p;
		}		//
		//			'-----------------查找指定的页码单据-----------------------------
		public void FindReceiptPage(ComboBox CboReceiptNo)
		{
//		int PageNo;
//		   PageNo = Val(InputBox("请输入指定的页：", "单据页面定位", ""));
//		If PageNo <= CboReceiptNo.ListCount - 1 And PageNo >= 0 Then CboReceiptNo.ListIndex = PageNo - 1
		}
//			'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//			'               在ComboBox控件中搜索字符串
//			'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
			public void ComboListSearch(ComboBox CboReceiptNo ,string strOtherValue)
			{
//				int l =CboReceiptNo.Items.Count  - 1 ;
//				string Search;
//				int SearchLen ;
//				if (strOtherValue == "") 
//				{
//					Search = UCase(CboReceiptNo.Text);
//				}
//			else
//				{
//					Search = UCase(strOtherValue);
//				}
//			SearchLen = Search.Length ;
//				for (int i=0;i<l;i++)
//				{
////			'任意摸湖
//			if (CboReceiptNo.Items[i].ToString().CompareTo(Search)>=1)
////			if (InStr(UCase(CboReceiptNo.List(i)), Search) >= 1) 
//			{
//				CboReceiptNo.SelectedIndex = i;
//				break;
//			}
//					//			''从左边数
//					//			''      If UCase(Left(CboReceiptNo.List(i), SearchLen)) = Search Then
//					//			''          CboReceiptNo.ListIndex = i
//					//			''         Exit For
//					//			''      End If
//				}
		}
		private void grd_Top_Cell_Enter(object sender, System.EventArgs e)
		{
			try
			{
				TextBox control = (TextBox) sender ; 
				TxtTemp =control;
				CellMouseDown(control);
			}
			catch
			{
				return;
			}
		}
		private void grd_Detail_Cell_Enter(object sender, System.EventArgs e)
		{
			TextBox control = (TextBox) sender ;
			TxtTemp =control;
			TxtTemp.Tag =grd_Detail.GetCellText(0,grd_Detail.Col);
//			grd_Detail.SetCellText(3,grd_Detail.Col,grd_Detail.GetCellText(0,grd_Detail.Col));

			CellMouseDown(control);
		}
		/// <summary>
		/// 设置参照按钮
		/// </summary>
		private void CellMouseDown(TextBox sender)
		{
			try
			{
				newCellDesc.FormatString =sender.Tag.ToString();
                if (newCellDesc.RefertoType!=null)
//				string v=GetSetupValue(sender.Tag.ToString(),1);
//				if (v!=null && Char.IsNumber(v,0)==true)
				{
					btnDown.Top  =sender.Top+sender.Parent.Top+1 ;
					btnDown.Left  =sender.Left+sender.Parent.Left +sender.Width -btnDown.Width  ;
					btnDown.Height   =sender.Height-1 ;
					btnDown.Visible =true;
					btnDown.BringToFront() ;
				}
				else
				{
					btnDown.Visible =false;
				}
			}
			catch
			{
				return;
			}
		}


		private void btnDown_Click(object sender, System.EventArgs e)
		{
			try
			{
				int T=0;
				newCellDesc.FormatString =TxtTemp.Tag.ToString();
				T=int.Parse(newCellDesc.RefertoType);
				frmReferto f=new frmReferto();
				f.ObjCmd=btnDown;
				f.SetFormSource=this;
				f.SetTextSource =TxtTemp;//grd_Detail.GetCell();
				f.RefertoType =T ;
				f.ShowDialog(this);
			}
			catch
			{
				return;
			}

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

		private void tbr_Toolbar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			switch (e.Button.Text)
			{
				case "新增":
				ReceiptAdd();

				break;
				case "修改":
				ReceiptModify();
				break;
				case "保存":
				ReceiptSave();
				break;
				case "放弃":
				ReceiptCancel();
				break;
				case "预览":
				ReceiptPreview();
				break;
				case "打印":
				ReceiptPrint();
				break;
				case "刷新":
				ReceiptRefresh();
				break;
				case "查询":
					ReceiptFind();
					break;
				case "首页":
					FirstPage();
					break;
				case "上页":
					UpPage();
					break;
				case "下页":
					DownPage();
					break;
				case "末页":
					LastPage();
					break;

				case "退出":
					this.Close();
					break;

			default:
 
			break;
			}
		}

		private void frmVoucherBase_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
             int j=this.Height ;
			for (int i=0;i<j;i++)
			{
				if (this.Height<20){ return;}
					this.Height=this.Height-30;
			
			}
		}

		private void grd_Header_Load(object sender, System.EventArgs e)
		{
		
		}

		private void frmVoucherBase_Resize(object sender, System.EventArgs e)
		{
			this.pnl_Face.Top=0;
			this.pnl_Face.Left =0;
			this.pnl_Face.Width =this.Width;
			this.pnl_Face.Height =this.Height ;
		}

		private void frmVoucherBase_Activated(object sender, System.EventArgs e)
		{


		}







		//		/// <summary>
		//		/// 解析 默认缺省值、参照
		//		/// </summary>
		//		private string GetSetupValue(string ReadText,int Index)
		//		{
		//			string [] ArrSplit = null; //     临时数组变量
		//			int j=0;
		//			ArrSplit=ReadText.Split(';'); 
		//			j=ArrSplit.Length ;
		//			//解析 0默认缺省值(Date=当前日期，Operator=登录操作员，)
		//			//解析 1参照类型(0,1,2,3,4,5)
		//			//解析 2参照数据源(数据表或SQL语句)
		//			//解析 3是否保存(True,False或 否)		
		//			//解析 4是否代码转换{表名，代码字段，名称字段}		
		//			//解析 5数据保存时数据验证（0或空=可以为空，1=不为空，2=日期验证，3=数值验证)
		//			if (j<Index) {return null;}
		//			if (ArrSplit[Index].Trim()!="" && Char.IsNumber(ArrSplit[Index].Trim(),0)!=true && Index==1)
		//			{
		//				return null;
		//			}
		//
		//			if (j>Index && ArrSplit[Index].Trim()!="")
		//			{
		//				return ArrSplit[Index].Trim();
		//			}
		//			else
		//			{
		//				return null;
		//			}
		//			
		//		}
		//		
		//		







	}
}
