//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 PrintSolution.LabelPrinter; //using System.IO; //using INI; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.IO; using System.Windows.Forms; using CoreFS.CA06; using PrintSolution.LabelPrinter; using INI; using Infragistics.Win.UltraWinGrid; using System.Reflection; namespace Core.LZMes.Client.UIM { public partial class UIM020020 : FrmBase { private ZebraPrinter printer = new ZebraPrinter(); private Hashtable pkgHt = new Hashtable(); private int hasPackaged = 0; public UIM020020() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; case "Save": this.DoSave(); break; case "Export": this.DoExport(); break; case "Print": this.DoPrint(); break; case "Exit": this.Close(); break; } } /// /// 查询原料库库存数据 /// private void DoQuery() { try { string ispack; if (Convert.ToBoolean(this.checkBox15.Checked)) ispack = "1"; else ispack = "0"; this.dataSet1.Tables[0].Clear(); string ordNo = this.textBox1.Text.Trim();// string ordSeq = this.textBox2.Text.Trim();// string coilNo = this.textBox3.Text.Trim();// hasPackaged = int.Parse(this.ultraComboEditor2.Value.ToString()); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIM.UIM02.UIM020020"; if (CustomInfo == "1") { ccp.MethodName = "queryPkgCoil"; } else { ccp.MethodName = "queryPkgCoilSx"; } ccp.ServerParams = new object[] { ordNo, ordSeq, coilNo, hasPackaged, ispack }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); //DataRowCollection drs = dataSet1.Tables[0].Rows; //for (int i = 0; i < drs.Count; i++) //{ // if (drs[i]["PRINT_TP"].ToString().Equals("Y")) // { // if (!drs[i]["ORG_ORD_NO"].ToString().Equals(drs[i]["ORD_NO"].ToString()) // && !drs[i]["ORG_ORD_SEQ"].ToString().Equals(drs[i]["ORD_SEQ"].ToString())) // ultraGrid1.Rows[i].Appearance.BackColor = Color.FromArgb(192, 255, 192); // } //} this.checkBox15.Checked = false; } catch (Exception EX) { MessageBox.Show(EX.ToString()); } } private void DoSave() { ultraGrid1.Update(); if (this.ultraDateTimeEditor1.Value == null) { MessageBox.Show("请选择包装日期!"); this.ultraDateTimeEditor1.Focus(); return; } ArrayList list = new ArrayList(); Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows; for (int i = 0; i < rs.Count; i++) { if ("TRUE".Equals(rs[i].Cells["CHK"].Text.ToUpperInvariant())) { string packageLevel = rs[i].Cells["PACKAGE_LEVEL"].Text; if (packageLevel.Equals("")) { MessageBox.Show("第" + (i + 1) + "行包装等级为空,请核对后再点击保存!"); return; } string[] packageArray = new string[2]; packageArray[0] = rs[i].Cells["OLD_SAMPL_NO"].Value.ToString(); packageArray[1] = pkgHt[rs[i].Cells["PACKAGE_LEVEL"].Text].ToString(); list.Add(packageArray); } } string pkgReg = this.UserInfo.GetUserID(); string pkgShift = this.UserInfo.GetUserOrder(); string pkgGroup = this.UserInfo.GetUserGroup(); string pkgDtime = this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd"); if (list.Count > 0) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIM.UIM02.UIM020020"; ccp.MethodName = "savePkgCoil"; ccp.ServerParams = new object[] { list, pkgShift, pkgGroup, pkgReg, pkgDtime, hasPackaged }; this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.DoQuery(); } } 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 DoPrint() { ultraGrid1.UpdateData(); //************************** Hashtable param = new Hashtable(); string XSQY = string.Empty; ArrayList coilLables = new ArrayList(); Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows; for (int i = 0; i < rs.Count; i++) { if (Convert.ToBoolean(rs[i].Cells["CHK"].Value)) { ColdCoilLable coilLabel = new ColdCoilLable(); coilLabel.rollNo = textBox40.Text.Trim().Substring(0, 9);//批号 coilLabel.specification = textBox37.Text.Trim();//标准号 coilLabel.steelGrade = textBox41.Text.Trim();//牌号 textBox45.Text.Trim()为客户牌号 coilLabel.dimension = textBox33.Text.Trim() + "*" + textBox32.Text.Trim();//厚度、宽度 coilLabel.coilNo = textBox40.Text.Trim();//卷号 coilLabel.weight = textBox36.Text.Trim();//重量 coilLabel.heatNo = textBox35.Text.Trim();//炉号 coilLabel.prodDate = textBox34.Text.Trim();//生产日期 coilLabel.custName = textBox44.Text.Trim();//收货单位 coilLabel.prodName = textBox43.Text.Trim();//收货单位 if (checkBox14.Checked)//合同号 { coilLabel.contractNo = textBox39.Text.Trim() + "-" + textBox38.Text.Trim();//合同号,订单号 } else { coilLabel.contractNo = string.Empty; } if (this.checkBox11.Checked)//许可证号 { coilLabel.licenseNo = this.textBox31.Text.Trim(); } else { coilLabel.licenseNo = string.Empty; } if (this.checkBox10.Checked)//许可证标识 { coilLabel.licenseMark = textBox30.Text;//string.Empty; } else { coilLabel.licenseMark = string.Empty; } coilLabel.checker = string.Empty; coilLabel.barcode = coilLabel.coilNo; coilLables.Add(coilLabel); XSQY = rs[i].Cells["XSQY"].Text.ToString(); } } //print try { PrintLabel(coilLables); PrintLabel(coilLables); //20130314添加标签打印标识 string coilNo1 = this.textBox40.Text.Trim(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIM.UIM02.UIM020020"; ccp.MethodName = "updateColor"; ccp.ServerParams = new object[] { coilNo1 }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); //20140304 param.Add("i1", XSQY); param.Add("i2", coilNo1); param.Add("i3", this.UserInfo.GetUserID()); param.Add("i4", "标签打印"); param.Add("i5", "UIM020020"); param.Add("i6", "打印后"); param.Add("o7", ""); CoreClientParam ccp4 = new CoreClientParam(); ccp4.ServerName = "UIB.COM.ComDBProcedure"; ccp4.MethodName = "doXmlProcedure"; ccp4.ServerParams = new Object[] { "UIL010020_02_CALL.CALL", param }; this.ExecuteNonQuery(ccp4, CoreInvokeType.Internal); //提示 ArrayList all = ccp4.ReturnObject as ArrayList; if (all[0].ToString() != "YY")//确认是否存在问题 { MessageBox.Show(all[0].ToString(), "提示"); return; } DoQuery(); } catch (Exception ex) { MessageBox.Show("连接打印机失败,请点击\"打印\"按钮重新打印!"); } } private void PrintLabel(ArrayList list) { foreach (ColdCoilLable coilLabel in list) { printer.printLable(coilLabel); } } private void UIM020020_Load(object sender, EventArgs e) { try { string Current = Directory.GetCurrentDirectory();//获取当前根目录 Ini ini = new Ini(Current + "/CoreFS.ini"); // 读取ini string labPrinterAddr = ini.ReadValue("LABPRINTERADDR", "6"); if (CustomInfo == "1") { printer.Addr = labPrinterAddr; } else { printer.Addr = "10.10.76.218"; } //printer.Addr = "10.10.75.142"; //此界面由酸洗酸轧同时使用,打印标签过程中双方打印机地址不一样,需要根据界面ID进行配置 --WL 20171109 string version = ini.ReadValue("LABPRINTERADDR", "Version"); version = "3";//应急处理 20180403 printer.LableVersion = int.Parse(version); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIM.UIM02.UIM020020"; ccp.MethodName = "queryPkgType"; ccp = this.ExecuteQuery(ccp, CoreInvokeType.Internal); ArrayList list = (ArrayList)ccp.ReturnObject; if (list != null) { this.ultraGrid1.DisplayLayout.ValueLists.Add("List1"); int listSize = list.Count; for (int i = 0; i < listSize; i++) { Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem(); Hashtable ht = (Hashtable)list[i]; string smCd = ht["SM_CD"].ToString(); string cmCfnm = ""; object obj = ht["SM_CFNM"]; if (obj != null) { cmCfnm = ht["SM_CFNM"].ToString(); } pkgHt.Add(cmCfnm, smCd); this.ultraGrid1.DisplayLayout.ValueLists["List1"].ValueListItems.Add(smCd, cmCfnm); } this.ultraGrid1.DisplayLayout.ValueLists["List1"].DisplayStyle = Infragistics.Win.ValueListDisplayStyle.DisplayText; this.ultraGrid1.DisplayLayout.Bands[0].Columns["PACKAGE_LEVEL"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; this.ultraGrid1.DisplayLayout.Bands[0].Columns["PACKAGE_LEVEL"].ValueList = this.ultraGrid1.DisplayLayout.ValueLists["List1"]; this.ultraComboEditor2.SelectedIndex = 0; } } catch (Exception ej) { System.Diagnostics.Debug.WriteLine(ej.ToString()); } } //20130122勾选统钢卷数量,钢卷重量 private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { try { //统计选中钢卷数量 int coilCount = 0; int count = 0; int count1 = 0; //统计选中钢卷重量 double coilSum = 0; double coilWeight = 0; double coilSum1 = 0; //判断是否选中 if (e.Cell.Column.Key == "CHK") { e.Cell.Row.Update(); if (e.Cell.Value.ToString().ToUpper() == "TRUE") { string vCHK = e.Cell.Row.Cells["CHK"].Text; Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows; for (int i = 0; i < rs.Count; i++) { if (rs[i].Cells["CHK"].Text == vCHK) { rs[i].Cells["CHK"].Value = true; rs[i].Appearance.ForeColor = System.Drawing.Color.Blue; coilWeight = double.Parse(rs[i].Cells["ACT_WGT"].Value.ToString().Trim()); coilCount = 1; } else { coilWeight = 0; coilCount = 0; } count += coilCount; coilSum += coilWeight; this.textBox4.Text = (count).ToString(); this.textBox5.Text = (coilSum).ToString(); //? this.textBox6.Text = (count).ToString(); this.textBox7.Text = (coilSum).ToString(); } } else { string coil_no = e.Cell.Row.Cells["OLD_SAMPL_NO"].Text; coilWeight = double.Parse(e.Cell.Row.Cells["ACT_WGT"].Text); string FALSE, FALSE1; Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows; for (int i = 0; i < rs.Count; i++) { if (rs[i].Cells["OLD_SAMPL_NO"].Text == coil_no) { rs[i].Appearance.ForeColor = System.Drawing.Color.Black; } } //for (int i = 0; i < rs.Count; i++) //{ // if (rs[i].Cells["CHK"].Text == vCHK) // { // //FALSE = rs[i].Cells["OLD_SAMPL_NO"].Text; // FALSE = rs[i].Cells["CHK"].Value.ToString(); // FALSE1 = rs[i].Cells["CHK"].Text.ToString(); // rs[i].Cells["CHK"].Value = false; // rs[i].Appearance.ForeColor = System.Drawing.Color.Black; // coilWeight = double.Parse(rs[i].Cells["ACT_WGT"].Value.ToString().Trim()); // coilCount = 1; // } // else // { // coilWeight = 0; // coilCount = 0; // } // count1 = int.Parse(this.textBox6.Text.ToString().Trim()) - coilCount; // this.textBox4.Text = (count1).ToString(); // this.textBox6.Text = (count1).ToString(); // coilSum1 = double.Parse(this.textBox7.Text.ToString().Trim()) - coilWeight; // this.textBox5.Text = (coilSum1).ToString(); // this.textBox7.Text = (coilSum1).ToString(); //} count1 = int.Parse(this.textBox6.Text.ToString().Trim()) - 1; this.textBox4.Text = (count1).ToString(); this.textBox6.Text = (count1).ToString(); coilSum1 = double.Parse(this.textBox7.Text.ToString().Trim()) - coilWeight; this.textBox5.Text = (coilSum1).ToString(); this.textBox7.Text = (coilSum1).ToString(); } } } catch (Exception ev) { System.Diagnostics.Debug.WriteLine(ev.ToString()); } //try //{ // if (e.Cell.Column.Key == "CHK") // { // string coilNo = string.Empty; // string weight = string.Empty; // string ordNo = string.Empty; // string ordSeq = string.Empty; // string ordThk = string.Empty; // string ordWth = string.Empty; // string heatNo = string.Empty; // string steelCode = string.Empty; // string standardNo = string.Empty; // string millTime = string.Empty; // if (!Convert.ToBoolean(e.Cell.Value)) // { // //for (int i = 0; i < ultraGrid1.Rows.Count; i++) // //{ // // ultraGrid1.Rows[i].Cells["CHK"].Value = false; // //} // coilNo = e.Cell.Row.Cells["OLD_SAMPL_NO"].Text; // weight = e.Cell.Row.Cells["ACT_WGT"].Text; // ordNo = e.Cell.Row.Cells["ORD_NO"].Text; // ordSeq = e.Cell.Row.Cells["ORD_SEQ"].Text; // ordThk = e.Cell.Row.Cells["INSTR_COIL_THK"].Text; // ordWth = e.Cell.Row.Cells["INSTR_COIL_WTH"].Text; // heatNo = e.Cell.Row.Cells["CHARGE_NO"].Text; // steelCode = e.Cell.Row.Cells["SPEC_STL_GRD"].Text; // // standardNo = e.Cell.Row.Cells["SPEC_ABBSYM"].Text; // millTime = e.Cell.Row.Cells["MILL_DTIME"].Text; // } // SetControlValue(coilNo, weight, ordNo, ordSeq, ordThk, ordWth, heatNo, steelCode, standardNo, millTime); // // e.Cell.Value = !Convert.ToBoolean(e.Cell.Value); // } //} //catch (Exception ej) //{ System.Diagnostics.Debug.WriteLine(ej.ToString()); } } private void SetControlValue(string coilNo, string weight, string ordNo, string ordSeq, string ordThk, string ordWth, string heatNo, string steelCode, string standardNo, string millTime,string prodname,string custname,string custspecstl) { textBox40.Text = coilNo; textBox36.Text = weight; textBox34.Text = millTime; textBox39.Text = ordNo; textBox38.Text = ordSeq; textBox33.Text = ordThk; textBox32.Text = ordWth; textBox41.Text = steelCode; textBox37.Text = standardNo; textBox35.Text = heatNo; textBox43.Text = prodname; textBox44.Text = custname; textBox45.Text = custspecstl; } private void ultraGroupBox1_Click(object sender, EventArgs e) { } private void ultraGrid1_DoubleClickRow(object sender, DoubleClickRowEventArgs e) { Infragistics.Win.UltraWinGrid.UltraGrid uGrid = (Infragistics.Win.UltraWinGrid.UltraGrid)sender; // uGrid.ActiveRow.Cells["DLIV_DIRNO"].Text.Trim(); string coilNo = string.Empty; string weight = string.Empty; string ordNo = string.Empty; string ordSeq = string.Empty; string ordThk = string.Empty; string ordWth = string.Empty; string heatNo = string.Empty; string steelCode = string.Empty; string standardNo = string.Empty; string millTime = string.Empty; string prodname = string.Empty; string custname = string.Empty; string custspecstl = string.Empty; coilNo = uGrid.ActiveRow.Cells["OLD_SAMPL_NO"].Text; weight = uGrid.ActiveRow.Cells["ACT_WGT"].Text; ordNo = uGrid.ActiveRow.Cells["ORD_NO"].Text; ordSeq = uGrid.ActiveRow.Cells["ORD_SEQ"].Text; ordThk = uGrid.ActiveRow.Cells["INSTR_COIL_THK"].Text; ordWth = uGrid.ActiveRow.Cells["INSTR_COIL_WTH"].Text; heatNo = uGrid.ActiveRow.Cells["CHARGE_NO"].Text; steelCode = uGrid.ActiveRow.Cells["SPEC_STL_GRD"].Text; standardNo = uGrid.ActiveRow.Cells["SPEC_ABBSYM"].Text; millTime = uGrid.ActiveRow.Cells["MILL_DTIME"].Text; prodname = uGrid.ActiveRow.Cells["C_ORD_USE_TP"].Text; custname = uGrid.ActiveRow.Cells["ORDCUST_CD"].Text; custspecstl = uGrid.ActiveRow.Cells["DDC_STL_GRD"].Text; SetControlValue(coilNo, weight, ordNo, ordSeq, ordThk, ordWth, heatNo, steelCode, standardNo, millTime, prodname, custname,custspecstl); } private void checkBox11_CheckedChanged(object sender, EventArgs e)//3 { try { this.textBox31.Enabled = this.checkBox11.Checked; this.textBox31.Enabled = this.checkBox11.Checked; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void checkBox14_CheckedChanged(object sender, EventArgs e)//ord { try { this.textBox39.Enabled = this.checkBox14.Checked; this.textBox38.Enabled = this.checkBox14.Checked; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void checkBox10_CheckedChanged(object sender, EventArgs e)//4 { try { this.textBox30.Enabled = this.checkBox10.Checked; this.textBox30.Enabled = this.checkBox10.Checked; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } //private void ultraGrid1_CellChange(object sender, CellEventArgs e) //{ // try // { // if (e.Cell.Column.Key == "CHK") // { // string coilNo = string.Empty; // string weight = string.Empty; // string ordNo = string.Empty; // string ordSeq = string.Empty; // string ordThk = string.Empty; // string ordWth = string.Empty; // string heatNo = string.Empty; // string steelCode = string.Empty; // string standardNo = string.Empty; // string millTime = string.Empty; // if (!Convert.ToBoolean(e.Cell.Value)) // { // for (int i = 0; i < ultraGrid1.Rows.Count; i++) // { // ultraGrid1.Rows[i].Cells["CHK"].Value = false; // } // coilNo = e.Cell.Row.Cells["OLD_SAMPL_NO"].Text; // weight = e.Cell.Row.Cells["ACT_WGT"].Text; // ordNo = e.Cell.Row.Cells["ORD_NO"].Text; // ordSeq = e.Cell.Row.Cells["ORD_SEQ"].Text; // ordThk = e.Cell.Row.Cells["INSTR_COIL_THK"].Text; // ordWth = e.Cell.Row.Cells["INSTR_COIL_WTH"].Text; // heatNo = e.Cell.Row.Cells["CHARGE_NO"].Text; // steelCode = e.Cell.Row.Cells["SPEC_STL_GRD"].Text; // // standardNo = e.Cell.Row.Cells["SPEC_ABBSYM"].Text; // millTime = e.Cell.Row.Cells["MILL_DTIME"].Text; // } // SetControlValue(coilNo, weight, ordNo, ordSeq, ordThk, ordWth, heatNo, steelCode, standardNo, millTime); // e.Cell.Value = !Convert.ToBoolean(e.Cell.Value); // } // } // catch (Exception ej) // { System.Diagnostics.Debug.WriteLine(ej.ToString()); } // } } }