using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BarTenderPrint { public class BarcodeManager { barcodeLable label; BigLableInfo labelinfo; public BarcodeManager(barcodeLable bL) { this.label = bL; labelinfo = new BigLableInfo(); } public BigLableInfo ConfigBigLableInfo() { check(); getProductInfo(); return labelinfo; } //获取总的字符串 public string getProductInfo() { StringBuilder sb = new StringBuilder(); sb.Append(label.traceCode).Append(" "); sb.Append(label.traceClass).Append(" "); sb.Append(label.Supplier).Append(" "); sb.Append(labelinfo.DateString).Append(" "); sb.Append(label.SerialNum).Append(" "); sb.Append(labelinfo.CheckCode).Append(" "); sb.Append(label.Return).Append(" "); labelinfo.ProductInfo=sb.ToString(); labelinfo.barcode =labelinfo.ProductInfo.Replace(" ", ""); //labelinfo.barcode = "*"+labelinfo.ProductInfo.Replace(" ","")+"*"; Console.WriteLine("条码" + labelinfo.barcode+" 校验码"+labelinfo.CheckCode); return labelinfo.barcode; } #region 校验 private void check() { GetCheckCode(); //获取checklist List checkList = GetCheckCodeList(); int sum = 0; foreach(var c in checkList) { sum += c; } int ss = sum % 36; Console.WriteLine("校验值" + ss.ToString()); EncheckCode checkcode = (EncheckCode)ss; labelinfo.CheckCode = checkcode.ToString(); Console.WriteLine("校验码:" + labelinfo.CheckCode); } public void GetCheckCode() { StringBuilder sb = new StringBuilder(); sb.Append(label.traceCode).Append(" "); sb.Append(label.traceClass).Append(" "); sb.Append(label.Supplier).Append(" "); labelinfo.DateString = getdateString(); sb.Append(labelinfo.DateString).Append(" "); sb.Append(label.SerialNum).Append(" "); labelinfo.CheckCodeString = sb.ToString().Replace("-", ""); Console.WriteLine("校验字符串:" + labelinfo.CheckCodeString); } private List GetCheckCodeList() { string sub; List checkList = new List(); for(int i=0;i 9) { return ((Endate)day).ToString(); } else { return day.ToString(); } } #endregion } }