protected override Expression <Func <Purchase, bool> > GetExpression() { if (!string.IsNullOrWhiteSpace(Keyword)) { ExpressionObj = x => x.OrderNumber.ToLower().Contains(Keyword) || x.ShipmentTrackingNo.ToLower().Contains(Keyword); } if (ParentId.IdIsOk()) { ExpressionObj = ExpressionObj.And(x => x.SupplierId == ParentId); } if (SupplierId.IdIsOk() && SupplierId != new Guid().ToString()) { ExpressionObj = ExpressionObj.And(x => x.SupplierId == SupplierId); } if (WarehouseId.IdIsOk() && WarehouseId != new Guid().ToString()) { this.ExpressionObj = this.ExpressionObj.And(x => x.WarehouseId == WarehouseId); } ExpressionObj = ExpressionObj.And(x => x.ShopId == ShopId); ExpressionObj = ExpressionObj.And(GenerateBaseEntityExpression()); return(ExpressionObj); }
protected override Expression <Func <SaleDetail, bool> > GetExpression() { if (!string.IsNullOrWhiteSpace(ParentId)) { ExpressionObj = ExpressionObj.And(x => x.SaleId == ParentId); } if (!string.IsNullOrWhiteSpace(ProductDetailId)) { ExpressionObj = ExpressionObj.And(x => x.ProductDetailId == ProductDetailId); } if (WarehouseId.IdIsOk()) { this.ExpressionObj = this.ExpressionObj.And(x => x.WarehouseId == WarehouseId); } //if (string.IsNullOrWhiteSpace(OrderState)) //{ // OrderState state = (OrderState)Enum.Parse(typeof(OrderState), OrderState); // ExpressionObj = this.ExpressionObj.And(x => x.Sale.OrderState ==) //} ExpressionObj = ExpressionObj.And(x => x.ShopId == ShopId); ExpressionObj = ExpressionObj.And(GenerateBaseEntityExpression()); return(ExpressionObj); }
protected override Expression <Func <PurchaseDetail, bool> > GetExpression() { if (!string.IsNullOrWhiteSpace(Keyword)) { ExpressionObj = x => x.Remarks.ToLower().Contains(Keyword); } if (!string.IsNullOrWhiteSpace(ParentId)) { ExpressionObj = ExpressionObj.And(x => x.PurchaseId == ParentId); } if (!string.IsNullOrWhiteSpace(ProductDetailId)) { ExpressionObj = ExpressionObj.And(x => x.ProductDetailId == ProductDetailId); } if (WarehouseId.IdIsOk()) { this.ExpressionObj = this.ExpressionObj.And(x => x.WarehouseId == WarehouseId); } ExpressionObj = ExpressionObj.And(x => x.ShopId == ShopId); ExpressionObj = ExpressionObj.And(GenerateBaseEntityExpression()); return(ExpressionObj); }
public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hash = 17; // Suitable nullity checks etc, of course :) hash = hash * 23 + OrderNumber.GetHashCode(); hash = hash * 23 + WarehouseId.GetHashCode(); hash = hash * 23 + WarehousePalletId.GetHashCode(); return(hash); } }
protected override IAsyncResult BeginExecute( AsyncCodeActivityContext context, AsyncCallback callback, object state) { InventoryLookupAsyncArgs parameters = new InventoryLookupAsyncArgs { ItemId = ItemId.Get(context), WarehouseId = WarehouseId.Get(context), RequestedQty = RequestedQty.Get(context), }; Func <InventoryLookupAsyncArgs, Int32> asyncWork = args => Lookup(args); context.UserState = asyncWork; return(asyncWork.BeginInvoke(parameters, callback, state)); }
protected override int Execute(CodeActivityContext context) { Int32 availableInventory = 0; Int32 warehouseId = WarehouseId.Get(context); Dictionary <Int32, Int32> warehouse = null; if (_warehouses.TryGetValue(warehouseId, out warehouse)) { Int32 itemId = ItemId.Get(context); if (warehouse.TryGetValue(itemId, out availableInventory)) { Int32 requestedQty = RequestedQty.Get(context); if (availableInventory > requestedQty) { availableInventory = requestedQty; } } } return(availableInventory); }
public string this[string columnName] { get { if (columnName == "AdjustmentNo") { if (string.IsNullOrEmpty(AdjustmentNo)) { return("Adjustment # is required"); } } if (columnName == "WarehouseId") { if (string.IsNullOrEmpty(WarehouseId.ToString())) { return("Warehouse required"); } } return(string.Empty); } }
protected override Expression <Func <Sale, bool> > GetExpression() { if (!string.IsNullOrWhiteSpace(Keyword)) { ExpressionObj = x => x.OrderNumber.ToLower().Contains(Keyword) || x.OrderReferenceNumber.ToLower().Contains(Keyword) || x.CustomerPhone.ToLower().Contains(Keyword) || x.CustomerName.ToLower().Contains(Keyword); } if (this.SaleChannel != SaleChannel.All) { ExpressionObj = ExpressionObj.And(x => x.SaleChannel == this.SaleChannel); } if (this.SaleFrom != SaleFrom.All) { ExpressionObj = ExpressionObj.And(x => x.SaleFrom == this.SaleFrom); } if (this.OrderState != All) { OrderState state = (OrderState)Enum.Parse(typeof(OrderState), this.OrderState); ExpressionObj = ExpressionObj.And(x => x.OrderState == state); } if (!string.IsNullOrWhiteSpace(DeliverymanId)) { this.ExpressionObj = this.ExpressionObj.And(x => x.DeliverymanId == DeliverymanId); } if (!string.IsNullOrWhiteSpace(Thana) && Thana != All) { this.ExpressionObj = this.ExpressionObj.And(x => x.Address.Thana == Thana); } this.ExpressionObj = this.ExpressionObj.And(x => x.IsDealerSale == this.IsDealerSale); if (OnlyDues) { this.ExpressionObj = this.ExpressionObj.And(x => x.DueAmount >= 1 && x.OrderState != Model.OrderState.Cancel); } if (IsDealerSale) { if (ParentId.IdIsOk()) { this.ExpressionObj = this.ExpressionObj.And(x => x.DealerId == ParentId); } } else { if (ParentId.IdIsOk()) { this.ExpressionObj = this.ExpressionObj.And(x => x.CustomerId == ParentId); } } if (SalesmanId.IdIsOk()) { this.ExpressionObj = this.ExpressionObj.And(x => x.EmployeeInfoId == SalesmanId); } if (WarehouseId.IdIsOk() && WarehouseId != new Guid().ToString()) { this.ExpressionObj = this.ExpressionObj.And(x => x.WarehouseId == WarehouseId); } //if (WarehouseId == new Guid().ToString()) //{ // this.ExpressionObj = this.ExpressionObj.And(x => x.WarehouseId == null); //} this.ExpressionObj = this.ExpressionObj.And(x => x.IsTaggedSale == IsTaggedSale); if (IsTaggedSale) { this.ExpressionObj = this.ExpressionObj.And(x => x.SaleTag == SaleTag); } ExpressionObj = ExpressionObj.And(x => x.ShopId == ShopId); ExpressionObj = ExpressionObj.And(GenerateBaseEntityExpression()); if (!string.IsNullOrWhiteSpace(DateSearchColumn)) { switch (DateSearchColumn) { case "Created": ExpressionObj = ExpressionObj.And(x => DbFunctions.TruncateTime(x.Created) >= StartDate && DbFunctions.TruncateTime(x.Created) <= EndDate); break; case "OrderDate": ExpressionObj = ExpressionObj.And(x => DbFunctions.TruncateTime(x.OrderDate) >= StartDate && DbFunctions.TruncateTime(x.OrderDate) <= EndDate); break; case "DeliveryDate": ExpressionObj = ExpressionObj.And(x => DbFunctions.TruncateTime(x.RequiredDeliveryDateByCustomer) >= StartDate && DbFunctions.TruncateTime(x.RequiredDeliveryDateByCustomer) <= EndDate); break; default: ExpressionObj = ExpressionObj.And(x => DbFunctions.TruncateTime(x.Modified) >= StartDate && DbFunctions.TruncateTime(x.Modified) <= EndDate); break; } } return(ExpressionObj); }
/// <summary>绑定数据源 /// </summary> protected void GridGoodsStock_NeedDataSource(object source, GridNeedDataSourceEventArgs e) { IList <StockTurnOverInfo> stockTurnOverList = new List <StockTurnOverInfo>(); if (!WarehouseId.Equals(Guid.Empty)) { //选择了责任人,则获取当前责任人负责的商品ID集合 var goodsIds = new List <Guid>(); if (PersonnelId != Guid.Empty || CompanyId != Guid.Empty) { goodsIds = _purchaseSet.GetGoodsIdByPersonnelId(PersonnelId, CompanyId).ToList(); } //根据条件获取商品信息 List <GoodsPerformance> goodsList = _goodsCenterSao.GetGoodsPerformanceList(GoodsClassId, goodsIds, GoodsNameOrCode, CB_IsPerformance.Checked); var tempGoodsIds = new List <Guid>(); //var isNeedStock = true; switch (State) { case 0: //全部 tempGoodsIds = goodsList.Select(ent => ent.GoodsId).ToList(); break; case 1: //下架缺货有库存 //备注: PurchaseState 0下架, 1上架 tempGoodsIds.AddRange(from item in goodsList where item.IsScarcity || item.PurchaseState == 0 select item.GoodsId); //isNeedStock = true; break; case 2: //无销售商品 tempGoodsIds.AddRange(from item in goodsList where !_salesDic.ContainsKey(item.GoodsId) select item.GoodsId); var newGoodsList = tempGoodsIds.Select(goodsId => goodsList.FirstOrDefault(ent => ent.GoodsId == goodsId)).ToList(); goodsList.Clear(); goodsList.AddRange(newGoodsList); break; } //获取商品库存信息 var goodsStockList = WMSSao.StockSearchByGoodsIds(tempGoodsIds, WarehouseId, FilialeId) ?? new Dictionary <Guid, int>(); //获取所有的商品采购设置 var allGoodsPurchaseSet = _purchaseSet.GetAllPurchaseSet(WarehouseId); var companyIdList = allGoodsPurchaseSet.Select(p => p.CompanyId).Distinct().ToList(); //获取商品的最后一次进货价信息 var goodsPurchaseLastPriceInfoList = _storageRecordDao.GetGoodsPurchaseLastPriceInfoByWarehouseId(WarehouseId); goodsPurchaseLastPriceInfoList = goodsPurchaseLastPriceInfoList.Where(p => tempGoodsIds.Contains(p.GoodsId) && companyIdList.Contains(p.ThirdCompanyId)).ToList(); foreach (var goodsInfo in goodsList) { // ReSharper disable once UseObjectOrCollectionInitializer var info = new StockTurnOverInfo(); info.GoodsID = goodsInfo.GoodsId; info.GoodsName = goodsInfo.GoodsName; info.GoodsCode = goodsInfo.GoodsCode; info.IsStatisticalPerformance = goodsInfo.IsStatisticalPerformance; info.IsStatisticalPerformanceStr = goodsInfo.IsStatisticalPerformance ? "√" : string.Empty; info.IsScarcity = goodsInfo.IsScarcity; info.IsScarcityStr = goodsInfo.IsScarcity ? "√" : string.Empty; info.State = goodsInfo.PurchaseState == 0; info.IsStateStr = goodsInfo.PurchaseState == 0 ? "√" : string.Empty; //库存信息获取 var stockQuantity = goodsStockList.ContainsKey(goodsInfo.GoodsId) ? goodsStockList[goodsInfo.GoodsId] : 0; if (stockQuantity <= 0) { continue; } info.StockNums = stockQuantity; if (!_salesDic.ContainsKey(goodsInfo.GoodsId)) { info.StockNumSort = stockQuantity; } //责任人供应商信息获取 var tempGoodsPurchaseSetInfo = allGoodsPurchaseSet.FirstOrDefault(ent => ent.GoodsId == goodsInfo.GoodsId); //根据商品id获取供应商 var companyId = tempGoodsPurchaseSetInfo != null ? tempGoodsPurchaseSetInfo.CompanyId : Guid.Empty; decimal unitPrice = 0; GoodsPurchaseLastPriceInfo goodsPurchaseLastPriceInfo = null; if (goodsPurchaseLastPriceInfoList.Count > 0) { goodsPurchaseLastPriceInfo = goodsPurchaseLastPriceInfoList.FirstOrDefault(p => p.GoodsId.Equals(goodsInfo.GoodsId) && p.ThirdCompanyId.Equals(companyId)); unitPrice = goodsPurchaseLastPriceInfo != null ? goodsPurchaseLastPriceInfo.UnitPrice : 0; } info.RecentInPrice = unitPrice; info.RecentCDate = (goodsPurchaseLastPriceInfo != null ? goodsPurchaseLastPriceInfo.LastPriceDate : DateTime.MinValue).ToString("yyyy-MM-dd"); if (tempGoodsPurchaseSetInfo != null) { info.PersonResponsible = tempGoodsPurchaseSetInfo.PersonResponsible; var firstOrDefault = PersonnelList.FirstOrDefault(ent => ent.PersonnelId == tempGoodsPurchaseSetInfo.PersonResponsible); if (firstOrDefault != null) { info.PersonResponsibleName = firstOrDefault.RealName; } info.CompanyId = tempGoodsPurchaseSetInfo.CompanyId; info.CompanyName = tempGoodsPurchaseSetInfo.CompanyName; } //销售数量 if (_salesDic.ContainsKey(goodsInfo.GoodsId)) { info.SaleNums = _salesDic[goodsInfo.GoodsId]; info.SaleNumSort = 1; info.StockNumSort = 0; } #region [计算商品库存周转情况(天数)] if (info.State && info.StockNums == 0) { info.TurnOverDays = 0; info.TurnOverStr = "下架"; } else if (info.State && info.StockNums != 0) { info.TurnOverDays = 0; info.TurnOverStr = "下架有库存"; } else if (info.IsScarcity && info.StockNums == 0) { info.TurnOverDays = 0; info.TurnOverStr = "缺货"; } else if (info.IsScarcity && info.StockNums != 0) { info.TurnOverDays = 0; info.TurnOverStr = "缺货有库存"; } else if (info.StockNums == 0) { info.TurnOverDays = 0; info.TurnOverStr = "0天"; } else if (info.SaleNums > 0) { var tempTurnOverDays = info.StockNums * 30 / info.SaleNums; info.TurnOverDays = tempTurnOverDays; info.TurnOverStr = tempTurnOverDays + "天"; } else { info.TurnOverDays = 0; info.TurnOverStr = "无销售"; } #endregion #region [计算商品报备周转天数] if (_weightedAverageSaleDic.ContainsKey(info.GoodsID)) { var weightedAverageSale = _weightedAverageSaleDic[info.GoodsID]; if (_weightedAverageSaleDic[info.GoodsID] != 0) { info.TurnOverByFiling = info.StockNums * 30 / weightedAverageSale + "天"; } } #endregion stockTurnOverList.Add(info); } } var pageIndex = GridGoodsStock.CurrentPageIndex; var pageSize = GridGoodsStock.PageSize; stockTurnOverList = stockTurnOverList.OrderBy(ent => ent.SaleNumSort).ThenByDescending(ent => ent.StockNumSort).ThenByDescending(ent => ent.TurnOverDays).ToList(); GridGoodsStock.DataSource = stockTurnOverList.Skip(pageIndex * pageSize).Take(pageSize).ToList(); GridGoodsStock.VirtualItemCount = stockTurnOverList.Count; }