public static string PrintBarCode(string barCode, string codeType, SortedList parameters) { string result = string.Empty; DataRow[] printTemplate = CnasBaseData.SystemBaseData.Select(string.Format("type_code='HCS_barcode_type' and key_code='{0}'", codeType)); if (printTemplate.Length > 0 && printTemplate[0]["other_code"] != null) { string template = printTemplate[0]["other_code"].ToString().Trim(); if (!string.IsNullOrEmpty(template)) { if (!parameters.ContainsKey("BarcodeValue")) { parameters.Add("BarcodeValue", barCode); } BarCodeParameterHelper helper = new BarCodeParameterHelper(); helper.GetParameters(template, barCode, parameters); Barcode_print barCodePrinter = new Barcode_print(template, parameters); AdoptPrinter adopter = new AdoptPrinter(barCodePrinter.PrintDialog); adopter.PrintDPI = barCodePrinter.DesignFormData01.DPI; adopter.GetPrintSetting(CnasBaseData.MacAddress, 1); if (adopter.PrinterDialogResult == System.Windows.Forms.DialogResult.OK) { barCodePrinter.ShowDialog(); adopter.SetBackToSystemDefaultPrint(); } } else { result = "对不起!没有设置好条码的打印模版,请联系管理员"; } } else { result = "对不起!没有设置好条码的打印模版,请联系管理员"; } return(result); }
public PrintHelper() { _printDialog = new PrintDialog(); _adopter = new AdoptPrinter(_printDialog); }