-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathucMedicineValidityCheck.cs
More file actions
54 lines (50 loc) · 1.71 KB
/
ucMedicineValidityCheck.cs
File metadata and controls
54 lines (50 loc) · 1.71 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
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.Services;
namespace Pharmacy_Management_Sysytem
{
public partial class ucMedicineValidityCheck : UserControl
{
private readonly IMedicineService _medicineService;
public ucMedicineValidityCheck()
{
InitializeComponent();
_medicineService = Program.Services.MedicineService;
}
void LoadMedicineData()
{
try
{
var result = comboBoxMedicineDate.SelectedIndex == 0
? _medicineService.GetValidMedicines()
: _medicineService.GetExpiredMedicines();
if (result.IsSuccess)
{
dataGridView1.DataSource = result.Data;
}
else
{
MessageBox.Show($"Error loading medicine data: {result.ErrorMessage}", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show($"Error loading medicine data: {ex.Message}", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void comboBoxMedicineDate_SelectedIndexChanged(object sender, EventArgs e)
{
LoadMedicineData();
}
}
}