Пример #1
0
        private void CurrentToggle_CheckedChanged(object sender, EventArgs e)
        {
            ClearTables();
            prod_data.Clear();
            current_month = !current_month;
            // clear data and tables, reset sales and renenue count
            _totalSales   = 0;
            _totalRevenue = 0;

            if (current_month)
            {
                _to   = DateTime.Now;
                _from = firstDayOfThisMonth;
            }
            else
            {
                _to   = firstDayOfThisMonth.AddDays(-1);
                _from = firstDayOfThisMonth.AddMonths(-1);
            }

            _SalesList.Clear();
            _SalesList = _PHPRepo.GetSaleByDate(_from, _to);
            DisplaySales();
            ReportTable.Update();
            TotalsTable.Update();
        }
Пример #2
0
 public WeeklyReport(PHPRepo pHPRepo)
 {
     InitializeComponent();
     _PHPRepo   = pHPRepo;
     _from      = DateTime.Now.AddDays(-(int)DateTime.Now.DayOfWeek);
     _to        = DateTime.Now;
     _SalesList = pHPRepo.GetSaleByDate(_from, _to);
     DisplaySales();
 }
Пример #3
0
        public MonthlyReport(PHPRepo pHPRepo)
        {
            InitializeComponent();

            firstDayOfThisMonth = DateTime.Today.AddDays(-(DateTime.Today.Day - 1));
            _to   = firstDayOfThisMonth.AddDays(-1);
            _from = firstDayOfThisMonth.AddMonths(-1);

            _PHPRepo   = pHPRepo;
            _SalesList = _PHPRepo.GetSaleByDate(_from, _to);
            DisplaySales();
        }
Пример #4
0
        private void PredictWeeklySales(object sender, EventArgs e)
        {
            List <Sale> WeeklySalesList;

            double[] WeeklySales = new double[4] {
                0, 0, 0, 0
            };
            double[] TotalCost = new double[4] {
                0, 0, 0, 0
            };
            ProductTypeList = _PHPRepo.GetProductByType(_productType);
            //Check for error in input
            if (!(ProductTypeList.Any()))
            {
                MessageBox.Show("Invalid Product Type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                ProductTypeTextBox.Text = _productType;
                PredictionPeriod.Text   = DateTime.Now.ToString() + " - " + DateTime.Now.AddDays(7).ToString();
            }
            //Data from previous 2 weeks
            for (int i = 0; i < 2; i++)
            {
                //Fill first 2 eleement of array with data from previous 2 weeks
                WeeklySalesList = _PHPRepo.GetSaleByDate(DateTime.Now.AddDays(-7 - i * 7), DateTime.Now.AddDays(-i * 7));
                foreach (Product p in ProductTypeList)
                {
                    foreach (Sale s in WeeklySalesList)
                    {
                        foreach (ProductSale ps in s.ProductSales)
                        {
                            if (ps.Product == p)
                            {
                                TotalCost[i]  += ps.Product.Price * ps.Quantity;
                                WeeklySales[i] = WeeklySales[i] + ps.Quantity;
                            }
                        }
                    }
                }
            }

            for (int i = 2; i < 4; i++)
            {
                WeeklySalesList = _PHPRepo.GetSaleByDate(DateTime.Now.AddYears(1 - i).AddDays(-7), DateTime.Now.AddYears(1 - i));
                foreach (Product p in ProductTypeList)
                {
                    foreach (Sale s in WeeklySalesList)
                    {
                        foreach (ProductSale ps in s.ProductSales)
                        {
                            if (ps.Product == p)
                            {
                                TotalCost[i]  += ps.Product.Price * ps.Quantity;
                                WeeklySales[i] = WeeklySales[i] + ps.Quantity;
                            }
                        }
                    }
                }
            }
            PredictedSales.Text = PredictSales(WeeklySales).ToString();
            TotalCostText.Text  = "$" + CostPrediction(TotalCost).ToString();
        }