private void createChart2()
        {
            var today     = DateTime.Today;
            var month     = new DateTime(today.Year, today.Month, 1);
            var lastMonth = month.AddMonths(-4);
            var invoices  = new double[4];
            var receipts  = new double[4];
            var expenses  = new double[4];

            Labels2 = new string[4];

            for (var i = 0; i < 4; i++)
            {
                receipts[i] = ReceiptViewModel.getTotalReceiptsMonthYear(lastMonth.Month, lastMonth.Year) + InvoiceViewModel.getPaidInvoicesbyMonthYear(lastMonth.Month, lastMonth.Year);;
                invoices[i] = InvoiceViewModel.getTotalSalesMonthYear(lastMonth.Month, lastMonth.Year);
                expenses[i] = ExpensesViewModel.getTotalExpensesMonthYear(lastMonth.Month, lastMonth.Year);
                Labels2[i]  = lastMonth.Month.ToString();
                lastMonth   = lastMonth.AddMonths(1);
            }

            var totalReceipt = new ChartValues <double>();

            totalReceipt.AddRange(receipts);

            var total = new ChartValues <double>();

            total.AddRange(invoices);

            var totalExpenses = new ChartValues <double>();

            totalExpenses.AddRange(expenses);

            SeriesCollection2 = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title  = "Sales",
                    Values = total
                },
                new ColumnSeries
                {
                    Title  = "Receipts",
                    Values = totalReceipt
                },
                new ColumnSeries
                {
                    Title  = "Expenses",
                    Values = totalExpenses
                }
            };

            Formatter = value => value.ToString("N");

            DataContext = this;
        }
        private void createChart1()
        {
            float  totalYearlySales    = 0;
            double totalYearlyReceipts = 0;

            var receipts = new double[12];

            for (var i = 0; i < 12; i++)
            {
                double temp1 = ReceiptViewModel.getTotalReceiptsMonthYear(i + 1, DateTime.Now.Year) + InvoiceViewModel.getPaidInvoicesbyMonthYear(i + 1, DateTime.Now.Year);
                receipts[i]          = temp1;
                totalYearlyReceipts += temp1;
            }
            var totalReceipt = new ChartValues <double>();

            totalReceipt.AddRange(receipts);

            var invoices = new double[12];

            for (var i = 0; i < 12; i++)
            {
                invoices[i]       = InvoiceViewModel.getTotalSalesMonthYear(i + 1, DateTime.Now.Year);
                totalYearlySales += InvoiceViewModel.getTotalSalesMonthYear(i + 1, DateTime.Now.Year);
            }
            var total = new ChartValues <double>();

            total.AddRange(invoices);
            SeriesCollection = new SeriesCollection

            {
                new LineSeries
                {
                    Title  = "Sales",
                    Values = total
                },
                new LineSeries
                {
                    Title         = "Receipts",
                    Values        = totalReceipt,
                    PointGeometry = null
                }
            };
            salesCountYearly.Text    = totalYearlySales.ToString();
            receiptsCountYearly.Text = totalYearlyReceipts.ToString("C");
            YFormatter  = value => value.ToString("C");
            DataContext = this;
        }
Example #3
0
        private void BtnSelectProduct_Click(object sender, RoutedEventArgs e)
        {
            totalReceipts.Clear();
            totalReceiptsLastYear.Clear();
            totalPaidInvoices.Clear();
            totalPaidInvoicesLastYear.Clear();
            total.Clear();
            totalLastYear.Clear();
            invoices.Clear();
            invoicesLastYear.Clear();

            var moment = DateTime.Now;

            if (cmbBoxLast.Text == "Numbers")
            {
                for (var i = 1; i <= 12; i++)
                {
                    var temp1 = ReceiptViewModel.getTotalReceiptsMonthYear(i, moment.Year);
                    totalReceipts.Add(temp1);
                    var temp2 = ReceiptViewModel.getTotalReceiptsMonthYear(i, moment.Year - 1);
                    totalReceiptsLastYear.Add(temp2);
                    var temp3 = InvoiceViewModel.getPaidInvoicesbyMonthYear(i, moment.Year);
                    totalPaidInvoices.Add(temp3);
                    var temp4 = InvoiceViewModel.getPaidInvoicesbyMonthYear(i, moment.Year - 1);
                    totalPaidInvoicesLastYear.Add(temp4);
                    total.Add(temp1 + temp3);
                    totalLastYear.Add(temp2 + temp4);
                    invoices.Add(InvoiceViewModel.getTotalSalesMonthYear(i, moment.Year));
                    invoicesLastYear.Add(InvoiceViewModel.getTotalSalesMonthYear(i, moment.Year - 1));
                }


                SeriesCollection = new SeriesCollection
                {
                    new LineSeries
                    {
                        Title  = "Total Receipts",
                        Values = totalReceipts
                    },
                    new LineSeries
                    {
                        Title  = "Last Year Receipts",
                        Values = totalReceiptsLastYear
                    }
                };
                SeriesCollection2 = new SeriesCollection
                {
                    new LineSeries
                    {
                        Title  = "Total Paid Invoices",
                        Values = totalPaidInvoices
                    },
                    new LineSeries
                    {
                        Title  = "Last Year Paid Invoices",
                        Values = totalPaidInvoicesLastYear
                    },
                };
                SeriesCollection3 = new SeriesCollection
                {
                    new LineSeries
                    {
                        Title  = "Total Paid Invoices",
                        Values = total
                    },
                    new LineSeries
                    {
                        Title  = "Total Last Year Paid Invoices",
                        Values = totalLastYear
                    },
                    new ColumnSeries
                    {
                        Title  = "Invoices",
                        Values = invoices
                    },
                    new ColumnSeries
                    {
                        Title  = "Invoices Last Year",
                        Values = invoicesLastYear
                    }
                };
                YFormatter = value => value.ToString("c");
            }
            if (cmbBoxLast.Text == "Percentage")
            {
                for (var i = 1; i <= 12; i++)
                {
                    var totalSales   = InvoiceViewModel.getTotalSalesMonthYear(i, moment.Year);
                    var totalSalesLY = InvoiceViewModel.getTotalSalesMonthYear(i, moment.Year - 1);

                    var temp1 = ReceiptViewModel.getTotalReceiptsMonthYear(i, moment.Year) / totalSales;
                    totalReceipts.Add(temp1);
                    var temp2 = ReceiptViewModel.getTotalReceiptsMonthYear(i, moment.Year - 1) / totalSalesLY;
                    totalReceiptsLastYear.Add(temp2);
                    var temp3 = InvoiceViewModel.getPaidInvoicesbyMonthYear(i, moment.Year) / totalSales;
                    totalPaidInvoices.Add(temp3);
                    var temp4 = InvoiceViewModel.getPaidInvoicesbyMonthYear(i, moment.Year - 1) / totalSalesLY;
                    totalPaidInvoicesLastYear.Add(temp4);
                    total.Add(temp1 + temp3);
                    totalLastYear.Add(temp2 + temp4);
                }


                SeriesCollection = new SeriesCollection
                {
                    new LineSeries
                    {
                        Title  = "Total Receipts",
                        Values = totalReceipts
                    },
                    new LineSeries
                    {
                        Title  = "Last Year Receipts",
                        Values = totalReceiptsLastYear
                    }
                };
                SeriesCollection2 = new SeriesCollection
                {
                    new LineSeries
                    {
                        Title  = "Total Paid Invoices",
                        Values = totalPaidInvoices
                    },
                    new LineSeries
                    {
                        Title  = "Last Year Paid Invoices",
                        Values = totalPaidInvoicesLastYear
                    },
                };
                SeriesCollection3 = new SeriesCollection
                {
                    new LineSeries
                    {
                        Title  = "Total Paid Invoices",
                        Values = total
                    },
                    new LineSeries
                    {
                        Title  = "Total Last Year Paid Invoices",
                        Values = totalLastYear
                    },
                };
                YFormatter = value => value.ToString("P");
            }

            DataContext = this;
        }