using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Collections; using System.Windows.Forms; using CoreFS.CA06; using System.IO; using Microsoft.Office.Interop.Excel; using ET; using PrintSolution; namespace Core.LZMes.Client.UIK { public partial class UIK020070 : FrmBase { private int coil_no_index = -1;//冷轧卷在轧制计划的下标位置 public UIK020070() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; case "Save": //this.DoSave(); break; case "Exit": this.Close(); break; case "Print": this.DoPrint(); break; case "Export": this.DoExport(); break; } } private void UIK020070_Load(object sender, EventArgs e) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIK.UIK02.UIK020060"; ccp.MethodName = "queryRollManaNo"; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); ArrayList list = (ArrayList)(ccp.ReturnObject); if (list != null) { int listSize = list.Count; Infragistics.Win.ValueListItem[] valueListItems = new Infragistics.Win.ValueListItem[listSize]; for (int i = 0; i < listSize; i++) { Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem(); string[] param = (string[])list[i]; item.DataValue = param[1]; item.DisplayText = param[1]; ; valueListItems[i] = item; } this.ultraComboEditor1.Items.AddRange(valueListItems); } ArrayList list2 = (ArrayList)(ccp.ReturnObject); if (list2 != null) { int listSize = list2.Count; Infragistics.Win.ValueListItem[] valueListItems2 = new Infragistics.Win.ValueListItem[listSize]; for (int i = 0; i < listSize; i++) { Infragistics.Win.ValueListItem item2 = new Infragistics.Win.ValueListItem(); string[] param = (string[])list2[i]; item2.DataValue = param[1]; item2.DisplayText = param[1]; ; valueListItems2[i] = item2; } this.ultraComboEditor4.Items.AddRange(valueListItems2); } } private void DoExport() { try { if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK) { string fileName = this.saveFileDialog1.FileName; this.ultraGrid1.DisplayLayout.Bands[0].Columns["SELECT_ITEM"].Hidden = true; // this.ultraGrid1.DisplayLayout.Bands[0].Columns["SEQ"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["ORD_WGT"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_INDIA"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_OUTDIA"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_LEN"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["H_ORD_LEN"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["H_ORD_INDIA"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["H_ORD_OUTDIA"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["C_EXTSHAPE_REQ"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["ACID_PROD_PATH"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["SM_CFNM"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["STATUS_CD"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["INGR_YN"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["INGR_DEC_GRD"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["ORD_FL"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["C_COIL_LOAD_LOC"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["ACT_WGT"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["BZ"].Hidden = true; this.ultraGrid1.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.None; ultraGridExcelExporter1.Export(ultraGrid1, fileName); System.Diagnostics.Process.Start(fileName); this.ultraGrid1.BeginUpdate(); this.ultraGrid1.DisplayLayout.Bands[0].Columns["SELECT_ITEM"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["SEQ"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["ORD_WGT"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_INDIA"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_OUTDIA"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_LEN"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["H_ORD_LEN"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["H_ORD_INDIA"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["H_ORD_OUTDIA"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["C_EXTSHAPE_REQ"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["ACID_PROD_PATH"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["SM_CFNM"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["STATUS_CD"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["INGR_YN"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["INGR_DEC_GRD"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["ORD_FL"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["C_COIL_LOAD_LOC"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["ACT_WGT"].Hidden = false; this.ultraGrid1.DisplayLayout.Bands[0].Columns["BZ"].Hidden = false; this.ultraGrid1.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.ExtendLastColumn; this.ultraGrid1.EndUpdate(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } private void DoPrint() { if (MessageBox.Show("您确认流程卡打印信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { if (coil_no_index >= 0) { string d_H_ORD_WTH = ""; string d_H_ORD_THK = ""; ArrayList param = new ArrayList(); param.Add(this.ultraTextC_PIHAO.Text.Trim()); param.Add(this.ultraTextpaihao.Text.Trim()); param.Add(this.ultraTextH_COILNO.Text.Trim()); d_H_ORD_WTH = this.ultraTextORD_THK.Text.Trim(); d_H_ORD_THK = this.ultraTextORD_WTH.Text.Trim(); param.Add(d_H_ORD_WTH + "*" + d_H_ORD_THK); param.Add(this.ultraTextH_WGT.Text.Trim()); param.Add(this.ultraTextc_paihao.Text.Trim()); string prodLine = ultraGrid1.Rows[coil_no_index].Cells["PROD_LINE"].Value.ToString().Trim(); string Consignee =ultraGrid1.Rows[coil_no_index].Cells["SM_CFNM"].Value.ToString().Trim(); if (Consignee == "中冶南方(新余)冷轧新材料技术有限公司") { param.Add("否"); } else { param.Add("是"); } if (prodLine == "L") { param.Add("否"); param.Add("连退"); param.Add("是"); } else { param.Add("是"); param.Add("酸轧成品"); param.Add("否"); } try { ExcelPrinter ePrinter = new ExcelPrinter("FlowCard.xml", param); ePrinter.PageSetup.IsCustom = true; ePrinter.PageSetup.TopMargin = 40; ePrinter.PageSetup.BottomMargin = 1; ePrinter.PageSetup.LeftMargin = 25; ePrinter.PageSetup.RightMargin = 0.5; ePrinter.Orientation = 1;//横向打印 ePrinter.printExcel(); } catch (Exception ex) { MessageBox.Show("打印失败,请关闭程序后重新操作!"); return; } } else { MessageBox.Show("请选择打印钢卷!"); return; } } } /// /// 查询酸轧计划 /// private void DoQuery() { bool flag = false; string rollManaNo = this.ultraComboEditor1.Text.Trim(); string rollManaNo2 = this.ultraComboEditor4.Text.Trim(); string pFromDate = null == this.ultraDateTimeEditor1.Value ? "" : this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd"); string pToDate = null == this.ultraDateTimeEditor2.Value ? "" : this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd"); string mFromDate = null == this.ultraDateTimeEditor3.Value ? "" : this.ultraDateTimeEditor3.DateTime.ToString("yyyyMMdd"); string mToDate = null == this.ultraDateTimeEditor4.Value ? "" : this.ultraDateTimeEditor4.DateTime.ToString("yyyyMMdd"); string ordNo = textBox3.Text.Trim(); string ordSeq = textBox1.Text.Trim(); if ("".Equals(rollManaNo) && "".Equals(ordNo) && "".Equals(rollManaNo2)) { if ("".Equals(mFromDate) || "".Equals(mToDate) || (ultraDateTimeEditor4.DateTime - ultraDateTimeEditor3.DateTime).Days > 30) { if ("".Equals(pFromDate) || "".Equals(pToDate) || (ultraDateTimeEditor2.DateTime - ultraDateTimeEditor1.DateTime).Days > 30) { MessageBox.Show("请选择合适的查询条件后再进行查询操作,否则导致数据量过大!"); return; } } } if (rollManaNo == "") flag = true; this.dataSet1.Tables[0].Clear(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIK.UIK02.UIK020060"; ccp.MethodName = "queryRollPlan"; ccp.ServerParams = new Object[] { rollManaNo,rollManaNo2, pFromDate, pToDate, mFromDate, mToDate, ordNo, ordSeq,flag }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); ///string x = this.ultraGrid1.Rows[0].Cells["SEQ"].Value.ToString(); //this.ultraGrid1.as // this.ultraGrid1.DataSource = dataSet1.Tables[0]; DataRowCollection drs = dataSet1.Tables[0].Rows; for (int i = 0; i < drs.Count; i++) { Color color = Color.FromArgb(255, 255, 255); string status = drs[i]["STATUS_CD"].ToString().Trim(); double coilWth = double.Parse(drs[i]["COIL_WTH"].ToString().Trim()); double ordWth = double.Parse(drs[i]["ORD_WTH"].ToString().Trim()); string ingDecGrd = drs[i]["INGR_DEC_GRD"].ToString().Trim(); if ("轧制吊销".Equals(status)) { color = Color.FromArgb(255, 128, 128); } else if ("轧制进行".Equals(status)) { color = Color.FromArgb(0, 192, 0); if (coilWth < ordWth) { color = Color.SandyBrown; } } else if ("轧制完成".Equals(status)) { color = Color.FromArgb(192, 255, 192); } else if ("上料完成".Equals(status)) { color = Color.FromArgb(192, 192, 255); } else if ("轧废".Equals(status)) { color = Color.FromArgb(192, 192, 192); } else { if (!"合格".Equals(ingDecGrd)) { color = Color.FromArgb(255, 204, 0); } else if (coilWth < ordWth) { color = Color.SandyBrown; } } ultraGrid1.Rows[i].Appearance.BackColor = color; } } private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { if (e.Cell.Column.Key == "SELECT_ITEM") { if (e.Cell.Text == "True") { string C_COILNO; C_COILNO = e.Cell.Row.Cells["OLD_SAMPL_NO"].Text.Trim(); /*for循环控制单选*/ int i = this.ultraGrid1.Rows.Count; for (int j = 0; j < i; j++) { if (this.ultraGrid1.Rows[j].Cells["OLD_SAMPL_NO"].Text != C_COILNO) { Infragistics.Win.UltraWinGrid.UltraGrid uGrid = (Infragistics.Win.UltraWinGrid.UltraGrid)sender; coil_no_index = uGrid.ActiveRow.VisibleIndex; this.ultraGrid1.Rows[j].Cells["SELECT_ITEM"].Value = false; string cCoilNo = this.ultraGrid1.Rows[coil_no_index].Cells["OLD_SAMPL_NO"].Text.Trim(); this.ultraTextC_PIHAO.Text = cCoilNo.Substring(0, cCoilNo.LastIndexOf('-')); this.ultraTextORD_WTH.Text = this.ultraGrid1.Rows[coil_no_index].Cells["H_ORD_WTH"].Text.Trim(); this.ultraTextORD_THK.Text = this.ultraGrid1.Rows[coil_no_index].Cells["H_ORD_THK"].Text.Trim(); this.ultraTextORD_FL.Text = this.ultraGrid1.Rows[coil_no_index].Cells["ORD_FL"].Text.Trim().Equals("1") ? "订单" : ""; this.ultraTextACT_WTH.Text = this.ultraGrid1.Rows[coil_no_index].Cells["H_ORD_WTH"].Text.Trim(); this.ultraTextACT_THK.Text = this.ultraGrid1.Rows[coil_no_index].Cells["COIL_THK"].Text.Trim(); this.ultraTextH_COILNO.Text = this.ultraGrid1.Rows[coil_no_index].Cells["COIL_NO"].Text.Trim(); this.ultraTextH_WGT.Text = this.ultraGrid1.Rows[coil_no_index].Cells["COIL_WGT"].Text.Trim(); this.ultraTextpaihao.Text = this.ultraGrid1.Rows[coil_no_index].Cells["STL_GRD"].Text.Trim(); this.ultraTextc_paihao.Text = this.ultraGrid1.Rows[coil_no_index].Cells["C_SPEC_STL_GRD"].Text.Trim(); this.ultraTextEditor17.Text = this.ultraGrid1.Rows[coil_no_index].Cells["SM_CFNM"].Text.Trim(); } } } } } } }