using System.Drawing; using Zen.Barcode; namespace Common { //20250318 - Updated barcode value to match unique ID shown on printout - maanie public static class BarcodeGenerator { public enum BarCodeType { Customer = 1000000, CustomerBagReference = 2000000, Invoice = 3000000, Package = 4000000, Dispatch = 5000000 }; public static int BarcodeValue(BarCodeType barCodeType, int i) { //20250318 - Updated barcode value to match unique ID shown on printout - maanie if(barCodeType == BarCodeType.Dispatch || barCodeType == BarCodeType.Invoice || barCodeType == BarCodeType.CustomerBagReference) { return i; } else { return ((int)barCodeType + i); } } public static Image Barcode(BarCodeType barCodeType, int i) { return Barcode(barCodeType, i, 20); } public static Image Barcode(BarCodeType barCodeType, int i, int height) { return BarcodeDrawFactory.Code128WithChecksum.Draw(BarcodeValue(barCodeType, i).ToString(), height); } public static string BarcodeValue(int i, BarCodeType type) { switch (type) { case BarCodeType.Customer: case BarCodeType.CustomerBagReference: return (i + (int)type).ToString(); case BarCodeType.Dispatch: case BarCodeType.Invoice: case BarCodeType.Package: return i.ToString(); default: return i.ToString(); } } public static string BarcodeValue(BarCodeType barCodeType, string i) { //20250318 - Updated barcode value to match unique ID shown on printout - maanie if (barCodeType == BarCodeType.Dispatch || barCodeType == BarCodeType.Invoice || barCodeType == BarCodeType.CustomerBagReference) { return i; } else { return ((int)barCodeType + i); } } public static Image Barcode(BarCodeType barCodeType, string i) { return Barcode(barCodeType, i, 20); } public static Image Barcode(BarCodeType barCodeType, string i, int height) { return BarcodeDrawFactory.Code128WithChecksum.Draw(BarcodeValue(barCodeType, i), height); } } }