/// <summary> /// 查询保健食品 /// </summary> /// <param name="keys"></param> /// <param name="index"></param> /// <param name="size"></param> /// <param name="pager"></param> /// <param name="ValidCondition"></param> /// <returns></returns> public System.Collections.Generic.IEnumerable <Business.Models.FoodModel> GetFoodByCondition(string keys, int index, int size, out BugsBox.Application.Core.PagerInfo pager, bool ValidCondition) { pager = PagerInfo.Validate(new PagerInfo { Index = index, Size = size }); try { var all = this.Queryable.Where(r => r.BusinessScopeCode.Contains("保健食品")); if (!string.IsNullOrEmpty(keys)) { all = all.Where(r => (r.Pinyin != null && r.Pinyin.ToUpper().Contains(keys.ToUpper())) || (r.ProductGeneralName != null && r.ProductGeneralName.Contains(keys)) || (r.DictionaryDosageCode != null && r.DictionaryDosageCode.Contains(keys)) || (r.DictionarySpecificationCode != null && r.DictionarySpecificationCode.Contains(keys))); } if (ValidCondition)//查询被锁定保健食品 { all = all.Where(r => r.Valid == false); } var c = from i in all join w in RepositoryProvider.Db.Warehouses on i.WareHouses equals w.Id join u in RepositoryProvider.Db.Users on i.CreateUserId equals u.Id select new Business.Models.FoodModel { BusinessScopeCode = i.BusinessScopeCode, CreateTime = i.CreateTime, CreateUserName = u.Employee.Name, DictionaryDosageCode = i.DictionaryDosageCode, DictionaryMeasurementUnitCode = i.DictionaryMeasurementUnitCode, DictionarySpecificationCode = i.DictionarySpecificationCode, DocCode = i.DocCode, Code = i.Code, DrugStorageTypeCode = i.DrugStorageTypeCode, FactoryName = i.FactoryName, Id = i.Id, IsApproval = i.IsApproval == true ? "审批通过" : "未审批通过", IsImport = i.IsImport == true ? "进口" : "非进口", LicensePermissionNumber = i.LicensePermissionNumber, LimitedUpPrice = i.LimitedUpPrice, MaxInventoryCount = i.MaxInventoryCount, MinInventoryCount = i.MinInventoryCount, PerformanceStandards = i.PerformanceStandards, Pinyin = i.Pinyin, Price = i.Price, ProductGeneralName = i.ProductGeneralName, SalePrice = i.SalePrice, Origin = i.Origin, LicensePermissionOutValidDate = i.PermitOutDate, Valid = i.Valid == true ? "有效" : "无效", ValidPeriod = i.ValidPeriod, WareHouses = w.Name, Locked = i.IsLock == true ? "锁定" : "未锁定", NotValidReason = i.ValidRemark, WareHouseZone = i.WareHouseZones, BarCode = i.BarCode, LimitedLowPrice = i.LimitedLowPrice, Contact = i.FactoryNameAbbreviation, Description = i.Description, }; pager.RecordCount = c.Count(); c = c.OrderBy(d => d.Code).ThenBy(r => r.ProductGeneralName); var records = c .Skip((pager.Index - 1) * pager.Size) .Take(pager.Size) .ToList(); records.ForEach(r => { if (!string.IsNullOrEmpty(r.WareHouseZone)) { Guid wzid = Guid.Parse(r.WareHouseZone); var wz = RepositoryProvider.Db.WarehouseZones.FirstOrDefault(u => u.Id == wzid); if (wz != null) { r.WareHouseZone = wz.Name; } } }); return(records); } catch (Exception ex) { return(null); } finally { this.Dispose(); } }
public PagerQuery(PagerInfo pager) { this.Pager = pager; this.DataList = Enumerable.Empty <TEntity>(); }
public System.Collections.Generic.IEnumerable <Business.Models.DeliveryTrasactionModel> GetDeliveryTransactionPaged(Business.Models.DeliveryIndexInput deliveryIndexInput, out BugsBox.Application.Core.PagerInfo pager, int pageindex, int pageSize) { PagerInfo pageInfo = new PagerInfo(); pageInfo.Index = pageindex; pageInfo.Size = pageSize; pageindex = pageindex - 1; int skipCount = pageindex * pageSize; var varDelivery = base.Queryable; if (deliveryIndexInput.DeliveryStatusValue > -1) { varDelivery = varDelivery.Where(p => p.DeliveryStatusValue == deliveryIndexInput.DeliveryStatusValue); } var c = from i in varDelivery join s in RepositoryProvider.Db.SalesOrders.Include(r => r.PurchaseUnit) on i.OrderID equals s.Id join o in RepositoryProvider.Db.OutInventorys.Include(r => r.SalesOutInventoryDetails) on i.OutInventoryID equals o.Id select new Business.Models.DeliveryTrasactionModel { Id = i.Id, OutInvetoryDocumentNumber = o.OrderOutInventoryCheckNumber, OutInvetoryId = o.Id, SalesOrderDocumentNumber = s.OrderCode, ReceivingCompasnyID = s.PurchaseUnitId, OutInventoryNumber = o.SalesOutInventoryDetails.Sum(r => r.OutAmount), SalesOrderId = s.Id, ReceivingCompasnyName = s.PurchaseUnit.Name, OutInventoryDateTime = i.CreateTime, Status = 0, }; var cc = from i in varDelivery join pr in RepositoryProvider.Db.PurchaseOrderReturns.Include(r => r.PurchaseOrderReturnDetails) on i.OrderID equals pr.Id join s in RepositoryProvider.Db.PurchaseOrders.Include(r => r.SupplyUnit) on pr.PurchaseOrderId equals s.Id select new Business.Models.DeliveryTrasactionModel { Id = i.Id, OutInvetoryDocumentNumber = pr.DocumentNumber, OutInvetoryId = s.Id, SalesOrderDocumentNumber = pr.DocumentNumber, ReceivingCompasnyID = s.SupplyUnitId, OutInventoryNumber = pr.PurchaseOrderReturnDetails.Sum(r => r.ReturnAmount), SalesOrderId = s.Id, ReceivingCompasnyName = s.SupplyUnit.Name, OutInventoryDateTime = i.CreateTime, Status = 1, }; c = cc.Count() > 0? c.Concat(cc):c; //合并采退和销售数据 if (!string.IsNullOrEmpty(deliveryIndexInput.OrderNumber)) { c = c.Where(r => r.OutInvetoryDocumentNumber.Contains(deliveryIndexInput.OrderNumber) || r.SalesOrderDocumentNumber.Contains(deliveryIndexInput.OrderNumber)); } if (!string.IsNullOrEmpty(deliveryIndexInput.ReceivingCompasnyName)) { c = c.Where(r => r.ReceivingCompasnyName.Contains(deliveryIndexInput.ReceivingCompasnyName)); } pageInfo.RecordCount = c.Count(); pager = pageInfo; c = c.OrderBy(r => r.OutInventoryDateTime); c = (skipCount == 0 ? c.Take(pageSize) : c.Skip(skipCount).Take(pageSize)); return(c); }
public virtual IEnumerable <T> Fetch(Expression <Func <T, bool> > predicate, Action <Orderable <T> > order, PagerInfo pager) { try { if (pager == null) { throw new NullReferenceException("分页对象不得为null"); } pager.Index = pager.Index < 1 ? 1 : pager.Index; pager.RecordCount = this.Count(predicate); pager.Size = pager.Size < 1 ? 20 : pager.Size; if (pager.RecordCount == 0) { pager.Index = 1; } return(Fetch(PreparePredicate(predicate), order, (pager.Index - 1) * pager.Size, pager.Size)); } catch (Exception ex) { return(HandleException <IEnumerable <T> >(string.Format("分页查询排序({0})出错", EntityName), ex)); } }