private void AddPackageArray(int nrBoxes, int itemsInLastBox, string fullBoxWeight, string partialBoxWeight, int valuePerFullBox, int valuePerPartialBox, inv_detl details, string packagingTypeCode, string currencyCode, UPSRateService.ShipmentType shipment)
        {
            UPSRateService.PackageType[] pkgArray;
            //if (itemsInLastBox > 0)
            //    pkgArray = new UPSRateService.PackageType[nrBoxes];
            //else
            pkgArray = new UPSRateService.PackageType[nrBoxes];

            int tempItemCount = nrBoxes;

            if (itemsInLastBox > 0)
            {
                tempItemCount = tempItemCount - 1;
            }
            for (int i = 0; i < tempItemCount; i++)
            {
                AddFullPackage(fullBoxWeight, valuePerFullBox, details, packagingTypeCode, currencyCode, pkgArray, i);
            }
            if (itemsInLastBox > 0 && !string.IsNullOrEmpty(partialBoxWeight))
            {
                AddPartialPackage(nrBoxes, partialBoxWeight, valuePerPartialBox, details, packagingTypeCode, currencyCode, pkgArray);
            }

            shipment.Package = pkgArray;
        }
        private void AddPartialPackage(int nrBoxes, string partialBoxWeight, int valuePerPartialBox, inv_detl details, string packagingTypeCode, string currencyCode, UPSRateService.PackageType[] pkgArray)
        {
            var package       = new UPSRateService.PackageType();
            var packageWeight = new UPSRateService.PackageWeightType();

            packageWeight.Weight = partialBoxWeight;
            var uom = new UPSRateService.CodeDescriptionType();

            uom.Code        = "LBS";
            uom.Description = "pounds";
            packageWeight.UnitOfMeasurement = uom;
            package.PackageWeight           = packageWeight;

            var packageDimensions = new UPSRateService.DimensionsType();

            //packageDimensions.Height = ((int)details.CASE_HI.Value).ToString();
            //packageDimensions.Length = ((int)details.CASE_LEN.Value).ToString();
            //packageDimensions.Width = ((int)details.CASE_WT.Value).ToString();

            packageDimensions.Height = "0";
            packageDimensions.Length = "0";
            packageDimensions.Width  = "0";

            var packDimType = new UPSRateService.CodeDescriptionType();

            packDimType.Code                    = "IN";
            packDimType.Description             = "Inches";
            packageDimensions.UnitOfMeasurement = packDimType;
            package.Dimensions                  = packageDimensions;

            var packageServiceOptions = new UPSRateService.PackageServiceOptionsType();
            var insuredValue          = new UPSRateService.InsuredValueType();

            insuredValue.CurrencyCode           = currencyCode;
            insuredValue.MonetaryValue          = valuePerPartialBox.ToString();
            packageServiceOptions.DeclaredValue = insuredValue;
            package.PackageServiceOptions       = packageServiceOptions;

            var packType = new UPSRateService.CodeDescriptionType();

            packType.Code         = packagingTypeCode;
            package.PackagingType = packType;
            pkgArray[nrBoxes - 1] = package;
        }
        private void AddPartialPackage(int nrBoxes, string partialBoxWeight, int valuePerPartialBox, inv_detl details, string packagingTypeCode, string currencyCode, UPSRateService.PackageType[] pkgArray)
        {
            var package = new UPSRateService.PackageType();
            var packageWeight = new UPSRateService.PackageWeightType();
            packageWeight.Weight = partialBoxWeight;
            var uom = new UPSRateService.CodeDescriptionType();
            uom.Code = "LBS";
            uom.Description = "pounds";
            packageWeight.UnitOfMeasurement = uom;
            package.PackageWeight = packageWeight;

            var packageDimensions = new UPSRateService.DimensionsType();
            //packageDimensions.Height = ((int)details.CASE_HI.Value).ToString();
            //packageDimensions.Length = ((int)details.CASE_LEN.Value).ToString();
            //packageDimensions.Width = ((int)details.CASE_WT.Value).ToString();

            packageDimensions.Height = "0";
            packageDimensions.Length = "0";
            packageDimensions.Width = "0";

            var packDimType = new UPSRateService.CodeDescriptionType();
            packDimType.Code = "IN";
            packDimType.Description = "Inches";
            packageDimensions.UnitOfMeasurement = packDimType;
            package.Dimensions = packageDimensions;

            var packageServiceOptions = new UPSRateService.PackageServiceOptionsType();
            var insuredValue = new UPSRateService.InsuredValueType();
            insuredValue.CurrencyCode = currencyCode;
            insuredValue.MonetaryValue = valuePerPartialBox.ToString();
            packageServiceOptions.DeclaredValue = insuredValue;
            package.PackageServiceOptions = packageServiceOptions;

            var packType = new UPSRateService.CodeDescriptionType();
            packType.Code = packagingTypeCode;
            package.PackagingType = packType;
            pkgArray[nrBoxes - 1] = package;
        }
        private void AddPackageArray(int nrBoxes, int itemsInLastBox, string fullBoxWeight, string partialBoxWeight, int valuePerFullBox, int valuePerPartialBox, inv_detl details, string packagingTypeCode, string currencyCode, UPSRateService.ShipmentType shipment)
        {
            UPSRateService.PackageType[] pkgArray;
            //if (itemsInLastBox > 0)
            //    pkgArray = new UPSRateService.PackageType[nrBoxes];
            //else
            pkgArray = new UPSRateService.PackageType[nrBoxes];

            int tempItemCount = nrBoxes;
            if (itemsInLastBox > 0)
                tempItemCount = tempItemCount - 1;
            for (int i = 0; i < tempItemCount; i++)
            {
                AddFullPackage(fullBoxWeight, valuePerFullBox, details, packagingTypeCode, currencyCode, pkgArray, i);
            }
            if (itemsInLastBox > 0 && !string.IsNullOrEmpty(partialBoxWeight))
                AddPartialPackage(nrBoxes, partialBoxWeight, valuePerPartialBox, details, packagingTypeCode, currencyCode, pkgArray);

            shipment.Package = pkgArray;
        }