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); }
public static bool Delete(Int32 shipRateMatrixId) { ShipRateMatrix shipRateMatrix = new ShipRateMatrix(); if (shipRateMatrix.Load(shipRateMatrixId)) { return(shipRateMatrix.Delete()); } return(false); }
/// <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; }
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); }
public static SaveResult Insert(ShipRateMatrix shipRateMatrix) { return(shipRateMatrix.Save()); }
public static SaveResult Update(ShipRateMatrix shipRateMatrix) { return(shipRateMatrix.Save()); }
public static bool Delete(ShipRateMatrix shipRateMatrix) { return(shipRateMatrix.Delete()); }