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

namespace JXC_MIS.UserTier.CommonForm
{
	/// <summary>
	/// frmReportWhere 的摘要说明。
	/// </summary>
	public class frmReportFilter : System.Windows.Forms.Form
	{
		private string m_colCaption ="开始日期,D,1|终止日期,D,1|班别,C,SELECT DISTINCT fstrClassTeam  FROM InitClassTeam|坯锭,C,18" ;						 //列标题
		private string m_queryName  ;				    //
		private string m_ReportName  ;				    //
		/// <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;} 
		}
		private System.Windows.Forms.Button cmd_OK;
		private System.Windows.Forms.Button cmd_Cancel;
		private ljs.MyGrid grd_Filter;
		private System.Windows.Forms.Panel pnl_Bottom;
		private System.Windows.Forms.DateTimePicker dt_Date;
		private System.Windows.Forms.ComboBox cbo_Value;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmReportFilter()
		{
			//
			// 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.grd_Filter = new ljs.MyGrid();
			this.pnl_Bottom = new System.Windows.Forms.Panel();
			this.cmd_Cancel = new System.Windows.Forms.Button();
			this.cmd_OK = new System.Windows.Forms.Button();
			this.dt_Date = new System.Windows.Forms.DateTimePicker();
			this.cbo_Value = new System.Windows.Forms.ComboBox();
			this.pnl_Bottom.SuspendLayout();
			this.SuspendLayout();
			// 
			// grd_Filter
			// 
			this.grd_Filter.BackColor = System.Drawing.Color.White;
			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(4, 2);
			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 = 22;
			this.grd_Filter.Rows = 2;
			this.grd_Filter.SetCellWidth = "100,100,100,100,100,100,100,100";
			this.grd_Filter.Size = new System.Drawing.Size(386, 160);
			this.grd_Filter.TabIndex = 0;
			this.grd_Filter.Cell_Click += new ljs.GridCell_Click(this.grd_Filter_Click);
			this.grd_Filter.Click += new System.EventHandler(this.grd_Filter_Click);
			// 
			// pnl_Bottom
			// 
			this.pnl_Bottom.Controls.Add(this.cmd_Cancel);
			this.pnl_Bottom.Controls.Add(this.cmd_OK);
			this.pnl_Bottom.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.pnl_Bottom.Location = new System.Drawing.Point(0, 171);
			this.pnl_Bottom.Name = "pnl_Bottom";
			this.pnl_Bottom.Size = new System.Drawing.Size(392, 38);
			this.pnl_Bottom.TabIndex = 1;
			// 
			// cmd_Cancel
			// 
			this.cmd_Cancel.Location = new System.Drawing.Point(268, 4);
			this.cmd_Cancel.Name = "cmd_Cancel";
			this.cmd_Cancel.TabIndex = 3;
			this.cmd_Cancel.Text = "取消";
			this.cmd_Cancel.Click += new System.EventHandler(this.cmd_Cancel_Click);
			// 
			// cmd_OK
			// 
			this.cmd_OK.Location = new System.Drawing.Point(192, 4);
			this.cmd_OK.Name = "cmd_OK";
			this.cmd_OK.TabIndex = 2;
			this.cmd_OK.Text = "确定";
			this.cmd_OK.Click += new System.EventHandler(this.cmd_OK_Click);
			// 
			// dt_Date
			// 
			this.dt_Date.Location = new System.Drawing.Point(194, 46);
			this.dt_Date.Name = "dt_Date";
			this.dt_Date.Size = new System.Drawing.Size(188, 21);
			this.dt_Date.TabIndex = 2;
			this.dt_Date.Visible = false;
			this.dt_Date.Leave += new System.EventHandler(this.dt_Date_Leave);
			// 
			// cbo_Value
			// 
			this.cbo_Value.Location = new System.Drawing.Point(194, 66);
			this.cbo_Value.Name = "cbo_Value";
			this.cbo_Value.Size = new System.Drawing.Size(188, 20);
			this.cbo_Value.TabIndex = 3;
			this.cbo_Value.Visible = false;
			this.cbo_Value.Leave += new System.EventHandler(this.cbo_Value_Leave);
			// 
			// frmReportFilter
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(392, 209);
			this.Controls.Add(this.cbo_Value);
			this.Controls.Add(this.dt_Date);
			this.Controls.Add(this.pnl_Bottom);
			this.Controls.Add(this.grd_Filter);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmReportFilter";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "报表过滤";
			this.Load += new System.EventHandler(this.frmReportFilter_Load);
			this.pnl_Bottom.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmReportFilter_Load(object sender, System.EventArgs e)
		{
			string [] ArrSplit = null; //     临时数组变量
			string [] ArrSplit1 = null; //     临时数组变量
			//'设置行数，列数
			ArrSplit = m_colCaption.Split('|');
			int rs=ArrSplit.Length;				//总行数
			grd_Filter.Rows =rs    ;			//设置行数
			grd_Filter.Cols = 4 ;    //    
			//'设置列宽
			grd_Filter.SetCellWidth ="90,270,0,0"; 
			grd_Filter.RowHeightMin =20;//22;
			grd_Filter.ShowGrid() ;
			grd_Filter.SetColBackColor(SystemColors.Control  ,true);
			int m=0;
			for (int i=0;i<rs;i++)
			{
				ArrSplit1 = ArrSplit[i].Split(',');
                m=ArrSplit1.Length ;
				if (m > 0) {grd_Filter.CellText(i,0,ArrSplit1[0]);}
				if (m > 1) {grd_Filter.CellText(i,2,ArrSplit1[1]);}
				if (m > 2) {grd_Filter.CellText(i,3,ArrSplit1[2]);}
			}
//			grd_Filter.Left =0;
			this.Width =grd_Filter.Width +10;
			this.Height =grd_Filter.Height +pnl_Bottom.Height*2+grd_Filter.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 cmd_Cancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void cmd_OK_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		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;
		}












		
	}
}
