private void AddPartialPackage(int nrBoxes, string partialBoxWeight, int valuePerPartialBox, inv_detl details, PackageType[] pkgArray) { PackageType package = new PackageType(); PackageWeightType packageWeight = new PackageWeightType(); packageWeight.Weight = partialBoxWeight; UPS_Shipping_Rate.UPSRateService.CodeDescriptionType uom = new UPS_Shipping_Rate.UPSRateService.CodeDescriptionType(); uom.Code = "LBS"; uom.Description = "pounds"; packageWeight.UnitOfMeasurement = uom; package.PackageWeight = packageWeight; DimensionsType packageDimensions = new 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(); UPS_Shipping_Rate.UPSRateService.CodeDescriptionType packDimType = new UPS_Shipping_Rate.UPSRateService.CodeDescriptionType(); packDimType.Code = "IN"; packDimType.Description = "Inches"; packageDimensions.UnitOfMeasurement = packDimType; package.Dimensions = packageDimensions; PackageServiceOptionsType packageServiceOptions = new PackageServiceOptionsType(); InsuredValueType insuredValue = new InsuredValueType(); insuredValue.CurrencyCode = "USD"; insuredValue.MonetaryValue = valuePerPartialBox.ToString(); packageServiceOptions.DeclaredValue = insuredValue; package.PackageServiceOptions = packageServiceOptions; UPS_Shipping_Rate.UPSRateService.CodeDescriptionType packType = new UPS_Shipping_Rate.UPSRateService.CodeDescriptionType(); packType.Code = "02"; package.PackagingType = packType; pkgArray[nrBoxes] = package; }
private void AddPackageArray(int nrBoxes, int itemsInLastBox, string fullBoxWeight, string partialBoxWeight, int valuePerFullBox, int valuePerPartialBox, inv_detl details, ShipmentType shipment) { PackageType[] pkgArray; if (itemsInLastBox > 0) pkgArray = new PackageType[nrBoxes + 1]; else pkgArray = new PackageType[nrBoxes]; for (int i = 0; i < nrBoxes; i++) { AddFullPackage(fullBoxWeight, valuePerFullBox, details, pkgArray, i); } if (itemsInLastBox > 0 && !string.IsNullOrEmpty(partialBoxWeight)) AddPartialPackage(nrBoxes, partialBoxWeight, valuePerPartialBox, details, pkgArray); shipment.Package = pkgArray; }