Beispiel #1
0
        private void WriteCategoryDisplay(XmlWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("display");

            xmlWriter.WriteElementString("store", "新蛋商城");
            xmlWriter.WriteElementString("store_pic", StorePic);

            BaiduCategoryEntity category = BaiduBP.GetBaiduCategory(CategoryId);

            if (category != null)
            {
                xmlWriter.WriteElementString("tags", JobHelper.bSubstring(category.CategoryName, 30));
            }
            else
            {
                xmlWriter.WriteElementString("tags", JobHelper.bSubstring("其它", 30));
            }

            xmlWriter.WriteElementString("services", @"正规发票\全国联保\七天退换货");
            xmlWriter.WriteElementString("brand", "");
            xmlWriter.WriteElementString("number", JobHelper.bSubstring(ProductCount.ToString(), 20));
            xmlWriter.WriteElementString("price", JobHelper.bSubstring(ProductPrice.ToString("0.00"), 20));

            xmlWriter.WriteEndElement();
        }
Beispiel #2
0
        /// <summary>
        /// Returns true if ContainerCreationDetails instances are equal
        /// </summary>
        /// <param name="other">Instance of ContainerCreationDetails to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ContainerCreationDetails other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     ProductCount == other.ProductCount ||
                     ProductCount.Equals(other.ProductCount)
                 ) &&
                 (
                     Measurements == other.Measurements ||
                     Measurements != null &&
                     Measurements.SequenceEqual(other.Measurements)
                 ));
        }
Beispiel #3
0
    public static void Main()
    {
        var products = new List <Product>()
        {
            new Product("a", "Clothes"),
            new Product("b", "Shoes"),
            new Product("c", "Clothes"),
            new Product("d", "Clothes"),
            new Product("e", "Shoes"),
            new Product("f", "Shoes"),
            new Product("g", "Laptop"),
            new Product("h", "Laptop"),
            new Product("h", "Shoes"),
        };
        var result = products
                     .GroupBy(p => p.Type)
                     .Select(
            group => new
            ProductCount(group.Key, group.Count())
            // You can use also an object as the commented code below
            //{
            //	Type = group.Key,
            //	Count = group.Count()
            //}
            )
                     .ToList();

        Console.WriteLine(ProductCount.ToFormatedString(result));
    }
Beispiel #4
0
        public static ProductCount GetProductStatisticsByPeriod(Guid userId, DateTime from, DateTime until)
        {
            var result = default(ProductCount);

            BCT.Execute(d =>
            {
                var bulletins   = d.BulletinDb.Bulletins.Where(q => q.UserId == userId).ToArray();
                var bulletinIds = bulletins.Select(q => q.Id);

                var instances = d.BulletinDb.BulletinInstances.Where(q => q.Url != null &&
                                                                     q.ActivationDate != null &&
                                                                     bulletinIds.Any(qq => qq == q.BulletinId) &&
                                                                     q.ActivationDate >= from && q.ActivationDate <= until).ToArray();

                var bulletinCount = instances.GroupBy(q => q.BulletinId).Count();
                var instanceCount = instances.Count();

                result = new ProductCount
                {
                    BulletinCount = bulletinCount,
                    InstanceCount = instanceCount
                };
            });
            return(result);
        }
        public object Any(ProductCount request)
        {
            var resp    = new Dto <long>();
            var handler = new ProductHandler(Db);

            resp.Result = handler.Count(request.IncludeDeleted);

            return(resp);
        }
 public async Task <List <BrandsProducts> > GetAllBrandsProducts() => await(from brand in _context.tblBrands
                                                                            join product in _context.tblProducts on brand.Id equals product.Brand_Id
                                                                            group brand by new { brand.Id, brand.Brand_Description } into ProductCount
                                                                            select new BrandsProducts
 {
     Id = ProductCount.Key.Id,
     Brand_Description = ProductCount.Key.Brand_Description,
     NumberOfProduct   = ProductCount.Count()
 }).ToListAsync();
Beispiel #7
0
        private ProductCountModel ProductCountDbToModel(ProductCount productCount)
        {
            ProductService productService = new ProductService(_dataManager);

            return(new ProductCountModel()
            {
                Count = productCount.Count,
                Product = productService.ProductDbToModel(productCount.Product)
            });
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (PotrName != null ? StringComparer.OrdinalIgnoreCase.GetHashCode(PotrName) : 0);
         hashCode = (hashCode * 397) ^ (ProductName != null ? StringComparer.OrdinalIgnoreCase.GetHashCode(ProductName) : 0);
         hashCode = (hashCode * 397) ^ ProductCount.GetHashCode();
         hashCode = (hashCode * 397) ^ SummaUsd.GetHashCode();
         hashCode = (hashCode * 397) ^ SummaRfRb.GetHashCode();
         return(hashCode);
     }
 }
Beispiel #9
0
        public void TestNumberOfProductsStartingWithP(int expected)
        {
            // arrange (instance)

            //act (method)

            //assert
            var instance = new ProductCount();

            int actual = instance.ProductCounting();


            Assert.AreEqual(expected, actual);
        }
        private async Task <List <ProductCount> > GetProductCountsByMonthAsync(int nam, int thang)
        {
            var orders = await _context.Orders
                         .Include(o => o.DetailOrders)
                         .ThenInclude(dd => dd.Product)
                         .AsNoTracking()
                         .Where(o => o.ThoiGianTao.Year == nam)
                         .ToListAsync();

            if (thang != 0)
            {
                orders = orders.Where(o => o.ThoiGianTao.Month == thang).ToList();
            }
            var items = new List <ProductCount>();

            foreach (var order in orders)
            {
                foreach (var i in order.DetailOrders)
                {
                    var item = new ProductCount
                    {
                        Ten     = i.Product.Ten,
                        Gia     = i.Gia,
                        SoLuong = i.SoLuong
                    };
                    items.Add(item);
                }
            }
            var itemsGroup = items.GroupBy(p => new { p.Ten, p.Gia })
                             .Select(p => new
            {
                Ten     = p.Key.Ten,
                Gia     = p.Key.Gia,
                SoLuong = (ushort)p.Sum(s => s.SoLuong)
            });
            var products = new List <ProductCount>();

            foreach (var i in itemsGroup)
            {
                var product = new ProductCount
                {
                    Ten     = i.Ten,
                    Gia     = i.Gia,
                    SoLuong = i.SoLuong
                };
                products.Add(product);
            }
            return(products);
        }
Beispiel #11
0
    public override string ToString()
    {
        var  sb      = new StringBuilder("ProductCategory(");
        bool __first = true;

        if (__isset.productCategoryId)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("ProductCategoryId: ");
            ProductCategoryId.ToString(sb);
        }
        if (Title != null && __isset.title)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("Title: ");
            Title.ToString(sb);
        }
        if (__isset.productCount)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("ProductCount: ");
            ProductCount.ToString(sb);
        }
        if (__isset.newFlag)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("NewFlag: ");
            NewFlag.ToString(sb);
        }
        sb.Append(")");
        return(sb.ToString());
    }
        private async Task <List <ProductCount> > GetProductCountsByDateAsync(DateTime dau, DateTime cuoi)
        {
            var orders = await _context.Orders
                         .Include(o => o.DetailOrders)
                         .ThenInclude(dd => dd.Product)
                         .AsNoTracking()
                         .Where(o => dau.Date <= o.ThoiGianTao.Date &&
                                o.ThoiGianTao.Date <= cuoi.Date)
                         .ToListAsync();

            var items = new List <ProductCount>();

            foreach (var order in orders)
            {
                foreach (var i in order.DetailOrders)
                {
                    var item = new ProductCount
                    {
                        Ten     = i.Product.Ten,
                        Gia     = i.Gia,
                        SoLuong = i.SoLuong
                    };
                    items.Add(item);
                }
            }
            var itemsGroup = items.GroupBy(i => new { i.Ten, i.Gia })
                             .Select(i => new
            {
                Ten     = i.Key.Ten,
                Gia     = i.Key.Gia,
                SoLuong = (uint)i.Sum(c => c.SoLuong)
            });
            var products = new List <ProductCount>();

            foreach (var i in itemsGroup)
            {
                var product = new ProductCount
                {
                    Ten     = i.Ten,
                    Gia     = i.Gia,
                    SoLuong = i.SoLuong
                };
                products.Add(product);
            }
            return(products);
        }
Beispiel #13
0
        /// <summary>
        /// Output all properties
        /// </summary>
        /// <returns>A string</returns>
        public override string ToString()
        {
            var toString = new StringBuilder();

            toString.Append("ID: ").AppendLine(Id);
            toString.Append("Title: ").AppendLine(Title);
            toString.Append("ProductCount: ").AppendLine(ProductCount.ToString(CultureInfo.InvariantCulture));
            toString.Append("ParentId: ").AppendLine(ParentId);
            toString.Append("Position: ").AppendLine(Position.ToString(CultureInfo.InvariantCulture));
            toString.Append("Slug: ").AppendLine(Slug);
            toString.Append("CreatedAt: ").AppendLine(CreatedAt.ToString(CultureInfo.InvariantCulture));
            if (ModifiedAt.HasValue)
            {
                toString.Append("ModifiedAt: ").AppendLine(ModifiedAt.Value.ToString(CultureInfo.InvariantCulture)).AppendLine();
            }
            return(toString.ToString());
        }
Beispiel #14
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         hashCode = hashCode * 59 + ProductCount.GetHashCode();
         if (Measurements != null)
         {
             hashCode = hashCode * 59 + Measurements.GetHashCode();
         }
         return(hashCode);
     }
 }
Beispiel #15
0
            public void AddProductStockRecord(string productId, int count)
            {
                ProductCount pc = null;

                foreach (ProductCount p in _products)
                {
                    if (p.Id.Equals(productId))
                    {
                        pc = p;
                        break;
                    }
                }

                if (null == pc)
                {
                    pc = new ProductCount(productId);
                    _products.Add(pc);
                }
                pc.AddCount(count);
            }
Beispiel #16
0
        private ProductCount GetProductCount(int year, int idProd)
        {
            var result = saleService.Get()
                         .Where(x => x.Date.Year == year && x.ProductId == idProd)
                         .GroupBy(x => x.Date.Year)
                         .Select(x => new ProductCount
            {
                Product = x.First().Product,
                Count   = x.Count()
            }).FirstOrDefault();

            if (result == null)
            {
                result = new ProductCount
                {
                    Product = null,
                    Count   = 0
                };
            }

            return(result);
        }
        public int CompareTo(ShipmentForDiler other)
        {
            const StringComparison comparisonIgnoreCase = StringComparison.OrdinalIgnoreCase;

            if (ReferenceEquals(this, other))
            {
                return(0);
            }

            if (ReferenceEquals(null, other))
            {
                return(1);
            }
            var potrNameComparison = string.Compare(PotrName, other.PotrName, comparisonIgnoreCase);

            if (potrNameComparison != 0)
            {
                return(potrNameComparison);
            }
            var productNameComparison = string.Compare(ProductName, other.ProductName, comparisonIgnoreCase);

            if (productNameComparison != 0)
            {
                return(productNameComparison);
            }
            var productCountComparison = ProductCount.CompareTo(other.ProductCount);

            if (productCountComparison != 0)
            {
                return(productCountComparison);
            }
            var summaUsdComparison = SummaUsd.CompareTo(other.SummaUsd);

            if (summaUsdComparison != 0)
            {
                return(summaUsdComparison);
            }
            return(SummaRfRb.CompareTo(other.SummaRfRb));
        }
Beispiel #18
0
        /// <summary>
        ///     GetProductCount
        /// </summary>
        /// <param name="productIds"></param>
        public List <ProductCount> GetProductCount(List <long> productIds)
        {
            var sql    = $@"select Count,userId,productId from Shop_OrderProduct
                        inner join Shop_Order
                        on Shop_Order.Id=Shop_OrderProduct.OrderId
                        where ProductId in ({productIds.ToSqlString()}) and (OrderStatus!=200 and OrderStatus!=1)";
            var result = new List <ProductCount>();

            using (var reader = RepositoryContext.ExecuteDataReader(sql))
            {
                while (reader.Read())
                {
                    var productCount = new ProductCount
                    {
                        Count     = reader["Count"].ConvertToLong(),
                        ProductId = reader["ProductId"].ConvertToLong()
                    };
                    result.Add(productCount);
                }
            }

            return(result);
        }
Beispiel #19
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (TerritoryName != null ? StringComparer.OrdinalIgnoreCase.GetHashCode(TerritoryName) : 0);
         hashCode = (hashCode * 397) ^ Ceh.GetHashCode();
         hashCode = (hashCode * 397) ^ NumberTtn.GetHashCode();
         hashCode = (hashCode * 397) ^ NumberAkt.GetHashCode();
         hashCode = (hashCode * 397) ^ ShipmentDate.GetHashCode();
         hashCode = (hashCode * 397) ^ (ProductName != null ? StringComparer.OrdinalIgnoreCase.GetHashCode(ProductName) : 0);
         hashCode = (hashCode * 397) ^ (CompanyName != null ? StringComparer.OrdinalIgnoreCase.GetHashCode(CompanyName) : 0);
         hashCode = (hashCode * 397) ^ ProductCount.GetHashCode();
         hashCode = (hashCode * 397) ^ CostWithoutNds.GetHashCode();
         hashCode = (hashCode * 397) ^ SummaWithoutNds.GetHashCode();
         hashCode = (hashCode * 397) ^ SummaNds.GetHashCode();
         hashCode = (hashCode * 397) ^ SummaWithNds.GetHashCode();
         hashCode = (hashCode * 397) ^ SummaWithoutNdsAndTaxes.GetHashCode();
         hashCode = (hashCode * 397) ^ SummaUsd.GetHashCode();
         hashCode = (hashCode * 397) ^ UsdRate.GetHashCode();
         hashCode = (hashCode * 397) ^ RusRate.GetHashCode();
         return(hashCode);
     }
 }
Beispiel #20
0
    public override int GetHashCode()
    {
        int hashcode = 157;

        unchecked {
            if (__isset.productCategoryId)
            {
                hashcode = (hashcode * 397) + ProductCategoryId.GetHashCode();
            }
            if (__isset.title)
            {
                hashcode = (hashcode * 397) + Title.GetHashCode();
            }
            if (__isset.productCount)
            {
                hashcode = (hashcode * 397) + ProductCount.GetHashCode();
            }
            if (__isset.newFlag)
            {
                hashcode = (hashcode * 397) + NewFlag.GetHashCode();
            }
        }
        return(hashcode);
    }
Beispiel #21
0
        /// <summary>
        /// 作者:Primo    
        /// 时间:2015.01.22
        /// 描述:组织全国学员执行人数报表
        /// </summary>
        /// <param name="siList"></param>
        /// <returns></returns>
        public List<BranchCount> GetModel(List<BranchActivityStudent_Result> siList, out List<ProductCount> productCountTitle)
        {
            var dList = new Dictionary<int, List<BranchActivityStudent_Result>>();
            //同时拥有4D
            var FD = siList.Where(p => p.ProductId == 1).ToList();

            //同时拥有MBG
            var MBG = siList.Where(p => p.ProductId == 2).ToList();
            var MBGIdList = (from a in MBG select a.StudentId).Distinct().ToList();

            //同时拥有VIP
            var VIP = siList.Where(p => p.ProductId == 3).ToList();
            var VIPIdList = (from a in VIP select a.StudentId).Distinct().ToList();

            //同时拥有V4D
            var V4D = siList.Where(p => p.ProductId == 4).ToList();
            var V4DIdList = (from a in V4D select a.StudentId).Distinct().ToList();

            //同时拥有MTEEN 青少
            var MTEEN = siList.Where(p => p.ProductId == 16).ToList();
            var MTEENIdList = (from a in MTEEN select a.StudentId).Distinct().ToList();

            //同时拥有MTEEN VIP
            var MTEENVIP = siList.Where(p => p.ProductId == 19).ToList();
            var MTEENVIPIdList = (from a in MTEENVIP select a.StudentId).Distinct().ToList();

            var allList = new List<int?>();
            //合并
            allList.AddRange(MBGIdList);
            allList.AddRange(V4DIdList);
            allList.AddRange(VIPIdList);
            allList.AddRange(MTEENIdList);
            allList.AddRange(MTEENVIPIdList);

            //移除拥有MBG,VIP,V4D,MTeen,MTeenVIP的4D
            FD = (from a in FD
                  where !allList.Contains(a.StudentId)
                  select a).ToList();

            //移除拥有VIP的MBG
            MBG = (from a in MBG where !VIPIdList.Contains(a.StudentId) select a).ToList();

            allList.Clear();
            allList.AddRange(V4DIdList);
            allList.AddRange(VIPIdList);
            allList.AddRange(MTEENVIPIdList);

            //移除拥有VIP的青少
            MTEEN = (from a in MTEEN
                     where !allList.Contains(a.StudentId)
                     select a).ToList();

            dList.Add(1, FD);
            dList.Add(2, MBG);
            dList.Add(3, VIP);
            dList.Add(4, V4D);
            dList.Add(16, MTEEN);
            dList.Add(19, MTEENVIP);

            //中心集合
            var branchIdList = (from a in siList select new { a.BranchId, a.BranchName }).Distinct().ToList();
            //产品ID集合
            var productList = (from a in siList select new { a.ProductId, a.ProductName }).Distinct().ToList();

            //Title
            productCountTitle = new List<ProductCount>();
            foreach (var item in productList)
            {
                var pcItem = new ProductCount();
                pcItem.ProductId = item.ProductId.Value;
                pcItem.ProductName = item.ProductName;
                var productLevelList = (from a in siList where a.ProductId == item.ProductId select new { a.ProductId, a.ProductName, a.ProductLevelId, a.ProductLevelName }).Distinct().ToList();
                pcItem.ProductLevelCounts = new List<ProductLevelCount>();
                var modelCount = dList[item.ProductId.Value];//获取当前产品
                foreach (var itemPL in productLevelList.OrderBy(p => p.ProductLevelName))
                {
                    var plItem = new ProductLevelCount();
                    plItem.ProductId = item.ProductId;
                    plItem.ProductLevelId = itemPL.ProductLevelId;
                    plItem.ProductLevelName = itemPL.ProductLevelName;

                    //移除重复学员
                    var removerModelCount = (from a in modelCount
                                             where a.ContractStatusType == ConvertEnum.ContractStatusTypeForExcute
                                                 && a.ProductId == item.ProductId.Value
                                                 && a.ProductLevelId == itemPL.ProductLevelId
                                             select a.StudentId).Distinct().ToList();

                    plItem.Total = (from a in modelCount
                                    where a.ContractStatusType == ConvertEnum.ContractStatusTypeForExcute
                                        && a.ProductId == item.ProductId.Value
                                        && a.ProductLevelId == itemPL.ProductLevelId
                                    select a.StudentId).Distinct().Count(); //获取小总计

                    modelCount = (from a in modelCount where !removerModelCount.Contains(a.StudentId) select a).ToList();

                    pcItem.ProductLevelCounts.Add(plItem);
                }
                productCountTitle.Add(pcItem);
            }

            //以中心为标准
            var branchCounts = new List<BranchCount>();
            foreach (var itemBranch in branchIdList)
            {
                var branchCount = new BranchCount();
                branchCount.BranchId = itemBranch.BranchId.Value;//中心ID
                branchCount.BranchName = itemBranch.BranchName;//中心名称
                branchCount.ProductCounts = new List<ProductCount>();
                branchCount.AllFreezeTotal = 0;
                branchCount.AllTotal = 0;
                foreach (var itemProduct in productList)
                {
                    var productCount = new ProductCount();
                    productCount.ProductId = itemProduct.ProductId.Value;//产品ID
                    productCount.ProductName = itemProduct.ProductName;//产品名称
                    //执行的人
                    var modelCount = dList[itemProduct.ProductId.Value];

                    productCount.FreezeTotal = (from a in modelCount
                                                where a.ContractStatusType == ConvertEnum.ContractStatusTypeForFreeze
                                                && a.ProductId == itemProduct.ProductId.Value
                                                && a.BranchId == itemBranch.BranchId.Value
                                                select a.StudentId).Distinct().Count();//产品下的冻结人数

                    branchCount.AllFreezeTotal = branchCount.AllFreezeTotal + productCount.FreezeTotal;

                    modelCount = modelCount.Where(p => p.ContractStatusType == ConvertEnum.ContractStatusTypeForExcute
                        && p.ProductId == itemProduct.ProductId.Value
                        && p.BranchId == itemBranch.BranchId.Value).ToList();

                    productCount.Total = (from a in modelCount
                                          where a.ContractStatusType == ConvertEnum.ContractStatusTypeForExcute
                                          && a.ProductId == itemProduct.ProductId.Value
                                          && a.BranchId == itemBranch.BranchId.Value
                                          select a.StudentId).Distinct().Count();//产品下的执行人数

                    branchCount.AllTotal = branchCount.AllTotal + productCount.Total;//该中心总的执行人数
                    //这些产品下的级别
                    var productLevelList = (from a in modelCount
                                            where a.ProductId == itemProduct.ProductId
                                            select new { a.ProductLevelId, a.ProductLevelName, a.ProductLevelOrderNum }).Distinct().ToList();

                    productCount.ProductLevelCounts = new List<ProductLevelCount>();
                    foreach (var itemPL in productLevelList.OrderBy(p => p.ProductLevelName))
                    {
                        var plc = new ProductLevelCount();
                        plc.ProductId = itemProduct.ProductId;
                        plc.ProductLevelId = itemPL.ProductLevelId;
                        plc.ProductLevelName = itemPL.ProductLevelName;
                        plc.ProductLevelOrderNum = itemPL.ProductLevelOrderNum;

                        //移除重复学员
                        var removerModelCount = (from a in modelCount
                                                 where a.ContractStatusType == ConvertEnum.ContractStatusTypeForExcute
                                                 && a.ProductId == itemProduct.ProductId.Value
                                                 && a.BranchId == itemBranch.BranchId.Value
                                                 && a.ProductLevelId == itemPL.ProductLevelId.Value
                                                 select a.StudentId).Distinct().ToList();

                        plc.Total = (from a in modelCount
                                     where a.ContractStatusType == ConvertEnum.ContractStatusTypeForExcute
                                     && a.ProductId == itemProduct.ProductId.Value
                                     && a.BranchId == itemBranch.BranchId.Value
                                     && a.ProductLevelId == itemPL.ProductLevelId.Value
                                     select a.StudentId).Distinct().Count();

                        modelCount = (from a in modelCount where !removerModelCount.Contains(a.StudentId) select a).ToList();

                        productCount.ProductLevelCounts.Add(plc);
                    }
                    branchCount.ProductCounts.Add(productCount);
                }
                branchCounts.Add(branchCount);
            }
            return branchCounts;
        }
Beispiel #22
0
        //Method to compare sales of each type of product
        private void getProductTypeSales(int TypeOrActivity)
        {
            //Clear and add series
            chartSalariesIncome.Series.Clear();
            chartSalariesIncome.Series.Add("Number of Sales");

            //Change chart type to pie chart
            chartSalariesIncome.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie;

            //For storing sales
            List<StoreRecord> storeRecordList = new List<StoreRecord>();

            //Set the list to the result of the SQL command getting all sales of all stores
            storeRecordList = graphConnect.chartStoresRecords(0);

            //Make list of product type and quantity
            List<ProductCount> productTypeQuantityList = new List<ProductCount>();

            //Loop through list of store records
            for (int i = 0; i < storeRecordList.Count; i++)
            {
                //Get list of sales from record
                List<StoreSale> currentSaleList = new List<StoreSale>(storeRecordList[i].getStoreSales());

                //Loop through sales
                for (int j = 0; j < currentSaleList.Count; j++)
                {
                    String currentType;

                    if (TypeOrActivity == 0)
                    {
                        currentType = currentSaleList[i].getType();
                    }
                    else
                    {
                        currentType = currentSaleList[i].getActivity();
                    }
                    int pos = findProductPos(currentType, productTypeQuantityList);

                    //If pos is less than 0, the search returned no results
                    //Therefore the entry to the list is a new entry
                    if (pos < 0)
                    {
                        ProductCount productToAdd = new ProductCount(currentType);
                        productToAdd.addToQuantity(currentSaleList[i].getQuantity());
                        productTypeQuantityList.Add(productToAdd);
                    }
                    //Else, it returned a position in which the country's sales are already stored
                    //Therefore, to avoid duplicate country entries, we simply add the sales of the current entry to the new list's entry
                    else
                    {
                        productTypeQuantityList[pos].addToQuantity(currentSaleList[i].getQuantity());
                    }

                }

            }

            //Now we display the data of the new list
            for (int i = 0; i < productTypeQuantityList.Count; i++)
            {
                //Get quantity for type
                decimal quantityTotal = productTypeQuantityList[i].getQuantity();

                //Display these on the chartSalariesIncome
                chartSalariesIncome.Series["Number of Sales"].Points.AddXY(productTypeQuantityList[i].getProductType(), quantityTotal);
            }

            chartSalariesIncome.Show();
        }
Beispiel #23
0
        public int CompareTo(ExpenditureOfProductsByTerritory other)
        {
            const StringComparison comparisonIgnoreCase = StringComparison.OrdinalIgnoreCase;

            if (ReferenceEquals(this, other))
            {
                return(0);
            }

            if (ReferenceEquals(null, other))
            {
                return(1);
            }
            var cehComparison = Ceh.CompareTo((other.Ceh));

            if (cehComparison != 0)
            {
                return(cehComparison);
            }
            var territoryNameComparison = string.Compare(TerritoryName, other.TerritoryName, comparisonIgnoreCase);

            if (territoryNameComparison != 0)
            {
                return(-territoryNameComparison);
            }
            var numberTtnComparison = NumberTtn.CompareTo(other.NumberTtn);

            if (numberTtnComparison != 0)
            {
                return(-numberTtnComparison);
            }
            var numberAktComparison = NumberAkt.CompareTo(other.NumberAkt);

            if (numberAktComparison != 0)
            {
                return(-numberAktComparison);
            }
            var shipmentDateComparison = ShipmentDate.CompareTo(other.ShipmentDate);

            if (shipmentDateComparison != 0)
            {
                return(shipmentDateComparison);
            }
            var productNameComparison = string.Compare(ProductName, other.ProductName, comparisonIgnoreCase);

            if (productNameComparison != 0)
            {
                return(productNameComparison);
            }
            var companyNameComparison = string.Compare(CompanyName, other.CompanyName, comparisonIgnoreCase);

            if (companyNameComparison != 0)
            {
                return(companyNameComparison);
            }
            var productCountComparison = ProductCount.CompareTo(other.ProductCount);

            if (productCountComparison != 0)
            {
                return(productCountComparison);
            }
            var costWithoutNdsComparison = CostWithoutNds.CompareTo(other.CostWithoutNds);

            if (costWithoutNdsComparison != 0)
            {
                return(costWithoutNdsComparison);
            }
            var summaWithoutNdsComparison = SummaWithoutNds.CompareTo(other.SummaWithoutNds);

            if (summaWithoutNdsComparison != 0)
            {
                return(summaWithoutNdsComparison);
            }
            var summaNdsComparison = SummaNds.CompareTo(other.SummaNds);

            if (summaNdsComparison != 0)
            {
                return(summaNdsComparison);
            }
            var summaWithNdsComparison = SummaWithNds.CompareTo(other.SummaWithNds);

            if (summaWithNdsComparison != 0)
            {
                return(summaWithNdsComparison);
            }
            var summaWithoutNdsAndTaxesComparison = SummaWithoutNdsAndTaxes.CompareTo(other.SummaWithoutNdsAndTaxes);

            if (summaWithoutNdsAndTaxesComparison != 0)
            {
                return(summaWithoutNdsAndTaxesComparison);
            }
            var summaUsdComparison = SummaUsd.CompareTo(other.SummaUsd);

            if (summaUsdComparison != 0)
            {
                return(summaUsdComparison);
            }
            var usdRateComparison = UsdRate.CompareTo(other.UsdRate);

            if (usdRateComparison != 0)
            {
                return(usdRateComparison);
            }
            return(RusRate.CompareTo(other.RusRate));
        }
Beispiel #24
0
        private void RefreshList()
        {
            try
            {
                lvwDayStats.Items.Clear();

                int[] totals = new int[_daystats[0].Products.Count];                // total0 = 0, total1 = 0, total2 = 0, total3 = 0, total4 = 0, total5 = 0;

                foreach (DayStat day in _daystats)
                {
                    if (day.Date < _dtpFrom.Value || day.Date > _dtpTo.Value)
                    {
                        continue;
                    }

                    DayStatListViewItem item = new DayStatListViewItem(day);
                    lvwDayStats.Items.Add(item);

                    for (int i = 0; i < day.Products.Count; i++)
                    {
                        totals[i] += day.Products[i].Count;
                    }
                }

                if (lvwDayStats.Items.Count > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append(string.Format("统计时间段: \n{0} - {1}\n\n",
                                            ((DayStatListViewItem)lvwDayStats.Items[lvwDayStats.Items.Count - 1]).DayStat.Date.ToString("yyyy/MM/dd"),
                                            ((DayStatListViewItem)lvwDayStats.Items[0]).DayStat.Date.ToString("yyyy/MM/dd")));

                    for (int i = 0; i < _daystats[0].Products.Count; i++)
                    {
                        ProductCount pc = _daystats[0].Products[i];
                        sb.Append(string.Format(
                                      "{0}: {1}({2:0.0})\n",
                                      ProductInfo.GetProductInfo(pc.Id).ShortName,
                                      totals[i], (float)totals[i] / lvwDayStats.Items.Count));
                    }

                    int periodTotal = 0;
                    foreach (int i in totals)
                    {
                        periodTotal += i;
                    }

                    sb.Append(string.Format("\n总计: {0}({1:0.0})", periodTotal, (float)periodTotal / lvwDayStats.Items.Count));

                    lblTotalInfo.Text = sb.ToString();

                    //lblTotalInfo.Text = string.Format(
                    //    "统计时间段: \n{7} - {8}\n\nPre: {0}({9:0.0})\n1段: {1}({10:0.0})\n2段: {2}({11:0.0})\n3段: {3}({12:0.0})\n1+: {4}({13:0.0})\n2+: {5}({14:0.0})\n\n总计: {6}({15:0.0})",
                    //    total0, total1, total2, total3, total4, total5,
                    //    total0 + total1 + total2 + total3 + total4 + total5,
                    //    ((DayStatListViewItem)lvwDayStats.Items[lvwDayStats.Items.Count-1]).DayStat.Date.ToString("yyyy/MM/dd"),
                    //    ((DayStatListViewItem)lvwDayStats.Items[0]).DayStat.Date.ToString("yyyy/MM/dd"),
                    //    (float)total0 / lvwDayStats.Items.Count, (float)total1 / lvwDayStats.Items.Count, (float)total2 / lvwDayStats.Items.Count,
                    //    (float)total3 / lvwDayStats.Items.Count, (float)total4 / lvwDayStats.Items.Count, (float)total5 / lvwDayStats.Items.Count,
                    //    (float)(total0 + total1 + total2 + total3 + total4 + total5) / lvwDayStats.Items.Count);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }
        }