public void ViewAccountIinfo() { if (lvCustomers.Items.Count == 0 && lvCustomers.SelectedIndex == -1) { MessageBox.Show("First choose a customer to view accounts"); return; } if (lvAccounts.Items.Count == 0 || lvAccounts.SelectedIndex == -1) { MessageBox.Show("Please choose an account to view"); return; } if (currentAccount.IsActive == false) { MessageBox.Show("Information is unavailable for closed account"); return; } ViewAccountInfo viewAccInfoDlg = new ViewAccountInfo(currentClient, currentAccount); viewAccInfoDlg.Owner = Utilities.adminDashboard; bool?result = viewAccInfoDlg.ShowDialog(); if (result == true) { LoadFoundAccounts(); } }
private void btOK_Click(object sender, RoutedEventArgs e) { if (!AreFieldsValid()) { return; } MessageBoxResult result = MessageBox.Show("Please confirm the new Account Information before proceed:\n\nCustomer name: " + currentCust.FullName + "\nAccount type: " + selectedAccType.Description + "\n" + lblFeeOrInterest.Content + " " + tbFeeOrInterest.Text + "\n\nWould you like to confirm the creation of the new account above?", "Confirmation required", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (result == MessageBoxResult.Yes) { Account account = new Account(); account.OpenDate = DateTime.Today; account.UserId = currentCust.Id; account.Balance = 0; account.AccountTypeId = selectedAccType.Id; if (selectedAccType.Description == "Checking" || selectedAccType.Description == "Business") { account.MonthlyFee = decimal.Parse(tbFeeOrInterest.Text); } if (selectedAccType.Description == "Savings" || selectedAccType.Description == "Investment") { account.Interest = decimal.Parse(tbFeeOrInterest.Text); } account.IsActive = true; try { EFData.context.Accounts.Add(account); EFData.context.SaveChanges(); } catch (DbEntityValidationException ex) { var error = ex.EntityValidationErrors.First().ValidationErrors.First(); MessageBox.Show(error.ErrorMessage); EFData.context.Entry(account).State = EntityState.Detached; return; } catch (SystemException ex) { MessageBox.Show("Database error: " + ex.Message, "Database operation failed", MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show(ex.InnerException.InnerException.Message); return; } MessageBox.Show("Account created successfully", "New account created", MessageBoxButton.OK, MessageBoxImage.Information); DialogResult = true; ViewAccountInfo viewCreatedAccInfoDialog = new ViewAccountInfo(currentCust, account); viewCreatedAccInfoDialog.Owner = Utilities.adminDashboard; viewCreatedAccInfoDialog.ShowDialog(); } }
private void lvAccounts_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (lvCustomers.Items.Count != 0 && lvCustomers.SelectedIndex != -1 && lvAccounts.Items.Count != 0 && lvAccounts.SelectedIndex != -1) { if (currentAccount.IsActive == false) { MessageBox.Show("This account is closed."); return; } ViewAccountInfo viewAccInfoDlg = new ViewAccountInfo(currentClient, currentAccount); // viewAccInfoDlg.Owner = this; bool?result = viewAccInfoDlg.ShowDialog(); if (result == true) { LoadFoundAccounts(); } } }