// ------------------------------------------------------------------- // BUTTONS ----------------------------------------------------------- // ------------------------------------------------------------------- private void Findme_btn_Click(object sender, EventArgs e) { // read value from textbox string email = userfindme_textbox.ForeColor == Color.Black ? userfindme_textbox.Text : ""; CURRENT_USER = email; // verify an email was given if (email.Equals("")) { ErrorMessenger.EmptyField("Email"); return; } // verify if user exists var exists = DB_API.ExistsUser(email); if (!exists) { ErrorMessenger.Error("User does not exist!"); return; } // populate account_listBox Populate_moneyAccounts_listBox(email); }
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 Update_btn_Click(object sender, EventArgs e) { // get values from text boxes if they attrValue inserted by user string username = username_textbox.ForeColor == Color.Black ? username_textbox.Text : ""; string email = email_textbox.ForeColor == Color.Black ? email_textbox.Text : ""; string fname = firstname_textbox.ForeColor == Color.Black ? firstname_textbox.Text : ""; string mname = middlename_textbox.ForeColor == Color.Black ? middlename_textbox.Text : ""; string lname = lastname_textbox.ForeColor == Color.Black ? lastname_textbox.Text : ""; string cardNo = cardnumber_textbox.ForeColor == Color.Black ? cardnumber_textbox.Text : ""; int periodicity = DB_API.SelectRecurenceIdbyDesignation((string)Periodicity_comboBox.SelectedItem); DateTime term = DateTime.Parse(term_dateTimePicker.Value.ToString()); // verify if email field is filled if (email.Equals("")) { ErrorMessenger.EmptyField("Email"); return; } // verify that all mandatory fields are filled (if subscripition is checked) if (active_checkBox.Checked) { if ("".Equals(fname) || "".Equals(lname) || "".Equals(cardNo) || "".Equals(periodicity)) { ErrorMessenger.EmptyField("Every field marked (*)"); return; } } // verify if user exists, so it can be updated var exists = DB_API.ExistsUser(email); if (!exists) { ErrorMessenger.Error("User does not exist. Unable to update!"); return; } // update user DB_API.UpdateUser(username, email, fname, mname, lname, cardNo, periodicity, term, active_checkBox.Checked); // update listBox PopulateUsersListView(); }
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); }