private void deleteAccountButton_Click(object sender, EventArgs e) { int accountNo = (int)accountComboBox.SelectedValue; bool accountDeleted = false; using (var core = new StandardBusinessLayer(DataCache)) { core.Connect(); int accountTransactionsCount = core.CountAccountTransactionsByAccountNo(accountNo); if (accountTransactionsCount > 0) { MessageBox.Show("Kontot kan inte tas bort eftersom den har registrerade kontotransaktioner.", CurrentApplication.Name, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } Account account = core.GetAccount(accountNo); DialogResult result = MessageBox.Show("Är du säker på att du vill ta bort kontot '" + account.Name + "'?", CurrentApplication.Name, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { core.DeleteAccount(accountNo); accountDeleted = true; } } if (accountDeleted) { ReloadForm(); } }