private void CheckCardBalance() { MessageBoxLayoutInfo messageBox = new MessageBoxLayoutInfo(); if (MainWindow.CardUid != null) { var card = rfidCardRequest.Get(MainWindow.CardUid); if (card == null) { throw new NullReferenceException("Invalid card!"); } else { var cardInfo = new CardInfo(card); messageBox = cardInfo.GetMessageBox(); } } else { messageBox.Message = "Operation canceled!"; } MainWindow.contentControl.Content = MainWindow.POSMainMenuView; messageBox.ShowDialog(); }
public async void ChangeToControlVoid(UserControl previousControl, string message) { MessageBoxLayoutInfo messageBox = new MessageBoxLayoutInfo(); MainWindow.contentControl.Content = ChangeToControl(previousControl, message); try { MainWindow.CardUid = await MainWindow.MFRC522ReaderWriter.ReadUIDAsync(); #region Checking card balance if (previousControl == MainWindow.POSMainMenuView) { CheckCardBalance(); } #endregion Checking card balance if (previousControl == MainWindow.PaymentMethodUserControl) { MainWindow.contentControl.Content = MainWindow.CardReadingUserControl.ChangeToControl(this, message); if (MainWindow.CardUid != null) { ExecuteTransaction(); messageBox.Message = "Payment started. Please take your card and pay at the cash payment point. Your card will be activated after payment is completed."; MainWindow.contentControl.Content = MainWindow.POSMainMenuView; messageBox.ShowDialog(); } else { messageBox.Message = "PAYMENT CANCELED\n TRY AGAIN"; messageBox.MessageBoxContent.Background = new SolidColorBrush(Color.FromRgb(211, 105, 105)); MainWindow.contentControl.Content = previousControl; messageBox.ShowDialog(); } } } catch (NullReferenceException e) { messageBox.Message = e.Message; MainWindow.contentControl.Content = previousControl; messageBox.ShowDialog(); } catch (Exception e) { messageBox.Message = e.Message; MainWindow.contentControl.Content = previousControl; messageBox.ShowDialog(); } }