private void PopulateCategoriesListBox() { // get categories from DB var rdr = DB_API.SelectAccountCategories(account_id); // verify if account has no categories if (!rdr.HasRows) { ErrorMessenger.Warning("Account has no categories!"); Categories_listbox.DataSource = new List <String>(); return; } // extract category names for listBox this.categories = new Dictionary <string, int>(); var res = new Dictionary <string, int>(); while (rdr.Read()) { string cat_name = rdr[DB_API.CategoryEnt.name.ToString()].ToString(); int cat_id = (int)rdr[DB_API.CategoryEnt.category_id.ToString()]; categories[cat_name] = cat_id; if (cat_id % 100 > 0) { cat_name = " -> " + cat_name; } res[cat_name] = cat_id; } Categories_listbox.DataSource = new List <string>(res.Keys); }
private void Delete_btn_Click(object sender, EventArgs e) { int transaction_id = 0; try { transaction_id = (int)((Transaction)Transactions_listView.SelectedItems[0].Tag).TransactionID; } catch { ErrorMessenger.Warning("A transaction must be selected from the list"); return; } DB_API.DeleteTransaction(transaction_id); // populate transactions listBox PopulateTransactionsListView(); }