public override void ButtonPressed(object parentForm, Dinerware.TicketCollection theTickets, Dinerware.Ticket currentTicket, Dinerware.User currentUser, Dinerware.Person currentCustomer)
        {
            try
            {
                if (!ConfigurationHelper.Instance.IS_Test_Virtual_Client_Connection || !ConfigurationHelper.Instance.IS_Test_BLoyal_Connection)
                {
                    frmConfigurationSettingsWarning frmConfigurationSettingsWarning = new frmConfigurationSettingsWarning();
                    frmConfigurationSettingsWarning.ShowDialog();
                    return;
                }

                if (currentTicket != null)
                {
                    currentOpenTicket   = currentTicket;
                    currentOpenTicketId = currentTicket.ID;
                    currentUserId       = currentUser.ID;
                }
                else
                {
                    currentOpenTicket   = null;
                    currentOpenTicketId = string.Empty;
                    currentUserId       = string.Empty;
                }
                var configObj = ConfigurationHelper.Instance;
                if (configObj.ENABLE_bLOYAL)
                {
                    if (!string.IsNullOrWhiteSpace(configObj.GIFTCARD_TENDER_CODE))
                    {
                        if (!ServiceURLHelper.IsbLoyalServiceUrlDown)
                        {
                            int ticketId = 0;
                            int.TryParse(currentOpenTicketId, out ticketId);
                            // Load Gift Card Tender Window
                            var gcTender = ticketId > 0 ? new frmbLoyalGiftCardTender(true, currentTicket) : new frmbLoyalGiftCardTender(false, currentTicket);
                            gcTender.ShowDialog();
                        }
                        else
                        {
                            frmbLoyalServiceUrlDownWarning frmServiceUrlDown = new frmbLoyalServiceUrlDownWarning();
                            frmServiceUrlDown.ShowDialog();
                        }
                    }
                    else
                    {
                        frmCheckGiftCardWarning tenderWarning = new frmCheckGiftCardWarning();
                        tenderWarning.ShowDialog();
                    }
                }
                else
                {
                    DisableEnablebLoyalFunctionality disableEnablebLoyal = new DisableEnablebLoyalFunctionality();
                    disableEnablebLoyal.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Instance.WriteLogError(ex, "LoyalGiftCardTender OEButtonPressed");
            }
        }
Exemplo n.º 2
0
        public override void ButtonPressed(object parentForm, Dinerware.TicketCollection theTickets, Dinerware.Ticket currentTicket, Dinerware.User currentUser, Dinerware.Person currentCustomer)
        {
            try
            {
                if (!ConfigurationHelper.Instance.IS_Test_Virtual_Client_Connection || !ConfigurationHelper.Instance.IS_Test_BLoyal_Connection)
                {
                    frmConfigurationSettingsWarning frmConfigurationSettingsWarning = new frmConfigurationSettingsWarning();
                    frmConfigurationSettingsWarning.ShowDialog();
                    return;
                }

                if (currentTicket != null)
                {
                    currentOpenTicket   = currentTicket;
                    currentOpenTicketId = currentTicket.ID;
                    currentUserId       = currentUser.ID;
                }
                else
                {
                    currentOpenTicket   = null;
                    currentOpenTicketId = string.Empty;
                    currentUserId       = string.Empty;
                }

                if (ConfigurationHelper.Instance.ENABLE_bLOYAL)
                {
                    if (!ServiceURLHelper.IsbLoyalServiceUrlDown)
                    {
                        int ticketId = 0;
                        int.TryParse(currentOpenTicketId, out ticketId);

                        if (ticketId != 0)
                        {
                            var    services = new Provider.LoyaltyEngineServices();
                            string key      = string.Empty;

                            key = AsyncHelper.RunSync(() => services.GetSessionAsync());

                            if (currentTicket != null && ticketId > 0 && currentTicket.AmountDue == 0 && currentTicket.PaymentTotal > 0)
                            {
                                frmTicketIsFullyPaid frmTicketIsFullyPaid = new frmTicketIsFullyPaid(true, Messages.APPLY_PAYMENT_WARNING);
                                frmTicketIsFullyPaid.ShowDialog();
                            }
                            else if (!string.IsNullOrWhiteSpace(key))
                            {
                                frmQuickEdit frmQuickEdit = new frmQuickEdit(key);
                                frmQuickEdit.ShowDialog();
                            }
                            else
                            {
                                if (ServiceURLHelper.IsbLoyalServiceUrlDown)
                                {
                                    frmbLoyalServiceUrlDownWarning frmServiceUrlDown = new frmbLoyalServiceUrlDownWarning();
                                    frmServiceUrlDown.ShowDialog();
                                }
                                else
                                {
                                    frmServerOfflineWarning offLineMsg = new frmServerOfflineWarning();
                                    offLineMsg.ShowDialog();
                                }
                            }
                        }
                        else
                        {
                            frmShowWarningMessage frmshowWarning = new frmShowWarningMessage();
                            frmshowWarning.ShowDialog();
                        }
                    }
                    else
                    {
                        frmbLoyalServiceUrlDownWarning frmServiceUrlDown = new frmbLoyalServiceUrlDownWarning();
                        frmServiceUrlDown.ShowDialog();
                    }
                }
                else
                {
                    DisableEnablebLoyalFunctionality disableEnablebLoyal = new DisableEnablebLoyalFunctionality();
                    disableEnablebLoyal.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Instance.WriteLogError(ex, "QuickEdit OEButtonPressed");
            }
        }
        public override void ButtonPressed(object parentForm, TicketCollection theTickets, Ticket currentTicket, User currentUser, Person currentCustomer)
        {
            try
            {
                if (!ConfigurationHelper.Instance.IS_Test_Virtual_Client_Connection || !ConfigurationHelper.Instance.IS_Test_BLoyal_Connection)
                {
                    frmConfigurationSettingsWarning frmConfigurationSettingsWarning = new frmConfigurationSettingsWarning();
                    frmConfigurationSettingsWarning.ShowDialog();
                    return;
                }
                if (currentTicket != null)
                {
                    currentOpenTicket   = currentTicket;
                    currentOpenTicketId = currentTicket.ID;
                    currentUserId       = currentUser.ID;
                }
                else
                {
                    currentOpenTicket   = null;
                    currentOpenTicketId = string.Empty;
                    currentUserId       = string.Empty;
                }

                if (ConfigurationHelper.Instance.ENABLE_bLOYAL)
                {
                    if (!ServiceURLHelper.IsbLoyalServiceUrlDown)
                    {
                        int ticketId = 0;
                        int userId   = 0;
                        int.TryParse(currentUser.ID, out userId);

                        if (int.TryParse(currentOpenTicketId, out ticketId) && currentTicket != null && currentTicket.Items != null)
                        {
                            if (currentTicket.Items.Count == 0 && currentTicket.AmountDue == 0 && currentTicket.PaymentTotal > 0)
                            {
                                frmTicketIsFullyPaid frmTicketIsFullyPaid = new frmTicketIsFullyPaid(true, Messages.ADD_IETM_WARNING);
                                frmTicketIsFullyPaid.ShowDialog();
                            }
                            else if (currentTicket.Items.Count > 0 && currentTicket.AmountDue == 0 && currentTicket.PaymentTotal > 0)
                            {
                                frmTicketIsFullyPaid frmTicketIsFullyPaid = new frmTicketIsFullyPaid(true, Messages.APPLY_PAYMENT_WARNING);
                                frmTicketIsFullyPaid.ShowDialog();
                            }
                            else if (currentTicket.Items.Count > 0 && currentTicket.AmountDue > 0)
                            {
                                if (DiscountSets.OrderLevelDiscountId > 0 && DiscountSets.ItemLevelDiscountId > 0 && DiscountSets.ItemLevelSalePriceId > 0)
                                {
                                    frmCalculateSalesTransaction frmCalculateSalesTransaction = new frmCalculateSalesTransaction(userId, ticketId, currentTicket);
                                    frmCalculateSalesTransaction.ShowDialog();
                                }
                                else
                                {
                                    frmbLoyalDiscountRuleWarning frmbLoyalDiscountRuleWarning = new frmbLoyalDiscountRuleWarning();
                                    frmbLoyalDiscountRuleWarning.ShowDialog();
                                }
                            }
                        }
                        else
                        {
                            frmShowWarningMessage frmshowWarning = new frmShowWarningMessage();
                            frmshowWarning.ShowDialog();
                        }
                    }
                    else
                    {
                        frmbLoyalServiceUrlDownWarning frmServiceUrlDown = new frmbLoyalServiceUrlDownWarning();
                        frmServiceUrlDown.ShowDialog();
                    }
                }
                else
                {
                    DisableEnablebLoyalFunctionality disableEnablebLoyal = new DisableEnablebLoyalFunctionality();
                    disableEnablebLoyal.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Instance.WriteLogError(ex, "CalculateSalesTransaction OEButtonPressed");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get Gift Card Balance
        /// </summary>
        private PaymentEngine.CardResponse GetGiftCardBalance(bool isCheckBalance = true)
        {
            var cardResponse = new PaymentEngine.CardResponse();

            try
            {
                GetTicketAmountDue();

                _paymentEngine = new PaymentEngineConnector(_conFigHelper.LOGIN_DOMAIN, _conFigHelper.ACCESS_KEY, string.Empty, string.Empty, null);

                cardResponse = _paymentEngine.GetCardBalance(txtGiftCardNumber.Text, _conFigHelper.GIFTCARD_TENDER_CODE);
                if (cardResponse != null)
                {
                    if (cardResponse.AvailableBalance != 0)
                    {
                        lblAvailableBalance.Visible = true;
                        _availableBalance           = Math.Round(cardResponse.AvailableBalance, 2);
                        if (isCheckBalance)
                        {
                            if (_availableBalance <= _ticketAmountDue)
                            {
                                _ticketAmountDue      = _availableBalance;
                                textApplyBalance.Text = Math.Round(_ticketAmountDue, 2).ToString();
                            }
                            else
                            {
                                textApplyBalance.Text = Math.Round(_ticketAmountDue, 2).ToString();
                            }
                        }
                        _availableBalance = Math.Round(_availableBalance, 2);
                        lblAvailableBalanceAmt.Visible = true;
                        lblAvailableBalanceAmt.Text    = _availableBalance.ToString();
                    }
                    else if (cardResponse.AvailableBalance == 0 &&
                             cardResponse.Status == PaymentEngine.CardRequestStatus.Approved &&
                             !string.IsNullOrWhiteSpace(cardResponse.Message) &&
                             (cardResponse.Message.StartsWith("Current balance is") ||
                              cardResponse.Message.StartsWith("Gift card is not provisioned - number is auto provisioned enabled")))
                    {
                        lblAvailableBalance.Visible = true;
                        lblAvailableBalanceAmt.Text = "0";
                        textApplyBalance.Text       = "0";
                        lblApplyBalanceError.Text   = cardResponse.Message;
                    }
                    else if (cardResponse.Status == PaymentEngine.CardRequestStatus.Declined)
                    {
                        textApplyBalance.Text          = "0";
                        lblAvailableBalance.Visible    = false;
                        lblAvailableBalanceAmt.Visible = false;
                        lblApplyBalanceError.Text      = cardResponse.Message;
                    }
                    else if (cardResponse.AvailableBalance == 0 && cardResponse.Status == PaymentEngine.CardRequestStatus.Approved)
                    {
                        textApplyBalance.Text          = "0";
                        lblAvailableBalance.Visible    = true;
                        lblAvailableBalanceAmt.Visible = true;
                        lblAvailableBalanceAmt.Text    = "0";
                    }
                }
                else
                {
                    lblApplyBalanceError.Text = "Service unavailable. Please try again later.";
                }
            }
            catch (Exception ex)
            {
                _logger.WriteLogError(ex, "bLoyal GiftCardTender GetApplyCardBalance");
                frmbLoyalServiceUrlDownWarning frmServiceUrlDown = new frmbLoyalServiceUrlDownWarning();
                frmServiceUrlDown.ShowDialog();
            }
            return(cardResponse);
        }
Exemplo n.º 5
0
        public override void ButtonPressed(object parentForm, Dinerware.TicketCollection theTickets, Dinerware.Ticket currentTicket, Dinerware.User currentUser, Dinerware.Person currentCustomer)
        {
            try
            {
                if (!ConfigurationHelper.Instance.IS_Test_Virtual_Client_Connection || !ConfigurationHelper.Instance.IS_Test_BLoyal_Connection)
                {
                    frmConfigurationSettingsWarning frmConfigurationSettingsWarning = new frmConfigurationSettingsWarning();
                    frmConfigurationSettingsWarning.ShowDialog();
                    return;
                }
                if (currentTicket != null)
                {
                    currentOpenTicket   = currentTicket;
                    currentOpenTicketId = currentTicket.ID;
                    currentUserId       = currentUser.ID;
                }
                else
                {
                    currentOpenTicket   = null;
                    currentOpenTicketId = string.Empty;
                    currentUserId       = string.Empty;
                }
                var configObj = ConfigurationHelper.Instance;
                if (configObj.ENABLE_bLOYAL)
                {
                    if (!string.IsNullOrWhiteSpace(configObj.LOYALTY_TENDER_CODE))
                    {
                        if (!ServiceURLHelper.IsbLoyalServiceUrlDown)
                        {
                            int ticketId = 0;
                            int.TryParse(currentOpenTicketId, out ticketId);

                            if (currentTicket != null && ticketId > 0 && currentTicket.AmountDue == 0)
                            {
                                frmTicketIsFullyPaid frmTicketIsFullyPaid = new frmTicketIsFullyPaid();
                                frmTicketIsFullyPaid.ShowDialog();
                            }
                            else if (ticketId > 0)
                            {
                                if (!ServiceURLHelper.IsbLoyalServiceUrlDown)
                                {
                                    bLoyal.Connectors.LoyaltyEngine.CalculatedCart calculatedCart = null;
                                    var services = new Provider.LoyaltyEngineServices();

                                    calculatedCart = AsyncHelper.RunSync(() => services.GetCartBySourceExternalId(currentOpenTicketId));

                                    if (calculatedCart != null && calculatedCart.Cart != null && calculatedCart.Cart.Customer != null && calculatedCart.Cart.Customer.Uid != Guid.Empty)
                                    {
                                        bLoyalLoyaltyTender frmbLoyalLoyaltyTender = new bLoyalLoyaltyTender(calculatedCart.Cart.Customer, currentTicket);
                                        frmbLoyalLoyaltyTender.ShowDialog();
                                    }
                                    else
                                    {
                                        frmCustomerNotAssignToTicket customerNotAssign = new frmCustomerNotAssignToTicket();
                                        customerNotAssign.ShowDialog();
                                    }
                                }
                                else
                                {
                                    if (ServiceURLHelper.IsbLoyalServiceUrlDown)
                                    {
                                        frmbLoyalServiceUrlDownWarning frmServiceUrlDown = new frmbLoyalServiceUrlDownWarning();
                                        frmServiceUrlDown.ShowDialog();
                                    }
                                    else
                                    {
                                        frmServerOfflineWarning offLineMsg = new frmServerOfflineWarning();
                                        offLineMsg.ShowDialog();
                                    }
                                }
                            }
                            else
                            {
                                frmShowWarningMessage frmshowWarning = new frmShowWarningMessage();
                                frmshowWarning.ShowDialog();
                            }
                        }
                        else
                        {
                            frmbLoyalServiceUrlDownWarning frmServiceUrlDown = new frmbLoyalServiceUrlDownWarning();
                            frmServiceUrlDown.ShowDialog();
                        }
                    }
                    else
                    {
                        frmLoyaltyTenderWarning loyaltyTenderWarning = new frmLoyaltyTenderWarning();
                        loyaltyTenderWarning.ShowDialog();
                    }
                }
                else
                {
                    DisableEnablebLoyalFunctionality disableEnablebLoyal = new DisableEnablebLoyalFunctionality();
                    disableEnablebLoyal.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Instance.WriteLogError(ex, "bLoyalLoyaltyTender OEButtonPressed");
            }
        }
        public override void ButtonPressed(object parentForm, Dinerware.TicketCollection theTickets, Dinerware.Ticket currentTicket, Dinerware.User currentUser, Dinerware.Person currentCustomer)
        {
            try
            {
                if (!ConfigurationHelper.Instance.IS_Test_Virtual_Client_Connection || !ConfigurationHelper.Instance.IS_Test_BLoyal_Connection)
                {
                    frmConfigurationSettingsWarning frmConfigurationSettingsWarning = new frmConfigurationSettingsWarning();
                    frmConfigurationSettingsWarning.ShowDialog();
                    return;
                }
                if (currentTicket != null)
                {
                    currentOpenTicket   = currentTicket;
                    currentOpenTicketId = currentTicket.ID;
                    currentUserId       = currentUser.ID;
                }
                else
                {
                    currentOpenTicket   = null;
                    currentOpenTicketId = string.Empty;
                    currentUserId       = string.Empty;
                }

                var configurationHelper = ConfigurationHelper.Instance;
                if (configurationHelper.ENABLE_bLOYAL)
                {
                    if (!string.IsNullOrWhiteSpace(configurationHelper.GIFTCARD_TENDER_CODE))
                    {
                        if (!ServiceURLHelper.IsbLoyalServiceUrlDown)
                        {
                            int ticketId = 0;
                            int.TryParse(currentOpenTicketId, out ticketId);

                            if (ticketId != 0)
                            {
                                if (!ServiceURLHelper.IsbLoyalServiceUrlDown)
                                {
                                    // Load Gift Card Tender Window
                                    frmLoadGiftCardWarning loadGiftCardWarning = null;

                                    var loadGiftCardItems = configurationHelper.LOAD_GIFTCARD_ITEMS.Where(p => currentTicket.Items.Any(p2 => p2.ItemName.Equals(p, StringComparison.InvariantCultureIgnoreCase)));
                                    if (loadGiftCardItems != null && loadGiftCardItems.Any())
                                    {
                                        foreach (var loadGiftItem in loadGiftCardItems)
                                        {
                                            var loadGiftCardMenuItems = currentTicket.Items.ToList().FindAll(t => t.ItemName.Equals(loadGiftItem, StringComparison.InvariantCultureIgnoreCase));
                                            if (loadGiftCardMenuItems != null)
                                            {
                                                foreach (var loadItem in loadGiftCardMenuItems)
                                                {
                                                    var service        = new LoyaltyEngineServices();
                                                    var calculatedCart = AsyncHelper.RunSync(() => service.GetCartBySourceExternalIdAsync(currentTicket.ID));

                                                    bLoyal.Connectors.LoyaltyEngine.CartLine giftCartLine = null;
                                                    if (calculatedCart != null && calculatedCart.Cart != null && calculatedCart.Cart.Lines != null && calculatedCart.Cart.Lines.Any())
                                                    {
                                                        giftCartLine = calculatedCart.Cart.Lines.FirstOrDefault(t => t.ProductName.Equals(loadGiftItem, StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrWhiteSpace(t.GiftCardNumber) && !string.IsNullOrWhiteSpace(t.ProductExternalId) && t.ProductExternalId.Equals(loadItem.TIID));
                                                    }

                                                    if (giftCartLine == null || string.IsNullOrWhiteSpace(giftCartLine.GiftCardNumber))
                                                    {
                                                        frmLoadGiftCardBalance loadGiftCardBalance = new frmLoadGiftCardBalance(ticketId, string.Empty, currentTicket, loadItem, calculatedCart, loadGiftItem);
                                                        loadGiftCardBalance.ShowDialog();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        loadGiftCardWarning = new frmLoadGiftCardWarning(Messages.ADD_LOAD_GIFTCARD_WARNING);
                                        loadGiftCardWarning.ShowDialog();
                                    }
                                }
                                else
                                {
                                    if (ServiceURLHelper.IsbLoyalServiceUrlDown)
                                    {
                                        frmbLoyalServiceUrlDownWarning frmServiceUrlDown = new frmbLoyalServiceUrlDownWarning();
                                        frmServiceUrlDown.ShowDialog();
                                    }
                                }
                            }
                            else
                            {
                                frmShowWarningMessage frmshowWarning = new frmShowWarningMessage();
                                frmshowWarning.ShowDialog();
                            }
                        }
                        else
                        {
                            frmbLoyalServiceUrlDownWarning frmServiceUrlDown = new frmbLoyalServiceUrlDownWarning();
                            frmServiceUrlDown.ShowDialog();
                        }
                    }
                    else
                    {
                        frmCheckGiftCardWarning giftCardWarning = new frmCheckGiftCardWarning();
                        giftCardWarning.ShowDialog();
                    }
                }
                else
                {
                    DisableEnablebLoyalFunctionality disableEnablebLoyal = new DisableEnablebLoyalFunctionality();
                    disableEnablebLoyal.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Instance.WriteLogError(ex, "bLoyalLoadGiftCard OEButtonPressed");
            }
        }