using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace JXC_MIS.UserTier.CommonForm
{
	public class frmReport : JXC_MIS.UserTier.BaseForm.frmTreeFlexGrid
	{
		private System.ComponentModel.IContainer components = null;
		private System.Data.DataTable dt =new System.Data.DataTable();
		private JXC_MIS.MyClass.ClsReceiptAttrib newR_Attrib=new JXC_MIS.MyClass.ClsReceiptAttrib();
		JXC_MIS.MyClass.ClsQueryAttrib newQueryAttrib=new JXC_MIS.MyClass.ClsQueryAttrib();

		private System.Windows.Forms.ContextMenu Menu_Right;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Data.DataSet dst = new System.Data.DataSet();
		private string s_ColCaption;
		private string s_QuerySQLName;
		private string s_ReportName="";
		private System.Windows.Forms.Label lbl_Prompt;
		private string  _DataSource="up_ljs_SelectSellForCollect";


		public frmReport()
		{
			// 该调用是 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()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmReport));
			this.lbl_Prompt = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// panel1
			// 
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(674, 446);
			// 
			// spt_H
			// 
			this.spt_H.Location = new System.Drawing.Point(3, 0);
			this.spt_H.Name = "spt_H";
			this.spt_H.Size = new System.Drawing.Size(671, 3);
			// 
			// spt_V
			// 
			this.spt_V.Location = new System.Drawing.Point(0, 0);
			this.spt_V.Name = "spt_V";
			this.spt_V.Size = new System.Drawing.Size(3, 446);
			// 
			// tv_Tree
			// 
			this.tv_Tree.Name = "tv_Tree";
			this.tv_Tree.Size = new System.Drawing.Size(0, 446);
			this.tv_Tree.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tv_Tree_AfterSelect);
			// 
			// 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";
			this.cmd_ExeQuery.Click += new System.EventHandler(this.cmd_ExeQuery_Click);
			// 
			// grd_Filter
			// 
			this.grd_Filter.Name = "grd_Filter";
			// 
			// sbr_StatusBar
			// 
			this.sbr_StatusBar.Name = "sbr_StatusBar";
			this.sbr_StatusBar.Size = new System.Drawing.Size(674, 25);
			// 
			// tbr_Toolbar
			// 
			this.tbr_Toolbar.Name = "tbr_Toolbar";
			this.tbr_Toolbar.Size = new System.Drawing.Size(674, 28);
			// 
			// grd_Top
			// 
			this.grd_Top.Location = new System.Drawing.Point(3, 0);
			this.grd_Top.Name = "grd_Top";
			this.grd_Top.Size = new System.Drawing.Size(671, 0);
			// 
			// grd_Bottom
			// 
			this.grd_Bottom.Location = new System.Drawing.Point(0, 0);
			this.grd_Bottom.Name = "grd_Bottom";
			this.grd_Bottom.Size = new System.Drawing.Size(672, 446);
			// 
			// TxtTemp
			// 
			this.TxtTemp.Name = "TxtTemp";
			// 
			// img_ImageList
			// 
			this.img_ImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("img_ImageList.ImageStream")));
			// 
			// btnDown
			// 
			this.btnDown.Name = "btnDown";
			// 
			// lbl_Prompt
			// 
			this.lbl_Prompt.ForeColor = System.Drawing.Color.Blue;
			this.lbl_Prompt.Location = new System.Drawing.Point(218, 10);
			this.lbl_Prompt.Name = "lbl_Prompt";
			this.lbl_Prompt.Size = new System.Drawing.Size(448, 14);
			this.lbl_Prompt.TabIndex = 23;
			this.lbl_Prompt.Text = "操作提示：";
			// 
			// frmReport
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(674, 499);
			this.Controls.Add(this.lbl_Prompt);
			this.Name = "frmReport";
			this.Load += new System.EventHandler(this.frmReport_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.lbl_Prompt, 0);
			this.ResumeLayout(false);

		}
		#endregion




		//		private  void ShowData(string p_Filter)
		//		{
		//			int rs=0;
		////			if (p_Filter=="<全部>") { p_Filter="";} 
		////			else { p_Filter=cbo_FliterValue.Text;}
		////			dst= newADO.GetDataSet("ljs_KC_ProLibStore '"+p_Filter +"'");
		////			this.grd_Top.DataSource=dst.Tables[0] ;
		////			rs=dst.Tables[0].Rows.Count;
		////			//添加行号
		////			for (int r=1;r<rs+1;r++)
		////			{
		////				this.grd_Top[r-1,grd_Top.CurrentCell.ColumnNumber]=r.ToString();
		////			}
		//			this.grd_Top.CaptionText="查询结果:   共"+rs.ToString()+"行" ;
		//
		//		}
		//
		//
		//
		//		private void grd_Top_DoubleClick(object sender, System.EventArgs e)
		//		{
		//			//"√";
		//			int rs=0;
		//			if (this.grd_Top[grd_Top.CurrentCell.RowNumber,0].ToString() =="√")
		//			{
		//				rs=grd_Top.CurrentCell.RowNumber+1;
		//				this.grd_Top[grd_Top.CurrentCell.RowNumber ,0]=rs.ToString();
		//			}
		//			else
		//			{
		//				this.grd_Top[grd_Top.CurrentCell.RowNumber ,0]="√";
		//				dt.Rows.Add(dt.NewRow());
		//				for (int intColIndex=0;intColIndex<dt.Columns.Count-1;intColIndex++)
		//				{
		//					dt.Rows[dt.Rows.Count-1][intColIndex]=this.grd_Top[grd_Top.CurrentCell.RowNumber ,intColIndex];
		//				}
		//				dt.Rows[dt.Rows.Count-1][0]=dt.Rows.Count.ToString();
		//				grd_Bottom.DataSource=dt;
		//               
		//			}
		//
		//            
		//		}
		//
		private void frmReport_Load(object sender, System.EventArgs e)
		{
			tv_Tree.Width =140;
			spt_H.Visible =false;
			grd_Top.Visible =false;
			spt_H.BringToFront() ;
			grd_Bottom.OnlyRead =true;
			
			this.ShowResize();
//			grd_Top.Height =400;
//			ShowData(grd_Top);
//			ShowData(grd_Bottom);


			//			int	cs=dst.Tables[0].Columns.Count;
			//
			//			for (int intRowIndex=0;intRowIndex<cs;intRowIndex++)
			//			{
			//				dt.Columns.Add(dst.Tables[0].Columns[intRowIndex].Caption);
			//			}	
			//			grd_Bottom.DataSource=dt;

			this.InitTreeData("Select fcReceiptName From S_receiptSetup where left(fcReceiptNo,3)='N03' and fcClass='2'");
		}
		protected override void InitTreeData(string p_TreeDataSource)
		{
			if (p_TreeDataSource!=null && p_TreeDataSource!="")
			{
				InitData.InitTreeView (tv_Tree,p_TreeDataSource,"报表一览");
			}

		}
		//
		//
		protected override  void tv_Tree_Click(object sender, System.EventArgs e)
		{
			TreeNode tn = new TreeNode();

			tn = tv_Tree.SelectedNode;
			try
			{
				if (tn != null)
				{
					string[] ArrTemp=null;
					this.pnl_Filter.Visible =true;
					this.pnl_Filter.BringToFront();
					this.OpenFilter(tn.Text); 
					s_ReportName =tn.Text ;
					lbl_Prompt.Text ="";
					if (this.m_ConnectReceipt!="")
					{
						ArrTemp=this.m_ConnectReceipt.Split('=');
						lbl_Prompt.Text ="操作提示：单击第["+ArrTemp[1]+"]列查看["+ArrTemp[0]+"] ";
					}
					else
					{}
					if (this.m_ConnectNextQuery!="")
					{
						ArrTemp=null;
						ArrTemp=this.m_ConnectNextQuery.Split('=');
						lbl_Prompt.Text =lbl_Prompt.Text+"  双击查看 ["+ArrTemp[0]+"]";
					}
					else
					{}
				}
			}
			catch
			{

			}


		}

		private  void ShowData(ljs.MyFlexGrid p_FlexGrid)
		{
//			string p_Filter="";
//			if (cbo_FliterValue.Text=="<全部>") { p_Filter="";} 
//			else { p_Filter=cbo_FliterValue.Text;}
			//添加行号
			p_FlexGrid.Clear();
//			InitData.ShowGridData(p_FlexGrid,_DataSource+ "  '"+p_Filter +"'");
			InitData.ShowGridData(p_FlexGrid,this.m_SQL );

			//			p_FlexGrid.ColWidthAuto();
//			p_FlexGrid.SetCellWidth =newR_Attrib.GetDetailColWidth("库存参照");


		}

		private void LoadData(string p_Where)
		{
			this.Cursor = Cursors.WaitCursor;

			try
			{
				string strSQL=p_Where;//"ljs_SellProductTotals";

				if (strSQL!="")
				{
					System.Data.DataSet dst = new System.Data.DataSet();
					dst= newADO.GetDataSet(strSQL);
					//					grd_Top.DataSource=dst.Tables[0] ;
				
				}
			}
			catch
			{}
			this.Cursor = Cursors.Default;
		}

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

		protected override void cmd_ExeQuery_Click(object sender, System.EventArgs e)
		{
			base.cmd_ExeQuery_Click(sender,e) ;
//			ShowData(grd_Bottom);

		}
		//
		//
		//
		//		protected override void tbr_Toolbar_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
		//		{
		//			base.tbr_Toolbar_ButtonClick (sender, 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();
		//			////					pnl_Filter.Visible =true;
		//			//					break;
		//			//				case "退出":
		//			//					this.Close();
		//			//					break;
		//			//
		//			//				default:
		//			// 
		//			//					break;
		//			//			}
		//
		//		}
		//
		//
		//		protected override void cmd_ExeQuery_Click(object sender, EventArgs e)
		//		{
		//			newR_Attrib.LoadData(s_ReportName); 
		//			s_QuerySQLName=newR_Attrib.MasterTableName ;
		//			s_ColCaption=newR_Attrib.PageTopFormat;
		//				this.InitFilter(s_ColCaption);
		//			 LoadData(s_QuerySQLName);
		//			base.cmd_ExeQuery_Click (sender, e);
		//		}
		//
		//














	}
}

