Example #1
0
        public static List<SalesModel> GetSalesOneQuery(DateTime stDate, DateTime endDate)
        {
            using (base3Entities db = new base3Entities())
            {
                var db3 = new base2Entities();
                List<SalesModel> result = new List<SalesModel>();

                var qSeb = Accessors.QueryForGetSalesForSeb(stDate, endDate, db, db3);
                //только инфа по группам и производителям или как их
                SalesModel tmp = new SalesModel();
                tmp.Date = stDate;
                tmp.Sales = QueryForGetSales(stDate, endDate, db, qSeb, db3);
                if (tmp.Sales.Count != 0)
                    result.Add(tmp);

                return result;
            }
        }
Example #2
0
        public static List<SalesModel> GetSales(DateTime stDate, DateTime endDate, bool isLoadBeginOfTheTime = false)
        {
            using (base3Entities db = new base3Entities())
            {                
                endDate = endDate.AddSeconds(-1);
                List<SalesModel> result = new List<SalesModel>();
                int[] endMonthYear = new int[] { endDate.Month, endDate.Year };

                var db3 = new base2Entities();
                int monthCount = 0;
                int[] startMonthYear = new int[] { stDate.Month, stDate.Year };//будем бежать от начала до конца периода
                List<SalesEnt> qSeb = new List<SalesEnt>();
                if(!isLoadBeginOfTheTime)
                    qSeb = Accessors.QueryForGetSalesForSeb(stDate, endDate, db, db3);
                do
                {
                    DateTime stDt = new DateTime(startMonthYear[1], startMonthYear[0], 1);
                    DateTime endDt = new DateTime();
                    #region Cчитаем кол-во месяцев
                    if (startMonthYear[0] == 12)
                    {
                        startMonthYear[1]++;
                        startMonthYear[0] = 1;
                        monthCount++;
                        endDt = new DateTime(startMonthYear[1], startMonthYear[0], 1);
                    }
                    else
                    {
                        startMonthYear[0]++;
                        monthCount++;
                        endDt = new DateTime(startMonthYear[1], startMonthYear[0], 1);
                    }
                    #endregion
                    
                    SalesModel tmp = new SalesModel();
                    tmp.Date = stDt;
                    tmp.Sales = QueryForGetSales(stDt, endDt, db, qSeb, db3);
                    if(tmp.Sales.Count != 0)
                        result.Add(tmp);
                }
                while ((startMonthYear[1] <= endMonthYear[1] && startMonthYear[1] != endMonthYear[1]) || (startMonthYear[0] <= endMonthYear[0] && startMonthYear[1] == endMonthYear[1]));
                
                return result;
            }
        }