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("请先指定款号"); } }
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)); }
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); }
/// <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); }
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); }
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; } }
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); }
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; } }
/// <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); }
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())); }
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); }
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); }
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); }