using System;
using System.Windows.Forms;
using System.Drawing;

using ljs;
using JXC_MIS.MyClass;
using JXC_MIS.DataTier;
namespace JXC_MIS.MyClass
{
	/// <summary>
	/// ClsReceiptAttrib 单据界面信息设置初始描述 。
	/// </summary>
	public class ClsReceiptAttrib
	{
		#region 定义属性变量
		//		类的属性所对应的变量，采用属性名前加“m_”(我为_)前缀的形式
		private string m_FirstChar="" ;				//               单据编号开头字符如"XS"+2004-09-0001
		private string m_MasterTableName="" ;		//                   主表表名
		private string m_MasterFeildName=""  ;		//                   主表字段名称
		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_QueryWhere ;									// 一般为了控制单据权限时用到,传递过滤条件
		private string m_FileNO ="" ;							//  文件号
		private string m_ReceiptName ="=" ;									//  单据名称
		private string m_ReceiptTitle1=""  ;						//  单据标题
		private string m_ReceiptTitle2=""  ;		//  副标题
		private int m_detailHeight=230  ;											// 单据高
		private int m_ReceiptWidth=700  ;											// 单据宽
		//		private double m_ReceiptFontSize  ;		//                   单据字体大小
		//		private double m_TitleFontSize  ;		//                   单据标题字体大小
		private string m_DetailColSumNo  ;		//                   单据明细网格列求和序号 例："1|3|4|5|7|9"
		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="备货人：||仓库主管：|| 产品核对：||发货人：|$|交(发)货日期：||运单号码：||运费金额||用户提货未付款签字：|";
		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" ;		  //               页底表格列宽
		private string m_FilterField="";
        private string m_HideFiledsMaster; //主表隐含字段保存
		private string m_HideFiledsDetail; //明细表隐含字段保存
		private string m_BrowseFilter;     //浏览过滤
		#endregion

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

		/// <summary>
		/// 明细表隐含字段保存
		/// </summary>
		public string BrowseFilter
		{ 
			get {return m_BrowseFilter;} 
			set { m_BrowseFilter=value;} 
		} 

		/// <summary>
		/// 明细表隐含字段保存
		/// </summary>
		public string HideFiledsDetail
		{ 
			get {return m_HideFiledsDetail;} 
			set { m_HideFiledsDetail=value;} 
		} 

		/// <summary>
		/// 主表隐含字段保存
		/// </summary>
		public string HideFiledsMaster
		{ 
			get {return m_HideFiledsMaster;} 
			set { m_HideFiledsMaster=value;} 
		} 

		/// <summary>
		/// 文件号
		/// </summary>
		public string FileNO
		{ 
			get {return m_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 DetailColSumNo
		{ 
			get {return m_DetailColSumNo;} 
			set { m_DetailColSumNo=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;} 
		}
		
		/// <summary>
		/// 查询过滤字段(描述;字段名;类型)
		/// </summary>
		public string FilterField
		{ 
			get {return m_FilterField;} 
			set { m_FilterField=value;} 
		}
#endregion
 
		public ClsReceiptAttrib()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}

		/// <summary>
		/// 功能： 得到所有主表标题字符串
		/// </summary>
		public string GetMasterCaption()
		{
			string strFormat="";
			string strResult="";
			string[] ArrTemp=null;
			if (m_PageTopFormat!=null && m_PageTopFormat!="") {strFormat=m_PageTopFormat;}
			if (m_PageHeaderFormat!=null && m_PageHeaderFormat!="") {strFormat=strFormat+"|"+m_PageHeaderFormat;}
			if (m_PageOtherFormat!=null && m_PageOtherFormat!="") {strFormat=strFormat+"|"+m_PageOtherFormat;}
			if (m_PageFooterFormat!=null && m_PageFooterFormat!="") {strFormat=strFormat+"|"+m_PageFooterFormat;}
			if (m_PageBottomFormat!=null && m_PageBottomFormat!="") {strFormat=strFormat+"|"+m_PageBottomFormat;}
			ArrTemp=strFormat.Split('|');
			int j=ArrTemp.Length ;
			for (int i=0;i<j;i++)
			{
				if (i%2==0)
				{
					strResult=strResult+ArrTemp[i]+"|";
				}
		
			}
			return strResult.Substring(0,strResult.Length-1) ;
		}


		/// <summary>
		/// 功能： 数据库中加载窗体界面设置信息 (通用)
		/// </summary>
		public void LoadData(string p_ReceiptName)
		{
			ClsDataBaseAccess AdoDB=new ClsDataBaseAccess();
			System.Data.DataSet dst = new System.Data.DataSet();
			dst= AdoDB.GetDataSet("SELECT * FROM S_ReceiptSetup where fcReceiptName='"+p_ReceiptName+"'");
			if (dst.Tables[0].Rows.Count >=1)
			{
				System.Data.DataRow dr = dst.Tables[0].Rows[0];
				if (dr!=null)
				{
					this.ReceiptName =dr["fcReceiptName"].ToString();
					this.FirstChar =dr["fcFirstChar"].ToString();
					this.ReceiptTitle1  =dr["fcReceiptTitle"].ToString();
					this.ReceiptTitle2  =dr["fcReceiptTitle2"].ToString();
					this.FileNO =dr["fcFileNo"].ToString();
					//this.ReceiptName =dr["fcFontSize"].ToString();
					if (dr["fcReceiptSize"].ToString()!="")
					{
						string[] sa=dr["fcReceiptSize"].ToString().Split(',') ;
						if (sa.Length >0) {	this.ReceiptWidth  =int.Parse(sa[0].ToString());}
						if (sa.Length >1) {	this.DetailHeight =int.Parse(sa[1].ToString());}
					}
					this.PageTopFormat  =dr["fcTopTitle"].ToString();
					this.PageTopColWidth =dr["fcTopColWidth"].ToString();
					this.PageHeaderFormat =dr["fcHeaderTitle"].ToString();
					this.PageHeaderColWidth  =dr["fcHeaderColWidth"].ToString();
					this.PageCaptionFormat1 =dr["fcCaptionTitle1"].ToString();
					this.PageCaptionFormat2 =dr["fcCaptionTitle2"].ToString();
					this.PageDetailFormat  =dr["fcDetailTitle"].ToString();
					this.PageFooterFormat =dr["fcFooterTitle"].ToString();
					this.PageFooterColWidth =dr["fcFooterColWidth"].ToString();
					this.PageBottomFormat =dr["fcBottomTitle"].ToString();
					this.PageBottomColWidth =dr["fcBottomColWidth"].ToString();
					this.PageOtherFormat =dr["fcOtherTitle"].ToString();
					this.PageOtherColWidth =dr["fcOtherColWidth"].ToString();
					this.MasterTableName =dr["fcMasterTable"].ToString();
					this.MasterFeildName  =dr["fcMasterFields"].ToString();
					this.DetailTableName =dr["fcDetailTable"].ToString();
					this.DetailFeildName   =dr["fcDetailFields"].ToString();
					this.KeyFieldName  =dr["fcKeyFieldName"].ToString();
					this.MasterViewName  =dr["fcMasterView"].ToString();
					this.MasterViewFeildName  =dr["fcMasterViewFields"].ToString();
					this.DetailViewName  =dr["fcDetailView"].ToString();
					this.DetailViewFeildName   =dr["fcDetailViewFields"].ToString();

					this.DetailColSumNo =dr["fcDetailColSumNo"].ToString();

					this.KeyViewFieldName =dr["fcViewKeyFieldName"].ToString();
					this.FilterField =dr["fcFilterField"].ToString();
					this.HideFiledsMaster =dr["fcHideFiledsMaster"].ToString();
					this.HideFiledsDetail =dr["fcHideFiledsDetail"].ToString();
					this.BrowseFilter=dr["fcBrowseFilter"].ToString();//m_BrowseFilter

				}
				else
				{
					MessageBox.Show("没有设置窗体界面信息！", "提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information );
				}
				
			}

			try
			{
//				ClsAccess AdoAccess=new ClsAccess();
//				System.Data.DataSet dst1 = new System.Data.DataSet();
//				dst1= AdoAccess.GetDataSet("Select  fcColWidth from  S_ColWidthSetup where fcMarkName='"+p_ReceiptName+"'");
//				if (dst1.Tables[0].Rows.Count >=1)
//				{
//					System.Data.DataRow dr1 = dst1.Tables[0].Rows[0];
//					if (dr1!=null)
//					{
//						this.PageDetailColWidth  =dr1["fcColWidth"].ToString();
//
//					}
//				}
				GetDetailColWidth(p_ReceiptName);
			}
          catch
			{
			}
		}


		/// <summary>
		/// 功能： 读取网格列宽设置信息
		/// </summary>
		public string GetDetailColWidth(string p_ReceiptName)
		{
		try
			{
				ClsAccess AdoAccess=new ClsAccess();
				System.Data.DataSet dst = new System.Data.DataSet();
				dst= AdoAccess.GetDataSet("Select  fcColWidth from  S_ColWidthSetup where fcMarkName='"+p_ReceiptName+"'");
				if (dst.Tables[0].Rows.Count >=1)
				{
					System.Data.DataRow dr = dst.Tables[0].Rows[0];
					if (dr!=null)
					{
						this.PageDetailColWidth  =dr["fcColWidth"].ToString();

					}
				}
			}
			catch
			{
			}
			return this.PageDetailColWidth;

		}
		
	


























	}
}
