/** * @desc this function is called by the associated BusinessLogic class when it requests the printing of a cash drawer * @param ICashReport object called cashReport which holds all the needed information in order to print a cash drawer report * @returns void */ public void printDrawerCashReport(ICashReport cashReport) { DOCINFOA docInfo = new DOCINFOA(); // first parameter is the windows recognized name of the printer to be used if (OpenPrinter("POS-58", out hPrinter, IntPtr.Zero)) // if WINAPI function OpenPrinter is successful.. { if (StartDocPrinter(hPrinter, 1, docInfo)) // if WINAPI function StartDocPrinter is successful.. { if (StartPagePrinter(hPrinter)) // if WINAPI function StartPagePrinter is successful.. { // printCashReportBody function encapsulates a series of functions called to facilitate the printing of a Cash Drawer Report printCashReportBody(cashReport); } } ClosePrinter(hPrinter); // WINAPI function to close handle to printer } }
/** * @desc function that encapsulates several function calls needed to print a cash report * @param ICashReport report object that holds all the required information needed to print * @return void */ public void printCashReportBody(ICashReport report) { initializePrinter(); print(largeText + centerAlign + "Cash Report" + skipTwo + cancelLargeText); setTabs(new string[] { "\x10", _currencyTabPoint }); print(leftAlign + "Count" + tab + tab); print(report.NumberOfOrders.ToString() + lineFeed); print("Cash Sales" + tab + tab); alignDecimalsAndPrintWithLineFeed(report.Cash); print("Credit" + tab + tab); alignDecimalsAndPrintWithLineFeed(report.Credit); print("Gift" + tab + tab); print(report.Gift.ToString(currencyFormat) + lineFeed); print("Net Sales" + tab + tab); print(report.NetSales.ToString(currencyFormat) + lineFeed); print("Sales Tax" + tab + tab); print(report.Tax.ToString(currencyFormat) + lineFeed); print("Gross Sales" + tab + tab); print(report.GrossSales.ToString(currencyFormat) + lineFeed); print("Cash to Count" + tab + tab); print(report.CashToCount.ToString(currencyFormat) + lineFeed); print(skipThree); }