private IPrinterResponse PrintSubTotal(ISalesDocument document, bool hardcopy) { IPrinterResponse response = null; FiscalPrinter.Document = document; List <String> subtotalItems = Invoicepage.FormatSubTotal(document); if (hardcopy) { foreach (String s in subtotalItems) { response = Send(SlipRequest.WriteLine(s)); } } return(response); }
private IPrinterResponse PrintHeader(ISalesDocument document, bool startSlipInfo) { IPrinterResponse response = null; //if document is not slip document, change printer if (document.DocumentTypeId < 0) { AdjustPrinter(document); return(Printer.PrintHeader(document)); } try { if (Invoicepage.Id == 0) { SlipPrinter.Document.Id = FiscalPrinter.Printer.CurrentDocumentId; Invoicepage.SubTotal = 0; totalLines = null; line_index_of_totals_to_print = 0; } } catch (NullReferenceException ex) { if (Invoicepage != null) { Invoicepage = new InvoicePage(); return(PrintHeader(document, false)); } throw ex; } if (startSlipInfo) { try { //Send data to start document as the following format response = StartSlipInfoReceipt(document); //get document id from response data if (!response.HasError) { document.Id = 0; } } catch (CmdSequenceException cse) { //if command sequence exception occurs switch ((Command)cse.LastCommand) { //if last command is 37, initialize invoice page case Command.START_SLİP: if (SlipPrinter.Invoicepage.SubTotal == 0 && Invoicepage.Id == 0) { SlipPrinter.Invoicepage.ClearInvoice(); //after page request } break; case Command.X_DAILY: //if x report has not been ended yet PrintXReport(true); //print x report return(PrintHeader(document, false)); //then start to print document case Command.START_RCPT: //if custom report has not been ended yet //case Command.CustomReportLine: // RecoverCustomReport();//print do required processes // return PrintHeader(document);//then start to print document default: throw cse; } } catch (NoReceiptRollException nrre) { throw nrre; } catch (Exception ex) { //store the data (write to a log file) FiscalPrinter.Log.Error(ex.Message); } finally { //if some error occured during the receive document id, get current document id if (document.Id == 0) { while (true) { try { document.Id = FiscalPrinter.Printer.CurrentDocumentId; break; } catch { System.Threading.Thread.Sleep(100); } } } } } FiscalPrinter.Document = document; List <String> rowList = Invoicepage.FormatHeader(document); if (!SlipReady()) { DocumentRequested(new RequestSlipException(), new EventArgs()); WaitForSlip(); } for (int lineCount = 0; lineCount < rowList.Count; lineCount++) { response = Send(SlipRequest.WriteLine(rowList[lineCount])); } return(response); }