예제 #1
0
        public static List <OrderSearchEntity> SearchOrder(IQueryable <OrderSearchEntity> billData, IEnumerable <IFilterDescriptor> billFilters, IEnumerable <IFilterDescriptor> detailsFilters, int pageIndex, int pageSize, ref int totalCount)
        {
            var lp = _query.LinqOP;
            var orderDetailsContext = lp.GetDataContext <BillOrderDetails>();
            var brands   = VMGlobal.PoweredBrands;
            var brandIDs = brands.Select(b => b.ID);

            billData = billData.Where(o => brandIDs.Contains(o.BrandID));
            if (FilterConditionHelper.IsConditionSetted(detailsFilters, "StyleCode"))
            {
                var productContext = lp.GetDataContext <ViewProduct>();
                var pdata          = from p in productContext
                                     where brandIDs.Contains(p.BrandID)
                                     select new { ProductID = p.ProductID, StyleCode = p.StyleCode };
                IEnumerable <int> pIDs = ((IQueryable <dynamic>)pdata.Where(detailsFilters)).ToList().Select(p => (int)p.ProductID);
                if (pIDs.Count() == 0)
                {
                    return(null);
                }
                else
                {
                    billData = from d in billData
                               where orderDetailsContext.Any(od => od.BillID == d.BillID && pIDs.Contains(od.ProductID))
                               select d;
                }
            }
            var filtedData = (IQueryable <OrderSearchEntity>)billData.Where(billFilters);

            totalCount = filtedData.Count();
            //var datas = new QueryableCollectionView(filtedData.OrderBy(o => o.BillID).Skip(pageIndex * pageSize).Take(pageSize).ToList()); //filtedData.ToList();
            var orders = filtedData.OrderBy(o => o.BillID).Skip(pageIndex * pageSize).Take(pageSize).ToList();//(List<OrderSearchEntity>)datas.SourceCollection;
            var bIDs   = orders.Select(o => (int)o.BillID);
            var sum    = orderDetailsContext.Where(o => bIDs.Contains(o.BillID) && o.IsDeleted == false).GroupBy(o => o.BillID).Select(g => new { BillID = g.Key, OrderQuantity = g.Sum(o => o.Quantity), CancelQuantity = g.Sum(o => o.QuaCancel), DeliveredQuantity = g.Sum(o => o.QuaDelivered) }).ToList();

            orders.ForEach(d =>
            {
                d.BrandName = brands.Find(o => d.BrandID == o.ID).Name;
                var order   = sum.Find(o => o.BillID == d.BillID);
                if (order != null)
                {
                    d.订货数量 = order.OrderQuantity;
                    d.取消量  = order.CancelQuantity;
                    d.已发数量 = order.DeliveredQuantity;
                    var realOrderQuantity = d.订货数量 - d.取消量;
                    d.发货状态 = realOrderQuantity == d.已发数量 ? "已完成" : (d.已发数量 == 0 ? "未发货" : (realOrderQuantity > d.已发数量 ? "部分已发货" : "数据有误"));
                }
            });
            return(orders);
        }
        private List <BillSubcontractSearchEntity> SearchSubcontract(IQueryable <BillSubcontractSearchEntity> billData)
        {
            var lp             = VMGlobal.ManufacturingQuery.LinqOP;
            var detailsContext = lp.GetDataContext <BillSubcontractDetails>();
            var brands         = VMGlobal.PoweredBrands;
            var brandIDs       = brands.Select(b => b.ID);

            billData = billData.Where(o => brandIDs.Contains(o.BrandID));
            if (FilterConditionHelper.IsConditionSetted(DetailsDescriptors, "StyleCode") || FilterConditionHelper.IsConditionSetted(DetailsDescriptors, "DeliveryDate"))
            {
                var productContext = lp.GetDataContext <ViewProduct>();
                var detailFilter   = from detail in detailsContext
                                     from p in productContext
                                     where detail.ProductID == p.ProductID && brandIDs.Contains(p.BrandID)
                                     select new DetailsFiltetEntity {
                    ProductID = p.ProductID, StyleCode = p.StyleCode, DeliveryDate = detail.DeliveryDate
                };
                detailFilter = (IQueryable <DetailsFiltetEntity>)detailFilter.Where(DetailsDescriptors);
                var pIDs = detailFilter.ToList().Select(p => p.ProductID);
                if (pIDs.Count() == 0)
                {
                    return(null);
                }
                billData = from d in billData
                           where detailsContext.Any(od => od.BillID == d.ID && pIDs.Contains(od.ProductID))
                           select d;
            }
            var filtedData = (IQueryable <BillSubcontractSearchEntity>)billData.Where(FilterDescriptors);

            TotalCount = filtedData.Count();
            //var datas = new QueryableCollectionView(filtedData.OrderBy(o => o.BillID).Skip(pageIndex * pageSize).Take(pageSize).ToList()); //filtedData.ToList();
            var subcontracts = filtedData.OrderBy(o => o.ID).Skip(PageIndex * PageSize).Take(PageSize).ToList();//(List<OrderSearchEntity>)datas.SourceCollection;
            var bIDs         = subcontracts.Select(o => (int)o.ID);
            var sum          = detailsContext.Where(o => bIDs.Contains(o.BillID) && o.IsDeleted == false).GroupBy(o => o.BillID).Select(g => new { BillID = g.Key, Quantity = g.Sum(o => o.Quantity), QuaCancel = g.Sum(o => o.QuaCancel), QuaCompleted = g.Sum(o => o.QuaCompleted) }).ToList();

            subcontracts.ForEach(d =>
            {
                d.BrandName           = brands.Find(o => d.BrandID == o.ID).Name;
                var subcontract       = sum.Find(o => o.BillID == d.ID);
                d.Quantity            = subcontract.Quantity;
                d.QuaCancel           = subcontract.QuaCancel;
                d.QuaCompleted        = subcontract.QuaCompleted;
                var realOrderQuantity = d.Quantity - d.QuaCancel;
                d.StatusName          = realOrderQuantity == d.QuaCompleted ? "已完成" : (d.QuaCompleted == 0 ? "未交货" : (realOrderQuantity > d.QuaCompleted ? "部分已交货" : "数据有误"));
            });
            return(subcontracts);
        }
예제 #3
0
 public static IEnumerable <int> GetProductIDArrayWithCondition(IEnumerable <IFilterDescriptor> filterDescriptors, IEnumerable <int> brandIDs = null)
 {
     if (FilterConditionHelper.IsConditionSetted(filterDescriptors, "StyleCode"))
     {
         if (brandIDs == null)
         {
             brandIDs = VMGlobal.PoweredBrands.Select(b => b.ID);
         }
         var productContext = VMGlobal.SysProcessQuery.LinqOP.GetDataContext <ViewProduct>();
         var pdata          = from p in productContext
                              where brandIDs.Contains(p.BrandID)
                              select new { ProductID = p.ProductID, StyleCode = p.StyleCode };
         //注意IQueryable<dynamic>类型的对象调用Where(filters)将产生0<>0的恒假条件
         IEnumerable <int> pIDs = ((IQueryable <dynamic>)pdata.Where(filterDescriptors)).ToList().Select(p => (int)p.ProductID);
         //if (pIDs.Count() == 0)
         //    return null;
         return(pIDs);
     }
     return(null);
 }
예제 #4
0
        protected override IEnumerable <VIPCard> SearchData()
        {
            List <VIPCardBO> vips = null;

            if (!FilterConditionHelper.IsConditionSetted(FilterDescriptors, "KindID"))
            {
                vips = base.SearchData().Select(o => new VIPCardBO(o)).ToList();
            }
            else
            {
                var cards = LinqOP.GetDataContext <VIPCard>();
                var maps  = LinqOP.GetDataContext <VIPCardKindMapping>();
                var data  = from card in cards
                            from map in maps
                            where card.ID == map.CardID
                            select new VIPCardEntityForSearch
                {
                    Birthday     = card.Birthday,
                    Code         = card.Code,
                    CustomerName = card.CustomerName,
                    KindID       = map.KindID,
                    Sex          = card.Sex,
                    MobilePhone  = card.MobilePhone,
                    ID           = card.ID
                };
                var filteredData = (IQueryable <VIPCardEntityForSearch>)data.Where(FilterDescriptors);
                var vids         = filteredData.Select(o => o.ID).Distinct().ToArray();
                var result       = cards.Where(o => vids.Contains(o.ID));
                TotalCount = result.Count();
                vips       = result.OrderBy(o => o.ID).Skip(PageIndex * PageSize).Take(PageSize).Select(o => new VIPCardBO(o)).ToList();
            }
            VIPCardVM.ApplyVIPKind(vips);
            vips.ForEach(o =>
            {
                if (!DownHierarchyOrganizationIDArray.Contains(o.OrganizationID))
                {
                    o.MobilePhone = "不可见";
                }
            });
            return(vips);
        }