-
Notifications
You must be signed in to change notification settings - Fork 0
/
HomePage.cs
138 lines (113 loc) · 4.51 KB
/
HomePage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using Xunit;
using MindFusion.Charting;
using MindFusion.Charting.Components;
using MindFusion.Drawing;
using Color = System.Drawing.Color;
namespace courseWork02
{
public partial class HomePage : Form
{
public HomePage()
{
InitializeComponent();
}
private void btnIncome_Click(object sender, EventArgs e)
{
var incomePage = new IncomePage();
incomePage.Activate();
incomePage.ShowDialog();
}
private void btnExpense_Click(object sender, EventArgs e)
{
var expensePage = new ExpensePage();
expensePage.Activate();
expensePage.ShowDialog();
}
private void button2_Click(object sender, EventArgs e)
{
FinancePredicPage financePredicPage = new FinancePredicPage();
financePredicPage.Activate();
financePredicPage.Show();
}
private void chart1_Click(object sender, EventArgs e)
{
}
private void HomePage_Load(object sender, EventArgs e)
{
using(MoneyPred db = new MoneyPred())
{
var result = (from expense in db.Expenses
join category in db.ExpenseCategories
on expense.CategoryId equals category.CategoryId
where expense.IsActive == 1
select new
{
Amount = expense.Amount,
CategoryName = category.CategoryName
}).ToList();
var a = result.GroupBy(o => o.CategoryName)
.Select(g => new { CategoryName = g.Key, total = g.Sum(i => i.Amount) }).ToList();
double[] total = new double[a.Count];
string[] categoryName = new string[a.Count];
for (int i = 0; i < a.Count; i++)
{
total[i] = Convert.ToDouble(a[i].total);
categoryName[i] = a[i].CategoryName;
}
pieChart.Series = new PieSeries(
total,
categoryName,
categoryName)
{ Title = "Expenses For Categories" };
pieChart.Dock = DockStyle.Fill;
pieChart.Title = "Expenses For Categories";
pieChart.AllowZoom = true;
pieChart.AllowRotate = true;
pieChart.ShowLegend = false;
pieChart.ShowDataLabels = LabelKinds.OuterLabel;
pieChart.Theme = new Theme();
pieChart.Theme.SeriesFills = GetPieFills();
pieChart.Theme.UniformSeriesStroke = new MindFusion.Drawing.SolidBrush(Color.FromArgb(240, 240, 240));
pieChart.Theme.SeriesStrokeThicknesses = new List<List<double>>() { new List<double>() { 15 } };
pieChart.Theme.HighlightStroke = new MindFusion.Drawing.SolidBrush(Color.White);
pieChart.Theme.HighlightStrokeThickness = 10;
pieChart.Theme.DataLabelsFontSize = 14;
}
}
private List<List<MindFusion.Drawing.Brush>> GetPieFills()
{
var fills = new List<List<MindFusion.Drawing.Brush>>();
fills.Add(new List<MindFusion.Drawing.Brush>() {
new MindFusion.Drawing.SolidBrush(Color.FromArgb(102, 154, 204)),
new MindFusion.Drawing.SolidBrush(Color.FromArgb(192, 192, 192)),
new MindFusion.Drawing.SolidBrush(Color.FromArgb(0, 52, 102)),
new MindFusion.Drawing.SolidBrush(Color.FromArgb(206, 0, 0)),
});
return fills;
}
private void btnAcc_Click(object sender, EventArgs e)
{
AccountDetails accPage = new AccountDetails();
accPage.Activate();
accPage.Show();
}
private void btnAppoinment_Click(object sender, EventArgs e)
{
AppointmentPage appointment = new AppointmentPage();
appointment.Activate();
appointment.Show();
}
}
}