private void button_back_Click(object sender, RoutedEventArgs e) { if (this.transferStage == TransferStage.ACCOUNT) { NavigationService service = NavigationService.GetNavigationService(this); service.GoBack(); } else if (this.transferStage == TransferStage.AMOUNT) { this.top_label.Content = "Please enter an account number:"; this.num_screen.Text = ""; this.transferStage = TransferStage.ACCOUNT; } }
public TransferPage() { InitializeComponent(); this.transferStage = TransferStage.ACCOUNT; }
private void button_submit_Click(object sender, RoutedEventArgs e) { if (this.transferStage == TransferStage.ACCOUNT) { if (this.num_screen.Text != "") { int toAccNum = 0; try { toAccNum = Int32.Parse(this.num_screen.Text); this.toAccount = Database.ValidateAccout(toAccNum); } catch { System.Windows.MessageBox.Show("Invalid input account, please try again!"); this.num_screen.Text = ""; } if (this.toAccount != null) { if (Globals.loginAccount.accountNumber == toAccNum) { System.Windows.MessageBox.Show("You cannot transfer to yourself."); this.num_screen.Text = ""; } else { this.top_label.Content = "Please enter an amount to transfer:"; this.num_screen.Text = ""; this.transferStage = TransferStage.AMOUNT; this.button_dot.IsEnabled = true; } } else { System.Windows.MessageBox.Show("Unknown account!"); this.num_screen.Text = ""; } } else { System.Windows.MessageBox.Show("Account number can not be empty!"); } } else { double amount = 0; try { amount = Double.Parse(this.num_screen.Text); } catch { System.Windows.MessageBox.Show("Invalid input amount, please try again!"); this.num_screen.Text = ""; } if (amount > 0) { MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show(String.Format("Are you sure you want to transfer ${0} to account {1}?", amount, this.toAccount.accountNumber), "Delete Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { NavigationService service = NavigationService.GetNavigationService(this); if (Globals.loginAccount.balance >= amount) { Globals.loginAccount.transfer(amount, this.toAccount); System.Windows.MessageBox.Show("Sucess, press OK to go to home page"); service.GoBack(); } else { System.Windows.MessageBox.Show("Failed. You don't have sufficient balance!"); this.num_screen.Text = ""; } } } } }