Ejemplo n.º 1
0
        public List <PriceLevelsTbl> GetAll(string SortBy)
        {
            List <PriceLevelsTbl> _DataItems = new List <PriceLevelsTbl>();
            TrackerDb             _TDB       = 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 = _TDB.ExecuteSQLGetDataReader(_sqlCmd);

            if (_DataReader != null)
            {
                while (_DataReader.Read())
                {
                    PriceLevelsTbl _DataItem = new PriceLevelsTbl();

                    #region StoreThisDataItem
                    _DataItem.PriceLevelID   = (_DataReader["PriceLevelID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["PriceLevelID"]);
                    _DataItem.PriceLevelDesc = (_DataReader["PriceLevelDesc"] == DBNull.Value) ? string.Empty : _DataReader["PriceLevelDesc"].ToString();
                    _DataItem.PricingFactor  = (_DataReader["PricingFactor"] == DBNull.Value) ? 0.0 : Math.Round(Convert.ToDouble(_DataReader["PricingFactor"]), 3);
                    _DataItem.Enabled        = (_DataReader["Enabled"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["Enabled"]);
                    _DataItem.Notes          = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString();
                    #endregion
                    _DataItems.Add(_DataItem);
                }
                _DataReader.Close();
            }
            _TDB.Close();
            return(_DataItems);
        }
Ejemplo n.º 2
0
        public string Update(PriceLevelsTbl pPriceLevelsTbl, int pOrignal_PriceLevelID)
        {
            string    _result = string.Empty;
            TrackerDb _TDB    = new TrackerDb();

            #region UpdateParameters
            if (pOrignal_PriceLevelID > 0)
            {
                _TDB.AddWhereParams(pOrignal_PriceLevelID, DbType.Int32); // check this line it assumes id field is int32
            }
            else
            {
                _TDB.AddWhereParams(pPriceLevelsTbl.PriceLevelID, DbType.Boolean, "@PriceLevelID");
            }

            _TDB.AddParams(pPriceLevelsTbl.PriceLevelDesc, DbType.String, "@PriceLevelDesc");
            _TDB.AddParams(Math.Round(pPriceLevelsTbl.PricingFactor, 3), DbType.Double, "@PricingFactor");
            _TDB.AddParams(pPriceLevelsTbl.Enabled, DbType.Int32, "@Enabled");
            _TDB.AddParams(pPriceLevelsTbl.Notes, DbType.String, "@Notes");
            #endregion
            // Now we have the parameters excute the SQL
            _result = _TDB.ExecuteNonQuerySQL(CONST_SQL_UPDATE);
            _TDB.Close();
            return(_result);
        }
Ejemplo n.º 3
0
        public string Insert(PriceLevelsTbl pPriceLevelsTbl)
        {
            string    _result = string.Empty;
            TrackerDb _TDB    = new TrackerDb();

            #region InsertParameters
            _TDB.AddParams(pPriceLevelsTbl.PriceLevelDesc, DbType.String, "@PriceLevelDesc");
            _TDB.AddParams(Math.Round(pPriceLevelsTbl.PricingFactor, 3), DbType.Single, "@PricingFactor");
            _TDB.AddParams(pPriceLevelsTbl.Enabled, DbType.Int32, "@Enabled");
            _TDB.AddParams(pPriceLevelsTbl.Notes, DbType.String, "@Notes");
            #endregion
            // Now we have the parameters excute the SQL
            _result = _TDB.ExecuteNonQuerySQL(CONST_SQL_INSERT);
            _TDB.Close();
            return(_result);
        }
Ejemplo n.º 4
0
 public string Delete(PriceLevelsTbl pPriceLevelsTbl)
 {
     return(Delete(pPriceLevelsTbl.PriceLevelID));
 }
Ejemplo n.º 5
0
 public string Update(PriceLevelsTbl pPriceLevelsTbl)
 {
     return(Update(pPriceLevelsTbl, 0));
 }