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 PrintSolution.LabelPrinter; using INI; using System.IO; using System.Collections; namespace Core.LZMes.Client.UIM.UIM02 { public partial class UIM020100 : FrmBase { private ZebraPrinter printer = new ZebraPrinter(); public UIM020100() { InitializeComponent(); } private void UIM020100_Load(object sender, EventArgs e) { try { string Current = Directory.GetCurrentDirectory();//获取当前根目录 Ini ini = new Ini(Current + "/CoreFS.ini"); // 读取ini string labPrinterAddr = ini.ReadValue("LABPRINTERADDR", "5"); printer.Addr = labPrinterAddr; string version = ini.ReadValue("LABPRINTERADDR", "Version"); printer.LableVersion = int.Parse(version); //MessageBox.Show(labPrinterAddr); } catch (Exception ej) { System.Diagnostics.Debug.WriteLine(ej.ToString()); } } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; //case "Export": // this.DoExport(); // break; case "Print": this.DoPrint(); break; } } // public void DoQuery() { try { this.dataSet1.Tables[0].Clear(); string startTime = this.ultraDateTimeEditor1.Value != null ? this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd") : "";//入库开始时间 string entTime = this.ultraDateTimeEditor2.Value != null ? this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd") : "";//入库结束时间 string driveNum = this.ultraTextEditor1.Text.Trim(); string ord = this.ultraTextEditor2.Text.Trim(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIM.UIM02.UIM020100"; ccp.MethodName = "queryCoil"; ccp.ServerParams = new object[] { startTime, entTime, driveNum, ord }; 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); // } //} }catch(Exception e){ System.Diagnostics.Debug.WriteLine(e.ToString()); } } public void DoPrint() { try { ultraGrid1.UpdateData(); Hashtable param = new Hashtable(); string printid = this.UserInfo.GetUserID(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ultraGrid1.Rows) { if (Convert.ToBoolean(row.Cells["CHK"].Value)) { param = new Hashtable(); ColdCoilLable coilLabel = new ColdCoilLable(); coilLabel.rollNo = row.Cells["OLD_SAMPL_NO"].Value.ToString().Substring(0, 9); //string.Empty; coilLabel.specification = row.Cells["SPEC_ABBSYM"].Text; coilLabel.steelGrade = row.Cells["SPEC_STL_GRD"].Text; coilLabel.dimension = row.Cells["INSTR_COIL_THK"].Text + "*" + row.Cells["INSTR_COIL_WTH"].Text; coilLabel.coilNo = row.Cells["OLD_SAMPL_NO"].Text; coilLabel.weight = row.Cells["ACT_WGT"].Text; coilLabel.heatNo = row.Cells["CHARGE_NO"].Text; coilLabel.prodDate = row.Cells["MILL_DTIME"].Text; coilLabel.contractNo = string.Empty; coilLabel.licenseNo = string.Empty; coilLabel.licenseMark = string.Empty; coilLabel.checker = string.Empty; coilLabel.barcode = coilLabel.coilNo; if (row.Cells["PRINT_TP"].Text == "Y") { if (MessageBox.Show(row.Cells["OLD_SAMPL_NO"].Value.ToString() + "已打印,需要再次打印?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { string coilno =row.Cells["OLD_SAMPL_NO"].Text; printer.printLable(coilLabel); //20140507 printer.printLable(coilLabel); UpdateColor(coilno, "B"); param.Add("i1", "L"); param.Add("i2", coilno); param.Add("i3", printid); param.Add("i4", "标签打印"); param.Add("i5", "UIM020100"); param.Add("i6", "打印后"); param.Add("o7", ""); PrintHistory(param); } } else if (row.Cells["PRINT_TP"].Text == "N") { string coilno = row.Cells["OLD_SAMPL_NO"].Text; printer.printLable(coilLabel); //20140507 printer.printLable(coilLabel); UpdateColor(coilno,"B"); param.Add("i1","L"); param.Add("i2", coilno); param.Add("i3", printid); param.Add("i4", "标签打印"); param.Add("i5", "UIM020100"); param.Add("i6", "打印后"); param.Add("o7", ""); PrintHistory(param); } } } this.DoQuery(); } catch (Exception EX) { MessageBox.Show("连接打印机失败,请点击\"打印\"按钮重新打印!"); } } private void UpdateColor(string coilno,string flag) { CoreClientParam ccp1 = new CoreClientParam(); ccp1.ServerName = "UIL.UIL01.UIL010020"; ccp1.MethodName = "dateColor"; ccp1.ServerParams = new object[] { coilno ,flag}; ccp1.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp1, CoreInvokeType.Internal); } //标签打印记录增加 private void PrintHistory(Hashtable param) { 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; } } private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { try { if (e.Cell.Column.Key == "CHK") { e.Cell.Row.Update(); if (e.Cell.Value.ToString().ToUpper() == "TRUE") { string vDLIV_DIRNO = e.Cell.Row.Cells["DLIV_DIRNO"].Text; Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows; for (int i = 0; i < rs.Count; i++) { if (rs[i].Cells["DLIV_DIRNO"].Text == vDLIV_DIRNO) { rs[i].Cells["CHK"].Value = true; } else { rs[i].Cells["CHK"].Value = false; } } } else { string vDLIV_DIRNO = e.Cell.Row.Cells["DLIV_DIRNO"].Text; Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows; for (int i = 0; i < rs.Count; i++) { if (rs[i].Cells["DLIV_DIRNO"].Text == vDLIV_DIRNO) { rs[i].Cells["CHK"].Value = false; } } } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } } }