/// <summary> /// 打印操作 /// </summary> /// <param name="listPrtStr"></param> public static void PrintOut(List <PrintString> listPrtStr) { if (Gattr.IsBillPrintLog) { string path = Gattr.BillFile.Substring(0, Gattr.BillFile.LastIndexOf(@"\")); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } FileStream stream = new FileStream(Gattr.BillFile, FileMode.Append, FileAccess.Write); StreamWriter writer = new StreamWriter(stream); foreach (PrintString str2 in listPrtStr) { writer.WriteLine(str2.PrtSrt.ToString()); } writer.Close(); stream.Close(); } if (Gattr.PosPrinter.IsWindowPrinter) { foreach (PrintString str in listPrtStr) { t_pos_printer_out item = new t_pos_printer_out { BigFont = str.IsBigSize, Text = str.PrtSrt }; _listWinPrtStr.Add(item); } } }
private void PrintPageEventHandler2(object obj, PrintPageEventArgs e) { float y = e.MarginBounds.Y; e.HasMorePages = false; if (FontSize <= 0) { FontSize = 10; } double num2 = FontSize * 1.25; float num3 = (float)num2; float height = 0f; for (int i = this.rowint; i < this._listPrint.Count; i++) { this.rowint++; t_pos_printer_out _out = this._listPrint[i]; using (Font font = new Font(FontName, _out.BigFont ? num3 : ((float)FontSize), FontStyle.Regular)) { e.Graphics.DrawString(_out.Text, font, Brushes.Black, (float)e.MarginBounds.X, y); height = font.GetHeight(); y += height; } if ((((y + (height * 3f)) * 96f) / 100f) > e.PageSettings.PrintableArea.Height) { e.HasMorePages = true; break; } } }
private void btnPrint_Click(object sender, EventArgs e) { try { if (this.chkCashBox.Checked) { Gfunc.OpenCash(); // string strMemo = Language.GetString("#0514"); // Gattr.Bll.WriteRetailLog("OPD", 0M, strMemo, Gattr.CashierNo, "", 0M, true); // Gattr.Bll.WriteSysLog(Gattr.LogFile, strMemo, strMemo, 1); } //Gattr.PosPrinter.OpenPrinter(Gattr.PrinterName, Gattr.PrinterPort); //Gattr.PosPrinter.PrintOut("\r\n"); string strOut = ""; List <t_pos_printer_out> listOut = new List <t_pos_printer_out>(); for (int i = 0; i < this.listBox.Items.Count; i++) { if (Gattr.PosPrinter.IsWindowPrinter) { t_pos_printer_out item = new t_pos_printer_out { BigFont = false, Text = this.listBox.Items[i].ToString() }; listOut.Add(item); } else { strOut = strOut + this.listBox.Items[i].ToString() + "\n"; } } if (Gattr.PosPrinter.IsWindowPrinter) { Gattr.PosPrinter.PrintOut(listOut); } else { //Gattr.PosPrinter.PrintOut(strOut); //Gattr.PosPrinter.FooterEmptyLine(); //Gattr.PosPrinter.PrintCut(); } //Gattr.PosPrinter.ClosePrinter(); LoggerHelper.Log("MsmkLogger", System.DateTime.Now.ToString() + "【" + Gattr.OperId + "】进行打印对账信息!", LogEnum.SysLog); } catch (Exception exception) { MessageBox.Show(exception.Message, Gattr.AppTitle); } }
public static void OpenCash() { Gattr.PosPrinter.OpenPrinter(Gattr.PosModel, Gattr.PosPort); string cashierNo = Gattr.PosId; if (Gattr.PosPrinter.IsWindowPrinter)// && RetailGlobal.IsWinPrtCashBox) { List <t_pos_printer_out> listOut = new List <t_pos_printer_out>(); t_pos_printer_out item = new t_pos_printer_out { BigFont = false, // Text = "." }; listOut.Add(item); Gattr.PosPrinter.PrintOut(listOut); } else { //Gattr.PosCashBox.OpenCashBox(); } //RetailGlobal.Bll.OpenCashBoxNumberAdd(RetailGlobal.CashierNo); //RetailGlobal.PosPrinter.ClosePrinter(); }