private void btn_PrintView_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tb_InputKey.Text.Trim())) { MessageBox.Show(@"请选输入需要打印预览的商品编号", @"打印提示", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { string goodscode = tb_InputKey.Text.Trim(); GoodsBarcodeInfo goodsBarcodeInfo = _stockManager.GetGoodsBarcodeInfo(goodscode); if (goodsBarcodeInfo != null) { DrawBarcodeImage(goodscode, goodsBarcodeInfo.GoodsName, goodsBarcodeInfo.SellPrice); if (_currentImage == null) { return; } new PrintReview(_currentImage).ShowDialog(); } else { MessageBox.Show(@"未能获取商品信息", @"打印提示", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } }
public void PrintGoods(IDrawLabel drawLabel, GoodsBarcodeInfo goods) { var document = new GlassGoodsPrintDocument(goods, drawLabel) { PrinterSettings = { PrinterName = PrinterName } }; PrintController printController = new StandardPrintController(); document.PrintController = printController; document.PrintPage += Print_PrintPage; document.Print(); }
private void Print_PrintPage(object sender, PrintPageEventArgs e) { var document = sender as GlassGoodsPrintDocument; if (document != null) { GoodsBarcodeInfo currentGoodsBarcodeInfo = document.CurrentGoodsBarcodeInfo; var goodsInfo = new DrawGoodsInfo { GoodsCode = currentGoodsBarcodeInfo.GoodsCode, GoodsName = currentGoodsBarcodeInfo.GoodsName, SellPrice = currentGoodsBarcodeInfo.SellPrice }; Image image = document.DrawLabel.DrawToImage(goodsInfo); e.Graphics.DrawImage(image, DrawTools.Millimeter2Pix(1f), DrawTools.Millimeter2Pix(1f), DrawTools.Millimeter2Pix(document.DrawLabel.Width), DrawTools.Millimeter2Pix(document.DrawLabel.Height)); } }
private void StartPrintBarcode(string labelType, string txtString, string printer) { IDrawLabel draw; if (radioButton_KEDE.Checked) { draw = new DrawShopKedePriceLabel(39, 43, 300); } else if (radioButton_KD.Checked) { draw = new DrawShopKDPriceLabel(65, 19, 300); } else { MessageBox.Show(@"请选择打印店面模版,是KD还是Kede", @"打印提示", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } if (labelType == "2") { IList <GoodsBarcodeInfo> goodsBarcodeList = ReadGoodsBarcode(labelType, txtString); if ((goodsBarcodeList == null) || (goodsBarcodeList.Count == 0)) { MessageBox.Show(@"输入的单据号没有相关的出库商品信息!", @"打印提示", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { var service = new GlassGoodsLabelPrintService(printer, goodsBarcodeList); service.StartPrintMany(draw); } } else if (labelType == "1") { string goodscode = tb_InputKey.Text.Trim(); GoodsBarcodeInfo goodsBarcodeInfo = _stockManager.GetGoodsBarcodeInfo(goodscode); if (goodsBarcodeInfo != null) { new GlassGoodsLabelPrintService(printer).PrintGoods(draw, goodsBarcodeInfo); } else { MessageBox.Show("未能获取商品信息", "打印提示", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } }
public GlassGoodsPrintDocument(GoodsBarcodeInfo goodsBarcodeInfo, IDrawLabel drawLabel) { CurrentGoodsBarcodeInfo = goodsBarcodeInfo; DrawLabel = drawLabel; }