private async void myCloseAccount_Click(object sender, RoutedEventArgs e) { if (accountList.SelectedItem != null) { MessageDialog msg = new MessageDialog("Remove account permanently?", "Remove account"); msg.Commands.Clear(); msg.Commands.Add(new UICommand { Label = "Yes", Id = 0 }); msg.Commands.Add(new UICommand { Label = "Cancel", Id = 1 }); var result = await msg.ShowAsync(); if ((int)result.Id == 0) { string rate = AccountLogic.PrintAccountInfo((Account)accountList.SelectedItem); customer.Accounts.Remove((Account)accountList.SelectedItem); MessageDialog msg2 = new MessageDialog(rate, "Deleted account information"); await msg2.ShowAsync(); } } }
/// <summary> /// Prints the account information upon removal. /// </summary> public static string RemoveCustomer(Customer customer) { string removedCustomer = "Accounts removed: \n"; try { foreach (var item in customer.Accounts) { removedCustomer += AccountLogic.PrintAccountInfo(item) + "\n"; } Customers.Remove(customer); } catch (Exception) { } return(removedCustomer); }
private async void myWithdraw_Click(object sender, RoutedEventArgs e) { bool success = false; decimal amount = 0; if (accountList.SelectedIndex != -1) { decimal.TryParse(amountBox.Text, out amount); success = AccountLogic.Withdraw(customer.Accounts[accountList.SelectedIndex], amount); } MessageDialog withdraw; if (success) { withdraw = new MessageDialog($"{amount} SEK withdrawn", "Withdrawal successful!"); Frame.Navigate(typeof(AccountPage), customer); Frame.GoBack(); } else { withdraw = new MessageDialog("Withdraw failed..."); } await withdraw.ShowAsync(); }
private async void myDeposit_Click(object sender, RoutedEventArgs e) { bool success = false; decimal amount = 0; if (accountList.SelectedIndex != -1) { decimal.TryParse(amountBox.Text, out amount); success = AccountLogic.Deposit(customer.Accounts[accountList.SelectedIndex], amount); } MessageDialog deposit; if (success) { deposit = new MessageDialog($"{amount} SEK Deposited", "Deposit Successful!"); Frame.Navigate(typeof(AccountPage), customer); Frame.GoBack(); } else { deposit = new MessageDialog("Deposit failed..."); } await deposit.ShowAsync(); }
} //MÅSTE VARA UNIKT public Account(long balance, double interest) { Balance = balance; Interest = interest; AccountID = AccountLogic.NewAccountID(); }
private async void addCredit_Click(object sender, RoutedEventArgs e) { MessageDialog CreditAccCreation = new MessageDialog($"Account ID: {AccountLogic.AddCreditAccount(customer)}", "Credit Account Created!"); await CreditAccCreation.ShowAsync(); }
private void myDeposit_Click(object sender, RoutedEventArgs e) { decimal.TryParse(depositBox.Text, out decimal amount); AccountLogic.Deposit(customer.Accounts[accountList.SelectedIndex], amount); }
private void myWithdraw_Click(object sender, RoutedEventArgs e) { decimal.TryParse(withdrawBox.Text, out decimal amount); AccountLogic.Withdraw(customer.Accounts[accountList.SelectedIndex], amount); }
private void addCredit_Click(object sender, RoutedEventArgs e) { AccountLogic.AddCreditAccount(customer); }
private void addSavings_Click(object sender, RoutedEventArgs e) { AccountLogic.AddSavingsAccount(customer); }