コード例 #1
0
        private List<PagingProductSum> Paging(List<Product> products, int rows)
        {
            List<PagingProductSum> sums = new List<PagingProductSum>();

            int record = Convert.ToInt16(Math.Ceiling((double)products.Count/rows));

            for (int i = 1; i < record + 1 ; i++)
            {
                IEnumerable<Product> enumerable = products.Skip((i - 1)*rows).Take(rows);

                PagingProductSum sum = new PagingProductSum();

                foreach (var product in enumerable)
                {
                    sum.Cost += product.Cost;
                    sum.Revenue += product.Revenue;
                    sum.SellPrice += product.SellPrice;
                }

                sums.Add(sum);
            }

            return sums;
        }
コード例 #2
0
        private List <PagingProductSum> Paging(List <Product> products, int rows)
        {
            List <PagingProductSum> sums = new List <PagingProductSum>();

            int record = Convert.ToInt16(Math.Ceiling((double)products.Count / rows));

            for (int i = 1; i < record + 1; i++)
            {
                IEnumerable <Product> enumerable = products.Skip((i - 1) * rows).Take(rows);

                PagingProductSum sum = new PagingProductSum();

                foreach (var product in enumerable)
                {
                    sum.Cost      += product.Cost;
                    sum.Revenue   += product.Revenue;
                    sum.SellPrice += product.SellPrice;
                }

                sums.Add(sum);
            }

            return(sums);
        }