Exemple #1
0
        private void BindData()
        {
            ShippingByWeightCollection shippingByWeightCollection = ShippingByWeightManager.GetAll();

            gvShippingByWeights.DataSource = shippingByWeightCollection;
            gvShippingByWeights.DataBind();
        }
Exemple #2
0
        /// <summary>
        /// Gets all ShippingByWeights
        /// </summary>
        /// <returns>ShippingByWeight collection</returns>
        public static ShippingByWeightCollection GetAll()
        {
            DBShippingByWeightCollection dbCollection = DBProviderManager <DBShippingByWeightProvider> .Provider.GetAll();

            ShippingByWeightCollection collection = DBMapping(dbCollection);

            return(collection);
        }
Exemple #3
0
        /// <summary>
        /// Gets all ShippingByWeights by shipping method identifier
        /// </summary>
        /// <param name="ShippingMethodID">The shipping method identifier</param>
        /// <returns>ShippingByWeight collection</returns>
        public static ShippingByWeightCollection GetAllByShippingMethodID(int ShippingMethodID)
        {
            DBShippingByWeightCollection dbCollection = DBProviderManager <DBShippingByWeightProvider> .Provider.GetAllByShippingMethodID(ShippingMethodID);

            ShippingByWeightCollection collection = DBMapping(dbCollection);

            return(collection);
        }
        private static ShippingByWeightCollection DBMapping(DBShippingByWeightCollection dbCollection)
        {
            if (dbCollection == null)
                return null;

            ShippingByWeightCollection collection = new ShippingByWeightCollection();
            foreach (DBShippingByWeight dbItem in dbCollection)
            {
                ShippingByWeight item = DBMapping(dbItem);
                collection.Add(item);
            }

            return collection;
        }
        private static ShippingByWeightCollection DBMapping(DBShippingByWeightCollection dbCollection)
        {
            if (dbCollection == null)
            {
                return(null);
            }

            var collection = new ShippingByWeightCollection();

            foreach (var dbItem in dbCollection)
            {
                var item = DBMapping(dbItem);
                collection.Add(item);
            }

            return(collection);
        }
Exemple #6
0
        private decimal GetRate(decimal subTotal, decimal Weight, int ShippingMethodID)
        {
            decimal shippingTotal = decimal.Zero;

            ShippingByWeight           shippingByWeight           = null;
            ShippingByWeightCollection shippingByWeightCollection = ShippingByWeightManager.GetAllByShippingMethodID(ShippingMethodID);

            foreach (ShippingByWeight shippingByWeight2 in shippingByWeightCollection)
            {
                if ((Weight >= shippingByWeight2.From) && (Weight <= shippingByWeight2.To))
                {
                    shippingByWeight = shippingByWeight2;
                    break;
                }
            }
            if (shippingByWeight == null)
            {
                return(decimal.Zero);
            }
            if (shippingByWeight.UsePercentage && shippingByWeight.ShippingChargePercentage <= decimal.Zero)
            {
                return(decimal.Zero);
            }
            if (!shippingByWeight.UsePercentage && shippingByWeight.ShippingChargeAmount <= decimal.Zero)
            {
                return(decimal.Zero);
            }
            if (shippingByWeight.UsePercentage)
            {
                shippingTotal = Math.Round((decimal)((((float)subTotal) * ((float)shippingByWeight.ShippingChargePercentage)) / 100f), 2);
            }
            else
            {
                shippingTotal = shippingByWeight.ShippingChargeAmount * Weight;
            }

            if (shippingTotal < decimal.Zero)
            {
                shippingTotal = decimal.Zero;
            }
            return(shippingTotal);
        }