private void Deleteaccount_btn_Click(object sender, EventArgs e) { // get textbox value string account_name = account_textbox.ForeColor == Color.Black ? account_textbox.Text : ""; int account_id = CURRENT_USER_ACCOUNTS[account_name]; // verify if account exists before trying to delete var exists = DB_API.ExistsMoneyAccount(account_id); if (!exists) { ErrorMessenger.Error("Account does not exist!"); return; } // delete money account bool sure = ErrorMessenger.OKCancel("Deleting a Money Account will permanently" + "delete all its transaction, categories," + "loans, goals and stock. Are you sure you want to delete?"); if (sure) { DB_API.DeleteMoneyAccount(account_id); CURRENT_USER_ACCOUNTS.Remove(account_name); } else { return; } // repopulate accounts_listbox Populate_moneyAccounts_listBox(CURRENT_USER); }
private void Adduser_btn_Click(object sender, EventArgs e) { // get textbox value string new_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("Acount 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 (new_user.Equals("")) { ErrorMessenger.Error("User must be selected to attribute account to!"); return; } // verify if user exists exists = DB_API.ExistsUser(new_user); if (!exists) { ErrorMessenger.Error("User does not exist!"); return; } // verify if user already is associated with account var rdr = DB_API.SelectMoneyAccountUsers(account_id); while (rdr.Read()) { if (rdr[DB_API.MoneyAccountEnt.user_email.ToString()].Equals(new_user)) { ErrorMessenger.Error("User already participates in account"); return; } } // insert new account into 'users_money_accounts table DB_API.MoneyAccountAddUser(account_id, new_user); Populate_associatedUsers_listBox(account_id); }
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); }
private void Login_btn_Click(object sender, EventArgs e) { string user = CURRENT_USER.Equals("") ? userfindme_textbox.Text : CURRENT_USER; if (user.Equals("")) { ErrorMessenger.EmptyField("Email"); return; } string account_name = account_textbox.ForeColor == Color.Black ? account_textbox.Text : ""; if (account_name.Equals("")) { ErrorMessenger.Error("Account must be selected!"); return; } int account_id = CURRENT_USER_ACCOUNTS[account_name]; var exists = DB_API.ExistsMoneyAccount(account_id); if (!exists) { ErrorMessenger.Error("Account does not exist!"); return; } var frm = new UserMenuForm(user, account_id) { Location = this.Location, StartPosition = FormStartPosition.Manual }; frm.FormClosing += delegate { this.Show(); }; frm.Show(); this.Hide(); }