using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using System.Collections; using Infragistics.Win.UltraWinGrid; namespace Core.LZMes.Client.UIM.UIM03 { public partial class UIM031100 : FrmBase { public UIM031100() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; case "Export": this.DoExport(); break; case "Exit": this.Close(); break; } } private void DoQuery() { try { this.dataSet1.Tables[0].Clear(); string queryDate = this.ultraDateTimeEditor1.Value == null ? "" : this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd"); string queryDate1 = this.ultraDateTimeEditor2.Value == null ? "" : this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd"); if (queryDate1.Substring(0, 6) != queryDate.Substring(0, 6)) { MessageBox.Show("请确保两个查询日期在同一月份", "错误"); return; } string queryDate2 = "";//月累统计截止日期 if (queryDate.Substring(0, 6) == DateTime.Today.ToString("yyyyMM"))//查询日期为当月 queryDate2 = DateTime.Today.ToString("yyyyMMdd"); else { DateTime date = ultraDateTimeEditor2.DateTime; queryDate2 = date.AddDays(1 - date.Day).AddMonths(1).AddDays(-1).ToString("yyyyMMdd"); } if (CustomInfo == "2" || CustomInfo == "1" || CustomInfo == "3" || CustomInfo == "4" || CustomInfo == "5" || CustomInfo == "6" || CustomInfo == "7" || CustomInfo == "8") { CoreClientParam ccp1 = null; ccp1 = new CoreClientParam(); Hashtable ht = new Hashtable(); ht.Add("i1", this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd")); ht.Add("i2", this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd")); ht.Add("o3", ""); //规格明细统计 ccp1.ServerName = "UIB.COM.ComDBProcedure"; ccp1.MethodName = "doXmlProcedure"; if (CustomInfo == "1") ccp1.ServerParams = new object[] { "UIM020010_01.CALL", ht }; else if (CustomInfo == "2") ccp1.ServerParams = new object[] { "UIM020010_02.CALL", ht }; else if (CustomInfo == "3") ccp1.ServerParams = new object[] { "UIM020010_03.CALL", ht }; else if (CustomInfo == "4") ccp1.ServerParams = new object[] { "UIM020010_04.CALL", ht }; else if (CustomInfo == "5") ccp1.ServerParams = new object[] { "UIM020010_05.CALL", ht }; else if (CustomInfo == "6") ccp1.ServerParams = new object[] { "UIM020010_06.CALL", ht }; else if (CustomInfo == "7") ccp1.ServerParams = new object[] { "UIM020010_07.CALL", ht }; else if (CustomInfo == "8") ccp1.ServerParams = new object[] { "UIM020010_08.CALL", ht }; this.ExecuteNonQuery(ccp1, CoreInvokeType.Internal); //规格明细查询 CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIM.UIM02.UIM020010"; if (CustomInfo == "1") ccp.MethodName = "queryPltcmSizeDetail"; else if (CustomInfo == "2") ccp.MethodName = "queryCalSizeDetail"; else if (CustomInfo == "3") ccp.MethodName = "queryRclSizeDetail"; else if (CustomInfo == "4") ccp.MethodName = "queryINYARDSizeDetail"; else if (CustomInfo == "5") ccp.MethodName = "querySuanXiSizeDetail"; else if (CustomInfo == "6") ccp.MethodName = "querySuanXiSizeDetail"; else if (CustomInfo == "7") ccp.MethodName = "queryPltcmSizeDetail"; else if (CustomInfo == "8") ccp.MethodName = "queryINYARDSizeDetail"; ccp.ServerParams = null; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); //合计成材率的计算 #region if (ultraGrid1.Rows.Count > 0) { UltraGridRow ur1 = null; UltraGridRow ur2 = null; UltraGridRow ur3 = null; int n = 0; foreach (UltraGridRow ur in ultraGrid1.Rows) { if (ur.Cells["SPEC_STL_GRD"].Text == "合计" && ur.Cells["PRODUCT_NAME"].Text == "原料") { ur1 = ur; n++; } else if (ur.Cells["SPEC_STL_GRD"].Text == "合计" && ur.Cells["PRODUCT_NAME"].Text == "产量") { ur2 = ur; n++; } else if (ur.Cells["SPEC_STL_GRD"].Text == "合计" && ur.Cells["PRODUCT_NAME"].Text == "成材率") { ur3 = ur; n++; } if (n == 3) break; } //ACT_WGT1 if (double.Parse(ur2.Cells["ACT_WGT1"].Value.ToString()) == 0 || double.Parse(ur1.Cells["ACT_WGT1"].Value.ToString())==0) ur3.Cells["ACT_WGT1"].Value = 0; else { double n1 = double.Parse(ur2.Cells["ACT_WGT1"].Value.ToString()) / double.Parse(ur1.Cells["ACT_WGT1"].Value.ToString()) * 100; n1 = Math.Round(n1, 2); ur3.Cells["ACT_WGT1"].Value = n1.ToString(); } //ACT_WGT2 if (double.Parse(ur2.Cells["ACT_WGT2"].Value.ToString())==0 || double.Parse(ur1.Cells["ACT_WGT2"].Value.ToString())==0) ur3.Cells["ACT_WGT2"].Value = 0; else { double n1 = double.Parse(ur2.Cells["ACT_WGT2"].Value.ToString()) / double.Parse(ur1.Cells["ACT_WGT2"].Value.ToString()) * 100; n1 = Math.Round(n1, 2); ur3.Cells["ACT_WGT2"].Value = n1.ToString(); } //ACT_WGT2_3 if (double.Parse(ur2.Cells["ACT_WGT2_3"].Value.ToString()) == 0 || double.Parse(ur1.Cells["ACT_WGT2_3"].Value.ToString()) == 0) ur3.Cells["ACT_WGT2_3"].Value = 0; else { double n1 = double.Parse(ur2.Cells["ACT_WGT2_3"].Value.ToString()) / double.Parse(ur1.Cells["ACT_WGT2_3"].Value.ToString()) * 100; n1 = Math.Round(n1, 2); ur3.Cells["ACT_WGT2_3"].Value = n1.ToString(); } //ACT_WGT3 if (double.Parse(ur2.Cells["ACT_WGT3"].Value.ToString()) == 0 || double.Parse(ur1.Cells["ACT_WGT3"].Value.ToString()) == 0) ur3.Cells["ACT_WGT3"].Value = 0; else { double n1 = double.Parse(ur2.Cells["ACT_WGT3"].Value.ToString()) / double.Parse(ur1.Cells["ACT_WGT3"].Value.ToString()) * 100; n1 = Math.Round(n1, 2); ur3.Cells["ACT_WGT3"].Value = n1.ToString(); } //ACT_WGT4 if (double.Parse(ur2.Cells["ACT_WGT4"].Value.ToString()) == 0 || double.Parse(ur1.Cells["ACT_WGT4"].Value.ToString()) == 0) ur3.Cells["ACT_WGT4"].Value = 0; else { double n1 = double.Parse(ur2.Cells["ACT_WGT4"].Value.ToString()) / double.Parse(ur1.Cells["ACT_WGT4"].Value.ToString()) * 100; n1 = Math.Round(n1, 2); ur3.Cells["ACT_WGT4"].Value = n1.ToString(); } //ACT_WGT5判断是否为空 if (string.IsNullOrEmpty(ur2.Cells["ACT_WGT5"].Value.ToString()) || string.IsNullOrEmpty(ur1.Cells["ACT_WGT5"].Value.ToString())) { ur3.Cells["ACT_WGT5"].Value = 0; } else if (double.Parse(ur2.Cells["ACT_WGT5"].Value.ToString()) == 0 || double.Parse(ur1.Cells["ACT_WGT5"].Value.ToString()) == 0) { ur3.Cells["ACT_WGT5"].Value = 0; } else { double n1 = double.Parse(ur2.Cells["ACT_WGT5"].Value.ToString()) / double.Parse(ur1.Cells["ACT_WGT5"].Value.ToString()) * 100; n1 = Math.Round(n1, 2); ur3.Cells["ACT_WGT5"].Value = n1.ToString(); } //ACT_WGT if (double.Parse(ur2.Cells["ACT_WGT"].Value.ToString()) == 0 || double.Parse(ur1.Cells["ACT_WGT"].Value.ToString()) == 0) ur3.Cells["ACT_WGT"].Value = 0; else { double n1 = double.Parse(ur2.Cells["ACT_WGT"].Value.ToString()) / double.Parse(ur1.Cells["ACT_WGT"].Value.ToString()) * 100; n1 = Math.Round(n1, 2); ur3.Cells["ACT_WGT"].Value = n1.ToString(); } //SUMACT_WGT1 if (double.Parse(ur2.Cells["SUMACT_WGT1"].Value.ToString()) == 0 || double.Parse(ur1.Cells["SUMACT_WGT1"].Value.ToString()) == 0) ur3.Cells["SUMACT_WGT1"].Value = 0; else { double n1 = double.Parse(ur2.Cells["SUMACT_WGT1"].Value.ToString()) / double.Parse(ur1.Cells["SUMACT_WGT1"].Value.ToString()) * 100; n1 = Math.Round(n1, 2); ur3.Cells["SUMACT_WGT1"].Value = n1.ToString(); } //SUMACT_WGT2 if (double.Parse(ur2.Cells["SUMACT_WGT2"].Value.ToString()) == 0 || double.Parse(ur1.Cells["SUMACT_WGT2"].Value.ToString()) == 0) ur3.Cells["SUMACT_WGT2"].Value = 0; else { double n1 = double.Parse(ur2.Cells["SUMACT_WGT2"].Value.ToString()) / double.Parse(ur1.Cells["SUMACT_WGT2"].Value.ToString()) * 100; n1 = Math.Round(n1, 2); ur3.Cells["SUMACT_WGT2"].Value = n1.ToString(); } //SUMACT_WGT2_3 if (double.Parse(ur2.Cells["SUMACT_WGT2_3"].Value.ToString()) == 0 || double.Parse(ur1.Cells["SUMACT_WGT2_3"].Value.ToString()) == 0) ur3.Cells["SUMACT_WGT2_3"].Value = 0; else { double n1 = double.Parse(ur2.Cells["SUMACT_WGT2_3"].Value.ToString()) / double.Parse(ur1.Cells["SUMACT_WGT2_3"].Value.ToString()) * 100; n1 = Math.Round(n1, 2); ur3.Cells["SUMACT_WGT2_3"].Value = n1.ToString(); } //SUMACT_WGT3 if (double.Parse(ur2.Cells["SUMACT_WGT3"].Value.ToString()) == 0 || double.Parse(ur1.Cells["SUMACT_WGT3"].Value.ToString()) == 0) ur3.Cells["SUMACT_WGT3"].Value = 0; else { double n1 = double.Parse(ur2.Cells["SUMACT_WGT3"].Value.ToString()) / double.Parse(ur1.Cells["SUMACT_WGT3"].Value.ToString()) * 100; n1 = Math.Round(n1, 2); ur3.Cells["SUMACT_WGT3"].Value = n1.ToString(); } //SUMACT_WGT4 if (double.Parse(ur2.Cells["SUMACT_WGT4"].Value.ToString()) == 0 || double.Parse(ur1.Cells["SUMACT_WGT4"].Value.ToString()) == 0) ur3.Cells["SUMACT_WGT4"].Value = 0; else { double n1 = double.Parse(ur2.Cells["SUMACT_WGT4"].Value.ToString()) / double.Parse(ur1.Cells["SUMACT_WGT4"].Value.ToString()) * 100; n1 = Math.Round(n1, 2); ur3.Cells["SUMACT_WGT4"].Value = n1.ToString(); } //SUMACT_WGT5判断是否为空 if (string.IsNullOrEmpty(ur2.Cells["SUMACT_WGT5"].Value.ToString()) || string.IsNullOrEmpty(ur1.Cells["SUMACT_WGT5"].Value.ToString())) { ur3.Cells["SUMACT_WGT5"].Value = 0; } else if (double.Parse(ur2.Cells["SUMACT_WGT5"].Value.ToString()) == 0 || double.Parse(ur1.Cells["SUMACT_WGT5"].Value.ToString()) == 0) ur3.Cells["SUMACT_WGT5"].Value = 0; else { double n1 = double.Parse(ur2.Cells["SUMACT_WGT5"].Value.ToString()) / double.Parse(ur1.Cells["SUMACT_WGT5"].Value.ToString()) * 100; n1 = Math.Round(n1, 2); ur3.Cells["SUMACT_WGT5"].Value = n1.ToString(); } //SUMACT_WGT if (double.Parse(ur2.Cells["SUMACT_WGT"].Value.ToString()) == 0 || double.Parse(ur1.Cells["SUMACT_WGT"].Value.ToString()) == 0) ur3.Cells["SUMACT_WGT"].Value = 0; else { double n1 = double.Parse(ur2.Cells["SUMACT_WGT"].Value.ToString()) / double.Parse(ur1.Cells["SUMACT_WGT"].Value.ToString()) * 100; n1 = Math.Round(n1, 2); ur3.Cells["SUMACT_WGT"].Value = n1.ToString(); } for (int i = 0; i < ultraGrid1.Rows.Count; i++) { if (ultraGrid1.Rows[i].Cells["SPEC_STL_GRD"].Text == "合计" && ultraGrid1.Rows[i].Cells["PRODUCT_NAME"].Text == "成材率") { ultraGrid1.Rows[i].Cells["SUMACT_WGT1"].Value = ur3.Cells["SUMACT_WGT1"].Value; ultraGrid1.Rows[i].Cells["SUMACT_WGT2"].Value = ur3.Cells["SUMACT_WGT2"].Value; ultraGrid1.Rows[i].Cells["SUMACT_WGT2_3"].Value = ur3.Cells["SUMACT_WGT2_3"].Value; ultraGrid1.Rows[i].Cells["SUMACT_WGT3"].Value = ur3.Cells["SUMACT_WGT3"].Value; ultraGrid1.Rows[i].Cells["SUMACT_WGT4"].Value = ur3.Cells["SUMACT_WGT4"].Value; ultraGrid1.Rows[i].Cells["SUMACT_WGT5"].Value = ur3.Cells["SUMACT_WGT5"].Value; ultraGrid1.Rows[i].Cells["SUMACT_WGT"].Value = ur3.Cells["SUMACT_WGT"].Value; ultraGrid1.Rows[i].Cells["ACT_WGT1"].Value = ur3.Cells["ACT_WGT1"].Value; ultraGrid1.Rows[i].Cells["ACT_WGT2"].Value = ur3.Cells["ACT_WGT2"].Value; ultraGrid1.Rows[i].Cells["ACT_WGT2_3"].Value = ur3.Cells["ACT_WGT2_3"].Value; ultraGrid1.Rows[i].Cells["ACT_WGT3"].Value = ur3.Cells["ACT_WGT3"].Value; ultraGrid1.Rows[i].Cells["ACT_WGT4"].Value = ur3.Cells["ACT_WGT4"].Value; ultraGrid1.Rows[i].Cells["ACT_WGT5"].Value = ur3.Cells["ACT_WGT5"].Value; ultraGrid1.Rows[i].Cells["ACT_WGT"].Value = ur3.Cells["ACT_WGT"].Value; ultraGrid1.Update(); break; } } } #endregion } //else if (CustomInfo == "3") //{ // //规格明细查询 // CoreClientParam ccp = new CoreClientParam(); // ccp.ServerName = "UIM.UIM02.UIM020010"; // ccp.MethodName = "queryRclSizeDetail"; // ccp.ServerParams = new object[] { queryDate, queryDate1, queryDate2 }; // ccp.SourceDataTable = this.dataSet1.Tables[0]; // this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); //} } catch (Exception EX) { MessageBox.Show(EX.ToString()); } } private void DoExport() { try { if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK) { string fileName = this.saveFileDialog1.FileName; ultraGridExcelExporter1.Export(ultraGrid1, fileName); System.Diagnostics.Process.Start(fileName); } } catch (Exception EX) { MessageBox.Show(EX.ToString()); } } private void UIM031100_Load(object sender, EventArgs e) { //if (CustomInfo == "7") //{ // this.ultraGrid1.DisplayLayout.Bands[0].RowLayoutStyle = RowLayoutStyle.GroupLayout; // modifyColumn("UnboundColumn2", "厚度≤3mm", 0, 0, 2, 1); // modifyColumn("UnboundColumn3", "3<厚度≤4mm", 0, 0, 2, 1); // modifyColumn("UnboundColumn4", "4<厚度≤5mm", 0, 0, 2, 1); // modifyColumn("UnboundColumn8", "5<厚度≤6mm", 0, 0, 2, 1); // modifyColumn("UnboundColumn5", "6<厚度", 0, 0, 2, 1); //} string url = "http://172.16.0.41/FineReport/decision/view/report?viewlet=MES_ZHB%252FMES_LRZ%252Fhotspmreport.cpt&ref_t=design&op=write&ref_c=88befe22-7680-4f77-b928-0df97b0f3043"; webBrowser1.Url = new Uri(url); this.webBrowser1.Refresh(); } private void modifyColumn(string columnName, string caption, int x, int y, int spanX, int spanY) { //this.ultraGrid1.DisplayLayout.Bands[0].Columns.Add(columnName); UltraGridColumn GridColumn = this.ultraGrid1.DisplayLayout.Bands[0].Columns[columnName]; GridColumn.Header.Caption = caption; //GridColumn.Header.Appearance.TextVAlign = Infragistics.Win.VAlign.Middle; //GridColumn.Header.Appearance.TextHAlign = Infragistics.Win.HAlign.Center; //GridColumn.RowLayoutColumnInfo.OriginX = x; //GridColumn.RowLayoutColumnInfo.OriginY = y; //GridColumn.RowLayoutColumnInfo.SpanX = spanX; //GridColumn.RowLayoutColumnInfo.SpanY = spanY; ////GridColumn.CellActivation = Activation.Disabled; //GridColumn.RowLayoutColumnInfo.AllowCellSizing = RowLayoutSizing.None; //GridColumn.SortIndicator = SortIndicator.Disabled; } } }