/// <summary> /// Event handler for if the user wants to finalize the sale /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void FinalizeSaleClicked(object sender, RoutedEventArgs e) { cashDrawer.PrintReceipt(true, thisOrder); Order newOrder = new Order(); MainMenuSelection main = new MainMenuSelection(); OrderComponent orderComponent = this.FindAncestor <OrderComponent>(); // Find the Order Component that is a parent of the current order summary orderComponent.DataContext = newOrder; // Set the data context of the order component to be the new order orderComponent.Swap(main); }
/// <summary> /// Event handler for if user selects credit card payment /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OnCreditSelect(object sender, RoutedEventArgs e) { if (DataContext is Order order) { var result = CardReader.RunCard(order.Total); if (result is CardTransactionResult.Approved) { Order newOrder = new Order(); UpdateCashDrawer cashDrawer = new UpdateCashDrawer(order.Total); MainMenuSelection main = new MainMenuSelection(); OrderComponent orderComponent = this.FindAncestor <OrderComponent>(); // Find the Order Component that is a parent of the current order summary orderComponent.DataContext = newOrder; // Set the data context of the order component to be the new order orderComponent.Swap(main); cashDrawer.PrintReceipt(false, order); // Print receipt for false (paying with card, not cash), and this order } } }