Esempio n. 1
0
        //展示费用详情
        private void showPriceProviderResult(PriceProviderExtResult priceResult)
        {
            string feeStr = string.Format("运费:{0}\r\n挂号费:{1}\r\n燃油费:{2}\r\n关税预付服务费:{3}\r\n处理费:{11}\r\n其他费用:{4}\r\n偏远附加费:{5}\r\n超长/超重费:{6}\r\n超周围长费:{7}\r\n安全附加费:{8}\r\n增值税费:{9}\r\n总费用:{10}"
                                          , priceResult.ShippingFee, priceResult.RegistrationFee, priceResult.FuelFee, priceResult.TariffPrepayFee, priceResult.OtherFee,
                                          priceResult.RemoteAreaFee, priceResult.OverWeightOrLengthFee, priceResult.OverGirthFee, priceResult.SecurityAppendFee, priceResult.AddedTaxFee, priceResult.Value,
                                          priceResult.HandlingFee);

            MessageBox.Show(feeStr, "费用明细");
        }
Esempio n. 2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            #region 检查输入数据

            if (string.IsNullOrWhiteSpace(this.txtPieces.Text))
            {
                this.lblTsg.Text = "请输入件数!";
                this.txtPieces.Focus();
                return;
            }

            if (int.Parse(this.txtPieces.Text.Trim()) != dgvPackageList.Rows.Count)
            {
                this.lblTsg.Text = "输入的件数与行数不正确!请检查";
                return;
            }

            #endregion

            WayBillInfoModel waybillModel = new WayBillInfoModel();

            CustomerInfoPackageRequest waybillRequest     = new CustomerInfoPackageRequest();
            List <PackageRequest>      packageRequestList = new List <PackageRequest>();

            //生成运费请求
            foreach (var package in waybilldetailList)
            {
                PackageRequest packageRequest = new PackageRequest();
                packageRequest.Weight = package.Weight.Value;
                packageRequest.Length = package.Length.Value;
                packageRequest.Width  = package.Width.Value;
                packageRequest.Height = package.Height.Value;
                packageRequestList.Add(packageRequest);
            }

            waybillRequest.CustomerId         = Guid.Parse(this.CustomerId);
            waybillRequest.CountryCode        = ResponseModel.CountryCode;
            waybillRequest.ShippingMethodId   = (int)cbbInStorage.SelectedValue;
            waybillRequest.ShippingTypeId     = (int)cbbGoodsType.SelectedValue;
            waybillRequest.Packages           = packageRequestList;
            waybillRequest.EnableTariffPrepay = ResponseModel.EnableTariffPrepay;//是否启用运费预付服务
            waybillRequest.ShippingInfo       = inStorageModel.ShippingInfo;

            //计算运费
            PriceProviderExtResult priceResult = InvokeWebApiHelper.PostCustomerPriceAuto(waybillRequest);

            if (priceResult == null)
            {
                this.lblTsg.Text = "网络错误,请重试";
                return;
            }

            //如果不能邮寄
            if (!priceResult.CanShipping)
            {
                this.lblTsg.Text = priceResult.Message;

                clearLeft();

                txtNumber.Focus();
                return;
            }

            var sumSettleWeight = priceResult.Weight;//结算重量
            var sumWeight       = priceResult.Weight;

            #region 包裹长宽高求和

            decimal sumLeng   = 0;
            decimal sumWidth  = 0;
            decimal sumHeight = 0;
            if (priceResult.PackageDetails.Count() > 0)
            {
                sumLeng = (from s in priceResult.PackageDetails
                           select s.Length).Sum();
                sumWidth = (from s in priceResult.PackageDetails
                            select s.Width).Sum();
                sumHeight = (from s in priceResult.PackageDetails
                             select s.Height).Sum();
            }

            #endregion

            if (!waybillList.Exists(p => p.WayBillNumber.Equals(ResponseModel.WayBillNumber)))
            {
                waybillModel.CountryCode = ResponseModel.CountryCode;
                waybillModel.Pieces      = Convert.ToInt32(txtPieces.Text.Trim());

                waybillModel.SettleWeight         = sumSettleWeight;
                waybillModel.Length               = sumLeng;
                waybillModel.Width                = sumWidth;
                waybillModel.Height               = sumHeight;
                waybillModel.WayBillNumber        = ResponseModel.WayBillNumber;
                waybillModel.TrackingNumber       = ResponseModel.TrackingNumber;
                waybillModel.CustomerOrderNumber  = ResponseModel.CustomerOrderNumber;
                waybillModel.InShippingMethodID   = (int)cbbInStorage.SelectedValue;
                waybillModel.ShippingMethodTypeId = ((ShippingMethodModel)cbbInStorage.SelectedItem).ShippingMethodTypeId;
                waybillModel.InShippingMethodName = cbbInStorage.Text;
                waybillModel.GoodsTypeID          = (int)cbbGoodsType.SelectedValue;
                waybillModel.PriceResult          = priceResult;
                waybillModel.IsBattery            = cbxBattery.Checked;
                waybillModel.SensitiveType        = cbxBattery.Checked?(int?)cbbSensitiveType.SelectedValue:null;

                //以下方便测试
                #region 弹出费用明细

                if (File.Exists(Application.StartupPath + @"\debug.txt"))
                {
                    showPriceProviderResult(priceResult);
                }

                #endregion

                #region 包裹明细赋值

                for (int j = 0; j < waybilldetailList.Count; j++)
                {
                    var r = waybilldetailList[j];
                    WaybillPackageDetailModel model = new WaybillPackageDetailModel();
                    model.WayBillNumber = r.WayBillNumber;
                    model.Pieces        = r.Pieces;
                    model.Weight        = priceResult.PackageDetails[j].Weight;
                    model.AddWeight     = priceResult.PackageDetails[j].AddWeight;
                    model.SettleWeight  = priceResult.PackageDetails[j].SettleWeight;
                    model.Length        = r.Length;
                    model.Width         = r.Width;
                    model.Height        = r.Height;
                    model.LengthFee     = priceResult.PackageDetails[j].OverGirthFee;
                    model.WeightFee     = priceResult.PackageDetails[j].OverWeightOrLengthFee;
                    waybillModel.WaybillPackageDetaillList.Add(model);
                }

                waybillModel.Weight = waybillModel.WaybillPackageDetaillList.Sum(p => (p.Weight + (p.AddWeight ?? 0)));

                #endregion


                waybillList.Add(waybillModel);
            }

            if (cbxPrintLable.Checked)//打印报表
            {
                string frxPath = Application.StartupPath + @"\Resource\PackageLable.frx";

                if (!File.Exists(frxPath))
                {
                    MessageBox.Show("找不到货物标签打印模板:" + frxPath);
                    return;
                }

                Report report = new Report();

                report.Load(frxPath);
                report.RegisterData(waybilldetailList, "waybilldetailList");
                var      datasource = report.GetDataSource("waybilldetailList");
                DataBand data1      = report.FindObject("data1") as DataBand;
                if (data1 != null)
                {
                    data1.DataSource = datasource;
                }
                report.Prepare();
                report.PrintSettings.ShowDialog = true;
                //report.Show();
                report.Print();
                report.Dispose();
            }

            updateScanInfo();

            this.dgvWaybillList.Rows.Add(new object[] { waybillModel.WayBillNumber, waybillModel.TrackingNumber, waybillModel.CustomerOrderNumber, waybillModel.InShippingMethodName, waybillModel.Pieces, waybillModel.SettleWeight, waybillModel.CountryCode, "删除" });
            clearLeft();
            txtNumber.Focus();

            PlaySuccessSound();
        }