Exemple #1
0
        /// <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);
        }
Exemple #2
0
        /// <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));
                }
            }
        }