private void BindData() { ShippingByWeightAndCountryCollection shippingByWeightAndCountryCollection = ShippingByWeightAndCountryManager.GetAll(); gvShippingByWeightAndCountry.DataSource = shippingByWeightAndCountryCollection; gvShippingByWeightAndCountry.DataBind(); }
/// <summary> /// Gets all ShippingByWeightAndCountrys /// </summary> /// <returns>ShippingByWeightAndCountry collection</returns> public static ShippingByWeightAndCountryCollection GetAll() { DBShippingByWeightAndCountryCollection dbCollection = DBProviderManager <DBShippingByWeightAndCountryProvider> .Provider.GetAll(); ShippingByWeightAndCountryCollection collection = DBMapping(dbCollection); return(collection); }
/// <summary> /// Gets all ShippingByWeightAndCountrys by shipping method identifier /// </summary> /// <param name="ShippingMethodID">The shipping method identifier</param> /// <param name="CountryID">The country identifier</param> /// <returns>ShippingByWeightAndCountry collection</returns> public static ShippingByWeightAndCountryCollection GetAllByShippingMethodIDAndCountryID(int ShippingMethodID, int CountryID) { DBShippingByWeightAndCountryCollection dbCollection = DBProviderManager <DBShippingByWeightAndCountryProvider> .Provider.GetAllByShippingMethodIDAndCountryID(ShippingMethodID, CountryID); ShippingByWeightAndCountryCollection collection = DBMapping(dbCollection); return(collection); }
private static ShippingByWeightAndCountryCollection DBMapping(DBShippingByWeightAndCountryCollection dbCollection) { if (dbCollection == null) return null; ShippingByWeightAndCountryCollection collection = new ShippingByWeightAndCountryCollection(); foreach (DBShippingByWeightAndCountry dbItem in dbCollection) { ShippingByWeightAndCountry item = DBMapping(dbItem); collection.Add(item); } return collection; }
private static ShippingByWeightAndCountryCollection DBMapping(DBShippingByWeightAndCountryCollection dbCollection) { if (dbCollection == null) { return(null); } var collection = new ShippingByWeightAndCountryCollection(); foreach (var dbItem in dbCollection) { var item = DBMapping(dbItem); collection.Add(item); } return(collection); }
private decimal GetRate(decimal subTotal, decimal weight, int ShippingMethodID, int CountryID) { decimal shippingTotal = decimal.Zero; ShippingByWeightAndCountry shippingByWeightAndCountry = null; ShippingByWeightAndCountryCollection shippingByWeightAndCountryCollection = ShippingByWeightAndCountryManager.GetAllByShippingMethodIDAndCountryID(ShippingMethodID, CountryID); foreach (ShippingByWeightAndCountry shippingByWeightAndCountry2 in shippingByWeightAndCountryCollection) { if ((weight >= shippingByWeightAndCountry2.From) && (weight <= shippingByWeightAndCountry2.To)) { shippingByWeightAndCountry = shippingByWeightAndCountry2; break; } } if (shippingByWeightAndCountry == null) { return(decimal.Zero); } if (shippingByWeightAndCountry.UsePercentage && shippingByWeightAndCountry.ShippingChargePercentage <= decimal.Zero) { return(decimal.Zero); } if (!shippingByWeightAndCountry.UsePercentage && shippingByWeightAndCountry.ShippingChargeAmount <= decimal.Zero) { return(decimal.Zero); } if (shippingByWeightAndCountry.UsePercentage) { shippingTotal = Math.Round((decimal)((((float)subTotal) * ((float)shippingByWeightAndCountry.ShippingChargePercentage)) / 100f), 2); } else { shippingTotal = shippingByWeightAndCountry.ShippingChargeAmount * weight; } if (shippingTotal < decimal.Zero) { shippingTotal = decimal.Zero; } return(shippingTotal); }