Exemplo n.º 1
0
        static public decimal GetShipByTotalAndZoneCharge(int ShippingMethodID, decimal OrderTotal, int ShippingZoneID)
        {
            decimal tmp = -1;

            using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
            {
                con.Open();
                using (IDataReader rs = DB.GetRS("Select ShippingCharge from ShippingTotalByZone  with (NOLOCK)  where LowValue<=" + Localization.CurrencyStringForDBWithoutExchangeRate(OrderTotal) + " and HighValue>=" + Localization.CurrencyStringForDBWithoutExchangeRate(OrderTotal) + " and ShippingMethodID=" + ShippingMethodID.ToString() + " and ShippingZoneID=" + ShippingZoneID.ToString(), con))
                {
                    if (rs.Read())
                    {
                        tmp = DB.RSFieldDecimal(rs, "ShippingCharge");
                    }
                }
            }

            return(tmp);
        }
Exemplo n.º 2
0
        private void FedExGetRates(Packages Shipment, out string RTShipRequest, out string RTShipResponse, decimal ExtraFee, Decimal MarkupPercent, decimal ShipmentValue, decimal ShippingTaxRate)     // Retrieves FedEx rates
        {
            RTShipRequest  = string.Empty;
            RTShipResponse = string.Empty;

            Hashtable   htRates = new Hashtable();
            RateRequest request = CreateRateRequest(Shipment);
            RateService service = new RateService(); // Initialize the service

            service.Url = this.FedexServer;


            try
            {
                // Call the web service passing in a RateRequest and returning a RateReply
                RateReply reply = service.getRates(request);

                if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING) // check if the call was successful
                {
                    //create list of available services

                    for (int i = 0; i < reply.RateReplyDetails.Length; i++)
                    {
                        RateReplyDetail     rateReplyDetail     = reply.RateReplyDetails[i];
                        RatedShipmentDetail ratedShipmentDetail = rateReplyDetail.RatedShipmentDetails[1];

                        decimal totalCharges = ratedShipmentDetail.ShipmentRateDetail.TotalNetCharge.Amount;
                        if (MarkupPercent != System.Decimal.Zero)
                        {
                            totalCharges = Decimal.Round(totalCharges * (1.00M + (MarkupPercent / 100.0M)), 2, MidpointRounding.AwayFromZero);
                        }

                        decimal vat      = Decimal.Round(totalCharges * ShippingTaxRate, 2, MidpointRounding.AwayFromZero);
                        string  rateName = rateReplyDetail.ServiceType.ToString();
                        if (htRates.ContainsKey(rateName))
                        {
                            // Get the sum of the rate(s)
                            decimal myTempCharge = Localization.ParseUSDecimal(htRates[rateName].ToString().Split('|')[0]);
                            totalCharges += myTempCharge;
                            vat          += Localization.ParseUSDecimal(htRates[rateName].ToString().Split('|')[1]);

                            // Remove the old value & add the new
                            htRates.Remove(rateName);
                        }

                        // Temporarily add rate to hash table
                        htRates.Add(rateName, Localization.CurrencyStringForDBWithoutExchangeRate(totalCharges) + "|" + Localization.CurrencyStringForDBWithoutExchangeRate(vat));
                    }
                }
                else
                {
                    ratesText.Add("Error: Call Not Successful");
                    ratesValues.Add("Error: Call Not Successful");
                }

                RTShipRequest  = Serialize(request);
                RTShipResponse = Serialize(reply);
            }
            catch (SoapException e)
            {
                ratesText.Add("Error: " + e.Detail.InnerText);
                ratesValues.Add("Error: " + e.Detail.InnerText);
            }
            catch (Exception e)
            {
                ratesText.Add("Error: " + e.Message);
                ratesValues.Add("Error: " + e.Message);
            }



            // Add rates from hastable into array(s)
            IDictionaryEnumerator myEnumerator = htRates.GetEnumerator();

            while (myEnumerator.MoveNext())
            {
                Decimal tmp_rate = Localization.ParseUSDecimal(myEnumerator.Value.ToString().Substring(0, myEnumerator.Value.ToString().IndexOf("|"))) + ExtraFee;
                Decimal tmp_vat  = Localization.ParseUSDecimal(myEnumerator.Value.ToString().Substring(myEnumerator.Value.ToString().LastIndexOf("|") + 1));
                String  rateText = tmp_rate.ToString() + "|" + tmp_vat.ToString();
                ratesText.Add(myEnumerator.Key.ToString() + " $" + rateText);
                ratesValues.Add(myEnumerator.Key.ToString() + "|" + rateText);
            }
        }
Exemplo n.º 3
0
        static public decimal GetShipByTotalByPercentCharge(int ShippingMethodID, decimal SubTotal)
        {
            decimal tmp           = System.Decimal.Zero;
            decimal MinimumCharge = System.Decimal.Zero;
            decimal SurCharge     = System.Decimal.Zero;

            using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
            {
                con.Open();
                using (IDataReader rs = DB.GetRS("select * from ShippingByTotalByPercent  with (NOLOCK)  where LowValue<=" + Localization.CurrencyStringForDBWithoutExchangeRate(SubTotal) + " and HighValue>=" + Localization.CurrencyStringForDBWithoutExchangeRate(SubTotal) + " and ShippingMethodID=" + ShippingMethodID.ToString(), con))
                {
                    if (rs.Read())
                    {
                        tmp           = DB.RSFieldDecimal(rs, "PercentOfTotal");
                        MinimumCharge = DB.RSFieldDecimal(rs, "MinimumCharge");
                        SurCharge     = DB.RSFieldDecimal(rs, "SurCharge");
                    }
                }
            }

            tmp = (SubTotal * (tmp / 100.0M)) + SurCharge;
            if (tmp < MinimumCharge)
            {
                tmp = MinimumCharge;
            }
            return(tmp);
        }
Exemplo n.º 4
0
        static public decimal GetShipByTotalCharge(int ShippingMethodID, decimal SubTotal)
        {
            var tmp = 0.0M;

            using (var con = new SqlConnection(DB.GetDBConn()))
            {
                con.Open();
                using (var rs = DB.GetRS("select * from ShippingByTotal  with (NOLOCK)  where LowValue<=" + Localization.CurrencyStringForDBWithoutExchangeRate(SubTotal) + " and HighValue>=" + Localization.CurrencyStringForDBWithoutExchangeRate(SubTotal) + " and ShippingMethodID=" + ShippingMethodID.ToString(), con))
                {
                    if (rs.Read())
                    {
                        tmp = DB.RSFieldDecimal(rs, "ShippingCharge");
                    }
                }
            }

            return(tmp);
        }