Esempio n. 1
0
        /// <summary>
        /// Used to populate quick preview listboxes
        /// </summary>
        private void GenerateQuickPreview()
        {
            DateTime          to = DateTime.Now;
            DateTime          from;
            List <Entry>      entries;
            EntriesController eController = new EntriesController();
            EntriesFilter     filter      = new EntriesFilter(DateTime.Now, to); // using DateTime.Now just to initialize

            // Today, past 7, past 30
            int[]     decrease = { 0, -7, -30 };
            ListBox[] lbs      = { today_lb, pastSevenDays_lb, pastThrityDays_lb };
            for (int i = 0; i < decrease.Length; i++)
            {
                from             = to.AddDays(decrease[i]).AddHours(to.Hour * -1).AddMinutes(to.Minute * -1).AddSeconds(to.Second * -1);
                filter.from_date = from;
                entries          = eController.FilterEntriesForChart(filter);
                PopulateListBox(entries, lbs[i]);
            }

            // Past 6 months
            from             = to.AddMonths(-6).AddHours(to.Hour * -1).AddMinutes(to.Minute * -1).AddSeconds(to.Second * -1);
            filter.from_date = from;
            entries          = eController.FilterEntriesForChart(filter);
            PopulateListBox(entries, pastSixMonths_lb);

            // Past year
            from             = to.AddYears(-1).AddHours(to.Hour * -1).AddMinutes(to.Minute * -1).AddSeconds(to.Second * -1);
            filter.from_date = from;
            entries          = eController.FilterEntriesForChart(filter);
            PopulateListBox(entries, pastYear_lb);

            // This year
            from             = to.AddMonths((to.Month - 1) * -1).AddDays((to.Day - 1) * -1).AddHours(to.Hour * -1).AddMinutes(to.Minute * -1).AddSeconds(to.Second * -1);
            filter.from_date = from;
            entries          = eController.FilterEntriesForChart(filter);
            PopulateListBox(entries, thisYear_lb);

            // All time
            entries = eController.GetAllEntries();
            PopulateListBox(entries, allTime_lb);
        }