-
Notifications
You must be signed in to change notification settings - Fork 1
/
frmDashboard.cs
47 lines (39 loc) · 1.48 KB
/
frmDashboard.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
using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
namespace POS_System
{
public partial class frmDashboard : Form
{
SqlConnection cn = new SqlConnection();
DBConnection dbcon = new DBConnection();
public frmDashboard()
{
InitializeComponent();
cn = new SqlConnection(dbcon.MyConnection());
LoadChart();
}
private void frmDashboard_Resize(object sender, EventArgs e)
{
panel1.Left = (this.Width - panel1.Width) / 2;
}
public void LoadChart()
{
cn.Open();
SqlDataAdapter dataAdapter = new SqlDataAdapter("SELECT YEAR(sdate) AS 'year', ISNULL(SUM(total), 0.0) AS 'total' FROM tblCart WHERE status LIKE 'Sold' GROUP BY YEAR(sdate) ;", cn);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet, "Sales");
chart1.DataSource = dataSet.Tables["Sales"];
Series series1 = chart1.Series["Series1"];
series1.ChartType = SeriesChartType.Doughnut;
series1.Name = "SALES";
var chart = chart1;
chart.Series[series1.Name].XValueMember = "year";
chart.Series[series1.Name].YValueMembers = "total";
chart.Series[0].IsValueShownAsLabel = true;
cn.Close();
}
}
}