/// <summary> /// Handles when a user clicks on the card button option. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">The RoutedEventArgs of the event.</param> private void CreditDebitButton_Click(object sender, RoutedEventArgs e) { CardTransactionResult res = CardReader.RunCard((DataContext as Order).Total); switch (res) { case CardTransactionResult.Approved: ((Order)this.DataContext).PrintReciept(PaymentType.Card, 0.00); NewOrderEvent?.Invoke(this, new NewOrderEventArgs(new Order())); break; case CardTransactionResult.Declined: MessageBox.Show("Your card was declined, contact your bank."); break; case CardTransactionResult.ReadError: MessageBox.Show("Error reading your card, try again."); break; case CardTransactionResult.InsufficientFunds: MessageBox.Show("Your card was rejected due to a lack of funds."); break; case CardTransactionResult.IncorrectPin: MessageBox.Show("Your pin was incorrect, try re-enterring"); break; } }
/// <summary> /// Finalizes the sale and prints the reciept. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">The RoutedEventArgs of the event.</param> private void FinalizeSale_Click(object sender, RoutedEventArgs e) { if (((CashRegister)DataContext).Due <= 0) { _orderInstance.PrintReciept(PaymentType.Cash, ((CashRegister)DataContext).Owed); NewOrderEvent?.Invoke(this, new NewOrderEventArgs(new Order())); } else { MessageBox.Show("Cannot finalize sale until fully paid"); } }
protected virtual void OnNewOrderEvent(NewOrderEventArgs e) { NewOrderEvent?.Invoke(this, e); }
/// <summary> /// Handles when the user clicks on the cancel order button. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">The RoutedEventArgs of the event.</param> private void CancelOrder(object sender, RoutedEventArgs e) { NewOrderEvent?.Invoke(this, new NewOrderEventArgs(new Order())); }