예제 #1
0
        static void Main(string[] args)
        {
            //Read all text documents into arrays
            string[] basic = File.ReadAllLines($"{Directory.GetCurrentDirectory()}\\Basic.txt");
            string[] delux = File.ReadAllLines($"{Directory.GetCurrentDirectory()}\\Delux.txt");
            string[] total = File.ReadAllLines($"{Directory.GetCurrentDirectory()}\\Total.txt");

            int      curIndex = basic.Length - 1;
            DateTime curDate  = DateTime.Today;

            List <DaySale> sales     = new List <DaySale>();
            RevenueTotals  RevTotals = new RevenueTotals(); //Main reporting class

            //Loop through indexes of all the basic, delux and total text files and create a new DaySale class and append to a list
            while (curIndex > 0)
            {
                int     basicSaleNum = Convert.ToInt32(basic[curIndex]);
                int     deluxSaleNum = Convert.ToInt32(delux[curIndex]);
                int     totalSale    = Convert.ToInt32(total[curIndex]);
                DaySale newDaySale   = new DaySale(basicSaleNum, deluxSaleNum, totalSale, curDate);

                sales.Add(newDaySale);
                RevTotals.addDay(newDaySale);

                curIndex--;
                curDate = curDate.AddDays(-1);
            }


            //Console.WriteLine(RevTotals.RevenueReport());
            //Console.WriteLine(RevTotals.GraphReport());
            WriteToFile("RevReport", RevTotals.RevenueReport());

            Console.ReadLine();
        }
예제 #2
0
        private void AddRevTotals(int year, int month, DaySale daySales)
        {
            RevTotals[year][month]["basic"] += daySales.Basic;
            RevTotals[year][month]["delux"] += daySales.Delux;
            RevTotals[year][month]["total"] += daySales.Total;

            if (YearsTotal.Keys.Contains(year))
            {
                YearsTotal[year] += daySales.Total;
            }
            else
            {
                YearsTotal.Add(year, daySales.Total);
            }
        }
예제 #3
0
        public void addDay(DaySale daySales)
        {
            //receive a daysale object, check to make sure year (from Date) is a key
            //If year is a key, check to make sure month is a key
            //if month is a key, add basic, delux and total
            //if month is not a key, create key
            //if year is not a key, add in new dictionary key and new month
            int year  = daySales.Date.Year;
            int month = daySales.Date.Month;

            if (RevTotals.Keys.Contains(year))
            {
                //contains year
                if (RevTotals[year].Keys.Contains(month))
                {
                    //contains month, add to year:month:(basic, delux, totals)
                    AddRevTotals(year, month, daySales);
                }
                else
                {
                    //add month
                    var dictTotals = new Dictionary <string, int>();
                    CreateNewDictTotals(dictTotals); //Add base values for new month dictionary totals

                    RevTotals[year].Add(month, dictTotals);

                    AddRevTotals(year, month, daySales);
                }
            }
            else
            {
                //add year and new month
                var dictTotals = new Dictionary <string, int>();
                CreateNewDictTotals(dictTotals); //Add base values for new month dictionary totals

                var yearDict = new Dictionary <int, Dictionary <string, int> >();
                yearDict.Add(daySales.Date.Month, dictTotals); //Add new month, and dictTotals to new dictionary month

                RevTotals.Add(daySales.Date.Year, yearDict);   //Add new year (and above yearDict) to the RevTotals

                AddRevTotals(year, month, daySales);
            }
        }