private void Deleteuser_btn_Click(object sender, EventArgs e) { // get textbox value string user = user_textbox.ForeColor == Color.Black ? user_textbox.Text : ""; string account_name = account_textbox.ForeColor == Color.Black ? account_textbox.Text : ""; int account_id = CURRENT_USER_ACCOUNTS[account_name]; // verify if account field is filled if ("".Equals(account_name)) { ErrorMessenger.EmptyField("Account name"); return; } // verify if account exists var exists = DB_API.ExistsMoneyAccount(account_id); if (!exists) { ErrorMessenger.Error("Account does not exist!"); return; } // verify that a user is selected if (user.Equals("")) { ErrorMessenger.Error("User must be selected to attribute account to!"); return; } // verify if user exists exists = DB_API.ExistsUser(user); if (!exists) { ErrorMessenger.Error("User does not exist!"); return; } // delete user access to account DB_API.MoneyAccountRemoveUser(account_id, user); // repopulate accounts_listbox Populate_moneyAccounts_listBox(CURRENT_USER); }