/// <summary> /// cancels the transaction and creates a new order /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CancelTransaction(object sender, RoutedEventArgs e) { var ordercontrol = this.FindAncestor <OrderControl>(); if (DataContext is Order data) { data = new Order(); this.DataContext = data; ordercontrol.DataContext = data; var screen = new MenuItemSelectionControl(); ordercontrol.SwapScreen(screen); } }
/// <summary> /// Lets you pay with Card /// </summary> /// <param name="sender">button</param> /// <param name="e">click</param> private void CardPay(object sender, RoutedEventArgs e) { var ordercontrol = this.FindAncestor <OrderControl>(); if (DataContext is Order data) { var item = data; var result = card.ProcessTransaction(item.Total); switch (result) { case ResultCode.Success: string print = Print(item.OrderNumber, item.Items, item.Subtotal, item.Total, "Credit/Debit Card"); receipt.Print(print); data = new Order(); this.DataContext = data; var screen = new MenuItemSelectionControl(); ordercontrol.SwapScreen(screen); ordercontrol.DataContext = data; break; case ResultCode.UnknownErrror: MessageBox.Show("Unknown Card Error"); break; case ResultCode.CancelledCard: MessageBox.Show("Cancelled Card"); break; case ResultCode.InsufficentFunds: MessageBox.Show("Insufficent Funds"); break; case ResultCode.ReadError: MessageBox.Show("Card Reading Error"); break; } } }