public static int Add(ProductPrice productPrice) { return ProductPriceDataMapper.Add(productPrice); }
public static void Update(ProductPrice productPrice) { ProductPriceDataMapper.Update(productPrice); }
internal static void FillFromReader(ProductPrice ProductPrice, SqlDataReader reader) { int colIndex = 0; colIndex = reader.GetOrdinal(CN_PRODUCT_PRICE_ID); if (!reader.IsDBNull(colIndex)) ProductPrice.ID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PRODUCT_PRICE_CURRENCY_ID); if (!reader.IsDBNull(colIndex)) ProductPrice.CurrencyID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PRODUCT_PRICE_COUNTRY_ID); if (!reader.IsDBNull(colIndex)) ProductPrice.CountryID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PRODUCT_PRICE_FROM_DAY); if (!reader.IsDBNull(colIndex)) ProductPrice.FromDay = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PRODUCT_PRICE_FROM_SEC); if (!reader.IsDBNull(colIndex)) ProductPrice.FromSecond = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PRODUCT_PRICE_TO_DAY); if (!reader.IsDBNull(colIndex)) ProductPrice.ToDay = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PRODUCT_PRICE_TO_SEC); if (!reader.IsDBNull(colIndex)) ProductPrice.ToSecond = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PRODUCT_PRICE_START_AT); if (!reader.IsDBNull(colIndex)) ProductPrice.StartAt = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PRODUCT_PRICE_VALUE); if (!reader.IsDBNull(colIndex)) ProductPrice.Value = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PRODUCT_PRICE_DISCOUNT_VALUE); if (!reader.IsDBNull(colIndex)) ProductPrice.DiscountValue = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PRODUCT_PRICE_DISCOUNT_TYPE); if (!reader.IsDBNull(colIndex)) ProductPrice.DiscountType = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PRODUCT_PRICE_PRODUCT_ID); if (!reader.IsDBNull(colIndex)) ProductPrice.DiscountType = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PRODUCT_PRICE_IS_DELETED); if (!reader.IsDBNull(colIndex)) ProductPrice.DiscountType = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PRODUCT_PRICE_IS_DELETED); if (!reader.IsDBNull(colIndex)) ProductPrice.IsDeleted = reader.GetBoolean(colIndex); }
internal static int Add(ProductPrice productPriceEntity) { using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString)) { SqlCommand sqlCommand = new SqlCommand(SN_PRODUCT_PRICE_ADD, sqlConnection); sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter sqlParameter = null; sqlParameter = new SqlParameter(PN_PRODUCT_PRICE_ID, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Output; sqlParameter.Value = productPriceEntity.ID; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_PRODUCT_PRICE_CURRENCY_ID, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = productPriceEntity.CurrencyID; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_PRODUCT_PRICE_COUNTRY_ID, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = productPriceEntity.CountryID; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_PRODUCT_PRICE_FROM_DAY, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = productPriceEntity.FromDay; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_PRODUCT_PRICE_FROM_SEC, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = productPriceEntity.FromSecond; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_PRODUCT_PRICE_TO_DAY, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = productPriceEntity.ToDay; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_PRODUCT_PRICE_TO_SEC, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = productPriceEntity.ToSecond; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_PRODUCT_PRICE_START_AT, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = productPriceEntity.StartAt; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_PRODUCT_PRICE_VALUE, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = productPriceEntity.Value; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_PRODUCT_PRICE_DISCOUNT_VALUE, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = productPriceEntity.DiscountValue; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_PRODUCT_PRICE_DISCOUNT_TYPE, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = productPriceEntity.DiscountType; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_PRODUCT_PRICE_PRODUCT_ID, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = productPriceEntity.ProductID; sqlCommand.Parameters.Add(sqlParameter); try { sqlCommand.Connection.Open(); sqlCommand.ExecuteNonQuery(); sqlCommand.Connection.Close(); productPriceEntity.ID = Convert.ToInt32(sqlCommand.Parameters[PN_PRODUCT_PRICE_ID].Value); } catch (Exception ex) { throw ex; } } return productPriceEntity.ID; }
internal static ProductPrice GetProductPrice(List<ProductPrice> ProductPrices, SqlDataReader reader) { int colIndex = 0; colIndex = reader.GetOrdinal(CN_PRODUCT_PRICE_ID); int value = reader.GetInt32(colIndex); ProductPrice ProductPrice = ProductPrices.Where(c => c.ID == value).FirstOrDefault(); if (ProductPrice == null) { ProductPrice = new ProductPrice(); ProductPrices.Add(ProductPrice); } return ProductPrice; }