/// <summary> /// RemoveItem /// </summary> /// <param name="theInfo"></param> /// <param name="targetTicket"></param> /// <param name="targetItem"></param> public void removeItem(IDisplayActions.displayActionInfo theInfo, Ticket targetTicket, MenuItem targetItem) { try { if (!ConfigurationHelper.Instance.IS_Test_Virtual_Client_Connection || !ConfigurationHelper.Instance.IS_Test_BLoyal_Connection) { return; } if (_configurationHelper != null && _configurationHelper.ENABLE_bLOYAL && targetItem != null && _configurationHelper.LOAD_GIFTCARD_ITEMS != null && _configurationHelper.LOAD_GIFTCARD_ITEMS.Any()) { RefreshTicket(targetTicket); UpdateTicketDictionary(_ticketId); var loadGiftCardItem = _configurationHelper.LOAD_GIFTCARD_ITEMS.Find(t => t.Equals(targetItem.ItemName, StringComparison.InvariantCultureIgnoreCase)); if (!string.IsNullOrWhiteSpace(loadGiftCardItem)) { var service = new LoyaltyEngineServices(); var calculatedCart = AsyncHelper.RunSync(() => service.GetCartBySourceExternalIdAsync(_targetTicket.ID)); if (calculatedCart != null && calculatedCart.Cart != null && calculatedCart.Cart.Lines != null && calculatedCart.Cart.Lines.Any()) { var lines = calculatedCart.Cart.Lines; var giftCartLine = calculatedCart.Cart.Lines.ToList().Find(t => t.ProductName.Equals(loadGiftCardItem, StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrWhiteSpace(t.GiftCardNumber) && t.ProductExternalId.Equals(targetItem.TIID)); if (giftCartLine != null && giftCartLine.GiftCardAmount.HasValue && giftCartLine.GiftCardAmount.Value > 0) { if (!_calculateTransaction.CreditLoadGiftCardItem(calculatedCart, targetItem.Price, giftCartLine.GiftCardNumber, targetTicket.ID, giftCartLine)) { frmServerOfflineWarning offLineMsg = new frmServerOfflineWarning(); offLineMsg.ShowDialog(); } else { lines.Remove(giftCartLine); } } calculatedCart.Cart.Lines = lines; var request = new CalculateCartCommand() { Cart = calculatedCart.Cart, Uid = calculatedCart.Cart.Uid }; service.CalculateCart(request); } } } } catch (Exception ex) { _loggerHelper.WriteLogError(ex, "removeItem"); } }
/// <summary> /// RemoveTransaction /// </summary> /// <param name="theInfo"></param> /// <param name="targetTicket"></param> /// <param name="displayField"></param> /// <param name="paymentAmount"></param> /// <param name="amountDue"></param> public void removeTransaction(IDisplayActions.displayActionInfo theInfo, Ticket targetTicket, string displayField, decimal paymentAmount, decimal amountDue) { try { if (!ConfigurationHelper.Instance.IS_Test_Virtual_Client_Connection || !ConfigurationHelper.Instance.IS_Test_BLoyal_Connection) { return; } if (_configurationHelper != null && _configurationHelper.ENABLE_bLOYAL) { RefreshTicket(targetTicket); if (_ticketId != 0) { bool isCreditbLoyalTendersError = AsyncHelper.RunSync(() => _calculateTransaction.RefundbLoyalTendersAsync(_ticketId, paymentAmount)); if (isCreditbLoyalTendersError) { System.Windows.Forms.Form frmServiceUrlDown = null; if (ServiceURLHelper.IsbLoyalServiceUrlDown) { frmServiceUrlDown = new frmbLoyalServiceUrlDownWarning(); } else { frmServiceUrlDown = new frmServerOfflineWarning(); } frmServiceUrlDown.ShowDialog(); } } } } catch (Exception ex) { _loggerHelper.WriteLogError(ex, "removeTransaction"); } }
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, 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"); } }
/// <summary> /// Void Ticket /// </summary> /// <param name="theInfo"></param> /// <param name="targetTicket"></param> public void voidTicket(IDisplayActions.displayActionInfo theInfo, Ticket targetTicket) { try { if (!ConfigurationHelper.Instance.IS_Test_Virtual_Client_Connection || !ConfigurationHelper.Instance.IS_Test_BLoyal_Connection) { return; } if (_configurationHelper != null && _configurationHelper.ENABLE_bLOYAL && targetTicket != null && targetTicket.Items != null && targetTicket.Items.Any() && _configurationHelper.LOAD_GIFTCARD_ITEMS != null && _configurationHelper.LOAD_GIFTCARD_ITEMS.Any()) { RefreshTicket(targetTicket); var loadGiftCardItems = _configurationHelper.LOAD_GIFTCARD_ITEMS.Where(p => targetTicket.Items.Any(p2 => p2.ItemName.Equals(p, StringComparison.InvariantCultureIgnoreCase))); if (loadGiftCardItems != null && loadGiftCardItems.Any()) { var service = new LoyaltyEngineServices(); bool isCreditLoadGiftCard = false; var calculatedCart = AsyncHelper.RunSync(() => service.GetCartBySourceExternalIdAsync(_targetTicket.ID)); if (calculatedCart != null && calculatedCart.Cart != null && calculatedCart.Cart.Lines != null) { var lines = new List <CartLine>(calculatedCart.Cart.Lines.ToList()); foreach (var giftCartLine in calculatedCart.Cart.Lines) { if (giftCartLine.GiftCardAmount.HasValue && giftCartLine.GiftCardAmount.Value > 0) { if (!_calculateTransaction.CreditLoadGiftCardItem(calculatedCart, giftCartLine.GiftCardAmount.Value, giftCartLine.GiftCardNumber, targetTicket.ID, giftCartLine)) { frmServerOfflineWarning offLineMsg = new frmServerOfflineWarning(); offLineMsg.ShowDialog(); } else { isCreditLoadGiftCard = true; lines.Remove(giftCartLine); } } } if (isCreditLoadGiftCard) { calculatedCart.Cart.Lines = lines; var request = new CalculateCartCommand() { Cart = calculatedCart.Cart, Uid = calculatedCart.Cart.Uid }; service.CalculateCart(request); } } } } } catch (Exception ex) { _loggerHelper.WriteLogError(ex, "voidTicket"); } }