using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Core.Mes.ClientFrameWork;

using Core.XgMes.Client.StorageBase;

namespace Core.XgMes.Client.JGKC.SteelPlateManager
{
	/// <summary>
	/// 中板成品发运综合查询
	/// </summary>
	public class TurnoffSendQuery : Core.XgMes.Client.StorageBase.FrmStorageBaseMode
	{
		#region "Varible"
		protected Infragistics.Win.Misc.UltraExpandableGroupBox exp_SetArea;
		private Infragistics.Win.Misc.UltraExpandableGroupBoxPanel ultraExpandableGroupBoxPanel1;
		private Infragistics.Win.Misc.UltraGroupBox Grp_QueryCondition;
		private Infragistics.Win.UltraWinGrid.UltraGrid Grd_Report;
		#endregion
        private Core.XgMes.Client.JGKC.SteelPlateManager.UCSendQuery ucSendQuery1;
		private Infragistics.Win.UltraWinEditors.UltraCheckEditor chk_AllowFilter;
        private Core.XgMes.Client.JGKC.SteelPlateManager.UCSendStat ucSendStat1;
		private System.Windows.Forms.Splitter splitter1;
        private Infragistics.Win.UltraWinEditors.UltraCheckEditor chk_IsOut;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public TurnoffSendQuery()
		{
			//
			// 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()
		{
            Infragistics.Win.Appearance appearance9 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance7 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance8 = new Infragistics.Win.Appearance();
            this.exp_SetArea = new Infragistics.Win.Misc.UltraExpandableGroupBox();
            this.ultraExpandableGroupBoxPanel1 = new Infragistics.Win.Misc.UltraExpandableGroupBoxPanel();
            this.Grp_QueryCondition = new Infragistics.Win.Misc.UltraGroupBox();
            this.splitter1 = new System.Windows.Forms.Splitter();
            this.ucSendStat1 = new Core.XgMes.Client.JGKC.SteelPlateManager.UCSendStat();
            this.chk_AllowFilter = new Infragistics.Win.UltraWinEditors.UltraCheckEditor();
            this.ucSendQuery1 = new  Core.XgMes.Client.JGKC.SteelPlateManager.UCSendQuery();
            this.Grd_Report = new Infragistics.Win.UltraWinGrid.UltraGrid();
            this.chk_IsOut = new Infragistics.Win.UltraWinEditors.UltraCheckEditor();
            ((System.ComponentModel.ISupportInitialize)(this.BaseToolBarManager)).BeginInit();
            this.FrmBaseMode_Fill_Panel.SuspendLayout();
            this.Pal_Top.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.Grp_Query)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.Calc_Manager)).BeginInit();
            this.Pal_Buttom.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.exp_SetArea)).BeginInit();
            this.exp_SetArea.SuspendLayout();
            this.ultraExpandableGroupBoxPanel1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.Grp_QueryCondition)).BeginInit();
            this.Grp_QueryCondition.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.Grd_Report)).BeginInit();
            this.SuspendLayout();
            // 
            // BaseToolBarManager
            // 
            this.BaseToolBarManager.MenuSettings.ForceSerialization = true;
            this.BaseToolBarManager.ToolbarSettings.AllowCustomize = Infragistics.Win.DefaultableBoolean.False;
            // 
            // FrmBaseMode_Fill_Panel
            // 
            this.FrmBaseMode_Fill_Panel.Size = new System.Drawing.Size(1028, 424);
            // 
            // _FrmBaseMode_Toolbars_Dock_Area_Left
            // 
            this._FrmBaseMode_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 20);
            this._FrmBaseMode_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 424);
            // 
            // _FrmBaseMode_Toolbars_Dock_Area_Right
            // 
            this._FrmBaseMode_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(1028, 20);
            this._FrmBaseMode_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 424);
            // 
            // _FrmBaseMode_Toolbars_Dock_Area_Top
            // 
            this._FrmBaseMode_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(1028, 20);
            // 
            // _FrmBaseMode_Toolbars_Dock_Area_Bottom
            // 
            this._FrmBaseMode_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 444);
            // 
            // Pal_Top
            // 
            this.Pal_Top.Size = new System.Drawing.Size(1028, 0);
            // 
            // Grp_Query
            // 
            this.Grp_Query.Size = new System.Drawing.Size(1028, 0);
            // 
            // Pal_Buttom
            // 
            this.Pal_Buttom.Controls.Add(this.Grd_Report);
            this.Pal_Buttom.Controls.Add(this.exp_SetArea);
            this.Pal_Buttom.Location = new System.Drawing.Point(0, 0);
            this.Pal_Buttom.Size = new System.Drawing.Size(1028, 424);
            // 
            // exp_SetArea
            // 
            this.exp_SetArea.BackColor = System.Drawing.SystemColors.Control;
            this.exp_SetArea.Controls.Add(this.ultraExpandableGroupBoxPanel1);
            this.exp_SetArea.Dock = System.Windows.Forms.DockStyle.Top;
            this.exp_SetArea.ExpandedSize = new System.Drawing.Size(1028, 216);
            this.exp_SetArea.Location = new System.Drawing.Point(0, 0);
            this.exp_SetArea.Name = "exp_SetArea";
            this.exp_SetArea.Size = new System.Drawing.Size(1028, 216);
            this.exp_SetArea.SupportThemes = false;
            this.exp_SetArea.TabIndex = 2;
            this.exp_SetArea.Text = "统计模式及查询条件设置区域";
            this.exp_SetArea.ViewStyle = Infragistics.Win.Misc.GroupBoxViewStyle.Office2003;
            // 
            // ultraExpandableGroupBoxPanel1
            // 
            this.ultraExpandableGroupBoxPanel1.Controls.Add(this.Grp_QueryCondition);
            this.ultraExpandableGroupBoxPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.ultraExpandableGroupBoxPanel1.Location = new System.Drawing.Point(2, 22);
            this.ultraExpandableGroupBoxPanel1.Name = "ultraExpandableGroupBoxPanel1";
            this.ultraExpandableGroupBoxPanel1.Size = new System.Drawing.Size(1024, 192);
            this.ultraExpandableGroupBoxPanel1.TabIndex = 0;
            // 
            // Grp_QueryCondition
            // 
            appearance9.BackColor = System.Drawing.SystemColors.Control;
            this.Grp_QueryCondition.ContentAreaAppearance = appearance9;
            this.Grp_QueryCondition.Controls.Add(this.chk_IsOut);
            this.Grp_QueryCondition.Controls.Add(this.splitter1);
            this.Grp_QueryCondition.Controls.Add(this.ucSendStat1);
            this.Grp_QueryCondition.Controls.Add(this.chk_AllowFilter);
            this.Grp_QueryCondition.Controls.Add(this.ucSendQuery1);
            this.Grp_QueryCondition.Dock = System.Windows.Forms.DockStyle.Fill;
            this.Grp_QueryCondition.Location = new System.Drawing.Point(0, 0);
            this.Grp_QueryCondition.Name = "Grp_QueryCondition";
            this.Grp_QueryCondition.Size = new System.Drawing.Size(1024, 192);
            this.Grp_QueryCondition.SupportThemes = false;
            this.Grp_QueryCondition.TabIndex = 1;
            this.Grp_QueryCondition.Text = "查询条件";
            this.Grp_QueryCondition.ViewStyle = Infragistics.Win.Misc.GroupBoxViewStyle.Office2003;
            // 
            // splitter1
            // 
            this.splitter1.Location = new System.Drawing.Point(752, 20);
            this.splitter1.Name = "splitter1";
            this.splitter1.Size = new System.Drawing.Size(3, 170);
            this.splitter1.TabIndex = 146;
            this.splitter1.TabStop = false;
            // 
            // ucSendStat1
            // 
            this.ucSendStat1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.ucSendStat1.Location = new System.Drawing.Point(752, 20);
            this.ucSendStat1.Name = "ucSendStat1";
            this.ucSendStat1.Size = new System.Drawing.Size(270, 170);
            this.ucSendStat1.TabIndex = 145;
            // 
            // chk_AllowFilter
            // 
            this.chk_AllowFilter.Location = new System.Drawing.Point(559, 167);
            this.chk_AllowFilter.Name = "chk_AllowFilter";
            this.chk_AllowFilter.Size = new System.Drawing.Size(48, 20);
            this.chk_AllowFilter.TabIndex = 144;
            this.chk_AllowFilter.TabStop = false;
            this.chk_AllowFilter.Text = "过滤";
            this.chk_AllowFilter.CheckedChanged += new System.EventHandler(this.chk_AllowFilter_CheckedChanged);
            // 
            // ucSendQuery1
            // 
            this.ucSendQuery1.Dock = System.Windows.Forms.DockStyle.Left;
            this.ucSendQuery1.Location = new System.Drawing.Point(2, 20);
            this.ucSendQuery1.Name = "ucSendQuery1";
            this.ucSendQuery1.Size = new System.Drawing.Size(750, 170);
            this.ucSendQuery1.TabIndex = 0;
            // 
            // Grd_Report
            // 
            this.Grd_Report.CalcManager = this.Calc_Manager;
            this.Grd_Report.DisplayLayout.CaptionVisible = Infragistics.Win.DefaultableBoolean.True;
            appearance1.BackColor = System.Drawing.SystemColors.ActiveBorder;
            appearance1.BackColor2 = System.Drawing.SystemColors.ControlDark;
            appearance1.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
            appearance1.BorderColor = System.Drawing.SystemColors.Window;
            this.Grd_Report.DisplayLayout.GroupByBox.Appearance = appearance1;
            appearance2.ForeColor = System.Drawing.SystemColors.GrayText;
            this.Grd_Report.DisplayLayout.GroupByBox.BandLabelAppearance = appearance2;
            this.Grd_Report.DisplayLayout.GroupByBox.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
            this.Grd_Report.DisplayLayout.GroupByBox.Hidden = true;
            appearance3.BackColor = System.Drawing.SystemColors.ControlLightLight;
            appearance3.BackColor2 = System.Drawing.SystemColors.Control;
            appearance3.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
            appearance3.ForeColor = System.Drawing.SystemColors.GrayText;
            this.Grd_Report.DisplayLayout.GroupByBox.PromptAppearance = appearance3;
            this.Grd_Report.DisplayLayout.Override.BorderStyleCell = Infragistics.Win.UIElementBorderStyle.RaisedSoft;
            this.Grd_Report.DisplayLayout.Override.CellPadding = 0;
            appearance4.BackColor = System.Drawing.SystemColors.Control;
            appearance4.BackColor2 = System.Drawing.SystemColors.ControlDark;
            appearance4.BackGradientAlignment = Infragistics.Win.GradientAlignment.Element;
            appearance4.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
            appearance4.BorderColor = System.Drawing.SystemColors.Window;
            this.Grd_Report.DisplayLayout.Override.GroupByRowAppearance = appearance4;
            appearance5.BackColor = System.Drawing.Color.LightSteelBlue;
            appearance5.TextHAlign = Infragistics.Win.HAlign.Center;
            this.Grd_Report.DisplayLayout.Override.HeaderAppearance = appearance5;
            this.Grd_Report.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.Select;
            this.Grd_Report.DisplayLayout.Override.HeaderStyle = Infragistics.Win.HeaderStyle.Standard;
            this.Grd_Report.DisplayLayout.Override.MinRowHeight = 21;
            appearance6.BackColor = System.Drawing.SystemColors.Window;
            appearance6.BorderColor = System.Drawing.Color.Silver;
            this.Grd_Report.DisplayLayout.Override.RowAppearance = appearance6;
            appearance7.BackColor = System.Drawing.Color.LightSteelBlue;
            this.Grd_Report.DisplayLayout.Override.RowSelectorAppearance = appearance7;
            this.Grd_Report.DisplayLayout.Override.RowSelectorHeaderStyle = Infragistics.Win.UltraWinGrid.RowSelectorHeaderStyle.SeparateElement;
            this.Grd_Report.DisplayLayout.Override.RowSelectorNumberStyle = Infragistics.Win.UltraWinGrid.RowSelectorNumberStyle.RowIndex;
            this.Grd_Report.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True;
            this.Grd_Report.DisplayLayout.Override.SelectTypeCell = Infragistics.Win.UltraWinGrid.SelectType.None;
            appearance8.BackColor = System.Drawing.SystemColors.ControlLight;
            this.Grd_Report.DisplayLayout.Override.TemplateAddRowAppearance = appearance8;
            this.Grd_Report.DisplayLayout.ScrollStyle = Infragistics.Win.UltraWinGrid.ScrollStyle.Immediate;
            this.Grd_Report.Dock = System.Windows.Forms.DockStyle.Fill;
            this.Grd_Report.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.Grd_Report.Location = new System.Drawing.Point(0, 216);
            this.Grd_Report.Name = "Grd_Report";
            this.Grd_Report.Size = new System.Drawing.Size(1028, 208);
            this.Grd_Report.TabIndex = 42;
            // 
            // chk_IsOut
            // 
            this.chk_IsOut.Location = new System.Drawing.Point(606, 167);
            this.chk_IsOut.Name = "chk_IsOut";
            this.chk_IsOut.Size = new System.Drawing.Size(48, 20);
            this.chk_IsOut.TabIndex = 147;
            this.chk_IsOut.TabStop = false;
            this.chk_IsOut.Text = "出口";
            // 
            // TurnoffSendQuery
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.ClientSize = new System.Drawing.Size(1028, 444);
            this.Name = "TurnoffSendQuery";
            this.Text = "TurnoffSendQuery";
            this.Load += new System.EventHandler(this.TurnoffSendQuery_Load);
            ((System.ComponentModel.ISupportInitialize)(this.BaseToolBarManager)).EndInit();
            this.FrmBaseMode_Fill_Panel.ResumeLayout(false);
            this.Pal_Top.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.Grp_Query)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.Calc_Manager)).EndInit();
            this.Pal_Buttom.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.exp_SetArea)).EndInit();
            this.exp_SetArea.ResumeLayout(false);
            this.ultraExpandableGroupBoxPanel1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.Grp_QueryCondition)).EndInit();
            this.Grp_QueryCondition.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.Grd_Report)).EndInit();
            this.ResumeLayout(false);

		}
		#endregion

		#region "Init"
        public string sstyle = "";
		private void TurnoffSendQuery_Load(object sender, System.EventArgs e)
		{
			try
			{
				this.ToolBarToolsConfig = this.Key.Split('@')[1];
				this.DBFileName = this.Key.Split('@')[2];
                sstyle = this.Key.Split('@')[3];
				InitFrmDataSet();
			}
			catch(System.Exception ex)
			{
				System.Diagnostics.Debug.WriteLine(ex.ToString());
			}
		}
		private void InitFrmDataSet()
		{
			try
			{
				if(this.DBFileName.Trim().Length >0)
				{
					object obj = StorageBaseClass.GetEntityInfo(this.DBFileName,this.ProductName);
					if(obj!=null)
					{
						this._FrmDataSet = obj as System.Data.DataSet;
						this._FrmDataSet.Tables["KCJ_TURNOFFOUTSTORAGE"].PrimaryKey = null;
						this._FrmDataSet.Tables["KCJ_TURNOFFOUTSTORAGE"].Constraints.Clear();
						Init_Frm();
					}
				}
			}
			catch(System.Exception ex)
			{
				System.Diagnostics.Debug.WriteLine(ex.ToString());
			}
		}
		protected override void Init_Frm()
		{
			StorageGridHelper.SetGrid(this.Grd_Report,ref this._FrmDataSet,"KCJ_TURNOFFOUTSTORAGE",new string[]{"KCJ_TURNOFFOUTSTORAGE"});
			this.Grd_Report.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.False; 
			this.ucSendQuery1.MyDataSet = this._FrmDataSet;
			foreach(Infragistics.Win.UltraWinGrid.UltraGridColumn col in this.Grd_Report.DisplayLayout.Bands[0].Columns)
			{
				col.RowLayoutColumnInfo.SpanY = 1;
				col.RowLayoutColumnInfo.SpanX = 1;
			}
		}
		#endregion

		#region "ToolBarButton"
		protected override bool Query()
		{
			try
			{
				this._FrmDataSet.Tables["KCJ_TURNOFFOUTSTORAGE"].Clear();
				string where =this.ucSendQuery1.WhereStr;
				System.Collections.ArrayList ps = new ArrayList();
				System.Collections.ArrayList pg = new ArrayList();
				System.Collections.ArrayList ps0 = this.ucSendStat1.SendSelectStr;
				System.Collections.ArrayList pg0 = this.ucSendStat1.SendGroupbyStr;
				System.Collections.ArrayList ps1 = this.ucSendStat1.ClearSendSelectStr;
		



                System.Collections.ArrayList ps3 = this.ucSendStat1.SendSelectStr1;
                System.Collections.ArrayList pg3 = this.ucSendStat1.SendGroupbyStr;
                //string where1 = " ";
               
                if (where.IndexOf("A.CLEARFLAG") < 0 && where.IndexOf("A.SENDTYPE='8'") <= 0 && chk_IsOut.Checked==false)
				{
					ps.AddRange(ps0);
					ps.AddRange(ps1);
					pg.AddRange(pg0);
                    pg.AddRange(ps1);
					
				}
				else if(where.IndexOf("A.CLEARFLAG='0'")>=0)
				{
					ps.AddRange(ps0);
					pg.AddRange(pg0);
				}
				
                
               
				string strerr = "";
                object obj = "";

                obj = Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod("BJZWStuff", "Core.XgMes.Server.JGKC.SteelPlateManager.TurnoffReportList",
                       "GetOutStorageData", new object[] { where, ps, pg }, out strerr);

				if(obj!=null)
				{
					this._FrmDataSet.Merge(obj as System.Data.DataSet);
					this._FrmDataSet.AcceptChanges();
					foreach(System.Data.DataColumn col in this._FrmDataSet.Tables["KCJ_TURNOFFOUTSTORAGE"].Columns)
					{
						if(!((System.Data.DataSet)obj).Tables[0].Columns.Contains(col.ColumnName))
						{
							this.Grd_Report.DisplayLayout.Bands[0].Columns[col.ColumnName].Hidden = true;
						}
						else
						{
							this.Grd_Report.DisplayLayout.Bands[0].Columns[col.ColumnName].Hidden = false;
						}
                     
					}
				}
				return true;
			}
			catch(System.Exception ex)
			{
				System.Diagnostics.Debug.WriteLine(ex.ToString());
				return false;
			}
		}
		public void Export()
		{
			try
			{
				string filename = @"成品发运.xls";
				base.ultraGridExcelExporter.Export(this.Grd_Report,filename);
				System.Diagnostics.ProcessStartInfo st = new System.Diagnostics.ProcessStartInfo(filename);
				st.WindowStyle =System.Diagnostics.ProcessWindowStyle.Maximized ; 
				System.Diagnostics.Process.Start(st);
			}
			catch(System.Exception ex)
			{
				System.Diagnostics.Debug.WriteLine(ex.ToString());
			}
		}
		#endregion

		private void chk_AllowFilter_CheckedChanged(object sender, System.EventArgs e)
		{
			if (this.chk_AllowFilter.Checked)
			{
				this.Grd_Report.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.True;				
				
			}
			else
			{
				this.Grd_Report.DisplayLayout.Bands[0].ColumnFilters.ClearAllFilters();
				this.Grd_Report.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;				
			
				
			}
		}

	
	}
}
