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 System.Collections; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; namespace Core.LZMes.Client.UIK { public partial class UIC020200 : FrmBase { public UIC020200() { 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; } } /// /// /// /// public void DoQuery() { string startTime = ultraStartTime.Value != null ? ultraStartTime.DateTime.ToString("yyyyMMdd") : ""; string endTime = ultraEndTime.Value != null ? ultraEndTime.DateTime.ToString("yyyyMMdd") : ""; string coilNo = txtCoilNo.Text.Trim(); string line = this.ultraComboEditor7.Value.ToString();//产线区分 P酸轧 S酸洗 if (("".Equals(startTime) || "".Equals(endTime)) && "".Equals(coilNo)) { MessageBox.Show("请选择查询条件!", "提示"); return; } this.dataSet1.Clear(); ArrayList al = new ArrayList(); if (line == "S") { al.Add("UIC020200_02.SELECT"); } else { al.Add("UIC020200_01.SELECT"); } al.Add(coilNo); al.Add(startTime); al.Add(endTime); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { al }; ccp.IfShowErrMsg = false; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); ArrayList arraylist = (ArrayList)ccp.ReturnObject;//得到返回结果 if (arraylist.Count == 0) { MessageBox.Show("未找到符合条件的记录,请修改查询条件!"); } //统计钢卷数量,钢卷总重量 int coilCount = (int)dataSet1.Tables[0].Compute("count(OLD_SAMPL_NO)", ""); double coilWgtSum = 0, actWgt1 = 0, coilWgtSum1 = 0, coilWgtSum2 = 0; foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in ultraGrid1.Rows) { double actWgt = 0, actWgt2 = 0; string status = ugr.Cells["EXTSHAPE_QUALITY"].Value.ToString().Trim(); try { actWgt = double.Parse(ugr.Cells["ACT_WGT"].Value.ToString().Trim()); actWgt2 = double.Parse(ugr.Cells["M_WGT"].Value.ToString().Trim()); if ("FA".Equals(status)) { actWgt1 = double.Parse(ugr.Cells["ACT_WGT"].Value.ToString().Trim()); coilWgtSum1 += actWgt1; } } catch (Exception e) { } coilWgtSum += actWgt; coilWgtSum2 += actWgt2; } this.textBox1.Text = coilCount.ToString(); this.textBox2.Text = (coilWgtSum / 1000).ToString(); this.textBox3.Text = (coilWgtSum1 / 1000).ToString(); this.textBox4.Text = (Math.Round(coilWgtSum2 / 1000, 2)).ToString(); } private void DoExport() { try { if (this.ultraGrid1.Rows.Count == 0) { MessageBox.Show("没有可以导出的数据", "提示"); return; } 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 ultraGrid1_ClickCell(object sender, Infragistics.Win.UltraWinGrid.ClickCellEventArgs e) { try { ultraGrid1.ActiveCell.SelectAll(); } catch { } } private void UIC020200_Load(object sender, EventArgs e) { this.ultraComboEditor7.Value = "P"; } } }