public List <SysDataTbl> GetAll() //(string SortBy) { List <SysDataTbl> _DataItems = new List <SysDataTbl>(); 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()) { SysDataTbl _DataItem = new SysDataTbl(); _DataItem.ID = (_DataReader["ID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ID"]); _DataItem.LastReoccurringDate = (_DataReader["LastReoccurringDate"] == DBNull.Value) ? System.DateTime.MinValue : Convert.ToDateTime(_DataReader["LastReoccurringDate"]).Date; _DataItem.DoReoccuringOrders = (_DataReader["DoReoccuringOrders"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["DoReoccuringOrders"]); _DataItem.DateLastPrepDateCalcd = (_DataReader["DateLastPrepDateCalcd"] == DBNull.Value) ? System.DateTime.MinValue : Convert.ToDateTime(_DataReader["DateLastPrepDateCalcd"]).Date; _DataItem.MinReminderDate = (_DataReader["MinReminderDate"] == DBNull.Value) ? System.DateTime.MinValue : Convert.ToDateTime(_DataReader["MinReminderDate"]).Date; _DataItem.GroupItemTypeID = (_DataReader["GroupItemTypeID"] == DBNull.Value) ? TrackerDb.CONST_INVALIDID : Convert.ToInt32(_DataReader["GroupItemTypeID"]); _DataItems.Add(_DataItem); } _DataReader.Close(); } _TrackerDb.Close(); return(_DataItems); }
public string Update(SysDataTbl SysDataItem, int orig_ID) { string _Result = String.Empty; if (orig_ID > 0) { TrackerDb _TDB = new TrackerDb(); // LastReoccurringDate = ?, DoReoccuringOrders = ?, DateLastPrepDateCalcd = ?, MinReminderDate = ?, GroupItemTypeID = ?" + _TDB.AddParams(SysDataItem.LastReoccurringDate, DbType.Date); _TDB.AddParams(SysDataItem.DoReoccuringOrders, DbType.Boolean); _TDB.AddParams(SysDataItem.DateLastPrepDateCalcd, DbType.Date); _TDB.AddParams(SysDataItem.MinReminderDate, DbType.Date); _TDB.AddParams(SysDataItem.GroupItemTypeID, DbType.Int32, "@GroupItemTypeID"); // "WHERE (SysDataTbl.ID = ?) _TDB.AddWhereParams(orig_ID, DbType.Int32); _Result = _TDB.ExecuteNonQuerySQL(CONST_SQL_UPDATEBYID); _TDB.Close(); } return(_Result); }
public string Update(SysDataTbl SysDataItem) { return(Update(SysDataItem, SysDataItem.ID)); }