private HLACancelCheckChannelMachine.Utils.CPrintData getPrintData(List <CChaYi> chayi, CheckResult cr, ref bool isHZ) { HLACancelCheckChannelMachine.Utils.CPrintData re = new Utils.CPrintData(); try { string curBoxNo = getBoxNo(); re.hu = curBoxNo; re.inventoryRe = cr.InventoryResult; re.totalNum = 0; re.beizhu = ""; if (!mDocData.docData.Exists(i => i.hu == curBoxNo)) { return(re); } CCancelDocData docData = mDocData.docData.FirstOrDefault(i => i.hu == curBoxNo); re.totalNum = docData.barQty.Sum(i => i.qty); if (docData.mIsCp) { re.beizhu += "客诉次品/"; } if (docData.mIsHz) { re.beizhu += "混规则/"; isHZ = true; } if (docData.mIsDd) { re.beizhu += "一箱多单/"; } foreach (var v in chayi) { Utils.CPrintContent con = new Utils.CPrintContent(); con.pin = v.pin; con.se = v.se; con.gui = v.gui; con.diff = v.barChaYiQty; con.diffAdd = v.barAddChaYiQty; con.isRFID = docData.mIsRFID; re.content.Add(con); } } catch (System.Exception ex) { LogHelper.WriteLine(ex.Message + "\r\n" + ex.StackTrace.ToString()); } return(re); }
public static void PrintTag(CPrintData contentData) { try { string filepath = Application.StartupPath + "\\LabelMultiSkuCancel.mrt"; StiReport report = new StiReport(); report.Load(filepath); report.Compile(); report["RE"] = contentData.inventoryRe ? "正常" : "异常"; report["TotalNum"] = contentData.totalNum.ToString(); report["Tag"] = contentData.beizhu; report["HU"] = contentData.hu; DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("pin", Type.GetType("System.String"))); dt.Columns.Add(new DataColumn("se", Type.GetType("System.String"))); dt.Columns.Add(new DataColumn("gui", Type.GetType("System.String"))); dt.Columns.Add(new DataColumn("diff", Type.GetType("System.String"))); dt.Columns.Add(new DataColumn("diffAdd", Type.GetType("System.String"))); dt.Columns.Add(new DataColumn("isRFID", Type.GetType("System.String"))); #if DEBUG CPrintContent pc = new CPrintContent(); pc.pin = "z"; pc.se = "s"; pc.gui = "g"; pc.diff = 2; pc.diffAdd = 2; pc.isRFID = true; contentData.content.Add(pc); #endif foreach (var v in contentData.content) { DataRow row = dt.NewRow(); row["pin"] = v.pin; row["se"] = v.se; row["gui"] = v.gui; row["diff"] = v.diff.ToString(); row["diffAdd"] = v.diffAdd.ToString(); row["isRFID"] = v.isRFID ? "是" : "否"; dt.Rows.Add(row); } report.RegData("demo", dt); PrinterSettings printerSettings = new PrinterSettings(); report.Print(false, printerSettings); } catch (Exception ex) { LogHelper.WriteLine(ex.Message + "\r\n" + ex.StackTrace); } }