/// <summary> /// Prints to printer. /// </summary> /// <param name="printerMap">The printer map.</param> /// <param name="formMod">The form mod.</param> /// <param name="formType">Type of the form.</param> /// <param name="posTransaction">The pos transaction.</param> /// <param name="copyReceipt">if set to <c>true</c> [copy receipt].</param> /// <returns></returns> internal static bool PrintFormTransaction( PrinterAssociation printerMap, FormModulation formMod, FormType formType, IPosTransaction posTransaction, bool copyReceipt) { FormInfo formInfo = printerMap.PrinterFormInfo; bool result = false; // Checking for header only. if (formInfo.HeaderTemplate == null) { // Note: This is allowed now that we have multiple printers... result = false; } else if (PrintingActions.ShouldWePrint(formInfo, formType, copyReceipt, printerMap)) { result = true; try { formMod.GetTransformedTransaction(formInfo, (RetailTransaction)posTransaction); if (formInfo.PrintAsSlip) { printerMap.Printer.PrintSlip(formInfo.Header, formInfo.Details, formInfo.Footer); } else { // Note: In this API Errors are handled in the printer and exceptions do not bubble up. printerMap.Printer.PrintReceipt(formInfo.Header + formInfo.Details + formInfo.Footer); } } catch (Exception ex) { NetTracer.Warning("Printing [Printing] - Exception while printing receipt"); POSFormsManager.ShowPOSErrorDialog(new PosisException(1003, ex)); result = false; } } return(result); }
/// <summary> /// Print form layout with specified content. /// </summary> /// <param name="formMod">Form modulation.</param> /// <param name="formInfo">Form info.</param> /// <param name="formType">Form type.</param> /// <param name="copyReceipt">Flag to identify if this is a copy.</param> /// <param name="getPrintTextHandler">Handler that is called to construct text for printing.</param> private static void PrintFormLayout( PrinterAssociation printerMap, FormModulation formMod, FormType formType, bool copyReceipt, bool formInfoTemplateRequired, GetTextHandler getPrintTextHandler) { FormInfo formInfo = printerMap.PrinterFormInfo; // Checking if formType requires template. if (formInfoTemplateRequired && (formInfo.HeaderTemplate == null)) { // 13038: Could not print the receipt because the receipt format could not be found. Printing.InternalApplication.Services.Dialog.ShowMessage(13038, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (PrintingActions.ShouldWePrint(formInfo, formType, copyReceipt, printerMap)) { try { string textToPrint = getPrintTextHandler(formMod, formInfo); if (formInfo.PrintAsSlip) { printerMap.Printer.PrintSlip(textToPrint); } else { printerMap.Printer.PrintReceipt(textToPrint); } } catch (Exception ex) { NetTracer.Warning("Printing [Print] - Exception while printing receipt"); POSFormsManager.ShowPOSErrorDialog(new PosisException(1003, ex)); } } }
/// <summary> /// Attempt to return invoices for the given order /// </summary> /// <param name="transaction"></param> /// <returns></returns> internal static CustomerOrderTransaction ReturnOrderInvoices(CustomerOrderTransaction transaction) { CustomerOrderTransaction result = null; try { if (transaction == null) { // Operation not valid for this type of transaction SalesOrder.InternalApplication.Services.Dialog.ShowMessage(3175, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(null); } if (transaction.OrderType != CustomerOrderType.SalesOrder) { // Operation not valid for this type of transaction SalesOrder.InternalApplication.Services.Dialog.ShowMessage(3175, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(null); } bool retValue = false; string comment = string.Empty; using (DataTable invoices = SalesOrder.GetSalesInvoiceList(ref retValue, ref comment, transaction.OrderId)) { if ((!retValue) || (invoices == null) || (invoices.Rows.Count == 0)) { if (!retValue) { ApplicationLog.Log(SalesOrderActions.LogSource, comment, LogTraceLevel.Error); } // There are no sales orders in the database for this customer.... SalesOrder.InternalApplication.Services.Dialog.ShowMessage(56123, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(null); } // Show the available sales orders for selection... using (frmGetSalesInvoices dlg = new frmGetSalesInvoices(invoices, transaction)) { SalesOrder.InternalApplication.ApplicationFramework.POSShowForm(dlg); if (dlg.DialogResult == System.Windows.Forms.DialogResult.OK) { // Copy the transaction back from the 'return invoices' form result = dlg.Transaction; SalesOrderActions.ProcessReturnReasonCodes(result); } } } } catch (PosisException px) { POSFormsManager.ShowPOSErrorDialog(px); ApplicationExceptionHandler.HandleException(SalesOrderActions.LogSource, px); } catch (Exception x) { ApplicationExceptionHandler.HandleException(SalesOrderActions.LogSource, x); throw; } return(result); }