/// <summary> /// Fills the <see cref="UnitHolder"/> with all the data from database. /// </summary> public static void FillUnitHolder(UnitHolder unitHolder) { string sql = "SELECT * FROM units"; try { using (SQLiteConnection cnt = new SQLiteConnection(dbPath)) using (SQLiteCommand cmd = new SQLiteCommand(sql, cnt)) { cnt.Open(); using (SQLiteDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { unitHolder.Add(rdr.GetInt32(0), rdr.GetString(1)); } } cnt.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Returns a <see cref="UnitHolder"/> containing currently checked <see cref="Unit"/>s. /// </summary> public static UnitHolder CheckedUnits(this CheckedListBox clb) { UnitHolder units = new UnitHolder(); foreach (Unit unit in clb.CheckedItems) { units.Add(unit); } return(units); }