private void yearChooser_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            if (yearChooser.SelectedItem.Equals("Total"))
            {
                monthChooser.Visible = false;
                category.GetTop();
                paidTo.GetTopPayments();
                paidFrom.GetTopIncomes();
            }
            else
            {
                if (monthChart.Visible == false)
                {
                    monthChooser.Visible = true;

                    category.GetTop(yearChooser.SelectedItem.ToString(), monthChooser.SelectedItem.ToString());
                    paidTo.GetTopPayments(yearChooser.SelectedItem.ToString(), monthChooser.SelectedItem.ToString());
                    paidFrom.GetTopIncomes(yearChooser.SelectedItem.ToString(), monthChooser.SelectedItem.ToString());
                }
            }

            DatabaseCalls.FillMonthArrays(yearChooser.SelectedItem.ToString(), paymentMonths, incomeMonths, netMonths);

            ChartCreation.CustomizeMonthChart(monthLiveChart, xAxis);
            ChartCreation.FillMonthChart(paymentChart, paymentMonths);
            ChartCreation.FillMonthChart(incomeChart, incomeMonths);
            ChartCreation.FillMonthChart(netChart, netMonths);

            ChartCreation.FillChart(categoryLiveChart, category.Categories);
            ChartCreation.FillChart(paymentLiveChart, paidTo.Recipients);
            ChartCreation.FillChart(incomeLiveChart, paidFrom.Recipients);
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            string[] sort = { "PaymentAccount", "Category", "Payment", "PaidTo", "TransactionDate" };
            transactionDatePicker.Format       = DateTimePickerFormat.Custom;
            transactionDatePicker.CustomFormat = "yyyy-MM-dd";

            List <Category> categories = DatabaseCalls.GetCategories();

            dataadapter = new MySqlDataAdapter(sql, connection);
            connection.Open();
            dataadapter.Fill(ds, "Budget");
            connection.Close();
            budgetGridView.DataSource = ds.Tables[0];

            budgetGridView.Columns[4].DefaultCellStyle.Format    = "C";
            budgetGridView.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

            budgetGridView.Columns[0].Width = 50;
            budgetGridView.Columns[2].Width = 120;
            budgetGridView.Columns[3].Width = 160;
            budgetGridView.Columns[5].Width = 130;

            foreach (Category category in categories)
            {
                categoryBox.Items.Add(category.Name);
            }
        }
Exemple #3
0
        private void IncomeWindow_Load(object sender, EventArgs e)
        {
            String[] sort = { "IncomeID", "PaidFrom", "Payment", "IncomeDate" };

            transactionDatePicker.Format       = DateTimePickerFormat.Custom;
            transactionDatePicker.CustomFormat = "yyyy-MM-dd";

            DatabaseCalls.GetIncome(dataadapter, ds);

            incomeGridView.DataSource = ds.Tables[0];
            incomeGridView.Columns[2].DefaultCellStyle.Format            = "C";
            incomeGridView.Columns["Payment"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

            incomeGridView.Columns["Id"].Width              = 50;
            incomeGridView.Columns["Recipient"].Width       = 140;
            incomeGridView.Columns["TransactionDate"].Width = 140;

            recipients = Recipient.GetRecipients();
            categories = Category.GetCategories();

            foreach (Category category in categories)
            {
                categoryBox.Items.Add(category.Name);
            }


            foreach (DataGridViewColumn column in incomeGridView.Columns)
            {
                column.SortMode = DataGridViewColumnSortMode.Automatic;
            }
        }
Exemple #4
0
        private void deleteBtn_Click(object sender, EventArgs e)
        {
            income = new Income
            {
                Id = int.Parse(IDBox.Text)
            };

            income.Delete();

            ds.Tables.Clear();
            DatabaseCalls.GetIncome(dataadapter, ds);
            incomeGridView.DataSource = ds.Tables[0];
        }
Exemple #5
0
        private void updateBtn_Click(object sender, EventArgs e)
        {
            income = new Income
            {
                Id          = int.Parse(IDBox.Text),
                RecipientId = recipients.Find(r => r.Name == recipientBox.Text).RecipientId,
                Payment     = Convert.ToDouble(paymentBox.Text),
                PaymentDate = transactionDatePicker.Text
            };

            income.Update();

            ds.Tables.Clear();
            DatabaseCalls.GetIncome(dataadapter, ds);
            incomeGridView.DataSource = ds.Tables[0];
        }
Exemple #6
0
        private void transactionBtn_Click(object sender, EventArgs e)
        {
            income.GetNewestIncome();
            recipients = Recipient.GetRecipients();

            income.RecipientId  = recipients.Find(r => r.Name == recipientBox.Text)?.RecipientId;
            category.CategoryId = categories.Find(c => c.Name == categoryBox.Text)?.CategoryId;

            if (income.RecipientId == null)
            {
                recipient = new Recipient
                {
                    Name = recipientBox.Text
                };
                recipient.Add();

                income.RecipientId = recipient.RecipientId;
            }

            if (category.CategoryId == null)
            {
                category = new Category
                {
                    Name = categoryBox.Text
                };
                category.Add();

                income.RecipientId = recipient.RecipientId;
            }


            income.Payment     = Convert.ToDouble(paymentBox.Text);
            income.PaymentDate = transactionDatePicker.Text;

            income.Insert();

            ds.Tables.Clear();
            DatabaseCalls.GetIncome(dataadapter, ds);
            incomeGridView.DataSource = ds.Tables[0];
        }
        private void StatsWindow_Load(object sender, EventArgs e)
        {
            defaultYearPoint = new Point(yearChooser.Location.X, yearChooser.Location.Y);
            yearPoint        = new Point(monthChooser.Location.X, monthChooser.Location.Y - 60);
            //Find the earliest date that an income or payment was recorded
            String temp1, temp2;

            temp1 = temp2 = "";
            DateTime temp3, temp4;
            int      startMonth = 0;
            int      startYear  = 0;

            try
            {
                temp1 = DatabaseCalls.GetEarliestPayment();
                temp2 = DatabaseCalls.GetEarliestIncome();

                //Convert date strings to DateTime for comparison
                temp3 = Convert.ToDateTime(temp1);
                temp4 = Convert.ToDateTime(temp2);

                startMonth = FindEarliestDate(temp1, temp2, temp3, temp4);
                startYear  = FindEarliestYear(temp1, temp2, temp3, temp4);
            }
            catch (InvalidOperationException)
            {
                label1.Text = "No Stats To Show";
                label1.Left = 190;
                label1.Top  = -50;
                monthBtn.Hide();
                categoryBtn.Hide();
                paidToBtn.Hide();
                paidFromBtn.Hide();
                return;
            }


            DateTime curr     = DateTime.Today;
            String   tempYear = curr.ToString("yyyy");

            //Fill year combobox
            for (int i = startYear; i <= Int32.Parse(tempYear); i++)
            {
                yearChooser.Items.Add(i);
            }
            yearChooser.Items.Add("Total");
            yearChooser.SelectedIndex = yearChooser.Items.Count - 1;

            monthChart.Visible     = false;
            categoryChart1.Visible = false;
            paymentChart1.Visible  = false;
            incomeChart1.Visible   = false;
            yearChooser.Visible    = false;
            monthChooser.Visible   = false;

            yearChooser.DropDownStyle  = ComboBoxStyle.DropDownList;
            monthChooser.DropDownStyle = ComboBoxStyle.DropDownList;

            categories.Clear();
            payments.Clear();
            incomes.Clear();

            String sMonth = DateTime.Now.ToString("MM");
            int    temp   = Int32.Parse(sMonth);

            for (int i = startMonth - 1; i < 12; i++)
            {
                monthChooser.Items.Add(monthName[i]);
            }
            monthChooser.Items.Add("Total");
            monthChooser.SelectedIndex = monthChooser.Items.Count - 1;

            DatabaseCalls.FillMonthArrays(yearChooser.SelectedItem.ToString(), paymentMonths, incomeMonths, netMonths);

            ChartCreation.CustomizeMonthChart(monthLiveChart, xAxis);
            ChartCreation.FillMonthChart(paymentChart, paymentMonths);
            ChartCreation.FillMonthChart(incomeChart, incomeMonths);
            ChartCreation.FillMonthChart(netChart, netMonths);

            foreach (Category category in netMonths)
            {
                xAxis.Add(category.Name);
            }

            monthLiveChart.LegendLocation = LegendLocation.Top;
            monthLiveChart.FontSize       = 20;

            monthLiveChart.Series = new SeriesCollection
            {
                new LineSeries
                {
                    Title             = "Income",
                    Values            = incomeChart,
                    PointForeground   = System.Windows.Media.Brushes.DodgerBlue,
                    PointGeometrySize = 15,
                    StrokeThickness   = 5,
                    Fill = System.Windows.Media.Brushes.Transparent
                },
                new LineSeries
                {
                    Title             = "Payments",
                    Values            = paymentChart,
                    Stroke            = System.Windows.Media.Brushes.Firebrick,
                    StrokeThickness   = 5,
                    PointForeground   = System.Windows.Media.Brushes.Firebrick,
                    PointGeometrySize = 15,
                    Fill = System.Windows.Media.Brushes.Transparent
                },
                new LineSeries
                {
                    Title             = "Profit",
                    Values            = netChart,
                    Stroke            = System.Windows.Media.Brushes.Goldenrod,
                    StrokeThickness   = 5,
                    PointForeground   = System.Windows.Media.Brushes.Goldenrod,
                    PointGeometrySize = 15,
                    Fill = System.Windows.Media.Brushes.Transparent
                }
            };


            category.GetTop();
            paidTo.GetTopPayments();
            paidFrom.GetTopIncomes();

            ChartCreation.FillChart(categoryLiveChart, category.Categories);
            ChartCreation.FillChart(paymentLiveChart, paidTo.Recipients);
            ChartCreation.FillChart(incomeLiveChart, paidFrom.Recipients);
        }