/// <summary> /// Return a list of projects in the database. /// </summary> /// <returns>A list of projects in the database.</returns> public ObservableCollectionEx <Project> GetProjectList() { // Create a list of projects ObservableCollectionEx <Project> list = new ObservableCollectionEx <Project>(); string query = "SELECT * FROM tblProjects;"; // Read in all the projects in the tb_Projects try { // Query the database for all the projects DataTable dt = Pulse.DbCommon.GetDataTableFromPulseDb(_dbMainConnection, query); // Go through the result, creating Project objects // for all projects found foreach (DataRow r in dt.Rows) { // Get the Project info int id = Convert.ToInt32(r[Pulse.DbCommon.COL_PRJ_ID]); string name = r[Pulse.DbCommon.COL_PRJ_NAME].ToString(); string dir = r[Pulse.DbCommon.COL_PRJ_DIR].ToString(); DateTime dateCreated = (DateTime)r[Pulse.DbCommon.COL_PRJ_DT_CREATED]; DateTime dateMod = (DateTime)r[Pulse.DbCommon.COL_PRJ_DT_LAST_MOD]; string serial = r[Pulse.DbCommon.COL_PRJ_SERIALNUMBER].ToString(); Project prj = new Project(id, name, dir, dateCreated, dateMod, serial); // Add the Project to the list list.Add(prj); } } catch (SQLiteException e) { log.Error("SQL Error adding project to database.", e); } catch (Exception ex) { log.Error("Error adding project to database.", ex); } return(list); }