예제 #1
0
 private DriverRatesDS.RateMileageRouteTableRow getMileRouteRates(string agentNumber, string route, decimal miles)
 {
     //Get a mileage rate
     DriverRatesDS.RateMileageRouteTableRow rate = null;
     try {
         string filter = "AgentNumber=" + agentNumber + " AND Route='" + route + "' AND Mile <= " + miles;
         DriverRatesDS.RateMileageRouteTableRow[] rates = (DriverRatesDS.RateMileageRouteTableRow[]) this.mRates.RateMileageRouteTable.Select(filter, "Mile DESC");
         if (rates.Length > 0)
         {
             //Take rate for largest mileage (assumes descending sort order)
             rate = rates[0];
         }
     }
     catch (ApplicationException ex) { throw ex; }
     catch (Exception ex) { throw new ApplicationException("Unexpected error determining mileage route rates.", ex); }
     return(rate);
 }
예제 #2
0
        public RouteRatings GetRouteRatings(string agentNumber, int equipmentTypeID, string route, decimal miles)
        {
            //Determine route ratings
            RouteRatings rates = new RouteRatings();

            try {
                DriverRatesDS.RateMileageRouteTableRow ratesMR = getMileRouteRates(agentNumber, route, miles);
                if (ratesMR != null)
                {
                    rates.RateTypeID          = RouteRatings.RATETYPE_ROUTE;
                    rates.MileBaseRate        = ratesMR.BaseRate;
                    rates.MileRate            = ratesMR.Rate;
                    rates.DayRate             = 0.0M;
                    rates.TripRate            = 0.0M;
                    rates.StopRate            = 0.0M;
                    rates.CartonRate          = 0.0M;
                    rates.PalletRate          = 0.0M;
                    rates.PickupCartonRate    = 0.0M;
                    rates.MinimumAmount       = 0.0M;
                    rates.MaximumAmount       = 0.0M;
                    rates.MaximumTriggerField = "";
                    rates.MaximumTriggerValue = 0;
                    rates.FSBase = 0.0M;
                }
                DriverRatesDS.RateUnitRouteTableRow ratesUR = getUnitRouteRates(agentNumber, route);
                if (ratesUR != null)
                {
                    rates.RateTypeID          = RouteRatings.RATETYPE_ROUTE;
                    rates.DayRate             = ratesUR.DayRate;
                    rates.TripRate            = ratesUR.MultiTripRate;
                    rates.StopRate            = ratesUR.StopRate;
                    rates.CartonRate          = ratesUR.CartonRate;
                    rates.PalletRate          = ratesUR.PalletRate;
                    rates.PickupCartonRate    = ratesUR.PickupCartonRate;
                    rates.MinimumAmount       = ratesUR.MinimumAmount;
                    rates.MaximumAmount       = ratesUR.MaximumAmount;
                    rates.MaximumTriggerField = ratesUR.MaximumTriggerField;
                    rates.MaximumTriggerValue = ratesUR.MaximumTriggerValue;
                    rates.FSBase = ratesUR.FSBase;
                }
                if (rates.RateTypeID == RouteRatings.RATETYPE_NONE)
                {
                    rates.RateTypeID = RouteRatings.RATETYPE_VEHICLE;
                    DriverRatesDS.RateMileageTableRow ratesMV = getMileRates(agentNumber, equipmentTypeID, miles);
                    if (ratesMV != null)
                    {
                        rates.MileBaseRate        = ratesMV.BaseRate;
                        rates.MileRate            = ratesMV.Rate;
                        rates.DayRate             = 0.0M;
                        rates.TripRate            = 0.0M;
                        rates.StopRate            = 0.0M;
                        rates.CartonRate          = 0.0M;
                        rates.PalletRate          = 0.0M;
                        rates.PickupCartonRate    = 0.0M;
                        rates.MinimumAmount       = 0.0M;
                        rates.MaximumAmount       = 0.0M;
                        rates.MaximumTriggerField = "";
                        rates.MaximumTriggerValue = 0;
                        rates.FSBase = 0.0M;
                    }
                    DriverRatesDS.RateUnitTableRow ratesUV = getUnitRates(agentNumber, equipmentTypeID);
                    if (ratesUV != null)
                    {
                        rates.DayRate             = ratesUV.DayRate;
                        rates.TripRate            = ratesUV.MultiTripRate;
                        rates.StopRate            = ratesUV.StopRate;
                        rates.CartonRate          = ratesUV.CartonRate;
                        rates.PalletRate          = ratesUV.PalletRate;
                        rates.PickupCartonRate    = ratesUV.PickupCartonRate;
                        rates.MinimumAmount       = ratesUV.MinimumAmount;
                        rates.MaximumAmount       = ratesUV.MaximumAmount;
                        rates.MaximumTriggerField = ratesUV.MaximumTriggerField;
                        rates.MaximumTriggerValue = ratesUV.MaximumTriggerValue;
                        rates.FSBase = ratesUV.FSBase;
                    }
                }
            }
            catch (Exception ex) { throw new ApplicationException("Unexpected error creating new DriverRates instance.", ex); }
            return(rates);
        }