Пример #1
0
        public static ShipRateMatrix Load(Int32 shipRateMatrixId, bool useCache)
        {
            if (shipRateMatrixId == 0)
            {
                return(null);
            }
            ShipRateMatrix shipRateMatrix = null;
            string         key            = "ShipRateMatrix_" + shipRateMatrixId.ToString();

            if (useCache)
            {
                shipRateMatrix = ContextCache.GetObject(key) as ShipRateMatrix;
                if (shipRateMatrix != null)
                {
                    return(shipRateMatrix);
                }
            }
            shipRateMatrix = new ShipRateMatrix();
            if (shipRateMatrix.Load(shipRateMatrixId))
            {
                if (useCache)
                {
                    ContextCache.SetObject(key, shipRateMatrix);
                }
                return(shipRateMatrix);
            }
            return(null);
        }
Пример #2
0
        public static bool Delete(Int32 shipRateMatrixId)
        {
            ShipRateMatrix shipRateMatrix = new ShipRateMatrix();

            if (shipRateMatrix.Load(shipRateMatrixId))
            {
                return(shipRateMatrix.Delete());
            }
            return(false);
        }
Пример #3
0
 /// <summary>
 /// Loads the given ShipRateMatrix object from the given database data reader.
 /// </summary>
 /// <param name="shipRateMatrix">The ShipRateMatrix object to load.</param>
 /// <param name="dr">The database data reader to read data from.</param>
 public static void LoadDataReader(ShipRateMatrix shipRateMatrix, IDataReader dr)
 {
     //SET FIELDS FROM ROW DATA
     shipRateMatrix.ShipRateMatrixId = dr.GetInt32(0);
     shipRateMatrix.ShipMethodId     = dr.GetInt32(1);
     shipRateMatrix.RangeStart       = NullableData.GetDecimal(dr, 2);
     shipRateMatrix.RangeEnd         = NullableData.GetDecimal(dr, 3);
     shipRateMatrix.Rate             = dr.GetDecimal(4);
     shipRateMatrix.IsPercent        = dr.GetBoolean(5);
     shipRateMatrix.IsDirty          = false;
 }
Пример #4
0
        public static ShipRateMatrixCollection LoadForShipMethod(Int32 shipMethodId, int maximumRows, int startRowIndex, string sortExpression)
        {
            //CREATE THE DYNAMIC SQL TO LOAD OBJECT
            StringBuilder selectQuery = new StringBuilder();

            selectQuery.Append("SELECT");
            if (maximumRows > 0)
            {
                selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString());
            }
            selectQuery.Append(" " + ShipRateMatrix.GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_ShipRateMatrix");
            selectQuery.Append(" WHERE ShipMethodId = @shipMethodId");
            if (!string.IsNullOrEmpty(sortExpression))
            {
                selectQuery.Append(" ORDER BY " + sortExpression);
            }
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString());

            database.AddInParameter(selectCommand, "@shipMethodId", System.Data.DbType.Int32, shipMethodId);
            //EXECUTE THE COMMAND
            ShipRateMatrixCollection results = new ShipRateMatrixCollection();
            int thisIndex = 0;
            int rowCount  = 0;

            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows)))
                {
                    if (thisIndex >= startRowIndex)
                    {
                        ShipRateMatrix shipRateMatrix = new ShipRateMatrix();
                        ShipRateMatrix.LoadDataReader(shipRateMatrix, dr);
                        results.Add(shipRateMatrix);
                        rowCount++;
                    }
                    thisIndex++;
                }
                dr.Close();
            }
            return(results);
        }
Пример #5
0
 public static SaveResult Insert(ShipRateMatrix shipRateMatrix)
 {
     return(shipRateMatrix.Save());
 }
Пример #6
0
 public static SaveResult Update(ShipRateMatrix shipRateMatrix)
 {
     return(shipRateMatrix.Save());
 }
Пример #7
0
 public static bool Delete(ShipRateMatrix shipRateMatrix)
 {
     return(shipRateMatrix.Delete());
 }