public List <SectionTypesTbl> GetAll(string SortBy) { List <SectionTypesTbl> _DataItems = new List <SectionTypesTbl>(); TrackerDb _TrackerDb = new TrackerDb(); string _sqlCmd = CONST_SQL_SELECT; if (!String.IsNullOrEmpty(SortBy)) { _sqlCmd += " ORDER BY " + SortBy; // Add order by string } // params would go here if need IDataReader _DataReader = _TrackerDb.ExecuteSQLGetDataReader(_sqlCmd); if (_DataReader != null) { while (_DataReader.Read()) { SectionTypesTbl _DataItem = new SectionTypesTbl(); _DataItem.SectionID = (_DataReader["SectionID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["SectionID"]); _DataItem.SectionType = (_DataReader["SectionType"] == DBNull.Value) ? string.Empty : _DataReader["SectionType"].ToString(); _DataItem.Notes = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString(); _DataItems.Add(_DataItem); } _DataReader.Close(); } _TrackerDb.Close(); return(_DataItems); }
public string InsertSectionType(SectionTypesTbl pSectionType) { TrackerDb _TDB = new TrackerDb(); _TDB.AddParams(pSectionType.SectionID, DbType.Int32); _TDB.AddParams(pSectionType.SectionType); _TDB.AddParams(pSectionType.Notes); string _Result = _TDB.ExecuteNonQuerySQL(CONST_SQL_INSERT); _TDB.Close(); return(_Result); }
public static void UpdateSection(SectionTypesTbl pSectionType, int pOrignal_SectionID) { TrackerDb _TDB = new TrackerDb(); _TDB.AddParams(pSectionType.SectionType); _TDB.AddParams(pSectionType.Notes); if (pOrignal_SectionID > 0) { _TDB.AddWhereParams(pOrignal_SectionID, DbType.Int32); } else { _TDB.AddWhereParams(pSectionType.SectionID, DbType.Int32); } string _Result = _TDB.ExecuteNonQuerySQL(CONST_SQL_UPDATE); _TDB.Close(); // return _Result; }
public static void UpdateSection(SectionTypesTbl pSectionType) { UpdateSection(pSectionType, 0); }