コード例 #1
0
        /// <summary>
        /// 创建入库单 add by huhaiyou 2014-4-24
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static ResponseResult CreateInStorageCS(InStorageSaveModel model)
        {
            try
            {
                // var resultModel = HttpHelper.DoRequest<string>(sysConfig.LMSAPIPath + "api/LMS/CheckOnInStorage?model=" + model, EnumHttpMethod.GET);
                // var resultModel = HttpHelper.DoRequest<ResponseResultModel>(sysConfig.LMSAPIPath + "api/Lms/PostBatchAddReturnGoods", EnumHttpMethod.POST, EnumContentType.Json, returnGoodsList);
                var resultModel = HttpHelper.DoRequest <ResponseResult>(sysConfig.LMSAPIPath + "api/WayBill/CreateInStorageCS", EnumHttpMethod.POST, EnumContentType.Json, model);

                Log.Info(resultModel.RawValue);
                return(resultModel.Value);
            }
            catch (Exception ex)
            {
                Log.Error("错误地址:" + sysConfig.LMSAPIPath + "api/WayBill/CreateInStorageCS/");
                Log.Exception(ex);
            }
            return(null);
        }
コード例 #2
0
        private void btnInStorage_Click(object sender, EventArgs e)
        {
            if (waybillList.Count <= 0)
            {
                MessageBox.Show("入库数据不能为空!");
                return;
            }

            InStorageSaveModel saveModel = new InStorageSaveModel();

            saveModel.CustomerCode     = this.txtCustomers.Text.Trim();
            saveModel.OperatorUserName = LoginHelper.CurrentUserName;
            saveModel.ReceivingDate    = txtReceivingDate.Text;
            if (waybillList != null && waybillList.Count > 0)
            {
                //遍历每个运单
                foreach (var waybill in waybillList)
                {
                    WayBillInfoSaveModel w = new WayBillInfoSaveModel();
                    w.WayBillNumber     = waybill.WayBillNumber;
                    w.Length            = waybill.Length.Value;
                    w.Width             = waybill.Width.Value;
                    w.Height            = waybill.Height.Value;
                    w.SettleWeight      = waybill.SettleWeight == null ? 0 : waybill.SettleWeight.Value;
                    w.Weight            = waybill.Weight.Value;
                    w.PriceResult       = waybill.PriceResult;
                    w.GoodsTypeID       = waybill.GoodsTypeID.Value;
                    w.ShippingMethodId  = waybill.InShippingMethodID.Value;
                    w.IsBusinessExpress = waybill.ShippingMethodTypeId == 2;
                    w.IsBattery         = waybill.IsBattery;
                    w.SensitiveType     = waybill.SensitiveType;

                    //遍历运单的每个包裹
                    foreach (var dateil in waybill.WaybillPackageDetaillList)
                    {
                        WaybillPackageDetailModel wayDetailModel = new WaybillPackageDetailModel();
                        wayDetailModel.WayBillNumber = dateil.WayBillNumber;
                        wayDetailModel.Weight        = dateil.Weight;
                        wayDetailModel.AddWeight     = dateil.AddWeight;
                        wayDetailModel.SettleWeight  = dateil.SettleWeight;
                        wayDetailModel.Length        = dateil.Length;
                        wayDetailModel.Width         = dateil.Width;
                        wayDetailModel.Height        = dateil.Height;
                        wayDetailModel.LengthFee     = dateil.LengthFee == null ? 0 : dateil.LengthFee.Value;
                        wayDetailModel.WeightFee     = dateil.WeightFee == null ? 0 : dateil.WeightFee.Value;
                        w.waybillPackageDetailList.Add(wayDetailModel);
                    }

                    saveModel.WayBillInfoSaveList.Add(w);
                }
            }


            ResponseResult responseResult = null;

            new BackgroundLoading(this, () =>
            {
                responseResult = InvokeWebApiHelper.CreateInStorageCS(saveModel);
            }, "正在提交到服务器...", "正在提交到服务器...").Show();

            if (responseResult == null)
            {
                MessageBox.Show("保存失败,请重试!");
                return;
            }

            if (responseResult.Result)
            {
                waybillList = new List <WayBillInfoModel>();
                this.dgvWaybillList.Rows.Clear();
                this.lblCount.Text       = "0";
                this.lblCountWeight.Text = "0";
                FrmInStorageInfo inStoragt = new FrmInStorageInfo(responseResult.Message);
                inStoragt.ShowDialog();
                //inStoragt.MdiParent = this;
            }
            else
            {
                MessageBox.Show(responseResult.Message);
            }
        }
コード例 #3
0
        /// <summary>
        /// CS版,快递入仓 add by huhaiyou 2014-4-25
        /// </summary>
        /// <param name="model"></param>
        /// <param name="wayBilllist"></param>
        /// <returns></returns>
        public ResponseResult CreateInStorageCS(InStorageSaveModel model)
        {
            var responseResult = new ResponseResult();

            if (model != null && model.WayBillInfoSaveList != null && model.WayBillInfoSaveList.Count > 0)
            {
                var inStorage = new CreateInStorageExtCS
                {
                    InStorage =
                    {
                        CustomerCode  = model.CustomerCode,
                        InStorageID   = SequenceNumberService.GetSequenceNumber(PrefixCode.InStorageID),
                        TotalQty      =                                                               0,
                        TotalWeight   =                                                               0,
                        CreatedBy     = model.OperatorUserName,
                        ReceivingDate = model.ReceivingDate,
                    }
                };

                model.WayBillInfoSaveList.ForEach(w =>
                {
                    var shippingMethod = _freightService.GetShippingMethod(w.ShippingMethodId);

                    if (!string.IsNullOrWhiteSpace(w.WayBillNumber))
                    {
                        //根据转换重量转换成文件类型 Add by zhengsong
                        #region
                        if (shippingMethod != null)
                        {
                            if (shippingMethod.Enabled && shippingMethod.ShippingMethodTypeId == 4)//4-代表EMS
                            {
                                if (w.Weight <= shippingMethod.PackageTransformFileWeight)
                                {
                                    w.GoodsTypeID = 2;//2-代表文件类型
                                }
                            }
                        }
                        #endregion
                        var extmodel               = new LMS.Data.Entity.ExtModel.WayBillInfoExt();
                        extmodel.CustomerCode      = model.CustomerCode.Trim();
                        extmodel.CustomerType      = model.CustomerType;
                        extmodel.GoodsTypeID       = w.GoodsTypeID;
                        extmodel.Length            = w.Length;
                        extmodel.Height            = w.Height;
                        extmodel.Width             = w.Width;
                        extmodel.Weight            = w.Weight;
                        extmodel.ShippingMethodId  = w.ShippingMethodId;
                        extmodel.TrackingNumber    = w.TrackingNumber;
                        extmodel.SettleWeight      = w.SettleWeight;
                        extmodel.WayBillNumber     = w.WayBillNumber.Trim();
                        extmodel.PriceResult       = w.PriceResult;
                        extmodel.IsBusinessExpress = w.IsBusinessExpress;
                        extmodel.IsBattery         = w.IsBattery;
                        extmodel.SensitiveType     = w.SensitiveType;

                        foreach (var package in w.waybillPackageDetailList)
                        {
                            WaybillPackageDetailExt packageModel = new WaybillPackageDetailExt();
                            packageModel.WayBillNumber           = w.WayBillNumber;
                            packageModel.Weight       = package.Weight.Value;
                            packageModel.AddWeight    = package.AddWeight.Value;
                            packageModel.SettleWeight = package.SettleWeight.Value;
                            packageModel.Length       = package.Length.Value;
                            packageModel.Width        = package.Width.Value;
                            packageModel.Height       = package.Height.Value;
                            packageModel.LengthFee    = package.LengthFee.Value;
                            packageModel.WeightFee    = package.WeightFee.Value;
                            extmodel.WaybillPackageDetailList.Add(packageModel);
                        }

                        inStorage.WayBillInfos.Add(extmodel);
                        inStorage.InStorage.TotalWeight += w.SettleWeight;
                        inStorage.InStorage.TotalQty++;
                    }
                });
                try
                {
                    _inStorageService.CreateInStorageCS(inStorage);
                    responseResult.Result  = true;
                    responseResult.Message = inStorage.InStorage.InStorageID;
                }
                catch (Exception ex)
                {
                    Log.Exception(ex);
                    responseResult.Result  = false;
                    responseResult.Message = ex.Message;
                }
            }
            return(responseResult);
        }