public async Task <IActionResult> Create([Bind("Id,Codigo,IdRemesa,FechaDespacho,IdBodega,Estado,Year,FechaLlegada,IT,Nivel")] WayBill wayBill) { var user = _userManager.GetUserAsync(User); wayBill.UsuarioCreacion = user.Result.Id; wayBill.FechaCreacion = DateTime.Now; if (ModelState.IsValid) { _context.Add(wayBill); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Edit), new { wayBill.Id })); } if (user.Result.IdSubOficina != null) { if (user.Result.IdBodega != null) { ViewData["IdBodega"] = new SelectList(_context.Bodega.Where(x => x.Id == user.Result.IdBodega), "Id", "Nombre", wayBill.IdBodega); } else { var bodegas = _context.Bodega.Where(x => x.Id == user.Result.IdSubOficina); ViewData["IdBodega"] = new SelectList(bodegas, "Id", "Nombre", wayBill.IdBodega); } } else { ViewData["IdBodega"] = new SelectList(_context.Bodega, "Id", "Nombre", wayBill.IdBodega); } ViewData["IdRemesa"] = new SelectList(_context.Remesa, "Id", "Nombre", wayBill.IdRemesa); return(View(wayBill)); }
public XtraReport GenerateReport(NameValueCollection parameters) { var wayBillData = AsyncContext.Run(() => _reportService.GetWayBill(long.Parse(parameters["id"].ToString()))); var report = new WayBill(); var wayBillObjectDataSource = new ObjectDataSource { DataSource = wayBillData[0], Name = "wayBillDataSource" }; report.DataSource = wayBillObjectDataSource; report.CreateDocument(true); for (int i = 1; i < wayBillData.Count; i++) { var wayBillReport = new WayBill(); wayBillObjectDataSource = new ObjectDataSource { DataSource = wayBillData[i], Name = "wayBillDataSource" }; wayBillReport.DataSource = wayBillObjectDataSource; wayBillReport.CreateDocument(true); report.ModifyDocument(x => { x.AddPages(wayBillReport.Pages); }); } return(report); }
public void WayBillPrepareIDList(WayBill oWayBill, bool bMultiSelect) { oWayBill.ID = null; oWayBill.IDList = null; int?nWayBillID = 0; if (bMultiSelect && grdWayBills.IsCheckerShow) { oWayBill.IDList = ""; DataView dMarked = new DataView(oWayBillList.MainTable); dMarked.RowFilter = "IsMarked = true"; dMarked.Sort = grdWayBills.GridSource.Sort; foreach (DataRowView r in dMarked) { if (!Convert.IsDBNull(r["ID"])) { nWayBillID = (int)r["ID"]; oWayBill.IDList = oWayBill.IDList + nWayBillID.ToString() + ","; } } } else { nWayBillID = (int?)grdWayBills.CurrentRow.Cells["grcWayBills_ID"].Value; if (nWayBillID.HasValue) { oWayBill.ID = nWayBillID; } } }
/// <summary> /// 保存换袋记录 /// </summary> /// <param name="bagNumber">目的袋牌</param> /// <param name="trackNumber">包裹单号</param> /// <param name="recordBy">操作人</param> /// <returns>-1-失败, 0-包裹单号不存在,1-该单号已退件,2-目的袋牌不存在, /// 3-该单号与目标袋牌国家不匹配,4-该目标袋牌重量已超重不能放入,5-该单号发货渠道错误, /// 100-验证成功,6-该目标袋牌已在中心局扫描过</returns> public int SacnPackageExchangeBag(string bagNumber, string trackNumber, string recordBy) { var ctx = this.UnitOfWork as LMS_DbContext; Check.Argument.IsNotNull(ctx, "数据库对象"); var sendstatus = WayBill.StatusToValue(WayBill.StatusEnum.Send); var trackNumberParam = new SqlParameter { ParameterName = "trackNumber", Value = trackNumber, DbType = DbType.String }; var bagNumberParam = new SqlParameter { ParameterName = "bagNumber", Value = bagNumber, DbType = DbType.String }; var statusParam = new SqlParameter { ParameterName = "status", Value = sendstatus, DbType = DbType.Int32 }; var recordByParam = new SqlParameter { ParameterName = "recordBy", Value = recordBy, DbType = DbType.String }; var result = new SqlParameter { ParameterName = "result", Value = 0, DbType = DbType.Int32, Direction = ParameterDirection.Output }; int isSuccess = -1; if (ctx != null) { ctx.ExecuteCommand( "Exec P_SacnPackageExchangeBag @trackNumber,@bagNumber,@status,@recordBy,@result output", trackNumberParam, bagNumberParam, statusParam, recordByParam, result); Int32.TryParse(result.Value.ToString(), out isSuccess); } return(isSuccess); }
private void cmbIrsaliyeID_SelectedIndexChanged(object sender, EventArgs e) { _wayBillDetail = new List <WayBillDetail>(); _wayBill = cmbIrsaliyeID.SelectedItem as WayBill; _wayBillDetail = (from w in Db.Context.WayBillDetails where w.WaybillID == _wayBill.ID select w).ToList(); var Sender = (from d in Db.Context.Payers where d.ID == _wayBill.SenderID select d).SingleOrDefault(); var Receiver = (from d in Db.Context.Payers where d.ID == _wayBill.ReceiverID select d).SingleOrDefault(); lblBillType.Text = Enum.GetName(typeof(WayBillType), (int)_wayBill.BillType); lblSender.Text = Sender.CompanyName.ToString(); lblReceiver.Text = Receiver.CompanyName.ToString(); lblDriver.Text = (from d in Db.Context.Drivers where d.ID == _wayBill.DriverID select d.FirstName).SingleOrDefault().ToString(); lblVehicle.Text = (from d in Db.Context.Vehicles where d.ID == _wayBill.VehicleID select d.Plate).SingleOrDefault().ToString(); lblShipmentDate.Text = _wayBill.ShipmentDate.ToString(); lblDeliveryDate.Text = _wayBill.DeliveryDate.ToString(); txtAdress.Text = Sender.Address.ToString(); txtContactName.Text = Sender.ContactName.ToString(); txtPhone.Text = Sender.Phone.ToString(); txtRAdress.Text = Receiver.Address.ToString(); txtRContactName.Text = Receiver.Address.ToString(); txtRPhone.Text = Receiver.Phone.ToString(); foreach (var item in _wayBillDetail) { string[] subitems = { ((ProductQuantityPerUnit)item.Product.QuantityPerUnit).ToString(), item.Quantity.ToString() }; listView1.Items.Add(item.Product.ProductName.ToString()).SubItems.AddRange(subitems); } }
//修改运单信息 public void UpdateWayBillInfo(string waybillNumber) { WayBillInfo getWayBillInfo = _wayBillInfoRepository.First(p => p.WayBillNumber == waybillNumber); getWayBillInfo.Status = WayBill.StatusToValue(WayBill.StatusEnum.Delivered); _wayBillInfoRepository.Modify(getWayBillInfo); _wayBillInfoRepository.UnitOfWork.Commit(); }
private B2CPreAlterViewModel GetB2CPreAlterViewModel(B2CPreAlterViewModel model) { WayBill.GetSearchFilterList().ForEach(p => { if (Int32.Parse(p.ValueField) < 4) { model.SearchWheres.Add(new SelectListItem() { Text = p.TextField, Value = p.ValueField, Selected = p.ValueField == model.Param.SearchWhere.ToString() }); } }); WayBill.GetDateFilterList().ForEach(p => { if (p.ValueField == "2" || p.ValueField == "3") { model.DateTimeWheres.Add(new SelectListItem() { Text = p.TextField, Value = p.ValueField, Selected = p.ValueField == model.Param.SearchTime.ToString() }); } }); model.StatusList.Add(new SelectListItem() { Text = "全部", Value = "" }); B2CPreAlter.GetStatusList().ForEach(p => { model.StatusList.Add(new SelectListItem() { Text = p.TextField, Value = p.ValueField, Selected = model.Param.Status.HasValue && p.ValueField == model.Param.Status.Value.ToString() }); }); var list = new List <int>(); sysConfig.DDPShippingMethodId.Split(',').ToList().ForEach(p => list.Add(Int32.Parse(p))); _freightService.GetShippingMethodsByIds(list).ForEach(p => { model.ShippingMethods.Add(new SelectListItem() { Text = p.FullName, Value = p.ShippingMethodId.ToString() }); }); model.Param.OutStartTime = DateTime.Parse(sysConfig.B2CPreAlterStartTime); return(model); }
//查询条件 public List <SelectListItem> GetSearchWhere() { var listItem = new List <SelectListItem>(); WayBill.GetSearchFilterList().ForEach(p => { listItem.Add(new SelectListItem() { Text = p.TextField, Value = p.ValueField }); }); return(listItem); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Codigo,IdRemesa,FechaDespacho,IdBodega,Estado,Year,FechaLlegada,IT,Nivel,FechaCreacion,UsuarioCreacion")] WayBill wayBill) { if (id != wayBill.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(wayBill); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WayBillExists(wayBill.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } var user = _userManager.GetUserAsync(User); if (user.Result.IdSubOficina != null) { if (user.Result.IdBodega != null) { ViewData["IdBodega"] = new SelectList(_context.Bodega.Where(x => x.Id == user.Result.IdBodega), "Id", "Nombre", wayBill.IdBodega); } else { var bodegas = _context.Bodega.Where(x => x.Id == user.Result.IdSubOficina); ViewData["IdBodega"] = new SelectList(bodegas, "Id", "Nombre", wayBill.IdBodega); } } else { ViewData["IdBodega"] = new SelectList(_context.Bodega, "Id", "Nombre", wayBill.IdBodega); } ViewData["IdRemesa"] = new SelectList(_context.Remesa, "Id", "Nombre", wayBill.IdRemesa); return(View(wayBill)); }
/// <summary> /// 验证目的袋牌 /// </summary> /// <param name="bagNumber">目的袋牌</param> /// <param name="trackNumber">包裹单号</param> /// <returns>0-包裹单号不存在,1-该单号已退件,2-目的袋牌不存在, /// 3-该单号与目标袋牌国家不匹配,4-该目标袋牌重量已超重不能放入, /// 100-验证成功,6-该目标袋牌已在中心局扫描过</returns> public string CheckBagNumber(string bagNumber, string trackNumber) { var ctx = this.UnitOfWork as LMS_DbContext; Check.Argument.IsNotNull(ctx, "数据库对象"); var sendstatus = WayBill.StatusToValue(WayBill.StatusEnum.Send); var waybillinfo = ctx.WayBillInfos.SingleOrDefault(p => p.TrackingNumber == trackNumber && p.Status == sendstatus); if (waybillinfo == null) { //包裹单号不存在 return("0"); } if (ctx.MailReturnGoodsLogs.Any(p => p.TrackNumber == trackNumber)) { //该单号已退件 return("1"); } var mailPostBagInfo = ctx.MailPostBagInfos.SingleOrDefault(p => p.PostBagNumber == bagNumber); if (mailPostBagInfo == null) { //目的袋牌不存在 return("2"); } if (waybillinfo.CountryCode != mailPostBagInfo.CountryCode) { //该单号与目标袋牌国家不匹配 return("3"); } if (waybillinfo.Weight + mailPostBagInfo.TotalWeight > 30) { //该目标袋牌重量已超重不能放入 return("4"); } if (ctx.MailTotalPackageOrPostBagRelationals.Any(p => p.PostBagNumber == mailPostBagInfo.PostBagNumber)) { //该目标袋牌已在中心局扫描过 return("6"); } return("100"); }
private void WayBillPrint(bool bAll) { if (grdWayBills.CurrentRow == null) { return; } RFMCursorWait.Set(true); WayBill oWayBillPrint = new WayBill(); WayBillPrepareIDList(oWayBillPrint, bAll); DataDynamics.ActiveReports.ActiveReport3 rep = new DataDynamics.ActiveReports.ActiveReport3(); rep = new WayBillShort(); LogService.WayBill_Print(oWayBillPrint, rep, this); }
public frmWayBills() { // для основных таблиц oWayBillList = new WayBill(); oWayBillCur = new WayBill(); oFillingList = new Filling(); oFillingCur = new Filling(); if (oWayBillList.ErrorNumber != 0 || oWayBillCur.ErrorNumber != 0 || oFillingList.ErrorNumber != 0 || oFillingCur.ErrorNumber != 0) { IsValid = false; } // для связанных таблиц if (IsValid) { oTripInWayBillList = new Trip(); oFillingInWayBillList = new Filling(); if (oTripInWayBillList.ErrorNumber != 0 || oFillingInWayBillList.ErrorNumber != 0) { IsValid = false; } } // для отображения таблиц if (IsValid) { oWayBillTemp = new WayBill(); oTripTemp = new Trip(); if (oWayBillTemp.ErrorNumber != 0 || oTripTemp.ErrorNumber != 0) { IsValid = false; } } if (IsValid) { InitializeComponent(); } }
public Task <WayBill> CreateAsync(WayBillCreationInfo creationInfo, Guid mechanicNoteId, IEnumerable <Guid> medicNotesIds, CancellationToken cancellationToken) { if (creationInfo == null) { throw new ArgumentException(nameof(creationInfo)); } if (medicNotesIds == null) { throw new ArgumentException(nameof(medicNotesIds)); } cancellationToken.ThrowIfCancellationRequested(); var wayBillWithSameSerialNumber = wayBills .Find(item => item.Serial == creationInfo.Serial && item.Number == creationInfo.Number) .FirstOrDefault(); if (wayBillWithSameSerialNumber != null) { throw new WayBillDuplicationException(wayBillWithSameSerialNumber.Serial, wayBillWithSameSerialNumber.Number); } var now = DateTime.Now; var id = Guid.NewGuid(); var wayBill = new WayBill { Id = id, Serial = creationInfo.Serial, Number = creationInfo.Number, Driver = creationInfo.DriverId, Vehicle = creationInfo.VehicleId, Route = creationInfo.RouteId, MechanicNote = mechanicNoteId, MedicNotes = medicNotesIds.ToArray(), CreatedAt = now, LastUpdateAt = now }; wayBills.InsertOneAsync(wayBill, cancellationToken: cancellationToken); return(Task.FromResult(wayBill)); }
public frmFillingsEdit(int?_nFillingID, int?_nWayBillID) { if (_nFillingID.HasValue) { nFillingID = (int)_nFillingID; } if (_nWayBillID.HasValue) { nWayBillID = (int)_nWayBillID; } oFilling = new Filling(); if (oFilling.ErrorNumber != 0) { IsValid = false; } if (IsValid) { oWayBill = new WayBill(); if (oWayBill.ErrorNumber != 0) { IsValid = false; } } if (IsValid) { oCar = new Car(); oDriver = new Driver(); if (oCar.ErrorNumber != 0 || oDriver.ErrorNumber != 0) { IsValid = false; } } if (IsValid) { InitializeComponent(); } }
public async Task <List <WayBill> > GetWayBill(long id) { var delivery = await _deliveryService.GetDeliveryById(id); List <WayBill> WayBills = new List <WayBill>(); if (delivery.WareHouse == null) { return(new List <WayBill>()); } foreach (var item in delivery.DeliveryTrackings) { WayBill waybill = new WayBill() { DeliveryName = delivery.DeliveryCustomer.FullName, DeliveryAddress = delivery.DeliveryCustomer.Address, DeliveryNumber = delivery.DeliveryNo, DeliveryPrice = delivery.Type == DeliveryType.Cod? item.DeliveryTrackingItems.Sum(x => x.Value) : 0, SupplierCode = delivery.Supplier.Code, SupplierName = delivery.Supplier.SupplierName, WareHouseAddress = delivery.WareHouse.Address.ToString(), WareHouseCode = delivery.WareHouse.Code, WareHouseName = delivery.WareHouse.Name, TrackingNo = item.TrackingNumber, WayBillItems = item.DeliveryTrackingItems.Where(i => i.Quantity > 0) .Select(i => new WayBillItem() { ItemCode = i.Product.Code, ItemDescription = i.Product.Name, Quantity = i.Quantity, UnitOfMeasure = i.Product.MassUnit.ToString(), UnitPrice = i.UnitCost, UnitWeight = i.Product.Weight }).ToList() }; WayBills.Add(waybill); } return(WayBills.OrderBy(x => x.TrackingNo).ToList()); }
/// <summary> /// 验证包裹单号 /// </summary> /// <param name="trackNumber"></param> /// <returns>0-验证成功,1-不存在,2-已退件</returns> public string CheckTrackNumber(string trackNumber) { var ctx = this.UnitOfWork as LMS_DbContext; Check.Argument.IsNotNull(ctx, "数据库对象"); string result = "0"; var sendstatus = WayBill.StatusToValue(WayBill.StatusEnum.Send); if (ctx.WayBillInfos.Any(p => p.TrackingNumber == trackNumber && p.Status == sendstatus)) { if (ctx.MailReturnGoodsLogs.Any(p => p.TrackNumber == trackNumber)) { result = "2"; } } else { result = "1"; } return(result); }
public static ViewWayBill prepareWB(Guid wbId) { using (var db = new SCMSEntities()) { WayBill entitymodel = db.WayBills.First(p => p.Id == wbId); ViewWayBill model = new ViewWayBill(); model.EntityWBill = entitymodel; WarehouseRelease wrn = model.EntityWBill.WarehouseRelease; model.issuer = db.VStaffDetails.FirstOrDefault(p => p.StaffID == entitymodel.PreparedBy); model.consignee = db.VStaffDetails.FirstOrDefault(p => p.StaffID == entitymodel.Consignee); model.ReceivedBy = db.VStaffDetails.FirstOrDefault(p => p.StaffID == entitymodel.ReceivedBy); model.OrrignWH = db.WareHouses.FirstOrDefault(p => p.Id == entitymodel.IssuerWarehouse); model.destinationWH = db.WareHouses.FirstOrDefault(p => p.Id == entitymodel.DestinationWarehouse); model.DestnationOfiice = db.CountrySubOffices.FirstOrDefault(p => p.Id == entitymodel.DestinationOffice); Model.Location loc = model.destinationWH.Location; Model.CountrySubOffice cso = model.destinationWH.CountrySubOffice; model.OrignSOfiice = db.CountrySubOffices.First(p => p.Id == entitymodel.IssuingOffice); Model.Location l = model.OrignSOfiice.Location; Model.Location lok = model.DestnationOfiice.Location; List <WarehouseReleaseItem> writems = entitymodel.WarehouseRelease.WarehouseReleaseItems.ToList(); foreach (WarehouseReleaseItem item in writems) { Model.Inventory inv = item.Inventory; Model.Item it = inv.Item; Model.ItemCategory ic = it.ItemCategory; Model.UnitOfMeasure u = it.UnitOfMeasure; Model.Asset ast = item.Asset; } model.WRItems = writems; //dummies var person = entitymodel.Staff.Person; if (entitymodel.Staff1 != null) { person = entitymodel.Staff1.Person; } return(model); } }
private void FormAddWayBill_FormClosing(object sender, FormClosingEventArgs e) { wayBill = null; insWayBill = null; }
public InStorageWayBillModel CheckOnInStorageSingele(InStorageFormModel filter) { var model = new InStorageWayBillModel(); var error = new StringBuilder(); var NumberStr = string.Empty; if (!string.IsNullOrWhiteSpace(filter.WayBillNumber)) { NumberStr = filter.WayBillNumber; } else { if (!string.IsNullOrWhiteSpace(filter.TrackingNumber)) { NumberStr = filter.TrackingNumber; } } var waybillinfo = _wayBillInfoRepository.GetWayBillInfoExtSilm(NumberStr); if (!string.IsNullOrWhiteSpace(NumberStr) && waybillinfo != null) { //if (!string.IsNullOrWhiteSpace(filter.TrackingNumber) && waybillinfo.TrackingNumber != filter.TrackingNumber) //{ // error.AppendLine("跟踪号与输入的跟踪号不一样!<br/>"); //} if (error.Length == 0 && WayBill.StatusToValue(WayBill.StatusEnum.Submitted) != waybillinfo.Status) { error.AppendLine(string.Format("运单:{0}状态不是已提交!<br/>", NumberStr)); } if (error.Length == 0 && waybillinfo.GoodsTypeID != filter.GoodsTypeID) { error.AppendLine(string.Format("运单:{0}货物类型不是一致", NumberStr)); } if (error.Length == 0 && waybillinfo.IsHold) { error.AppendLine(string.Format("运单:{0}已经Hold!<br/>", NumberStr)); } if (error.Length == 0 && waybillinfo.InShippingMethodID.HasValue && waybillinfo.InShippingMethodID.Value != filter.ShippingMethodId) { error.AppendLine(string.Format("入仓运输方式与运单运输方式:{0}不一致!<br/>", waybillinfo.InShippingMethodName)); //_orderService.AddAbnormalWayBill(waybillinfo.WayBillNumber, WayBill.AbnormalTypeEnum.InAbnormal, string.Format("运单号:{0}国家或运输方式异常", waybillinfo.WayBillNumber)); } if (error.Length == 0 && waybillinfo.CustomerCode.ToUpper().Trim() != filter.CustomerCode.ToUpper().Trim()) { error.AppendLine(string.Format("入仓客户与运单客户:{0}不一致!<br/>", waybillinfo.CustomerCode)); //_orderService.AddAbnormalWayBill(waybillinfo.WayBillNumber, WayBill.AbnormalTypeEnum.InAbnormal, string.Format("入仓客户与运单客户:{0}不一致", waybillinfo.CustomerCode.ToUpper())); } //小包检查重量偏差 if (error.Length == 0 && !filter.IsBusinessExpress) { //该客户该运输方式设置的重量偏差值 var weightDeviations = GetWeightDeviations(filter.CustomerCode, filter.ShippingMethodId); //预报重量与称重的偏差 var diff = Math.Abs((filter.Weight - waybillinfo.Weight ?? 0) * 1000); if (weightDeviations != 0 && diff > weightDeviations) { string errMessage = string.Format("称重重量与预报重量相差" + diff + "g大于配置的 " + weightDeviations + "g不能入仓!"); error.AppendLine(errMessage); //增加运单异常日志 _orderService.AddAbnormalWayBill(waybillinfo.WayBillNumber, WayBill.AbnormalTypeEnum.InStorageWeightAbnormal, errMessage, filter.OperatorUserName); if (_orderService.IsExistInStorageWeightAbnormal(waybillinfo.WayBillNumber)) { _orderService.UpdateInStorageWeightAbnormal(waybillinfo.WayBillNumber, filter.Weight); } else { //增加入仓对比重量异常单 _orderService.AddInStorageWeightAbnormal(new WeightAbnormalLog { CustomerCode = waybillinfo.CustomerCode, WayBillNumber = waybillinfo.WayBillNumber, CustomerOrderID = waybillinfo.CustomerOrderID, TrackingNumber = waybillinfo.TrackingNumber, Length = filter.Length ?? waybillinfo.Length, Width = filter.Width ?? waybillinfo.Width, Height = filter.Height ?? waybillinfo.Height, Weight = filter.Weight,//称重重量 CreatedOn = DateTime.Now, CreatedBy = filter.OperatorUserName }); } } } if (error.Length > 0) { model.IsSuccess = false; model.Message = error.ToString(); } else { // 根据转换重量转换包裹类型 Add by zhengsong #region var shippingMethod = _freightService.GetShippingMethod(filter.ShippingMethodId); if (shippingMethod != null) { if (shippingMethod.Enabled && shippingMethod.ShippingMethodTypeId == 4) { if (filter.Weight <= shippingMethod.PackageTransformFileWeight) { filter.GoodsTypeID = 2; } } } #endregion Guid customerId = Guid.Empty; Customer customer = GetGetCustomerListFromCache().Find(p => p.CustomerCode == waybillinfo.CustomerCode); if (customer != null) { customerId = customer.CustomerID; } //判断是否超周长 var result = _freightService.IsOverMaxGirthSingle(new CustomerInfoPackageModel() { CountryCode = waybillinfo.CountryCode, CustomerTypeId = filter.CustomerType, Height = filter.Height ?? 0, Length = filter.Length ?? 0, ShippingMethodId = filter.ShippingMethodId, Weight = filter.Weight, Width = filter.Width ?? 0, ShippingTypeId = filter.GoodsTypeID, CustomerId = customerId }); //如果没有超周长 if (!result.Result) { model.IsSuccess = true; model.Message = ""; model.WayBillNumber = waybillinfo.WayBillNumber; model.CountryCode = waybillinfo.CountryCode; model.CountryName = _freightService.GetChineseName(waybillinfo.CountryCode); model.CustomerOrderNumber = waybillinfo.CustomerOrderNumber; model.SettleWeight = Convert.ToDecimal(result.Message); //结算重量 model.EnableTariffPrepay = waybillinfo.EnableTariffPrepay; //是否启用关税预付服务 model.TrackingNumber = !string.IsNullOrWhiteSpace(waybillinfo.TrackingNumber) ? waybillinfo.TrackingNumber : ""; } else { model.IsSuccess = false; model.Message = result.Message; } } } else { model.IsSuccess = false; model.Message = string.Format("单号:{0}系统找不到!", NumberStr); } return(model); }
public void CreateOutStorage(CreateOutStorageExt createOutStorageExt) { Check.Argument.IsNotNull(createOutStorageExt, "createOutStorageExt"); Check.Argument.IsNotNull(createOutStorageExt.OutStorage, "createOutStorageExt.OutStorage"); Check.Argument.IsNotNull(createOutStorageExt.WayBillInfos, "createOutStorageExt.WayBillInfos"); DateTime outStorageCreatedOn = DateTime.Now; List <string> waybillinfoIds = new List <string>(); createOutStorageExt.WayBillInfos.Each(p => waybillinfoIds.Add(p.WayBillNumber)); var wayBills = _wayBillInfoRepository.GetList(p => waybillinfoIds.Contains(p.WayBillNumber)); List <WayBillEventLog> listWayBillEventLog = new List <WayBillEventLog>(); List <OutStorageInfo> listOutStorageInfo = new List <OutStorageInfo>(); List <CustomerOrderStatus> listCustomerOrderStatus = new List <CustomerOrderStatus>(); List <string> listWaybillSend = new List <string>(); List <string> listWaybillWaitOrder = new List <string>(); List <int> listCustomerOrderId = new List <int>(); var outShippingMethodId = createOutStorageExt.WayBillInfos.First().OutShippingMethodID; var outShippingMethodName = createOutStorageExt.WayBillInfos.First().OutShippingMethodName; createOutStorageExt.WayBillInfos.Each(p => { #region 修改运单资料信息和订单状态 var oldstatus = WayBill.StatusToValue(WayBill.StatusEnum.Have); var wayBillInfo = wayBills.Find(w => w.WayBillNumber == p.WayBillNumber && w.Status == oldstatus); if (wayBillInfo == null) { throw new ArgumentException("该运单号\"{0}\"不存在,或则是当前状态不是已收货!".FormatWith(p.WayBillNumber)); } //有跟踪号 if (p.HaveTrackingNum) { if (p.TrackingNumber == "null" || string.IsNullOrEmpty(p.TrackingNumber)) { //修改运单状态 待转单 listWaybillWaitOrder.Add(p.WayBillNumber); } else { //修改运单状态 已发货 listWaybillSend.Add(p.WayBillNumber); } } else { //修改运单状态 已发货 listWaybillSend.Add(p.WayBillNumber); } //插入订单状态记录 listCustomerOrderStatus.Add(new CustomerOrderStatus { CustomerOrderID = wayBillInfo.CustomerOrderID.Value, CreatedOn = DateTime.Now, Status = CustomerOrder.StatusToValue(CustomerOrder.StatusEnum.Send) }); listCustomerOrderId.Add(wayBillInfo.CustomerOrderID.Value); #region 录入内部信息 var wayBillEventLog = new WayBillEventLog() { WayBillNumber = wayBillInfo.WayBillNumber, EventCode = (int)WayBillEvent.EventCodeEnum.OutStorage, Description = WayBillEvent.GetEventCodeDescription((int)WayBillEvent.EventCodeEnum.OutStorage), EventDate = outStorageCreatedOn, LastUpdatedOn = outStorageCreatedOn, Operator = _workContext.User.UserUame, }; listWayBillEventLog.Add(wayBillEventLog); #endregion #endregion }); //createOutStorageExt.WayBillInfos.Each(p => // { // #region 修改运单资料信息和订单状态 // var oldstatus = WayBill.StatusToValue(WayBill.StatusEnum.Have); // var wayBillInfo = wayBills.Find(w => w.WayBillNumber == p.WayBillNumber && w.Status == oldstatus); // if (wayBillInfo == null) // { // throw new ArgumentException("该运单号\"{0}\"不存在,或则是当前状态不是已收货!".FormatWith(p.WayBillNumber)); // } // wayBillInfo.OutShippingMethodID = p.OutShippingMethodID; // wayBillInfo.OutShippingMethodName = p.OutShippingMethodName; // wayBillInfo.OutStorageID = createOutStorageExt.OutStorage.OutStorageID; // wayBillInfo.VenderCode = createOutStorageExt.OutStorage.VenderCode; // //有跟踪号 // if (p.HaveTrackingNum) // { // if (p.TrackingNumber == "null" || string.IsNullOrEmpty(p.TrackingNumber)) // { // //修改运单状态 待转单 // wayBillInfo.Status = WayBill.StatusToValue(WayBill.StatusEnum.WaitOrder); // } // else // { // //修改运单状态 已发货 // wayBillInfo.Status = WayBill.StatusToValue(WayBill.StatusEnum.Send); // } // } // else // { // //修改运单状态 已发货 // wayBillInfo.Status = WayBill.StatusToValue(WayBill.StatusEnum.Send); // } // if (wayBillInfo.CustomerOrderID.HasValue) // { // //修改订单状态 // wayBillInfo.CustomerOrderInfo.Status = // CustomerOrder.StatusToValue(CustomerOrder.StatusEnum.Send); // wayBillInfo.CustomerOrderInfo.LastUpdatedBy = _workContext.User.UserUame; // wayBillInfo.CustomerOrderInfo.LastUpdatedOn = DateTime.Now; // //插入订单状态记录 // listCustomerOrderStatus.Add(new CustomerOrderStatus // { // CustomerOrderID = wayBillInfo.CustomerOrderID.Value, // CreatedOn = DateTime.Now, // Status = CustomerOrder.StatusToValue(CustomerOrder.StatusEnum.Send) // }); // } // wayBillInfo.LastUpdatedBy = _workContext.User.UserUame; // wayBillInfo.LastUpdatedOn = DateTime.Now; // wayBillInfo.OutStorageCreatedOn = outStorageCreatedOn; // _wayBillInfoRepository.Modify(wayBillInfo); // #endregion // #region 录入内部信息 // //Add By zxq // //Time:2014-09-15 // var wayBillEventLog = new WayBillEventLog() // { // WayBillNumber = wayBillInfo.WayBillNumber, // EventCode = (int)WayBillEvent.EventCodeEnum.OutStorage, // Description = WayBillEvent.GetEventCodeDescription((int)WayBillEvent.EventCodeEnum.OutStorage), // EventDate = DateTime.Now, // LastUpdatedOn = DateTime.Now, // Operator = _workContext.User.UserUame, // }; // listWayBillEventLog.Add(wayBillEventLog); // #endregion // }); //生成出仓资料 var outStorage = new OutStorageInfo(); outStorage = createOutStorageExt.OutStorage; outStorage.DeliveryStaff = outStorage.CreatedBy = outStorage.LastUpdatedBy = _workContext.User.UserUame; outStorage.CreatedOn = outStorage.LastUpdatedOn = outStorageCreatedOn; outStorage.Status = 1; if (createOutStorageExt.WayBillInfos.First().OutShippingMethodName == "国际小包优+") { var countryCode = createOutStorageExt.WayBillInfos.First().CountryCode; string sequenceNumber = SequenceNumberService.GetSequenceNumber("U-"); _mailPostBagInfoRepository.Add(new MailPostBagInfo() { CountryCode = countryCode, OutStorageID = outStorage.OutStorageID, IsBattery = createOutStorageExt.WayBillInfos.First().IsBattery, PostBagNumber = sequenceNumber.Replace("-", "-" + countryCode + "-"), TotalWeight = createOutStorageExt.WayBillInfos.Sum(p => p.Weight), CreatedBy = outStorage.LastUpdatedBy, CreatedOn = DateTime.Now, LastUpdatedBy = outStorage.LastUpdatedBy, LastUpdatedOn = DateTime.Now, }); } //_outStorageInfoRepository.Add(outStorage); listOutStorageInfo.Add(outStorage); using (var transaction = new TransactionScope()) { _wayBillInfoRepository.BulkInsert("WayBillEventLogs", listWayBillEventLog); _wayBillInfoRepository.BulkInsert("OutStorageInfos", listOutStorageInfo); _wayBillInfoRepository.BulkInsert("CustomerOrderStatuses", listCustomerOrderStatus); if (listWaybillSend.Any()) { _wayBillInfoRepository.Modify(w => new WayBillInfo() { OutShippingMethodID = outShippingMethodId, OutShippingMethodName = outShippingMethodName, OutStorageID = createOutStorageExt.OutStorage.OutStorageID, VenderCode = createOutStorageExt.OutStorage.VenderCode, LastUpdatedBy = _workContext.User.UserUame, LastUpdatedOn = outStorageCreatedOn, OutStorageCreatedOn = outStorageCreatedOn, Status = WayBill.StatusToValue(WayBill.StatusEnum.Send), }, w => listWaybillSend.Contains(w.WayBillNumber)); } if (listWaybillWaitOrder.Any()) { _wayBillInfoRepository.Modify(w => new WayBillInfo() { OutShippingMethodID = outShippingMethodId, OutShippingMethodName = outShippingMethodName, OutStorageID = createOutStorageExt.OutStorage.OutStorageID, VenderCode = createOutStorageExt.OutStorage.VenderCode, LastUpdatedBy = _workContext.User.UserUame, LastUpdatedOn = outStorageCreatedOn, OutStorageCreatedOn = outStorageCreatedOn, Status = WayBill.StatusToValue(WayBill.StatusEnum.WaitOrder), }, w => listWaybillWaitOrder.Contains(w.WayBillNumber)); } if (listCustomerOrderId.Any()) { _customerOrderInfoRepository.Modify(c => new CustomerOrderInfo() { Status = CustomerOrder.StatusToValue(CustomerOrder.StatusEnum.Send), LastUpdatedBy = _workContext.User.UserUame, LastUpdatedOn = outStorageCreatedOn, }, c => listCustomerOrderId.Contains(c.CustomerOrderID)); } //_wayBillInfoRepository.UnitOfWork.Commit(); _mailPostBagInfoRepository.UnitOfWork.Commit(); transaction.Complete(); } //创建总包号 if (createOutStorageExt.IsCreateTotalPackageNumber.HasValue) { if (createOutStorageExt.IsCreateTotalPackageNumber.Value) { //创建新的 var totalPackageInfo = new TotalPackageInfo { CreatedBy = _workContext.User.UserUame, LastUpdatedBy = _workContext.User.UserUame, CreatedOn = outStorageCreatedOn, LastUpdatedOn = outStorageCreatedOn, TotalPackageNumber = createOutStorageExt.TotalPackageNumber, Remark = createOutStorageExt.Remark, TotalQty = createOutStorageExt.TotalQty, TotalVotes = createOutStorageExt.TotalVotes, TotalWeight = createOutStorageExt.TotalWeight, VenderCode = createOutStorageExt.OutStorage.VenderCode, VenderName = createOutStorageExt.OutStorage.VenderName }; _totalPackageInfoRepository.Add(totalPackageInfo); var relational = new TotalPackageOutStorageRelationalInfo { OutStorageID = createOutStorageExt.OutStorage.OutStorageID, TotalPackageNumber = createOutStorageExt.TotalPackageNumber, CreatedOn = DateTime.Now }; _totalPackageOutStorageRelationalInfoRepository.Add(relational); } else { ////追加到已存在的总包号里面 var totalPackageInfo = _totalPackageInfoRepository.Single( p => p.TotalPackageNumber == createOutStorageExt.TotalPackageNumber && p.VenderCode == createOutStorageExt.OutStorage.VenderCode); if (totalPackageInfo != null) { totalPackageInfo.TotalQty += createOutStorageExt.TotalQty; totalPackageInfo.TotalVotes += createOutStorageExt.TotalVotes; totalPackageInfo.TotalWeight += createOutStorageExt.TotalWeight; totalPackageInfo.LastUpdatedBy = _workContext.User.UserUame; totalPackageInfo.LastUpdatedOn = outStorageCreatedOn; _totalPackageInfoRepository.Modify(totalPackageInfo); var relational = new TotalPackageOutStorageRelationalInfo { OutStorageID = createOutStorageExt.OutStorage.OutStorageID, TotalPackageNumber = createOutStorageExt.TotalPackageNumber, CreatedOn = DateTime.Now }; _totalPackageOutStorageRelationalInfoRepository.Add(relational); } } using (var transaction = new TransactionScope()) { _totalPackageInfoRepository.UnitOfWork.Commit(); _totalPackageOutStorageRelationalInfoRepository.UnitOfWork.Commit(); transaction.Complete(); } } }
//数据源 public List <ContactTable> GetContactTables(List <WayBillInfo> waybillInfoList) { var listContactTable = new List <ContactTable>(); var contactTable = new ContactTable(); var enumStatus = new EnumStatus(); foreach (var wayBillInfo in waybillInfoList) { ////判断运单状态,是否是退回,退货在仓 //int returnStatus = WayBill.StatusToValue(WayBill.StatusEnum.Return); //int reGoodsInStorageStatus = WayBill.StatusToValue(WayBill.StatusEnum.ReGoodsInStorage); //if (wayBillInfo.Status == returnStatus || wayBillInfo.Status == reGoodsInStorageStatus) //{ // contactTable.WaybillReurnStatus = true; //} #region 获取数据 //获取外部数据 OrderTrackingModel getOuterOrderTrackingModel = _iFreightService.GetOutTrackingInfo(wayBillInfo.TrueTrackingNumber) ?? _iFreightService.GetOutTrackingInfo(wayBillInfo.TrackingNumber); //外部信息已签收--反写该运单已签收 if (getOuterOrderTrackingModel != null && getOuterOrderTrackingModel.PackageState == (int)EnumStatus.PackageStateEnum.Delivered) { _trackingService.UpdateWayBillInfo(wayBillInfo.WayBillNumber); } //去除外部轨迹抓取第一条 if (getOuterOrderTrackingModel != null && getOuterOrderTrackingModel.OrderTrackingDetails.Any()) { getOuterOrderTrackingModel.OrderTrackingDetails.RemoveAt(getOuterOrderTrackingModel.OrderTrackingDetails.Count - 1); } //获取内部数据列表 List <InTrackingLogInfo> getInTackingLogInfo = _trackingService.GetInTrackingLogInfos(wayBillInfo.WayBillNumber).OrderByDescending(a => a.ProcessDate).ToList(); List <InTrackingLogInfo> getInTackingLogInfoList = _trackingService.GetInTrackingLogInfos(wayBillInfo.WayBillNumber).ToList(); #endregion var orderTrackingDetailModelInfo = new List <OrderTrackingDetailModelInfo>(); //都有数据 if (getInTackingLogInfo.Any() && getOuterOrderTrackingModel != null) { int?getSpanDay = 0; int getCount = 0; if (getOuterOrderTrackingModel.OrderTrackingDetails.Any()) { //获取内部数据收货时间(第二条) DateTime getSecondInnerDate = getInTackingLogInfoList.Count >= 2 ? getInTackingLogInfoList.Skip(1).Take(1).ToList()[0].ProcessDate.Value : getInTackingLogInfo[0].ProcessDate.Value; //签收天数 TimeSpan ts = getOuterOrderTrackingModel.OrderTrackingDetails.First().ProcessDate.Value - getSecondInnerDate; getSpanDay = Convert.ToInt32(Math.Ceiling(Math.Abs(ts.TotalDays))); //外部明细 getCount = getOuterOrderTrackingModel.OrderTrackingDetails.Count(); //添加外部轨迹信息 getOuterOrderTrackingModel.OrderTrackingDetails.ForEach( p => orderTrackingDetailModelInfo.Add(new OrderTrackingDetailModelInfo { WaybillNumber = wayBillInfo.WayBillNumber, ProcessDate = p.ProcessDate, ProcessContent = p.ProcessContent, ProcessLocation = p.ProcessLocation })); } //添加内部轨迹信息 getInTackingLogInfo.ForEach(p => orderTrackingDetailModelInfo.Add(new OrderTrackingDetailModelInfo { WaybillNumber = wayBillInfo.WayBillNumber, ProcessDate = p.ProcessDate, ProcessContent = p.ProcessContent, ProcessLocation = p.ProcessLocation })); listContactTable.Add(new ContactTable() { WaybillNumber = wayBillInfo.WayBillNumber, FalseTrackNumber = wayBillInfo.TrackingNumber, CurrentLocation = "China", CustomerOrderNumber = wayBillInfo.CustomerOrderNumber, InShippingMethodName = wayBillInfo.InShippingMethodName, //运单退回情况 WaybillReurnStatus = contactTable.WaybillReurnStatus, //目的地 Destination = _trackingNumberService.GetShippingInfo(wayBillInfo.WayBillNumber).CountryCode, //最新事件时间 LastEventDate = getCount == 0 ? getInTackingLogInfo.First().ProcessDate : getOuterOrderTrackingModel.OrderTrackingDetails.First().ProcessDate, LastEventContent = getCount == 0 ? getInTackingLogInfo.First().ProcessContent : getOuterOrderTrackingModel.OrderTrackingDetails.First().ProcessContent, //包裹状态 EnumStingStatus = getCount != 0 ? enumStatus.PackageState(getOuterOrderTrackingModel.PackageState.Value) : WayBill.GetStatusDescription(wayBillInfo.Status), //运单状态 WaybillStatus = wayBillInfo.Status, //是否hold IsHold = wayBillInfo.IsHold, //收货天数 IntervalDays = getCount != 0 ? getSpanDay : Convert.ToInt32((System.DateTime.Now - getInTackingLogInfo.Min(a => a.ProcessDate).Value).TotalDays), //真实跟踪号时 TrackNumber = wayBillInfo.TrueTrackingNumber, //显示轨迹信息 OrderTrackingDetailModelInfo = orderTrackingDetailModelInfo }); } //内部表有数据,外部表没有数据 if (getInTackingLogInfo.Any() && getOuterOrderTrackingModel == null) { //添加内部轨迹信息 getInTackingLogInfo.ForEach(p => orderTrackingDetailModelInfo.Add(new OrderTrackingDetailModelInfo { WaybillNumber = wayBillInfo.WayBillNumber, ProcessDate = p.ProcessDate, ProcessContent = p.ProcessContent, ProcessLocation = p.ProcessLocation })); listContactTable.Add(new ContactTable() { WaybillNumber = wayBillInfo.WayBillNumber, FalseTrackNumber = wayBillInfo.TrackingNumber, CurrentLocation = "中国", CustomerOrderNumber = wayBillInfo.CustomerOrderNumber, InShippingMethodName = wayBillInfo.InShippingMethodName, //目的地 Destination = _trackingNumberService.GetShippingInfo(wayBillInfo.WayBillNumber).CountryCode, //最新事件时间 LastEventDate = getInTackingLogInfo.First().ProcessDate, LastEventContent = getInTackingLogInfo.First().ProcessContent, //包裹状态 EnumStingStatus = WayBill.GetStatusDescription(wayBillInfo.Status), //运单状态 WaybillStatus = wayBillInfo.Status, //是否hold IsHold = wayBillInfo.IsHold, //显示轨迹信息 OrderTrackingDetailModelInfo = orderTrackingDetailModelInfo }); } //都没有轨迹数据 if (!getInTackingLogInfo.Any() && getOuterOrderTrackingModel == null) { listContactTable.Add(new ContactTable() { NoQueryWaybillnumber = wayBillInfo.WayBillNumber }); } } return(listContactTable); }
public void BatchAddReturnGoods(List <ReturnGoodsExt> list) { var returnList = list.FindAll(p => p.IsDirectReturnGoods).Where(returnGoods => !_returnGoodsRepository.Exists(p => p.WayBillNumber == returnGoods.WayBillNumber)).ToList(); if (returnList.Any()) { //直接退货操作 foreach (var returnGoods in returnList) { #region 修改订单、运单状态 var wayBillInfo = _wayBillInfoRepository.Get(returnGoods.WayBillNumber); if (wayBillInfo != null) { if (wayBillInfo.Status != (int)WayBill.StatusEnum.Send && wayBillInfo.Status != (int)WayBill.StatusEnum.WaitOrder) { throw new Exception(string.Format("运单{0}的状态不是已发货或待转单", returnGoods.WayBillNumber)); } wayBillInfo.Status = WayBill.StatusToValue(WayBill.StatusEnum.ReGoodsInStorage); wayBillInfo.LastUpdatedOn = DateTime.Now; wayBillInfo.LastUpdatedBy = returnGoods.UserName; wayBillInfo.CustomerOrderInfo.Status = CustomerOrder.StatusToValue(CustomerOrder.StatusEnum.ReGoodsInStorage); wayBillInfo.CustomerOrderInfo.LastUpdatedBy = returnGoods.UserName; wayBillInfo.CustomerOrderInfo.LastUpdatedOn = DateTime.Now; _wayBillInfoRepository.Modify(wayBillInfo); } #endregion #region 录入内部信息 if (wayBillInfo != null) { //Add By zxq //Time:2014-09-15 var wayBillEventLog = new WayBillEventLog() { WayBillNumber = wayBillInfo.WayBillNumber, EventCode = (int)WayBillEvent.EventCodeEnum.OutStorage, Description = WayBillEvent.GetEventCodeDescription((int)WayBillEvent.EventCodeEnum.OutStorage), EventDate = DateTime.Now, LastUpdatedOn = DateTime.Now, Operator = returnGoods.UserName, }; _wayBillEventLogRepository.Add(wayBillEventLog); } #endregion //退货详细 if (wayBillInfo != null) { ReceivingExpensesEditExt receivingExpensesEditExt = new ReceivingExpensesEditExt(); receivingExpensesEditExt = _financialService.GetReceivingExpensesEditExt(wayBillInfo.WayBillNumber); ReturnGoods rgGoods = new ReturnGoods() { WayBillNumber = returnGoods.WayBillNumber, Weight = returnGoods.Weight != 0 ? returnGoods.Weight : wayBillInfo.Weight.Value, CreatedBy = returnGoods.UserName, CreatedOn = DateTime.Now, IsReturnShipping = returnGoods.IsReturnShipping, LastUpdatedBy = returnGoods.UserName, LastUpdatedOn = DateTime.Now, Reason = returnGoods.Reason, ReasonRemark = returnGoods.ReasonRemark, ReGoodsId = SequenceNumberService.GetSequenceNumber(PrefixCode.ReturnGoodsID), Type = returnGoods.Type, Status = (int)ReturnGood.ReturnStatusEnum.UnAudited, ReturnSource = (int)ReturnGood.ReturnSourceStatusEnum.CSReturn }; //是否退运费 if (returnGoods.IsReturnShipping) { if (receivingExpensesEditExt != null) { if (receivingExpensesEditExt.TotalFeeFinal.HasValue) { rgGoods.ShippingFee = receivingExpensesEditExt.TotalFeeFinal ?? 0; } else if (receivingExpensesEditExt.TotalFeeOriginal.HasValue) { rgGoods.ShippingFee = receivingExpensesEditExt.TotalFeeOriginal ?? 0; } } else { rgGoods.ShippingFee = 0; } } else { rgGoods.ShippingFee = 0; } _returnGoodsRepository.Add(rgGoods); } using (var transaction = new TransactionScope()) { _returnGoodsRepository.UnitOfWork.Commit(); _wayBillInfoRepository.UnitOfWork.Commit(); _wayBillEventLogRepository.UnitOfWork.Commit(); _receivingExpensRepository.UnitOfWork.Commit(); transaction.Complete(); } } } }
public async Task <JsonResult> Import([Bind("Id")] WayBill wayBill, IFormFile formFile, CancellationToken cancellationToken) { if (formFile == null || formFile.Length <= 0) { return(Json(Response <List <WayBillDetalle> > .GetResult(-1, "formfile is empty"))); } if (!Path.GetExtension(formFile.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase)) { return(Json(Response <List <WayBillDetalle> > .GetResult(-1, "Not Support file extension"))); } List <WayBillDetalle> items = new List <WayBillDetalle>(); using (var stream = new MemoryStream()) { await formFile.CopyToAsync(stream, cancellationToken); using (var package = new ExcelPackage(stream)) { ExcelWorksheet worksheet = package.Workbook.Worksheets[0]; var rowCount = worksheet.Dimension.Rows; try { int errors = 0; string message; int idproducto; decimal cantidad; for (int row = 2; row <= rowCount; row++) { ModelState.Clear(); int.TryParse((worksheet.Cells[row, 1].Text == "" ? null : worksheet.Cells[row, 1].Text), out idproducto); decimal.TryParse((worksheet.Cells[row, 2].Text == "" ? null : worksheet.Cells[row, 2].Text), out cantidad); WayBillDetalle item = new WayBillDetalle(); item.IdWayBill = wayBill.Id; item.IdProducto = idproducto; item.Cantidad = cantidad; item.Fecha = DateTime.Now; TryValidateModel(item); var res = ModelState.IsValid; if (res == false) { errors += 1; message = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage)); } else { message = "Ok"; } item.resultado = message; items.Add(item); //ModelState.Clear(); } if (errors == 0) { _context.AddRange(items); _context.SaveChanges(); return(Json(Response <List <WayBillDetalle> > .GetResult(0, "OK", items))); } } catch (Exception e) { return(Json(Response <List <WayBillDetalle> > .GetResult(-2, e.Message, items))); } } } return(Json(Response <List <WayBillDetalle> > .GetResult(0, "OK", items))); }
public PagedList <B2CPreAlterExt> GetB2CPreAlterExtList(B2CPreAlterListParam param) { var ctx = this.UnitOfWork as LMS_DbContext; Check.Argument.IsNotNull(ctx, "数据库对象"); var wayBillStatus = new List <int> { WayBill.StatusEnum.WaitOrder.GetStatusValue(), WayBill.StatusEnum.Send.GetStatusValue() }; Expression <Func <WayBillInfo, bool> > filterWayBill = o => wayBillStatus.Contains(o.Status); Expression <Func <B2CPreAlertLogs, bool> > filterB2C = o => true; filterWayBill = filterWayBill.And(p => p.OutStorageCreatedOn >= param.OutStartTime); int isNotExist = 0; if (!param.SearchContext.IsNullOrWhiteSpace()) { var wayBillList = param.SearchContext.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries) .ToList(); switch (WayBill.ParseToSearchFilter(param.SearchWhere)) { case WayBill.SearchFilterEnum.WayBillNumber: filterWayBill = filterWayBill.And(p => wayBillList.Contains(p.WayBillNumber)); break; case WayBill.SearchFilterEnum.TrackingNumber: filterWayBill = filterWayBill.And(p => wayBillList.Contains(p.TrackingNumber)); break; case WayBill.SearchFilterEnum.CustomerOrderNumber: filterWayBill = filterWayBill.And(p => wayBillList.Contains(p.CustomerOrderNumber)); break; } filterWayBill = filterWayBill.And(p => param.ShippingMethodIds.Contains(p.OutShippingMethodID.Value)); } else { if (!string.IsNullOrWhiteSpace(param.CountryCode)) { var codes = param.CountryCode.Split(',').ToList(); if (codes.Count > 0) { filterWayBill = filterWayBill.And(p => codes.Contains(p.CountryCode)); } } filterWayBill = filterWayBill.AndIf(p => p.CustomerCode == param.CustomerCode, !string.IsNullOrWhiteSpace(param.CustomerCode)) .AndIf(p => p.SettleWeight >= param.StartWeight, param.StartWeight.HasValue) .AndIf(p => p.SettleWeight <= param.EndWeight, param.EndWeight.HasValue) .And(p => p.OutShippingMethodID == param.ShippingMethodId) ; switch (WayBill.ParseToDateFilter(param.SearchTime)) { case WayBill.DateFilterEnum.TakeOverOn: filterWayBill = filterWayBill.AndIf(p => p.InStorageCreatedOn >= param.StartTime, param.StartTime.HasValue) .AndIf(p => p.InStorageCreatedOn <= param.EndTime, param.EndTime.HasValue); break; case WayBill.DateFilterEnum.DeliverOn: filterWayBill = filterWayBill.AndIf(p => p.OutStorageCreatedOn >= param.StartTime, param.StartTime.HasValue) .AndIf(p => p.OutStorageCreatedOn <= param.EndTime, param.EndTime.HasValue); break; } if (param.Status.HasValue) { if (B2CPreAlter.ParseToStatus(param.Status.Value) == B2CPreAlter.StatusEnum.None) { isNotExist = 1; } else { isNotExist = 2; filterB2C = filterB2C.And(p => p.Status == param.Status.Value); } } } var okStatus = B2CPreAlter.StatusToValue(B2CPreAlter.StatusEnum.OK); var noneStatus = B2CPreAlter.StatusToValue(B2CPreAlter.StatusEnum.None); if (isNotExist == 0) { return((from w in ctx.WayBillInfos.Where(filterWayBill) join o in ctx.OutStorageInfos on w.OutStorageID equals o.OutStorageID join b in ctx.B2CPreAlertLogs on w.WayBillNumber equals b.WayBillNumber into B2C from c in B2C.DefaultIfEmpty() orderby w.OutStorageCreatedOn descending select new B2CPreAlterExt { CountryCode = w.CountryCode, CustomerCode = w.CustomerCode, ErrorMsg = c != null ? (c.Status == okStatus ? "" : c.ErrorMsg) : "", InStorageCreatedOn = w.InStorageCreatedOn, OutShippingMethodName = w.OutShippingMethodName, SettleWeight = w.SettleWeight ?? 0, TrackingNumber = w.TrackingNumber, VenderName = o.VenderName, WayBillNumber = w.WayBillNumber, Status = c != null ? c.Status : 0 }).ToPagedList(param.Page, param.PageSize)); } else if (isNotExist == 1) { return((from w in ctx.WayBillInfos.Where(filterWayBill) join o in ctx.OutStorageInfos on w.OutStorageID equals o.OutStorageID where !(from c in ctx.B2CPreAlertLogs select c.WayBillNumber).Contains(w.WayBillNumber) orderby w.OutStorageCreatedOn descending select new B2CPreAlterExt { CountryCode = w.CountryCode, CustomerCode = w.CustomerCode, ErrorMsg = "", InStorageCreatedOn = w.InStorageCreatedOn, OutShippingMethodName = w.OutShippingMethodName, SettleWeight = w.SettleWeight ?? 0, TrackingNumber = w.TrackingNumber, VenderName = o.VenderName, WayBillNumber = w.WayBillNumber, Status = noneStatus }).ToPagedList(param.Page, param.PageSize)); } else { return((from w in ctx.WayBillInfos.Where(filterWayBill) join o in ctx.OutStorageInfos on w.OutStorageID equals o.OutStorageID join b in ctx.B2CPreAlertLogs.Where(filterB2C) on w.WayBillNumber equals b.WayBillNumber orderby w.OutStorageCreatedOn descending select new B2CPreAlterExt { CountryCode = w.CountryCode, CustomerCode = w.CustomerCode, ErrorMsg = b.Status == okStatus ? "" : b.ErrorMsg, InStorageCreatedOn = w.InStorageCreatedOn, OutShippingMethodName = w.OutShippingMethodName, SettleWeight = w.SettleWeight ?? 0, TrackingNumber = w.TrackingNumber, VenderName = o.VenderName, WayBillNumber = w.WayBillNumber, Status = b.Status }).ToPagedList(param.Page, param.PageSize)); } }
public bool PreAlterB2CBySearch(B2CPreAlterListParam param) { var ctx = this.UnitOfWork as LMS_DbContext; Check.Argument.IsNotNull(ctx, "数据库对象"); var wayBillStatus = new List <int> { WayBill.StatusEnum.WaitOrder.GetStatusValue(), WayBill.StatusEnum.Send.GetStatusValue() }; Expression <Func <WayBillInfo, bool> > filterWayBill = o => wayBillStatus.Contains(o.Status); filterWayBill = filterWayBill.And(p => p.OutStorageCreatedOn >= param.OutStartTime); if (!param.SearchContext.IsNullOrWhiteSpace()) { var wayBillList = param.SearchContext.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries) .ToList(); switch (WayBill.ParseToSearchFilter(param.SearchWhere)) { case WayBill.SearchFilterEnum.WayBillNumber: filterWayBill = filterWayBill.And(p => wayBillList.Contains(p.WayBillNumber)); break; case WayBill.SearchFilterEnum.TrackingNumber: filterWayBill = filterWayBill.And(p => wayBillList.Contains(p.TrackingNumber)); break; case WayBill.SearchFilterEnum.CustomerOrderNumber: filterWayBill = filterWayBill.And(p => wayBillList.Contains(p.CustomerOrderNumber)); break; } filterWayBill = filterWayBill.And(p => param.ShippingMethodIds.Contains(p.OutShippingMethodID.Value)); } else { if (!string.IsNullOrWhiteSpace(param.CountryCode)) { var codes = param.CountryCode.Split(',').ToList(); if (codes.Count > 0) { filterWayBill = filterWayBill.And(p => codes.Contains(p.CountryCode)); } } filterWayBill = filterWayBill.AndIf(p => p.CustomerCode == param.CustomerCode, !string.IsNullOrWhiteSpace(param.CustomerCode)) .AndIf(p => p.SettleWeight >= param.StartWeight, param.StartWeight.HasValue) .AndIf(p => p.SettleWeight <= param.EndWeight, param.EndWeight.HasValue) .And(p => p.OutShippingMethodID == param.ShippingMethodId) ; switch (WayBill.ParseToDateFilter(param.SearchTime)) { case WayBill.DateFilterEnum.TakeOverOn: filterWayBill = filterWayBill.AndIf(p => p.InStorageCreatedOn >= param.StartTime, param.StartTime.HasValue) .AndIf(p => p.InStorageCreatedOn <= param.EndTime, param.EndTime.HasValue); break; case WayBill.DateFilterEnum.DeliverOn: filterWayBill = filterWayBill.AndIf(p => p.OutStorageCreatedOn >= param.StartTime, param.StartTime.HasValue) .AndIf(p => p.OutStorageCreatedOn <= param.EndTime, param.EndTime.HasValue); break; } } var list = (from w in ctx.WayBillInfos.Where(filterWayBill) join o in ctx.OutStorageInfos on w.OutStorageID equals o.OutStorageID where !(from c in ctx.B2CPreAlertLogs select c.WayBillNumber).Contains(w.WayBillNumber) select w.WayBillNumber).ToList(); return(PreAlterB2CByWayBillNumber(list)); }
/// <summary> /// 获取退货信息列表 /// Add by zhengsong /// Time:2014-05-16 /// </summary> /// <param name="param"></param> /// <returns></returns> public IPagedList <ReturnWayBillModelExt> GetPagedListReturnWayBill(ReturnWayBillParam param) { var ctx = this.UnitOfWork as LMS_DbContext; Check.Argument.IsNotNull(ctx, "数据库对象"); IQueryable <ReturnWayBillModelExt> list; Expression <Func <ReturnGoods, bool> > filter = o => true; Expression <Func <WayBillInfo, bool> > filterWayBill = o => true; if (!string.IsNullOrWhiteSpace(param.SearchContext)) { var numberList = param.SearchContext.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries) .ToList(); if (param.SearchWhere.HasValue && numberList.Count > 0) { switch (WayBill.ParseToSearchFilter(param.SearchWhere.Value)) { case WayBill.SearchFilterEnum.WayBillNumber: filterWayBill = filterWayBill.And(p => numberList.Contains(p.WayBillNumber)); break; case WayBill.SearchFilterEnum.TrackingNumber: filterWayBill = filterWayBill.And(p => numberList.Contains(p.TrackingNumber)); break; case WayBill.SearchFilterEnum.CustomerOrderNumber: filterWayBill = filterWayBill.And(p => numberList.Contains(p.CustomerOrderNumber)); break; } } filter = filter.AndIf(r => r.Status == param.Status, param.Status.HasValue); } else { filter = filter.AndIf(r => r.CreatedOn >= param.ReturnStartTime, param.ReturnStartTime.HasValue) .AndIf(r => r.CreatedOn <= param.ReturnEndTime, param.ReturnEndTime.HasValue) .AndIf(r => r.CreatedBy.Contains(param.CreateBy), !param.CreateBy.IsNullOrWhiteSpace()) .AndIf(r => r.Status == param.Status, param.Status.HasValue) .AndIf(r => r.IsReturnShipping == param.IsReturnShipping, param.IsReturnShipping.HasValue) .AndIf(r => param.ReturnReason.Contains(r.Reason), !param.ReturnReason.IsNullOrWhiteSpace()); filterWayBill = filterWayBill.AndIf(w => w.CustomerCode == param.CustomerCode, !param.CustomerCode.IsNullOrWhiteSpace()) .AndIf(w => w.InShippingMethodID == param.InShippingMehtodId, param.InShippingMehtodId != 0); } list = from r in ctx.ReturnGoods.Where(filter) join w in ctx.WayBillInfos.Where(filterWayBill) on r.WayBillNumber equals w.WayBillNumber join c in ctx.Customers on r.CreatedBy equals c.CustomerCode into rwcList from rwc in rwcList.DefaultIfEmpty() join g in ctx.Countries on w.CountryCode equals g.CountryCode into rwcgList from rList in rwcgList.DefaultIfEmpty() join i in ctx.InStorageInfos on w.InStorageID equals i.InStorageID into ilist from il in ilist.DefaultIfEmpty() join o in ctx.OutStorageInfos on w.OutStorageID equals o.OutStorageID into newList from n in newList.DefaultIfEmpty() orderby r.CreatedOn descending select new ReturnWayBillModelExt { CustomerName = w.CustomerCode, WayBillNumber = r.WayBillNumber, CustomerOrderNumber = w.CustomerOrderNumber, InShippingMehtodName = w.InShippingMethodName, TrackingNumber = w.TrackingNumber, TotalWeight = r.Weight, CountryCode = w.CountryCode, ChineseName = rList.ChineseName, ShippingFee = r.ShippingFee, Type = r.Type, Reason = r.Reason, ReasonRemark = r.ReasonRemark, IsReturnShipping = r.IsReturnShipping, OutCreatedOn = n.CreatedOn, ReturnCreatedOn = r.CreatedOn, CreatedBy = r.CreatedBy, CreatedByEeName = rwc.AccountID, Auditor = r.Auditor, AuditorDate = r.AuditorDate }; return(list.ToPagedList(param.Page, param.PageSize)); }
public FormWaybillDetails() { InitializeComponent(); _wayBill = new WayBill(); }
/// <summary> /// 生成运货单 /// </summary> /// <param name="code">货物id</param> /// <param name="truckId">卡车id</param> /// <returns></returns> public async Task <bool> ToWayBill(string code, Guid truckId) { //查询状态是否正确--->修改订单中的状态--->生成waybill--->生成waybillLink bool flag = true; Order order; using (var orderservice = new OrderService()) { order = orderservice.GetAll().Where(p => p.BarCode == code).FirstOrDefault(); if (order == null || order.Status != "2") { flag = false; } } if (flag) { var context = new LogisticsContext(); using (var transaction = context.Database.BeginTransaction()) { try { //修改订单的状态 order.Status = "3"; context.Entry(order).State = EntityState.Modified; await context.SaveChangesAsync(); //创建waybill WayBill wayBill = new WayBill() { FinishTime = DateTime.Now, PlanPath = "NULL" }; context.Set <WayBill>().Add(wayBill); await context.SaveChangesAsync(); //创建truck waybill联系 WaybillTransportLink transportLink = new WaybillTransportLink() { TransportInfoId = truckId, WayBillId = wayBill.Id }; context.Set <WaybillTransportLink>().Add(transportLink); await context.SaveChangesAsync(); //创建order waybill联系 OrderWaybillLink orderWaybillLink = new OrderWaybillLink() { OrderId = order.Id, WaybillId = wayBill.Id }; context.Set <OrderWaybillLink>().Add(orderWaybillLink); await context.SaveChangesAsync(); transaction.Commit(); } catch (Exception errer) { transaction.Rollback(); flag = false; throw errer; } finally { context.Dispose(); } } } return(flag); }
public PagedList <CustomerOrderInfoExt> GetCustomerOrderByBlockedList(CustomerOrderParam param, int maxCustomerOrderId = 0) { var ctx = this.UnitOfWork as LMS_DbContext; Check.Argument.IsNotNull(ctx, "数据库对象"); IQueryable <CustomerOrderInfoExt> list; int deleteSatus = CustomerOrder.StatusEnum.Delete.GetStatusValue(); Expression <Func <CustomerOrderInfo, bool> > filter = o => o.Status != deleteSatus; filter = filter.AndIf(o => o.CustomerCode == param.CustomerCode, !param.CustomerCode.IsNullOrWhiteSpace()); Expression <Func <WayBillInfo, bool> > filterWayBill = o => true; //if (!param.WayBillNumber.IsNullOrWhiteSpace()) //{ // var numberList = param.WayBillNumber.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries) // .ToList(); // if (numberList.Count > 0) // { // string number = numberList[0]; // filterWayBill = numberList.Count == 1 ? filterWayBill.And(a => a.WayBillNumber == number) : filterWayBill.And(a => numberList.Contains(a.WayBillNumber)); // } //} //else if (!param.CustomerOrderNumber.IsNullOrWhiteSpace()) //{ // var numberList = // param.CustomerOrderNumber.Split(Environment.NewLine.ToCharArray(), // StringSplitOptions.RemoveEmptyEntries) // .ToList(); // if (numberList.Count > 0) // { // string number = numberList[0]; // filter = numberList.Count == 1 // ? filter.And(o => o.CustomerOrderNumber == number) // : filter.And(o => numberList.Contains(o.CustomerOrderNumber)); // } //} //else //{ if (!string.IsNullOrWhiteSpace(param.SearchContext)) { var numberList = param.SearchContext.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries) .ToList(); if (param.SearchWhere.HasValue && numberList.Count > 0) { switch (WayBill.ParseToSearchFilter(param.SearchWhere.Value)) { case WayBill.SearchFilterEnum.WayBillNumber: filterWayBill = filterWayBill.And(p => numberList.Contains(p.WayBillNumber)); break; case WayBill.SearchFilterEnum.TrackingNumber: filter = filter.And(p => numberList.Contains(p.TrackingNumber)); break; case WayBill.SearchFilterEnum.CustomerOrderNumber: filter = filter.And(p => numberList.Contains(p.CustomerOrderNumber)); break; } } } else { if (!param.CustomerOrderNumber.IsNullOrWhiteSpace()) { var numberList = param.CustomerOrderNumber.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries) .ToList(); filter = filter.AndIf(o => numberList.Contains(o.CustomerOrderNumber), numberList.Count > 0); } } //if (!param.WayBillNumber.IsNullOrWhiteSpace()) //{ // var numberList = // param.WayBillNumber.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries) // .ToList(); // if (numberList.Count > 0) // { // string number = numberList[0]; // filterWayBill = numberList.Count == 1 // ? filterWayBill.And(a => a.WayBillNumber == number) // : filterWayBill.And(a => numberList.Contains(a.WayBillNumber)); // } //} filterWayBill = filterWayBill.AndIf(o => o.CountryCode == param.CountryCode, !param.CountryCode.IsNullOrWhiteSpace()); filter = filter .AndIf(o => o.ShippingMethodId == param.ShippingMethodId.Value, param.ShippingMethodId.HasValue) .AndIf(o => o.CreatedOn >= param.CreatedOnFrom.Value, param.CreatedOnFrom.HasValue) .AndIf(o => o.CreatedOn <= param.CreatedOnTo.Value, param.CreatedOnTo.HasValue) .AndIf(o => o.CustomerOrderID <= maxCustomerOrderId, maxCustomerOrderId > 0) ; //} ////异常类型只查询,拦截与入仓异常状态 //var lsitType = new List<int>() // { // WayBill.AbnormalTypeEnum.Intercepted.GetAbnormalTypeValue(), // WayBill.AbnormalTypeEnum.OutAbnormal.GetAbnormalTypeValue() // }; //lsitType.Contains(l.OperateType) //查询异常状态为未完成的 int abnormalStatus = WayBill.AbnormalStatusEnum.NO.GetAbnormalStatusValue(); list = from w in ctx.WayBillInfos.Where(filterWayBill) join l in ctx.AbnormalWayBillLogs on w.AbnormalID equals l.AbnormalID join o in ctx.CustomerOrderInfos.Where(filter) on w.CustomerOrderID equals o.CustomerOrderID where o.IsHold == true && l.AbnormalStatus == abnormalStatus orderby o.CustomerOrderID descending select new CustomerOrderInfoExt { CustomerCode = o.CustomerCode, CustomerOrderID = o.CustomerOrderID, CustomerOrderNumber = o.CustomerOrderNumber, WayBillNumber = w.WayBillNumber, Status = o.Status, TrackingNumber = o.TrackingNumber, CountryCode = w.CountryCode, ShippingMethodId = w.InShippingMethodID, ShippingMethodName = w.InShippingMethodName, CreatedOn = o.CreatedOn, AbnormalDescription = l.AbnormalDescription, RawTrackingNumber = w.RawTrackingNumber, TransferOrderDate = w.TransferOrderDate }; return(list.ToPagedList(param.Page, param.PageSize)); }
public PagedList <CustomerOrderInfoExt> GetCustomerOrderInfoList(CustomerOrderParam param, int maxCustomerOrderId = 0) { var ctx = this.UnitOfWork as LMS_DbContext; Check.Argument.IsNotNull(ctx, "数据库对象"); IQueryable <CustomerOrderInfoExt> list; int deleteSatus = CustomerOrder.StatusEnum.Delete.GetStatusValue(); Expression <Func <CustomerOrderInfo, bool> > filter = o => true; Expression <Func <WayBillInfo, bool> > filterWayBill = o => true; filter = filter.AndIf(o => o.IsHold == param.IsHold.Value, param.IsHold.HasValue) .AndIf(o => o.CustomerCode == param.CustomerCode, !param.CustomerCode.IsNullOrWhiteSpace()) .AndIf(o => o.Status == param.Status.Value, param.Status.HasValue) .AndIf(o => o.Status != deleteSatus, !param.Status.HasValue) .AndIf(o => o.CustomerOrderID <= maxCustomerOrderId, maxCustomerOrderId > 0) ; //Expression<Func<InStorageInfo, bool>> filterInStorage = o => true; //Expression<Func<OutStorageInfo, bool>> filterOutStorage = o => true; //Func<IQueryable<WayBillInfo>, IOrderedQueryable<WayBillInfo>> orderFunc; if (!string.IsNullOrWhiteSpace(param.SearchContext)) { var numberList = param.SearchContext.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries) .ToList(); if (param.SearchWhere.HasValue && numberList.Count > 0) { switch (WayBill.ParseToSearchFilter(param.SearchWhere.Value)) { case WayBill.SearchFilterEnum.WayBillNumber: filterWayBill = filterWayBill.And(p => numberList.Contains(p.WayBillNumber)); break; case WayBill.SearchFilterEnum.TrackingNumber: filter = filter.And(p => numberList.Contains(p.TrackingNumber)); break; case WayBill.SearchFilterEnum.CustomerOrderNumber: filter = filter.And(p => numberList.Contains(p.CustomerOrderNumber)); break; } } } else if (!param.CustomerOrderNumber.IsNullOrWhiteSpace()) { var numberList = param.CustomerOrderNumber.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries) .ToList(); if (numberList.Count > 0) { string number = numberList[0]; filter = numberList.Count == 1 ? filter.And(o => o.CustomerOrderNumber == number) : filter.And(o => numberList.Contains(o.CustomerOrderNumber)); } } if (param.IsReceived) { filterWayBill = filterWayBill .AndIf(o => o.InStorageCreatedOn >= param.CreatedOnFrom.Value, param.CreatedOnFrom.HasValue) .AndIf(o => o.InStorageCreatedOn <= param.CreatedOnTo.Value, param.CreatedOnTo.HasValue); } else if (param.IsDeliver) { filterWayBill = filterWayBill .AndIf(o => o.OutStorageCreatedOn >= param.CreatedOnFrom.Value, param.CreatedOnFrom.HasValue) .AndIf(o => o.OutStorageCreatedOn <= param.CreatedOnTo.Value, param.CreatedOnTo.HasValue); } else { filter = filter .AndIf(o => o.CreatedOn >= param.CreatedOnFrom.Value, param.CreatedOnFrom.HasValue) .AndIf(o => o.CreatedOn <= param.CreatedOnTo.Value, param.CreatedOnTo.HasValue); } filter = filter .AndIf(o => o.ShippingMethodId == param.ShippingMethodId.Value, param.ShippingMethodId.HasValue) .AndIf(o => o.ShippingInfo.CountryCode == param.CountryCode, !param.CountryCode.IsNullOrWhiteSpace()) .AndIf(o => o.IsPrinted == param.IsPrinted.Value, param.IsPrinted.HasValue); //} if (param.SearchWhere.HasValue && !string.IsNullOrWhiteSpace(param.SearchContext)) { if (param.IsDeliver) { list = from w in ctx.WayBillInfos.Where(filterWayBill) join o in ctx.CustomerOrderInfos.Where(filter) on w.CustomerOrderID equals o.CustomerOrderID orderby w.OutStorageCreatedOn descending select new CustomerOrderInfoExt { CustomerCode = o.CustomerCode, CustomerOrderID = o.CustomerOrderID, CustomerOrderNumber = o.CustomerOrderNumber, WayBillNumber = w.WayBillNumber, Status = o.Status, TrackingNumber = o.TrackingNumber, RawTrackingNumber = w.RawTrackingNumber, CountryCode = w.CountryCode, Weight = w.Weight ?? 0, SettleWeight = w.SettleWeight, Width = w.Width ?? 0, Height = w.Height ?? 0, Length = w.Length ?? 0, ShippingMethodId = w.InShippingMethodID, ShippingMethodName = w.InShippingMethodName, CreatedOn = w.OutStorageCreatedOn ?? DateTime.Now, TransferOrderDate = w.TransferOrderDate, }; } else if (param.IsReceived) { list = from w in ctx.WayBillInfos.Where(filterWayBill) //join i in ctx.InStorageInfos.Where(filterInStorage) on w.InStorageID equals i.InStorageID join o in ctx.CustomerOrderInfos.Where(filter) on w.CustomerOrderID equals o.CustomerOrderID orderby w.InStorageCreatedOn descending select new CustomerOrderInfoExt { CustomerCode = o.CustomerCode, CustomerOrderID = o.CustomerOrderID, CustomerOrderNumber = o.CustomerOrderNumber, WayBillNumber = w.WayBillNumber, Status = o.Status, TrackingNumber = o.TrackingNumber, RawTrackingNumber = w.RawTrackingNumber, CountryCode = w.CountryCode, Weight = w.Weight ?? 0, SettleWeight = w.SettleWeight, Width = w.Width ?? 0, Height = w.Height ?? 0, Length = w.Length ?? 0, ShippingMethodId = w.InShippingMethodID, ShippingMethodName = w.InShippingMethodName, CreatedOn = w.InStorageCreatedOn ?? DateTime.Now, TransferOrderDate = w.TransferOrderDate, }; } else { list = from w in ctx.WayBillInfos.Where(filterWayBill) join o in ctx.CustomerOrderInfos.Where(filter) on w.CustomerOrderID equals o.CustomerOrderID orderby o.CreatedOn descending select new CustomerOrderInfoExt { CustomerCode = o.CustomerCode, CustomerOrderID = o.CustomerOrderID, CustomerOrderNumber = o.CustomerOrderNumber, WayBillNumber = w.WayBillNumber, Status = o.Status, TrackingNumber = o.TrackingNumber, RawTrackingNumber = w.RawTrackingNumber, CountryCode = w.CountryCode, Weight = w.Weight ?? 0, SettleWeight = w.SettleWeight, Width = w.Width ?? 0, Height = w.Height ?? 0, Length = w.Length ?? 0, ShippingMethodId = w.InShippingMethodID, ShippingMethodName = w.InShippingMethodName, CreatedOn = o.CreatedOn, TransferOrderDate = w.TransferOrderDate, Remark = o.Remark, }; } } else { //if (param.IsDeliver) //{ // list = from o in ctx.CustomerOrderInfos.Where(filter) // join w in ctx.WayBillInfos.Where(filterWayBill) on o.CustomerOrderID equals w.CustomerOrderID // into Grp // from grp in Grp.DefaultIfEmpty() // orderby grp.TransferOrderDate descending, grp.CreatedOn descending // select new CustomerOrderInfoExt // { // CustomerCode = o.CustomerCode, // CustomerOrderID = o.CustomerOrderID, // CustomerOrderNumber = o.CustomerOrderNumber, // WayBillNumber = grp.WayBillNumber, // Status = o.Status, // TrackingNumber = o.TrackingNumber, // RawTrackingNumber = grp.RawTrackingNumber, // CountryCode = o.ShippingInfo.CountryCode, // Weight = grp.Weight ?? 0, // SettleWeight = grp.SettleWeight, // Width = grp.Width ?? 0, // Height = grp.Height ?? 0, // Length = grp.Length ?? 0, // ShippingMethodId = o.ShippingMethodId, // ShippingMethodName = o.ShippingMethodName, // CreatedOn = grp.CreatedOn, // TransferOrderDate = grp.TransferOrderDate, // }; //}else if (param.IsReceived) //{ // list = from o in ctx.CustomerOrderInfos.Where(filter) // join w in ctx.WayBillInfos.Where(filterWayBill) on o.CustomerOrderID equals w.CustomerOrderID // join i in ctx.InStorageInfos.Where(filterInStorage) on w.InStorageID equals i.InStorageID into Grp // from grp in Grp.DefaultIfEmpty() // orderby w.TransferOrderDate descending, grp.CreatedOn descending // select new CustomerOrderInfoExt // { // CustomerCode = o.CustomerCode, // CustomerOrderID = o.CustomerOrderID, // CustomerOrderNumber = o.CustomerOrderNumber, // WayBillNumber = w.WayBillNumber, // Status = o.Status, // TrackingNumber = o.TrackingNumber, // RawTrackingNumber = w.RawTrackingNumber, // CountryCode = o.ShippingInfo.CountryCode, // Weight = w.Weight ?? 0, // SettleWeight = w.SettleWeight, // Width = w.Width ?? 0, // Height = w.Height ?? 0, // Length = w.Length ?? 0, // ShippingMethodId = o.ShippingMethodId, // ShippingMethodName = o.ShippingMethodName, // CreatedOn = grp.CreatedOn, // TransferOrderDate = w.TransferOrderDate, // }; //} //else //{ if (param.Status.HasValue) { switch (CustomerOrder.ParseToStatus(param.Status.Value)) { case CustomerOrder.StatusEnum.None: case CustomerOrder.StatusEnum.OK: case CustomerOrder.StatusEnum.SubmitFail: list = from o in ctx.CustomerOrderInfos.Where(filter) orderby o.CreatedOn descending select new CustomerOrderInfoExt { CustomerCode = o.CustomerCode, CustomerOrderID = o.CustomerOrderID, CustomerOrderNumber = o.CustomerOrderNumber, WayBillNumber = "", Status = o.Status, TrackingNumber = o.TrackingNumber, RawTrackingNumber = "", CountryCode = "", Weight = o.Weight, SettleWeight = 0, Width = o.Width, Height = o.Height, Length = o.Length, ShippingMethodId = o.ShippingMethodId, ShippingMethodName = o.ShippingMethodName, CreatedOn = o.CreatedOn, TransferOrderDate = null, Remark = o.Remark, }; break; default: list = from o in ctx.CustomerOrderInfos.Where(filter) join w in ctx.WayBillInfos.Where(filterWayBill) on o.CustomerOrderID equals w.CustomerOrderID into Grp from grp in Grp.DefaultIfEmpty() orderby grp.TransferOrderDate descending, o.CreatedOn descending, grp.WayBillNumber descending select new CustomerOrderInfoExt { CustomerCode = o.CustomerCode, CustomerOrderID = o.CustomerOrderID, CustomerOrderNumber = o.CustomerOrderNumber, WayBillNumber = grp.WayBillNumber, Status = o.Status, TrackingNumber = o.TrackingNumber, RawTrackingNumber = grp.RawTrackingNumber, CountryCode = grp.CountryCode, Weight = grp.Weight ?? 0, SettleWeight = grp.SettleWeight, Width = grp.Width ?? 0, Height = grp.Height ?? 0, Length = grp.Length ?? 0, ShippingMethodId = o.ShippingMethodId, ShippingMethodName = o.ShippingMethodName, CreatedOn = o.CreatedOn, TransferOrderDate = grp.TransferOrderDate, Remark = o.Remark, }; break; } } else { list = from o in ctx.CustomerOrderInfos.Where(filter) join w in ctx.WayBillInfos.Where(filterWayBill) on o.CustomerOrderID equals w.CustomerOrderID into Grp from grp in Grp.DefaultIfEmpty() orderby grp.TransferOrderDate descending, o.CreatedOn descending, grp.WayBillNumber descending select new CustomerOrderInfoExt { CustomerCode = o.CustomerCode, CustomerOrderID = o.CustomerOrderID, CustomerOrderNumber = o.CustomerOrderNumber, WayBillNumber = grp.WayBillNumber, Status = o.Status, TrackingNumber = o.TrackingNumber, RawTrackingNumber = grp.RawTrackingNumber, CountryCode = grp.CountryCode, Weight = grp.Weight ?? 0, SettleWeight = grp.SettleWeight, Width = grp.Width ?? 0, Height = grp.Height ?? 0, Length = grp.Length ?? 0, ShippingMethodId = o.ShippingMethodId, ShippingMethodName = o.ShippingMethodName, CreatedOn = o.CreatedOn, TransferOrderDate = grp.TransferOrderDate, Remark = o.Remark, }; } //} } return(list.ToPagedList(param.Page, param.PageSize)); }