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

namespace JXC_MIS.UserTier.NewForm
{
	public class frmSellCollectList : JXC_MIS.UserTier.BaseForm.frmTreeFlexGrid
	{
		private System.ComponentModel.IContainer components = null;
		private System.Data.DataSet dst = new System.Data.DataSet();
		protected ClsDataBase newDB=new ClsDataBase() ;
		protected ClsReceiptAttrib newR_Attrib=new ClsReceiptAttrib();
		protected ClsReceiptMethod newR_Method=new ClsReceiptMethod();
		protected ClsInitData InitData=new ClsInitData();

		protected ClsCellAttrib newCellAttrib=new ClsCellAttrib();
		private ToolTip nToolTip=new ToolTip();  //控件提示
		private string m_ColExpress;                   //计算列表达式
		private string m_ShowFormat;                    //显示格式
		string MasterSql="";
		string DetailSql="";
		private System.Windows.Forms.Button cmd_Look;
		string sReceiptNO="";
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.DateTimePicker dtp_End;
		private System.Windows.Forms.DateTimePicker dtp_Start;
		private System.Windows.Forms.ComboBox cbo_Customer;
		private System.Windows.Forms.ComboBox cbo_ValueType;
		string sReceiptType="销售收款";

		public frmSellCollectList()
		{
			// 该调用是 Windows 窗体设计器所必需的。
			InitializeComponent();

			// TODO: 在 InitializeComponent 调用后添加任何初始化
		}

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

		#region 设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.cmd_Look = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.cbo_Customer = new System.Windows.Forms.ComboBox();
			this.cbo_ValueType = new System.Windows.Forms.ComboBox();
			this.dtp_End = new System.Windows.Forms.DateTimePicker();
			this.dtp_Start = new System.Windows.Forms.DateTimePicker();
			this.SuspendLayout();
			// 
			// panel1
			// 
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(742, 446);
			// 
			// spt_H
			// 
			this.spt_H.Location = new System.Drawing.Point(144, 256);
			this.spt_H.Name = "spt_H";
			this.spt_H.Size = new System.Drawing.Size(598, 4);
			// 
			// spt_V
			// 
			this.spt_V.Location = new System.Drawing.Point(140, 0);
			this.spt_V.Name = "spt_V";
			this.spt_V.Size = new System.Drawing.Size(4, 446);
			// 
			// tv_Tree
			// 
			this.tv_Tree.Name = "tv_Tree";
			this.tv_Tree.Size = new System.Drawing.Size(140, 446);
			// 
			// cbo_SetupName
			// 
			this.cbo_SetupName.Name = "cbo_SetupName";
			this.cbo_SetupName.Size = new System.Drawing.Size(124, 20);
			// 
			// pnl_Filter
			// 
			this.pnl_Filter.Name = "pnl_Filter";
			// 
			// cmd_Cancel
			// 
			this.cmd_Cancel.Name = "cmd_Cancel";
			// 
			// cmd_ExeQuery
			// 
			this.cmd_ExeQuery.Name = "cmd_ExeQuery";
			// 
			// grd_Filter
			// 
			this.grd_Filter.Name = "grd_Filter";
			// 
			// sbr_StatusBar
			// 
			this.sbr_StatusBar.Name = "sbr_StatusBar";
			this.sbr_StatusBar.Size = new System.Drawing.Size(742, 25);
			// 
			// tbr_Toolbar
			// 
			this.tbr_Toolbar.Name = "tbr_Toolbar";
			this.tbr_Toolbar.Size = new System.Drawing.Size(742, 28);
			// 
			// t_new
			// 
			this.t_new.Visible = true;
			// 
			// grd_Top
			// 
			this.grd_Top.Location = new System.Drawing.Point(144, 0);
			this.grd_Top.Name = "grd_Top";
			this.grd_Top.Size = new System.Drawing.Size(598, 256);
			// 
			// grd_Bottom
			// 
			this.grd_Bottom.Location = new System.Drawing.Point(144, 260);
			this.grd_Bottom.Name = "grd_Bottom";
			this.grd_Bottom.Size = new System.Drawing.Size(596, 186);
			// 
			// img_ImageList
			// 
			this.img_ImageList.ImageStream = null;
			// 
			// cmd_Look
			// 
			this.cmd_Look.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.cmd_Look.Location = new System.Drawing.Point(700, 2);
			this.cmd_Look.Name = "cmd_Look";
			this.cmd_Look.Size = new System.Drawing.Size(42, 24);
			this.cmd_Look.TabIndex = 23;
			this.cmd_Look.Text = "查看单据";
			this.cmd_Look.Click += new System.EventHandler(this.cmd_Look_Click);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(212, 6);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(368, 12);
			this.label1.TabIndex = 24;
			this.label1.Text = "客户：";
			// 
			// cbo_Customer
			// 
			this.cbo_Customer.Location = new System.Drawing.Point(248, 4);
			this.cbo_Customer.Name = "cbo_Customer";
			this.cbo_Customer.Size = new System.Drawing.Size(182, 20);
			this.cbo_Customer.TabIndex = 25;
			this.cbo_Customer.Text = "<全部>";
			this.cbo_Customer.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cbo_Customer_KeyDown);
			this.cbo_Customer.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.cbo_Customer_KeyPress);
			// 
			// cbo_ValueType
			// 
			this.cbo_ValueType.Items.AddRange(new object[] {
															   "未开票未收款",
															   "已开票未收款",
															   "不开发票"});
			this.cbo_ValueType.Location = new System.Drawing.Point(430, 4);
			this.cbo_ValueType.Name = "cbo_ValueType";
			this.cbo_ValueType.Size = new System.Drawing.Size(90, 20);
			this.cbo_ValueType.TabIndex = 26;
			this.cbo_ValueType.Text = "已开票未收款";
			// 
			// dtp_End
			// 
			this.dtp_End.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
			this.dtp_End.Location = new System.Drawing.Point(616, 4);
			this.dtp_End.Name = "dtp_End";
			this.dtp_End.Size = new System.Drawing.Size(84, 21);
			this.dtp_End.TabIndex = 27;
			this.dtp_End.Value = new System.DateTime(2005, 2, 22, 0, 0, 0, 0);
			// 
			// dtp_Start
			// 
			this.dtp_Start.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
			this.dtp_Start.Location = new System.Drawing.Point(524, 4);
			this.dtp_Start.Name = "dtp_Start";
			this.dtp_Start.Size = new System.Drawing.Size(90, 21);
			this.dtp_Start.TabIndex = 28;
			this.dtp_Start.Value = new System.DateTime(2005, 2, 22, 0, 0, 0, 0);
			// 
			// frmSellCollectList
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(742, 499);
			this.Controls.Add(this.dtp_Start);
			this.Controls.Add(this.dtp_End);
			this.Controls.Add(this.cbo_ValueType);
			this.Controls.Add(this.cbo_Customer);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.cmd_Look);
			this.Name = "frmSellCollectList";
			this.Load += new System.EventHandler(this.frmSellCollectList_Load);
			this.Controls.SetChildIndex(this.tbr_Toolbar, 0);
			this.Controls.SetChildIndex(this.sbr_StatusBar, 0);
			this.Controls.SetChildIndex(this.panel1, 0);
			this.Controls.SetChildIndex(this.pnl_Filter, 0);
			this.Controls.SetChildIndex(this.cmd_Look, 0);
			this.Controls.SetChildIndex(this.label1, 0);
			this.Controls.SetChildIndex(this.cbo_Customer, 0);
			this.Controls.SetChildIndex(this.cbo_ValueType, 0);
			this.Controls.SetChildIndex(this.dtp_End, 0);
			this.Controls.SetChildIndex(this.dtp_Start, 0);
			this.ResumeLayout(false);

		}
		#endregion

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

			tv_Tree.Width =140;
			spt_H.Visible =true;
			this.grd_Top.Height =300;
			spt_H.BringToFront() ;
			this.ShowResize();
			grd_Top.OnlyRead=true;
			grd_Bottom.OnlyRead=true;
			dtp_Start.Text=System.DateTime.Today.ToString();//("yyyy-mm-dd") ;
			dtp_End.Text =System.DateTime.Today.ToString();//("yyyy-mm-dd") ;
			InitData.InitComboBox(cbo_Customer,"SELECT fcName FROM I_Customer ");
			newR_Attrib.LoadData("销售收款单") ;
			MasterSql=newR_Attrib.MasterViewFeildName;
			DetailSql=newR_Attrib.DetailViewFeildName;
			this.InitTreeData("SELECT I_Enum.fcname FROM I_EnumType INNER JOIN  I_Enum ON I_EnumType.fgEnumTypeID = I_Enum.fgEnumTypeID WHERE (I_EnumType.fcName = '收款类型')");
			ShowData(grd_Top,MasterSql);
			ShowData(grd_Bottom,DetailSql);
			grd_Bottom.SetCellWidth =newR_Attrib.GetDetailColWidth("销售收款单");
		}
		protected override void InitTreeData(string p_TreeDataSource)
		{
			if (p_TreeDataSource!=null && p_TreeDataSource!="")
			{
				InitData.InitTreeView (tv_Tree,p_TreeDataSource,"收款类型");
			}

		}
		private  void ShowData(ljs.MyFlexGrid p_FlexGrid ,string p_Filter)
		{
			//添加行号
			p_FlexGrid.Clear();
			InitData.ShowGridData(p_FlexGrid,p_Filter);

		}
		protected override void tv_Tree_Click(object sender, EventArgs e)
		{

			TreeNode tn = new TreeNode();
			tn = tv_Tree.SelectedNode;
			if (tn != null)
			{
				string[] arrTemp=tn.Text.Split(':')  ;
				
				sReceiptType=arrTemp[0];
//				CboReceiptNo.Text=sReceiptNO;
				//替换主从SQL语句中的单据编号变量
				string MasterSql1=MasterSql.ToLower().Replace("@receiptno",sReceiptNO);
				string DetailSql1=DetailSql.ToLower().Replace("@receiptno",sReceiptNO);
				ShowData(grd_Top,MasterSql1);
				ShowData(grd_Bottom,DetailSql1);

			}

		}

		private void cmd_Look_Click(object sender, System.EventArgs e)
		{
			frmSellReceive f=new frmSellReceive();
			    f.SetReceiptType=sReceiptType;
			    f.ShowDialog();

		}

		private void cbo_Customer_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
		  		
			if (e.KeyChar == (char)13) 
			{
				newR_Method.ComboListSearch(cbo_Customer);
			}
       
		}

		private void cbo_Customer_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
		}

	














	}
}

