public new void DataBind()
        {
            using (var ctx = new DCFactory<StoreDataContext>())
            {

                var TotalStringCount = LightBO.GetStringCount(LowDate, HiDate, CurrentPageSize, CurrentPageIndex, CurrentUserId, OrderId, LightBO.SupplyOrderLineStatus);
                List<ReportString> ordlnsdto = new List<ReportString>();
                //Вставили пустые те, что до заполненных
                ordlnsdto.InsertRange(0, new ReportString[(CurrentPageSize * (CurrentPageIndex))].ToList());
                ordlnsdto.InsertRange(ordlnsdto.Count, LightBO.GetSupplyStrings(LowDate, HiDate, CurrentPageSize, CurrentPageIndex, sortExpression, direction, CurrentUserId, OrderId));
                ordlnsdto.InsertRange(ordlnsdto.Count, new ReportString[(TotalStringCount - ordlnsdto.Count)].ToList()); //Добавили недостающие пустые строчки

                LightBO.FillSupplyPrice(ordlnsdto);
                ordlnsdto.FindAll(x => x != null).ForEach(n => n.Total = n.UnitPrice * n.Qty);

                 //Итоговая строчка добаляется на последней странице
                if ((TotalStringCount + 1) / CurrentPageSize == CurrentPageIndex && ordlnsdto.Count > 0)
                {

                    ordlnsdto = LightBO.GetSupplyStrings(LowDate, HiDate, TotalStringCount, 0, sortExpression, direction, CurrentUserId, OrderId);
                    LightBO.FillSupplyPrice(ordlnsdto);
                    ReportString s = new ReportString() { StatusChangeTime = HiDate, ClientName = ReportString.TotalString, Qty = ordlnsdto.Sum(y => y.Qty), SupplyTotal = ordlnsdto.Sum(x => x.SupplyTotal) };
                    s.SortAttribute = 1;
                    ordlnsdto.Add(s);
                }

                ReportGrid.DataSource = ordlnsdto.ToArray();
                ReportGrid.DataBind();
            }
        }
        public ActionResult ReportOut()
        {
            string[][] RaschetCount = new string[4][];
            string[][] RaschetSum   = new string[4][];



            DataClasses1DataContext db     = new DataClasses1DataContext();
            Calculations            calcDB = new Calculations();

            var listTariffServiecs = db.ExecuteQuery <type_servies>(@"SELECT * FROM [type_servies]").ToList <type_servies>();

            //тут все весна
            //DateTime Do = new DateTime(2016, 04, 01, 0, 0, 0);
            //DateTime To = new DateTime(2016, 06, 30, 23, 59, 59);
            string Do = "2016-04-01T00:00:00.000";
            string To = "2016-06-30T23:59:59.997";


            for (int i = 0; i < RaschetCount.Length; i++)
            {
                RaschetCount[i] = new string[4];
                RaschetSum[i]   = new string[4];

                int sum = 0, count = 0;
                for (int j = 0; j < RaschetCount[i].Length; j++)
                {
                    RaschetCount[i][j] = FromQueryCount(db, j + 1, i + 1, Do, To).ToString();
                    //RaschetSum[i][j] = FromQuerySum(db, i, j, Do, To).ToString();
                    RaschetSum[i][j] = (Convert.ToInt32(listTariffServiecs[i].tariff) * Convert.ToInt32(RaschetCount[i][j])).ToString();

                    count += int.Parse(RaschetCount[i][j]);
                    sum   += int.Parse(RaschetSum[i][j]);
                }
                RaschetCount[i][3] = count.ToString();
                RaschetSum[i][3]   = sum.ToString();
            }


            //RaschetSum[RaschetSum.Length][RaschetSum[RaschetSum[RaschetSum.Length]]] =

            { }

            /*
             *
             *
             * // тут типы номеров
             * int Econom = 3;
             * int Standart = 2;
             * int Lux = 1;
             *
             * //тут дополнительные услуги
             * int dicko = 1;
             * int bar = 2;
             * int beauty = 3;
             * int beach = 4;
             *
             *
             *
             *
             * //Эконом класс
             * //Дискотека
             * calcDB.EconomDiscoCount = FromQueryCount(db, Econom, dicko, Do, To);
             * calcDB.EconomDiscoSum = FromQuerySum(db, Econom, dicko, Do, To);
             *
             *
             * //Бар
             * calcDB.EconomBarCount = FromQueryCount(db, Econom, bar, Do, To);
             * calcDB.EconomBarSum = FromQuerySum(db, Econom, bar, Do, To);
             *
             * //Салон красоты
             * calcDB.EconomBeautyCount = FromQueryCount(db, Econom, beauty, Do, To);
             * calcDB.EconomBeautySum = FromQuerySum(db, Econom, beauty, Do, To);
             *
             * //Пляж
             * calcDB.EconomBeachCount = FromQueryCount(db, Econom, beach, Do, To);
             * calcDB.EconomBeachSum = FromQuerySum(db, Econom, beach, Do, To);
             *
             * //Итоги
             * calcDB.itogiEconomCount = calcDB.EconomDiscoCount + calcDB.EconomBarCount + calcDB.EconomBeautyCount + calcDB.EconomBeachCount;
             * calcDB.itogiEconomSum = calcDB.EconomDiscoSum + calcDB.EconomBarSum + calcDB.EconomBeachSum + calcDB.EconomBeachSum;
             *
             *
             *
             *
             * //Стандарт
             * //Дискотека
             * calcDB.StandartDiscoCount = FromQueryCount(db, Standart, dicko, Do, To);
             * calcDB.StandartDiscoSum = FromQuerySum(db, Standart, dicko, Do, To);
             *
             * //Бар
             * calcDB.StandartBarCount = FromQueryCount(db, Standart, bar, Do, To);
             * calcDB.StandartBarSum = FromQuerySum(db, Standart, bar, Do, To);
             *
             * //Салон красоты
             * calcDB.StandartBeautyCount = FromQueryCount(db, Standart, beauty, Do, To);
             * calcDB.StandartBeautySum = FromQuerySum(db, Standart, beauty, Do, To);
             *
             * //Пляж
             * calcDB.StandartBeachCount = FromQueryCount(db, Standart, beach, Do, To);
             * calcDB.StandartBeachSum = FromQuerySum(db, Standart, beach, Do, To);
             *
             * //Итоги
             * calcDB.itogiStandartCount = calcDB.StandartDiscoCount + calcDB.StandartBarCount + calcDB.StandartBeautyCount + calcDB.StandartBeachCount;
             * calcDB.itogiStandartSum = calcDB.StandartDiscoSum + calcDB.StandartBarSum + calcDB.StandartBeautySum + calcDB.StandartBeachSum;
             *
             *
             *
             *
             * //Люкс
             * //Дискотека
             * calcDB.LuxDiscoCount = FromQueryCount(db, Lux, dicko, Do, To);
             * calcDB.LuxDiscoSum = FromQuerySum(db, Lux, dicko, Do, To);
             *
             * //Бар
             * calcDB.LuxBarCount = FromQueryCount(db, Lux, bar, Do, To);
             * calcDB.LuxBarSum = FromQuerySum(db, Lux, bar, Do, To);
             *
             * //Салон красоты
             * calcDB.LuxBeautyCount = FromQueryCount(db, Lux, beauty, Do, To);
             * calcDB.LuxBeautySum = FromQuerySum(db, Lux, beauty, Do, To);
             *
             * //Пляж
             * calcDB.LuxBeachCount = FromQueryCount(db, Lux, beach, Do, To);
             * calcDB.LuxBeachSum = FromQuerySum(db, Lux, beach, Do, To);
             *
             * //Итоги
             * calcDB.itogiLuxCount = calcDB.LuxDiscoCount + calcDB.LuxBarCount + calcDB.LuxBeautyCount + calcDB.LuxBeachCount;
             * calcDB.itogiLuxSum = calcDB.LuxDiscoSum + calcDB.LuxBarSum + calcDB.LuxBeautySum + calcDB.LuxBeachSum;
             *
             */
            //
            //Люкс
            //calcDB.itogiBarLuxCount =

            //return View(calcDB);

            ReportString fff = new ReportString();

            fff.RRR = RaschetSum;
            fff.TTT = RaschetCount;

            //return View(RaschetSum);

            return(View(fff));
        }
        public new void DataBind()
        {
            var TotalStringCount = LightBO.GetStringCount(LowDate, HiDate, CurrentPageSize, CurrentPageIndex, CurrentUserId, OrderId, LightBO.SaleOrderLineStatus);
            List<ReportString> ordlnsdto = new List<ReportString>();
            //Вставили пустые те, что до заполненных
            ordlnsdto.InsertRange(0, new ReportString[(CurrentPageSize * (CurrentPageIndex))].ToList());
            ordlnsdto.InsertRange(ordlnsdto.Count, LightBO.GetSaleStrings(LowDate, HiDate, CurrentPageSize, CurrentPageIndex, sortExpression, direction, CurrentUserId, OrderId));
            ordlnsdto.InsertRange(ordlnsdto.Count, new ReportString[(TotalStringCount - ordlnsdto.Count)].ToList()); //Добавили недостающие пустые строчки

            LightBO.FillSupplyPrice(ordlnsdto);

            ordlnsdto.FindAll(n => n != null).ForEach(n => n.ProfitSumm = (n.UnitPrice - n.SupplyPrice) * n.Qty);
            ////ordlnsdto.ForEach(n => n.ProfitPercent = Math.Round((n.ProfitSumm / n.SaleSumm ) * 100, 2));
            //// Рентабельность = Прибыль / Цена закупки (*100 - в процентах) !!! Со слов И.С. Беженуца рентабельность = колонка 12 / колонка 9 * кол-во
            ordlnsdto.FindAll(n => n != null).ForEach(n => n.ProfitPercent = Math.Round((n.ProfitSumm / (n.SupplyPrice * n.Qty)) * 100, 2));

            //Итоговая строчка добаляется на последней странице
            if ((TotalStringCount +1) / CurrentPageSize == CurrentPageIndex)
            {
                List<ReportString> ordlnsSum = LightBO.GetRefId(LowDate, HiDate, CurrentPageSize, CurrentPageIndex, sortExpression, direction, CurrentUserId, OrderId);

                LightBO.FillSupplyPrice(ordlnsSum);

                ReportString s = new ReportString()
                {
                    StatusChangeTime = HiDate,
                    ClientName = ReportString.TotalString,
                    Qty = ordlnsSum.Sum(y => y.Qty),
                    Total = ordlnsSum.Sum(x => x.Total),
                    ProfitSumm = ordlnsSum.Sum(x => x.Total) - ordlnsSum.Sum(x => x.SupplyPrice * x.Qty),

                    // ProfitPercent = Math.Round(((ordlnsSum.Sum(x => x.ProfitSumm) / (ordlnsSum.Sum(x => x.Total) == 0 ? 1 : ordlnsSum.Sum(x => x.Total))) * 100), 2),
                    SortAttribute = 1
                };

                if (ordlnsSum.Count > 0)
                {
                    s.ProfitPercent = Math.Round(s.ProfitSumm / ordlnsSum.Sum(x => x.SupplyPrice * x.Qty) * 100, 2);
                    ordlnsdto.Add(s);
                }
            }

            ReportGrid.DataSource = ordlnsdto.ToArray();
            ReportGrid.DataBind();
        }