Ejemplo n.º 1
0
        private void btnFloatPrice_Click(object sender, RoutedEventArgs e)
        {
            RadButton btn    = (RadButton)sender;
            var       entity = btn.DataContext as CertificationBO;

            if (entity.StyleID != default(int))
            {
                FloatPriceTacticSelectWin win = new FloatPriceTacticSelectWin();
                win.DataContext         = _dataContext.GetFloatPriceTactics(entity.Style.Code);
                win.Owner               = View.Extension.UIHelper.GetAncestor <Window>(this);
                win.SelectionCompleted += delegate(OrganizationPriceFloat pf)
                {
                    if (_fpHelper == null)
                    {
                        _fpHelper = new FloatPriceHelper();
                    }
                    entity.Price = _fpHelper.GetFloatPrice(pf.OrganizationID, entity.Style.BYQID, entity.Style.Price);
                };
                win.ShowDialog();
            }
            else
            {
                MessageBox.Show("请先指定款号");
            }
        }
Ejemplo n.º 2
0
        protected override IEnumerable <ProStyle> SearchData()
        {
            var styles   = LinqOP.GetDataContext <ProStyle>();
            var brandIDs = VMGlobal.PoweredBrands.Select(o => o.ID);
            var byqs     = LinqOP.GetDataContext <ProBYQ>();
            var data     = from style in styles
                           from byq in byqs
                           where style.BYQID == byq.ID && brandIDs.Contains(byq.BrandID)
                           select new ProStyleBO
            {
                BoduanID   = style.BoduanID,
                BrandID    = byq.BrandID,
                BYQID      = style.BYQID,
                Code       = style.Code,
                CreateTime = style.CreateTime,
                CreatorID  = style.CreatorID,
                Flag       = style.Flag,
                ID         = style.ID,
                NameID     = style.NameID,
                //PictureUrl = style.PictureUrl,
                Price     = style.Price,
                CostPrice = style.CostPrice,
                Quarter   = byq.Quarter,
                UnitID    = style.UnitID,
                Year      = byq.Year
            };
            var temp = (IQueryable <ProStyleBO>)data.Where(FilterDescriptors);

            TotalCount = temp.Count();
            var result = temp.OrderBy(o => o.ID).Skip(PageIndex * PageSize).Take(PageSize).ToList();

            foreach (var r in result)
            {
                //r.BoduanName = VMGlobal.Boduans.Find(o => o.ID == r.BoduanID).Name;
                //r.Name = VMGlobal.ProNames.Find(o => o.ID == r.NameID).Name;
                //r.UnitName = VMGlobal.Units.Find(o => o.ID == r.UnitID).Name;
                if (VMGlobal.CurrentUser.OrganizationID != 1)
                {
                    r.CostPrice = _fpHelper.GetFloatPrice(OrganizationListVM.CurrentOrganization.ParentID, r.BYQID, r.Price);
                    r.Price     = _fpHelper.GetFloatPrice(VMGlobal.CurrentUser.OrganizationID, r.BYQID, r.Price);
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
        public static ObservableCollection <BillGoodReturnForSearch> SearchBillSubordinateGoodReturnForStoring()
        {
            var lp = VMGlobal.DistributionQuery.LinqOP;
            var childOrganizations = OrganizationListVM.CurrentOrganization.ChildrenOrganizations;
            var oids              = childOrganizations.Select(o => o.ID);
            var brands            = VMGlobal.PoweredBrands;
            var brandIDs          = brands.Select(b => b.ID);
            int status            = (int)BillGoodReturnStatusEnum.在途中;
            var goodreturnContext = lp.Search <BillGoodReturn>(o => o.Status == status && oids.Contains(o.OrganizationID) && brandIDs.Contains(o.BrandID));
            var billData          = from d in goodreturnContext
                                    select new BillGoodReturnForSearch
            {
                ID             = d.ID,
                OrganizationID = d.OrganizationID,
                Remark         = d.Remark,
                Code           = d.Code,
                BrandID        = d.BrandID,
                CreateTime     = d.CreateTime
            };
            var goodreturns    = billData.ToList();
            var detailsContext = lp.GetDataContext <BillGoodReturnDetails>();
            var bIDs           = goodreturns.Select(o => (int)o.ID);
            var detailQuery    = from detail in detailsContext
                                 where bIDs.Contains(detail.BillID)
                                 select new
            {
                detail.BillID,
                detail.ProductID,
                detail.Quantity
            };
            var details  = detailQuery.ToList();
            var pids     = details.Select(o => o.ProductID).ToArray();
            var products = lp.Search <ViewProduct>(o => pids.Contains(o.ProductID)).ToList();
            //var sum = detailsContext.Where(o => bIDs.Contains(o.BillID)).GroupBy(o => o.BillID).Select(g => new { BillID = g.Key, Quantity = g.Sum(o => o.Quantity) }).ToList();
            var sum = details.GroupBy(o => o.BillID).Select(g => new { BillID = g.Key, Quantity = g.Sum(o => o.Quantity) }).ToList();
            FloatPriceHelper fpHelper = new FloatPriceHelper();

            goodreturns.ForEach(d =>
            {
                d.OrganizationName = OrganizationListVM.CurrentOrganization.ChildrenOrganizations.Find(o => o.ID == d.OrganizationID).Name;
                d.BrandName        = brands.Find(o => d.BrandID == o.ID).Name;
                d.Quantity         = sum.Find(o => o.BillID == d.ID).Quantity;
                var tempDetails    = details.FindAll(o => o.BillID == d.ID);
                foreach (var detail in tempDetails)
                {
                    var product   = products.First(p => p.ProductID == detail.ProductID);
                    var price     = fpHelper.GetFloatPrice(VMGlobal.CurrentUser.OrganizationID, product.BYQID, product.Price);
                    d.TotalPrice += price * detail.Quantity;
                }
            });
            return(new ObservableCollection <BillGoodReturnForSearch>(goodreturns));
        }
Ejemplo n.º 4
0
 public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
 {
     try
     {
         int pid = (int)values[0];
         int oid = (int)values[1];
         return(_fpHelper.GetFloatPrice(oid, pid).ToString());//不转成string,竟然就不能绑定到前台UI控件的Text属性上,不知道这是MultiBinding特有的还是Binding也有这个情况
     }
     catch
     {
         return("0");
     }
 }
Ejemplo n.º 5
0
        protected override IEnumerable <StockStatisticsEntity> SearchData()
        {
            var lp             = VMGlobal.DistributionQuery.LinqOP;
            var provider       = VMGlobal.DistributionQuery.QueryProvider;
            var stockContext   = VMGlobal.DistributionQuery.LinqOP.GetDataContext <Stock>();
            var storageContext = VMGlobal.DistributionQuery.LinqOP.Search <Storage>(o => o.OrganizationID == VMGlobal.CurrentUser.OrganizationID && o.Flag);
            var productContext = lp.GetDataContext <ViewProduct>();
            var byqs           = VMGlobal.DistributionQuery.QueryProvider.GetTable <ProBYQ>("SysProcess.dbo.ProBYQ");
            var colors         = VMGlobal.DistributionQuery.QueryProvider.GetTable <ProColor>("SysProcess.dbo.ProColor");
            var brandIDs       = VMGlobal.PoweredBrands.Select(o => o.ID);

            var data = from stock in stockContext
                       from storage in storageContext
                       where stock.StorageID == storage.ID && stock.Quantity != 0
                       from product in productContext
                       where stock.ProductID == product.ProductID && brandIDs.Contains(product.BrandID)
                       from byq in byqs
                       where product.BYQID == byq.ID
                       from color in colors
                       where product.ColorID == color.ID
                       select new StockStatisticsEntity
            {
                StorageID = storage.ID,
                NameID    = product.NameID,
                StyleCode = product.StyleCode,
                ColorID   = product.ColorID,
                BYQID     = product.BYQID,
                Quantity  = stock.Quantity,
                Price     = product.Price,
                ProductID = product.ProductID,
                BrandID   = byq.BrandID,
                Year      = byq.Year,
                Quarter   = byq.Quarter,
                ColorCode = color.Code
            };
            var result = ((IQueryable <StockStatisticsEntity>)data.Where(FilterDescriptors)).ToList();

            foreach (var r in result)
            {
                r.ProductName = VMGlobal.ProNames.Find(o => o.ID == r.NameID).Name;
                r.BrandCode   = VMGlobal.PoweredBrands.Find(o => o.ID == r.BrandID).Code;
            }
            FloatPriceHelper fpHelper = new FloatPriceHelper();

            result.ForEach(o => o.Price = fpHelper.GetFloatPrice(VMGlobal.CurrentUser.OrganizationID, o.BYQID, o.Price));
            AmountCostMoney             = result.Sum(o => o.Price * o.Quantity);
            AmountQuantity = result.Sum(o => o.Quantity);
            OnPropertyChanged("AmountCostMoney");
            OnPropertyChanged("AmountQuantity");
            return(result);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 发货单查询(机构收货入库使用)
        /// </summary>
        public static List <DeliverySearchEntity> SearchBillDeliveryForStoring()
        {
            var lp = VMGlobal.DistributionQuery.LinqOP;
            var deliveryContext       = lp.GetDataContext <BillDelivery>();
            var deliveryDetailContext = lp.GetDataContext <BillDeliveryDetails>();
            var brandIDs  = VMGlobal.PoweredBrands.Select(o => o.ID);
            int status    = (int)BillDeliveryStatusEnum.在途中;
            var dataQuery = from d in deliveryContext
                            where d.ToOrganizationID == VMGlobal.CurrentUser.OrganizationID && d.Status == status && brandIDs.Contains(d.BrandID)
                            select new DeliverySearchEntity
            {
                ID         = d.ID,
                Remark     = d.Remark,
                Code       = d.Code,
                CreateTime = d.CreateTime,
                BrandID    = d.BrandID
            };
            var deliveries  = dataQuery.ToList();
            var bIDs        = deliveries.Select(o => (int)o.ID);
            var detailQuery = from detail in deliveryDetailContext
                              where bIDs.Contains(detail.BillID)
                              select new
            {
                detail.BillID,
                detail.ProductID,
                detail.Quantity
            };
            var details  = detailQuery.ToList();
            var pids     = details.Select(o => o.ProductID).ToArray();
            var products = lp.Search <ViewProduct>(o => pids.Contains(o.ProductID)).ToList();
            //var sum = deliveryDetailContext.Where(o => bIDs.Contains(o.BillID)).GroupBy(o => o.BillID).Select(g => new { BillID = g.Key, Quantity = g.Sum(o => o.Quantity) }).ToList();
            var sum = details.GroupBy(o => o.BillID).Select(g => new { BillID = g.Key, Quantity = g.Sum(o => o.Quantity) }).ToList();
            FloatPriceHelper fpHelper = new FloatPriceHelper();

            deliveries.ForEach(d =>
            {
                d.BrandName     = VMGlobal.PoweredBrands.Find(o => o.ID == d.BrandID).Name;
                d.Quantity      = sum.Find(o => o.BillID == d.ID).Quantity;
                var tempDetails = details.FindAll(o => o.BillID == d.ID);
                foreach (var detail in tempDetails)
                {
                    var product   = products.First(p => p.ProductID == detail.ProductID);
                    var price     = fpHelper.GetFloatPrice(VMGlobal.CurrentUser.OrganizationID, product.BYQID, product.Price);
                    d.TotalPrice += price * detail.Quantity;
                }
            });
            return(deliveries);
        }
        /// <summary>
        /// 调拨单查询(机构收货入库使用)
        /// </summary>
        public static List <CannibalizeSearchEntity> SearchBillCannibalizeForStoring()
        {
            var lp = VMGlobal.DistributionQuery.LinqOP;
            var cannibalizeContext = lp.GetDataContext <BillCannibalize>();
            var detailContext      = lp.GetDataContext <BillCannibalizeDetails>();
            var brandIDs           = VMGlobal.PoweredBrands.Select(o => o.ID);
            var dataQuery          = from d in cannibalizeContext
                                     where d.ToOrganizationID == VMGlobal.CurrentUser.OrganizationID && !d.Status && brandIDs.Contains(d.BrandID)
                                     select new CannibalizeSearchEntity
            {
                ID             = d.ID,
                OrganizationID = d.OrganizationID,
                Remark         = d.Remark,
                Code           = d.Code,
                CreateTime     = d.CreateTime,
                BrandID        = d.BrandID
            };
            var cannibalizes = dataQuery.ToList();
            var bIDs         = cannibalizes.Select(o => (int)o.ID);
            var detailQuery  = from detail in detailContext
                               where bIDs.Contains(detail.BillID)
                               select new
            {
                detail.BillID,
                detail.ProductID,
                detail.Quantity
            };
            var details = detailQuery.ToList();
            //var sum = cannibalizeDetailContext.Where(o => bIDs.Contains(o.BillID)).GroupBy(o => o.BillID).Select(g => new { BillID = g.Key, Quantity = g.Sum(o => o.Quantity) }).ToList();
            var sum = details.GroupBy(o => o.BillID).Select(g => new { BillID = g.Key, Quantity = g.Sum(o => o.Quantity) }).ToList();
            FloatPriceHelper fpHelper = new FloatPriceHelper();
            var siblings = OrganizationLogic.GetSiblingOrganizations(VMGlobal.CurrentUser.OrganizationID);

            cannibalizes.ForEach(d =>
            {
                d.OrganizationName = siblings.Find(o => o.ID == d.OrganizationID).Name;
                d.BrandName        = VMGlobal.PoweredBrands.Find(o => o.ID == d.BrandID).Name;
                d.Quantity         = sum.Find(o => o.BillID == d.ID).Quantity;
                var tempDetails    = details.FindAll(o => o.BillID == d.ID);
                foreach (var detail in tempDetails)
                {
                    var price     = fpHelper.GetFloatPrice(VMGlobal.CurrentUser.OrganizationID, detail.ProductID);
                    d.TotalPrice += price * detail.Quantity;
                }
            });
            return(cannibalizes);
        }
Ejemplo n.º 8
0
        protected override IEnumerable <RetailAggregationEntity> SearchData()
        {
            var lp             = VMGlobal.DistributionQuery.LinqOP;
            var retailContext  = lp.Search <BillRetail>(o => o.OrganizationID == VMGlobal.CurrentUser.OrganizationID);
            var detailsContext = lp.GetDataContext <BillRetailDetails>();
            var productContext = lp.GetDataContext <ViewProduct>();
            var vipContext     = lp.GetDataContext <VIPCard>();
            var brandIDs       = VMGlobal.PoweredBrands.Select(o => o.ID);
            var data           = from retail in retailContext
                                 from details in detailsContext
                                 where retail.ID == details.BillID
                                 from product in productContext
                                 join vip in vipContext on retail.VIPID equals vip.ID into vips
                                 from v in vips.DefaultIfEmpty()//生成Left [outer] join左联接语句,就不会产生重复数据了
                                 where product.ProductID == details.ProductID && brandIDs.Contains(product.BrandID)
                                 select new RetailEntityForAggregation
            {
                OrganizationID = retail.OrganizationID,
                ProductID      = product.ProductID,
                BrandID        = product.BrandID,
                StorageID      = retail.StorageID,
                CreateTime     = retail.CreateTime.Date,
                StyleCode      = product.StyleCode,
                Quantity       = details.Quantity,
                DiscountMoney  = details.Price * details.Quantity * details.Discount / 100,
                CutMoney       = details.CutMoney,
                VIPCode        = v.Code,
                ShiftID        = retail.ShiftID,
                GuideID        = retail.GuideID,
                //Year = product.Year,
                //Quarter = product.Quarter,
                BYQID = product.BYQID
            };

            data = (IQueryable <RetailEntityForAggregation>)data.Where(FilterDescriptors);
            var result = ReportDataContext.AggregateBillRetail(data);
            FloatPriceHelper fpHelper = new FloatPriceHelper();

            result.ForEach(o =>
            {
                o.Price     = fpHelper.GetFloatPrice(VMGlobal.CurrentUser.OrganizationID, o.BYQID, o.Price);
                o.CostMoney = o.DiscountMoney - o.CutMoney;
            });
            return(result);
        }
Ejemplo n.º 9
0
 private void RadGridView1_RowDetailsVisibilityChanged(object sender, GridViewRowDetailsEventArgs e)
 {
     if (e.DetailsElement != null)
     {
         var gv      = (RadGridView)e.DetailsElement;
         var item    = (StoreOutSearchEntity)e.Row.Item;
         var details = ReportDataContext.SearchBillDetails <BillStoreOutDetails>(item.ID);
         if (_fpHelper == null)
         {
             _fpHelper = new FloatPriceHelper();
         }
         foreach (var d in details)
         {
             d.Price = _fpHelper.GetFloatPrice(VMGlobal.CurrentUser.OrganizationID, d.BYQID, d.Price);
         }
         gv.ItemsSource = details;
     }
 }
Ejemplo n.º 10
0
        protected override IEnumerable <RetailAggregationEntity> SearchData()
        {
            var lp             = VMGlobal.DistributionQuery.LinqOP;
            var retailContext  = lp.GetDataContext <BillRetail>();
            var detailsContext = lp.GetDataContext <BillRetailDetails>();
            var productContext = lp.GetDataContext <ViewProduct>();
            var oids           = OrganizationArray.Select(o => o.ID).ToArray();
            //var orgContext = lp.Search<ViewOrganization>(o => oids.Contains(o.ID) && o.Flag);
            var brandIDs = VMGlobal.PoweredBrands.Select(o => o.ID);
            var data     = from retail in retailContext
                           //from org in orgContext
                           //where retail.OrganizationID == org.ID
                           from details in detailsContext
                           where retail.ID == details.BillID && oids.Contains(retail.OrganizationID)
                           from product in productContext
                           where product.ProductID == details.ProductID && brandIDs.Contains(product.BrandID)
                           select new RetailEntityForAggregation
            {
                OrganizationID = retail.OrganizationID,
                ProductID      = product.ProductID,
                BrandID        = product.BrandID,
                CreateTime     = retail.CreateTime.Date,
                StyleCode      = product.StyleCode,
                Quantity       = details.Quantity,
                //Year = product.Year,
                //Quarter = product.Quarter,
                BYQID         = product.BYQID,
                DiscountMoney = details.Price * details.Quantity * details.Discount / 100,           //这里的CostMoney和Retail表里的CostMoney不一样,相差下面的CutMoney
                CutMoney      = details.CutMoney,
                Year          = product.Year,
                Quarter       = product.Quarter
            };

            data = (IQueryable <RetailEntityForAggregation>)data.Where(FilterDescriptors);
            var result = ReportDataContext.AggregateBillRetail(data);
            FloatPriceHelper fpHelper = new FloatPriceHelper();

            result.ForEach(o =>
            {
                o.Price     = fpHelper.GetFloatPrice(VMGlobal.CurrentUser.OrganizationID, o.BYQID, o.Price);
                o.CostMoney = o.DiscountMoney - o.CutMoney;
            });
            return(result);
        }
Ejemplo n.º 11
0
 private void RadGridView1_RowDetailsVisibilityChanged(object sender, GridViewRowDetailsEventArgs e)
 {
     if (e.DetailsElement != null)
     {
         var gv      = (RadGridView)e.DetailsElement;
         var item    = e.Row.Item;
         var proBill = item.GetType().GetProperty("BillID");
         var billID  = (int)proBill.GetValue(item, null);
         var details = ReportDataContext.SearchBillDetails <BillStoringDetails>(billID);
         if (_fpHelper == null)
         {
             _fpHelper = new FloatPriceHelper();
         }
         foreach (var d in details)
         {
             d.Price = _fpHelper.GetFloatPrice(VMGlobal.CurrentUser.OrganizationID, d.BYQID, d.Price);
         }
         gv.ItemsSource = details;
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 单据汇总
        /// </summary>
        internal static List <DistributionProductShow> AggregateBill(IQueryable <IProductForAggregation> data, bool caluteFloatPrice = true)
        {
            var temp     = data.GroupBy(o => o.ProductID).Select(g => new { g.Key, Quantity = g.Sum(o => o.Quantity) }).ToList();
            var pids     = temp.Select(o => o.Key).ToArray();
            var products = _query.LinqOP.Search <ViewProduct>(o => pids.Contains(o.ProductID)).ToList();
            var result   = temp.Select(o =>
            {
                var product = products.First(p => p.ProductID == o.Key);
                return(new DistributionProductShow
                {
                    ProductID = product.ProductID,
                    ProductCode = product.ProductCode,
                    StyleCode = product.StyleCode,
                    ColorID = product.ColorID,
                    SizeID = product.SizeID,
                    NameID = product.NameID,
                    Quantity = o.Quantity,
                    Price = product.Price,
                    BYQID = product.BYQID
                });
            }).ToList();

            foreach (var r in result)
            {
                r.ColorCode   = VMGlobal.Colors.Find(o => o.ID == r.ColorID).Code;
                r.SizeName    = VMGlobal.Sizes.Find(o => o.ID == r.SizeID).Name;
                r.ProductName = VMGlobal.ProNames.Find(o => o.ID == r.NameID).Name;
                var byq = VMGlobal.BYQs.Find(o => o.ID == r.BYQID);
                r.BrandID   = byq.BrandID;
                r.BrandCode = VMGlobal.PoweredBrands.Find(o => o.ID == r.BrandID).Code;
                r.Year      = byq.Year;
                r.Quarter   = byq.Quarter;
            }
            if (caluteFloatPrice)
            {
                FloatPriceHelper fpHelper = new FloatPriceHelper();
                result.ForEach(o => o.Price = fpHelper.GetFloatPrice(VMGlobal.CurrentUser.OrganizationID, o.BYQID, o.Price));
            }
            return(result);
        }
Ejemplo n.º 13
0
        internal static ObservableCollection <OrderAggregationEntity> AggregateOrder(IQueryable <OrderEntityForAggregation> data, bool isShowAll)
        {
            var tempData = data.GroupBy(o => o.ProductID).Select(g => new { g.Key, Quantity = g.Sum(o => o.Quantity), QuaDelivered = g.Sum(o => o.QuaDelivered) });

            if (!isShowAll)
            {
                tempData = tempData.Where(o => o.Quantity != o.QuaDelivered);
            }
            var temp     = tempData.ToList();
            var pids     = temp.Select(o => o.Key).ToArray();
            var products = VMGlobal.DistributionQuery.LinqOP.Search <ViewProduct>(o => pids.Contains(o.ProductID)).ToList();
            FloatPriceHelper fpHelper = new FloatPriceHelper();

            temp.RemoveAll(o => o.Quantity == 0 && o.QuaDelivered == 0);
            return(new ObservableCollection <OrderAggregationEntity>(temp.Select(o =>
            {
                var product = products.First(p => p.ProductID == o.Key);
                var entity = new OrderAggregationEntity
                {
                    ProductID = o.Key,
                    ProductCode = product.ProductCode,
                    StyleCode = product.StyleCode,
                    BYQID = product.BYQID,
                    NameID = product.NameID,
                    ColorID = product.ColorID,
                    SizeID = product.SizeID,
                    Price = fpHelper.GetFloatPrice(VMGlobal.CurrentUser.OrganizationID, product.BYQID, product.Price),
                    Quantity = isShowAll ? o.Quantity : o.Quantity - o.QuaDelivered,
                    QuaDelivered = o.QuaDelivered
                };
                entity.ColorCode = VMGlobal.Colors.Find(c => c.ID == entity.ColorID).Code;
                entity.SizeName = VMGlobal.Sizes.Find(c => c.ID == entity.SizeID).Name;
                entity.ProductName = VMGlobal.ProNames.Find(c => c.ID == entity.NameID).Name;
                var byq = VMGlobal.BYQs.Find(c => c.ID == entity.BYQID);
                entity.BrandID = byq.BrandID;
                entity.BrandCode = VMGlobal.PoweredBrands.Find(c => c.ID == entity.BrandID).Code;
                return entity;
            }).ToList()));
        }
Ejemplo n.º 14
0
        protected override IEnumerable <RetailAggregationEntity> SearchData()
        {
            var lp             = VMGlobal.DistributionQuery.LinqOP;
            var oids           = OrganizationListVM.CurrentAndChildrenOrganizations.Select(o => o.ID).ToArray();
            var retailContext  = lp.GetDataContext <BillRetail>();
            var detailsContext = lp.GetDataContext <BillRetailDetails>();
            var productContext = lp.GetDataContext <ViewProduct>();
            var orgContext     = lp.Search <ViewOrganization>(o => oids.Contains(o.ID) && o.Flag);
            var brandIDs       = VMGlobal.PoweredBrands.Select(o => o.ID);
            var data           = from retail in retailContext
                                 from org in orgContext
                                 where retail.OrganizationID == org.ID
                                 from details in detailsContext
                                 where retail.ID == details.BillID
                                 from product in productContext
                                 where product.ProductID == details.ProductID && brandIDs.Contains(product.BrandID)
                                 select new RetailEntityForAggregation
            {
                OrganizationID     = retail.OrganizationID,
                ProductID          = product.ProductID,
                BrandID            = product.BrandID,
                CreateTime         = retail.CreateTime.Date,
                StyleCode          = product.StyleCode,
                Quantity           = details.Quantity,
                AreaID             = org.AreaID,
                ProvienceID        = org.ProvienceID,
                OrganizationTypeID = org.TypeId,
                CostMoney          = details.Price * details.Quantity * details.Discount / 100,
                CutMoney           = details.CutMoney
            };

            data = (IQueryable <RetailEntityForAggregation>)data.Where(filters);
            var result = AggregateBillRetail(data);
            FloatPriceHelper fpHelper = new FloatPriceHelper();

            result.ForEach(o => o.Price = fpHelper.GetFloatPrice(VMGlobal.CurrentUser.OrganizationID, o.ProductID));
            return(result);
        }
Ejemplo n.º 15
0
        public List <CertificationBO> GetCertifications(DeliverySearchEntity entity, CertificationMakeVM certvm)
        {
            if (_fpHelper == null)
            {
                _fpHelper = new FloatPriceHelper();
            }

            IEnumerable <string> scodes = entity.Details.Select(o => o.StyleCode);
            var styles             = VMGlobal.SysProcessQuery.LinqOP.Search <ProStyle>(o => scodes.Contains(o.Code)).Select(o => new ProStyleBO(o)).ToList();
            IEnumerable <int> sids = styles.Select(o => o.ID);
            var certs = VMGlobal.SysProcessQuery.LinqOP.Search <Certification>(o => sids.Contains(o.StyleID)).Select(o => new CertificationBO(o)).ToList();

            foreach (var cert in certs)
            {
                cert.GradeName           = certvm.Grades.First(o => o.ID == cert.Grade).Name;
                cert.SafetyTechniqueName = certvm.SafetyTechs.First(o => o.ID == cert.SafetyTechnique).Name;
                cert.CarriedStandardName = certvm.CarriedStandards.First(o => o.ID == cert.CarriedStandard).Name;
                var style = styles.Find(o => o.ID == cert.StyleID);
                cert.Style = style;
                cert.Price = _fpHelper.GetFloatPrice(entity.ToOrganizationID, style.BYQID, style.Price);
            }
            return(certs);
        }
Ejemplo n.º 16
0
        protected override IEnumerable <ShopProfitEntity> SearchData()
        {
            var oids = OrganizationArray.Select(o => o.ID).ToArray();
            var organizations = OrganizationArray.ToArray();
            int by = BeginMonth.Year, bm = BeginMonth.Month, ey = EndMonth.Year, em = EndMonth.Month;
            var endMonth = EndMonth.AddMonths(1);

            var lp         = VMGlobal.DistributionQuery.LinqOP;
            var retailData = lp.Search <BillRetail>(o => o.CreateTime >= BeginMonth && o.CreateTime < endMonth);
            var targets    = lp.Search <RetailMonthTaget>(o => oids.Contains(o.OrganizationID) && o.Year >= by && o.Month >= bm && o.Year <= ey && o.Month <= em).ToArray();
            var expenses   = lp.Search <ShopExpense>(o => o.OccurDate >= BeginMonth && o.OccurDate < endMonth && oids.Contains(o.OrganizationID)).ToArray();

            if (IsShowShopHasExpensesOnly)
            {
                var sids = expenses.Select(o => o.OrganizationID).Intersect(oids).ToArray();
                retailData    = retailData.Where(o => sids.Contains(o.OrganizationID));
                organizations = organizations.Where(o => sids.Contains(o.ID)).ToArray();
            }
            else
            {
                retailData = retailData.Where(o => oids.Contains(o.OrganizationID));
            }
            var retails = retailData.Select(o => new
            {
                OrganizationID = o.OrganizationID,
                RetailID       = o.ID,
                QuaRetail      = o.Quantity,
                MoneyRetail    = o.CostMoney,
                RetailTime     = o.CreateTime
            }).ToList();

            if (IsShowShopHasRetailOnly)
            {
                var rids = retails.Select(o => o.OrganizationID);
                expenses      = expenses.Where(o => rids.Contains(o.OrganizationID)).ToArray();
                organizations = organizations.Where(o => rids.Contains(o.ID)).ToArray();
            }
            var rbillIDs     = retails.Select(o => o.RetailID).ToArray();
            var rDetailData  = lp.Search <BillRetailDetails>(o => rbillIDs.Contains(o.BillID));
            var productData  = lp.GetDataContext <ViewProduct>();
            var rDetailQuery = from rDetail in rDetailData
                               from product in productData
                               where rDetail.ProductID == product.ProductID
                               select new
            {
                RetailID = rDetail.BillID,
                rDetail.Price,
                rDetail.ProductID,
                rDetail.Quantity,
                product.BYQID,
                product.CostPrice
            };
            var rDetails = rDetailQuery.ToList();

            List <ShopProfitEntity> result = new List <ShopProfitEntity>();

            foreach (var organization in organizations)
            {
                var ryms = retails.Where(o => o.OrganizationID == organization.ID).Select(o => new DateTime(o.RetailTime.Year, o.RetailTime.Month, 1)).Distinct();
                var eyms = expenses.Where(o => o.OrganizationID == organization.ID).Select(o => new DateTime(o.OccurDate.Year, o.OccurDate.Month, 1)).Distinct();
                var yms  = ryms.Union(eyms);
                foreach (var ym in yms)
                {
                    ShopProfitEntity entity = new ShopProfitEntity
                    {
                        OrganizationID   = organization.ID,
                        OrganizationName = organization.Name,
                        YearMonth        = ym.ToString("yyyy-MM")
                    };
                    var target = targets.FirstOrDefault(o => o.OrganizationID == organization.ID && ym.Year == o.Year && ym.Month == o.Month);
                    if (target != null)
                    {
                        entity.MonthTarget = target.SaleTaget;
                    }
                    var tempRetails = retails.Where(o => o.OrganizationID == organization.ID && ym.Year == o.RetailTime.Year && ym.Month == o.RetailTime.Month);
                    entity.SaleQuantity = tempRetails.Sum(o => o.QuaRetail);
                    entity.SaleMoney    = tempRetails.Sum(o => o.MoneyRetail);
                    var tempRDetails = rDetails.Where(o => tempRetails.Select(r => r.RetailID).Contains(o.RetailID));
                    entity.OriginalPrice = tempRDetails.Sum(o => o.Quantity * o.Price);
                    if (VMGlobal.CurrentUser.OrganizationID == 1)
                    {
                        entity.CostPrice = tempRDetails.Sum(o => o.Quantity * o.CostPrice);
                    }
                    else
                    {
                        entity.CostPrice = tempRDetails.Sum(o => o.Quantity * (_fpHelper.GetFloatPrice(OrganizationListVM.CurrentOrganization.ParentID, o.BYQID, o.Price) * _cdhelper.GetDiscount(o.BYQID, VMGlobal.CurrentUser.OrganizationID) * 0.01M));
                    }
                    //        var expense = expenses.FirstOrDefault(o => o.OrganizationID == organization.ID && ym.Year == o.Year && ym.Month == o.Month);
                    //        if (expense != null)
                    //        {
                    //            entity.AdvertisingFee = expense.AdvertisingFee;
                    //            entity.BaseCost = expense.BaseCost;
                    //            entity.Bonus = expense.Bonus;
                    //            entity.ElectricCharge = expense.ElectricCharge;
                    //            entity.ExpressCharge = expense.ExpressCharge;
                    //            entity.ManagerCost = expense.ManagerCost;
                    //            entity.OrganizationID = expense.OrganizationID;
                    //            entity.OtherCost = expense.OtherCost;
                    //            entity.RenovationCost = expense.RenovationCost;
                    //            entity.Rent = expense.Rent;
                    //            entity.Salary = expense.Salary;
                    //            entity.SocialSecurityCharge = expense.SocialSecurityCharge;
                    //            entity.TelephoneCharge = expense.TelephoneCharge;
                    //        }

                    result.Add(entity);
                }
            }
            TableData = this.TransferToTable(result, expenses);
            return(result);
        }
Ejemplo n.º 17
0
        protected IEnumerable <StockStatisticsEntity> SearchData(int organizationID)
        {
            var lp             = VMGlobal.DistributionQuery.LinqOP;
            var provider       = VMGlobal.DistributionQuery.QueryProvider;
            var stockContext   = VMGlobal.DistributionQuery.LinqOP.GetDataContext <Stock>();
            var storageContext = VMGlobal.DistributionQuery.LinqOP.Search <Storage>(o => o.OrganizationID == organizationID && o.Flag);
            var productContext = provider.GetTable <Product>("SysProcess.dbo.Product");
            var styleContext   = provider.GetTable <ProStyle>("SysProcess.dbo.ProStyle");
            var pnameContext   = provider.GetTable <ProName>("SysProcess.dbo.ProName");
            var brandContext   = provider.GetTable <ProBrand>("SysProcess.dbo.ProBrand");
            var colorContext   = provider.GetTable <ProColor>("SysProcess.dbo.ProColor");
            var sizeContext    = provider.GetTable <ProSize>("SysProcess.dbo.ProSize");
            var byqContext     = provider.GetTable <ProBYQ>("SysProcess.dbo.ProBYQ");

            var brandIDs = VMGlobal.PoweredBrands.Select(o => o.ID);

            var data = from stock in stockContext
                       from storage in storageContext
                       where stock.StorageID == storage.ID && stock.Quantity != 0
                       from product in productContext
                       where stock.ProductID == product.ID
                       from style in styleContext
                       where product.StyleID == style.ID
                       from byq in byqContext
                       where style.BYQID == byq.ID
                       from brand in brandContext
                       where byq.BrandID == brand.ID && brandIDs.Contains(brand.ID)
                       from color in colorContext
                       where product.ColorID == color.ID
                       from size in sizeContext
                       where product.SizeID == size.ID
                       from pname in pnameContext
                       where style.NameID == pname.ID
                       select new StockStatisticsEntity
            {
                StorageID   = storage.ID,
                NameID      = pname.ID,
                StyleCode   = style.Code,
                ColorCode   = color.Code,
                ColorName   = color.Name,
                SizeID      = size.ID,
                BrandID     = brand.ID,
                Year        = byq.Year,
                Quarter     = byq.Quarter,
                ProductCode = product.Code,
                //StorageName = storage.Name,
                BrandCode   = brand.Code,
                SizeName    = size.Name,
                ProductName = pname.Name,
                Quantity    = stock.Quantity,
                Price       = style.Price,
                ProductID   = product.ID,
                BYQID       = byq.ID
            };
            var temp   = ((IQueryable <StockStatisticsEntity>)data.Where(FilterDescriptors)).ToList();//即使filters中有data没有的过滤属性,也不会出错,但是会产生0<>0的恒为假条件
            var groups = temp.GroupBy(o => o.ProductID).Select(g => new { ProductID = g.Key, Quantity = g.Sum(o => o.Quantity) }).ToList();
            FloatPriceHelper fpHelper = new FloatPriceHelper();
            var result = groups.Select(o =>
            {
                var item         = temp.Find(t => t.ProductID == o.ProductID);
                item.Quantity    = o.Quantity;
                item.Price       = fpHelper.GetFloatPrice(VMGlobal.CurrentUser.OrganizationID, item.BYQID, item.Price);
                item.QuarterName = VMGlobal.Quarters.Find(q => q.ID == item.Quarter).Name;
                return(item);
            }).ToList();

            return(result);
        }