-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.cs
More file actions
84 lines (78 loc) · 2.92 KB
/
dashboard.cs
File metadata and controls
84 lines (78 loc) · 2.92 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Pharmacy_Management_Sysytem.BusinessLogic;
using Pharmacy_Management_Sysytem.Common;
namespace Pharmacy_Management_Sysytem
{
/// <summary>
/// Dashboard user control displaying medicine statistics and charts
/// </summary>
public partial class dashboard : UserControl
{
private readonly IMedicineService _medicineService;
/// <summary>
/// Initializes a new instance of the dashboard class
/// </summary>
public dashboard()
{
InitializeComponent();
_medicineService = Program.Services.MedicineService;
}
/// <summary>
/// Loads the medicine validity chart with current data
/// </summary>
private void LoadChart()
{
try
{
// Clear existing chart data
chart1.Series["Valid Medicine"].Points.Clear();
chart1.Series["Expired Medicine"].Points.Clear();
// Get medicine statistics
var statisticsResult = _medicineService.GetMedicineStatistics();
if (statisticsResult.IsSuccess)
{
var statistics = statisticsResult.Data;
// Add data to chart
chart1.Series["Valid Medicine"].Points.AddXY("Medicine Validity Chart", statistics.ValidMedicines);
chart1.Series["Expired Medicine"].Points.AddXY("Medicine Validity Chart", statistics.ExpiredMedicines);
}
else
{
MessageBox.Show($"Error loading chart data: {statisticsResult.ErrorMessage}",
"Chart Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
MessageBox.Show($"Error loading chart: {ex.Message}",
"Chart Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
/// <summary>
/// Handles the refresh button click event
/// </summary>
/// <param name="sender">The event sender</param>
/// <param name="e">The event arguments</param>
private void btnRefresh_Click(object sender, EventArgs e)
{
LoadChart();
}
/// <summary>
/// Handles the dashboard load event
/// </summary>
/// <param name="sender">The event sender</param>
/// <param name="e">The event arguments</param>
private void dashboard_Load(object sender, EventArgs e)
{
LoadChart();
}
}
}