public static List <int> BasketAverages()
        {
            using (Data_AllTablesDataContext db = new Data_AllTablesDataContext("Data Source=10.1.10.114,1434;Initial Catalog=benDover;Persist Security Info=True;User ID=ugoadmin;Password=ugo-2019"))
            {
                var q = (from x in db.theORDERs select x);
                q.ToList();

                int one = 0, two = 0, three = 0,
                    four = 0, five = 0, overFive = 0;

                foreach (var z in q)
                {
                    // if total is less than or equal 9.99
                    if (z.BasketSize.CompareTo(Convert.ToDecimal(1.00)) <= 0)
                    {
                        one++;
                    }
                    else if (z.BasketSize.CompareTo(Convert.ToDecimal(2.00)) <= 0)
                    {
                        two++;
                    }
                    else if (z.BasketSize.CompareTo(Convert.ToDecimal(3.00)) <= 0)
                    {
                        three++;
                    }
                    else if (z.BasketSize.CompareTo(Convert.ToDecimal(4.00)) <= 0)
                    {
                        four++;
                    }
                    else if (z.BasketSize.CompareTo(Convert.ToDecimal(5.00)) <= 0)
                    {
                        five++;
                    }
                    else if (z.BasketSize.CompareTo(Convert.ToDecimal(5.00)) > 0)
                    {
                        overFive++;
                    }
                }

                List <int> countList = new List <int>
                {
                    one,
                    two,
                    three,
                    four,
                    five,
                    overFive
                };

                return(countList);
            }
        }
        public static List <int> OrderRanges()
        {
            using (Data_AllTablesDataContext db = new Data_AllTablesDataContext("Data Source=10.1.10.114,1434;Initial Catalog=benDover;Persist Security Info=True;User ID=ugoadmin;Password=ugo-2019"))
            {
                var q = (from x in db.theORDERs select x);
                q.ToList();

                int zeroToTen = 0, tenToFteen = 0, fteenToTwenty = 0,
                    twentyToTFive = 0, tFiveToThrity = 0, overThirty = 0;

                foreach (var z in q)
                {
                    // if total is less than or equal 9.99
                    if (z.Total.CompareTo(Convert.ToDecimal(10.00)) <= 0)
                    {
                        zeroToTen++;
                    }
                    else if (z.Total.CompareTo(Convert.ToDecimal(15.00)) <= 0)
                    {
                        tenToFteen++;
                    }
                    else if (z.Total.CompareTo(Convert.ToDecimal(20.00)) <= 0)
                    {
                        fteenToTwenty++;
                    }
                    else if (z.Total.CompareTo(Convert.ToDecimal(25.00)) <= 0)
                    {
                        twentyToTFive++;
                    }
                    else if (z.Total.CompareTo(Convert.ToDecimal(30.00)) <= 0)
                    {
                        tFiveToThrity++;
                    }
                    else if (z.Total.CompareTo(Convert.ToDecimal(30.00)) > 0)
                    {
                        overThirty++;
                    }
                }

                List <int> countList = new List <int>
                {
                    zeroToTen,
                    tenToFteen,
                    fteenToTwenty,
                    twentyToTFive,
                    tFiveToThrity,
                    overThirty
                };

                return(countList);
            }
        }
        public static void GetSalesDataToday()
        {
            using (Data_AllTablesDataContext db = new Data_AllTablesDataContext("Data Source=10.1.10.114,1434;Initial Catalog=benDover;Persist Security Info=True;User ID=ugoadmin;Password=ugo-2019"))
            {
                CultureInfo ci = new CultureInfo("en-us");

                // Set the number of orders for today (12:00:00 am - 11:59:59 pm)
                var q = from theORDERs in db.theORDERs
                        where theORDERs.oTimeStamp.Date.CompareTo(DateTime.Now.Date) >= 0
                        select theORDERs;
                Properties.Settings.Default.Orders_Today = q.Count();

                // Set the average basket size for today
                foreach (var y in q)
                {
                    _avgBasketToday += double.Parse(y.BasketSize.ToString("N"));
                }
                Properties.Settings.Default.BAVG_Today = Math.Round(_avgBasketToday / q.Count(), 1);

                // Set the average price for today
                tmp = 0.0;
                foreach (var z in q)
                {
                    tmp += double.Parse(z.Total.ToString("N"));
                }
                Properties.Settings.Default.PAVG_Today = Math.Round(tmp / q.Count(), 2).ToString("C", ci);

                // Set the number of orders for the trailing week
                var qw = from theORDERs in db.theORDERs
                         where theORDERs.oTimeStamp.Date.CompareTo(DateTime.Now.AddDays(-7).Date) >= 0
                         select theORDERs;
                Properties.Settings.Default.Orders_Week = qw.Count();

                // Set the average basket size for the trailing week
                foreach (var yw in qw)
                {
                    _avgBasketWeek += double.Parse(yw.BasketSize.ToString("N"));
                }
                _avgBasketWeek = Math.Round(_avgBasketToday / qw.Count(), 1);
                Properties.Settings.Default.BAVG_Week = _avgBasketWeek;

                // Set the average price for the trailing week
                tmp = 0.0;
                foreach (var zw in qw)
                {
                    tmp += double.Parse(zw.Total.ToString("N"));
                }
                Properties.Settings.Default.PAVG_Week = Math.Round(tmp / qw.Count(), 2).ToString("C", ci);

                // Set the number of orders for the trailing month
                var qm = from theORDERs in db.theORDERs
                         where theORDERs.oTimeStamp.Date.CompareTo(DateTime.Now.AddDays(-31).Date) >= 0
                         select theORDERs;
                Properties.Settings.Default.Orders_Month = qm.Count();

                // Set the average basket size for the trailing month
                tmp = 0.0;
                foreach (var ym in qm)
                {
                    tmp += double.Parse(ym.BasketSize.ToString("N"));
                }
                Properties.Settings.Default.BAVG_Month = Math.Round(tmp / qm.Count(), 1);

                // Set the average price for the trailing month
                tmp = 0.0;
                foreach (var tm in qm)
                {
                    tmp += double.Parse(tm.Total.ToString("N"));
                }
                Properties.Settings.Default.PAVG_Month = Math.Round(tmp / qm.Count(), 2).ToString("C", ci);

                Properties.Settings.Default.Save();
            }
        }