Example #1
0
        public static HardwareErrorResponse ShowHardwareErrorMessage(HardwareErrorException ex, MessageButtons buttonsMask)
        {
            HardwareErrorResponse ret = new HardwareErrorResponse {
                CancelLastReceipt = true
            };
            string         message = string.Empty;
            MessageButtons buttons = MessageButtons.Retry | MessageButtons.Cancel;
            ErrorState     error   = ex.Error;

            if (error.Check(ErrorState.CashReceiptPrinterDisconnected))
            {
                message = Translator.GetString("Unable to connect to the cash receipt printer!");
            }
            else if (error.Check(ErrorState.NonFiscalPrinterDisconnected))
            {
                message = Translator.GetString("Unable to connect to the receipt printer!");
            }
            else if (error.Check(ErrorState.ExternalDisplayDisconnected))
            {
                message = Translator.GetString("Unable to connect to the external display!");
            }
            else if (error.Check(ErrorState.CardReaderDisconnected))
            {
                message = Translator.GetString("Unable to connect to the card reader!");
            }
            else if (error.Check(ErrorState.KitchenPrinterError))
            {
                if ((buttonsMask & MessageButtons.OK) == MessageButtons.OK)
                {
                    message  = Translator.GetString("Unable to print on the kitchen printer! Press \"Retry\" to try again or \"OK\" to print the receipt on the printer for customer orders.");
                    buttons |= MessageButtons.OK;
                }
                else
                {
                    message = Translator.GetString("Unable to print on the kitchen printer! Press \"Retry\" to try again.");
                }
            }
            else if (error.Check(ErrorState.KitchenPrinterDisconnected))
            {
                message = Translator.GetString("Unable to connect to the kitchen printer!");
            }
            else if (error.Check(ErrorState.ElectronicScaleDisconnected))
            {
                message = Translator.GetString("Unable to connect to the electronic scale!");
            }
            else if (error.Check(ErrorState.ElectronicScaleNotEnabled))
            {
                message = Translator.GetString("There is no electronic scale installed or the electronic scale is not enabled!");
                buttons = MessageButtons.Cancel;
            }
            else if (error.Check(ErrorState.SalesDataControllerDisconnected))
            {
                message = Translator.GetString("Unable to connect to the sales data controller!");
            }
            else if (error.Check(ErrorState.ClockNotSet))
            {
                message = Translator.GetString("The clock of the fiscal printer is not set. Please set it to the correct time!");
            }
            else if (error.Check(ErrorState.KitchenPrinterNoPaper))
            {
                message  = Translator.GetString("The kitchen printer is out of paper!");
                buttons |= MessageButtons.OK;
            }
            else if (error.CheckError(ErrorState.NoPaper))
            {
                message = Translator.GetString("The fiscal printer is out of paper. Please replace!");
                ret.RetryWithoutPrint = true;
            }
            else if (error.Check(ErrorState.FiscalPrinterNotReady))
            {
                message = Translator.GetString("The fiscal printer is not ready to print. Please make sure that the fiscal printer is in the correct mode!");
            }
            else if (error.Check(ErrorState.WaitingPaperReplaceConfirmation))
            {
                message = Translator.GetString("The fiscal printer waits for key combination to accept the replaced paper roll!");
                ret.RetryWithoutPrint = true;
            }
            else if (error.CheckError(ErrorState.LittlePaper))
            {
                message = Translator.GetString("There is a little paper in the printer. Please replace!");
                ret.RetryWithoutPrint = true;
            }
            else if (error.Check(ErrorState.Report24HRequired))
            {
                message = Translator.GetString("24 Hour report is required before you can continue working with the fiscal printer!");
            }
            else if (error.Check(ErrorState.BadSerialPort))
            {
                message = Translator.GetString("There was a problem connecting with the serial port. Please check the serial port!");
            }
            else if (error.Check(ErrorState.BadConnectionParameters))
            {
                message = Translator.GetString("There was a problem connecting with the device. Please check the connection parameters!");
            }
            else if (error.Check(ErrorState.BadPassword))
            {
                message = Translator.GetString("The password for the device is not correct!");
            }
            else if (error.Check(ErrorState.BadLogicalAddress))
            {
                message = Translator.GetString("The logical address for the device is not correct!");
            }
            else if (error.Check(ErrorState.NotEnoughCashInTheRegister))
            {
                message           = Translator.GetString("There is not enough cash in the register to return change for the payment!");
                ret.AskForPayment = true;
            }
            else if (error.Check(ErrorState.FiscalPrinterOverflow))
            {
                message = Translator.GetString("An overflow occurred while transferring data to the fiscal printer!");
            }
            else if (error.Check(ErrorState.TooManyTransactionsInReceipt))
            {
                message = Translator.GetString("There are too many transactions in the operation for the fiscal printer to handle!");
                buttons = MessageButtons.Cancel;
            }
            else if (error.Check(ErrorState.VATGroupsMismatch))
            {
                message = Translator.GetString("The VAT groups defined does not match the VAT groups of the fiscal printer!");
                buttons = MessageButtons.Cancel;
            }
            else if (error.Check(ErrorState.EvalItemsLimitation))
            {
                message = string.Format(Translator.GetString("This is not a licensed version of {0}! Only less than 5 lines are allowed in a sale."), DataHelper.ProductName);
                buttons = MessageButtons.Cancel;
            }
            else if (error.Check(ErrorState.EvalPriceLimitation))
            {
                message = string.Format(Translator.GetString("This is not a licensed version of {0}! Only prices less than 10 are allowed in a sale."), DataHelper.ProductName);
                buttons = MessageButtons.Cancel;
            }
            else if (error.Check(ErrorState.EvalQttyLimitation))
            {
                message = string.Format(Translator.GetString("This is not a licensed version of {0}! Only quantities less than 3 are allowed in a sale."), DataHelper.ProductName);
                buttons = MessageButtons.Cancel;
            }
            else if (error.Check(ErrorState.EvalLimitation))
            {
                message = string.Format(Translator.GetString("This is not a licensed version of {0}! Please purchase a license to use this device."), DataHelper.ProductName);
                buttons = MessageButtons.Cancel;
            }
            else if (error.Check(ErrorState.DriverNotFound))
            {
                message = Translator.GetString("The device driver was not found. Please verify that it is properly installed and try again.");
                buttons = MessageButtons.Cancel;
            }
            else if (error.Count > 0)
            {
                message  = Translator.GetString("An error in a peripheral device has occurred!");
                message += "\n" + error;
            }

            using (MessageError msgDialog = new MessageError(message, ErrorSeverity.Error, ex)) {
                msgDialog.Buttons = buttons & buttonsMask;
                PresentationDomain.OnShowingDialog();
                ret.Retry  = false;
                ret.Button = MessageButtons.None;
                switch (msgDialog.Run())
                {
                case ResponseType.Reject:
                    ret.Button |= MessageButtons.Retry;
                    ret.Retry   = true;
                    break;

                case ResponseType.Ok:
                    ret.Button |= MessageButtons.OK;
                    break;

                case ResponseType.Cancel:
                    ret.Button |= MessageButtons.Cancel;
                    break;

                case ResponseType.Yes:
                    ret.Button |= MessageButtons.Yes;
                    break;

                case ResponseType.No:
                    ret.Button |= MessageButtons.No;
                    break;
                }
            }

            return(ret);
        }