예제 #1
0
 private async void BtnSubmit_Click(object sender, RoutedEventArgs e)
 {
     if (AppState.AllAccounts.All(account => account.Name != TxtAccountName.Text))
     {
         Enum.TryParse(CmbAccountTypes.SelectedValue.ToString().Replace(" ", ""), out AccountTypes currentType);
         Account newAccount = new Account(TxtAccountName.Text, currentType, new List <FinancialTransaction>());
         FinancialTransaction newTransaction = new FinancialTransaction(await AppState.GetNextFinancialTransactionIndex(), DateTime.Now,
                                                                        "Income", "Income", "Starting Balance", "", 0.00M, DecimalHelper.Parse(TxtBalance.Text),
                                                                        newAccount.Name);
         newAccount.AddTransaction(newTransaction);
         if (await AppState.AddAccount(newAccount))
         {
             if (await AppState.AddFinancialTransaction(newTransaction, newAccount))
             {
                 ClosePage();
             }
             else
             {
                 AppState.DisplayNotification("Unable to process new account.", "Personal Tracker");
             }
         }
     }
     else
     {
         AppState.DisplayNotification("That account name already exists.", "Personal Tracker");
     }
 }