c969-project/C969Project/ReportsForm.cs
2025-06-26 15:21:45 -05:00

67 lines
1.8 KiB
C#

using C969Project.Data;
namespace C969Project;
public partial class ReportsForm : Form
{
private string[] _months =
[
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
];
private string[] _appointmentTypes =
[
"Scrum", "Presentation", "Other"
];
public ReportsForm()
{
InitializeComponent();
ApptTypeByMonth_GenerateReport();
refreshButton1.Click += (sender, args) => { ApptTypeByMonth_GenerateReport(); };
}
#region Apptointments types by Month
private void ApptTypeByMonth_GenerateReport()
{
apptByMonthDataGrid.DataSource = null;
List<AppointmentTypeByMonth> appointmentTypes = new();
var appointments = DatabaseHelper.RetrieveAppointments();
foreach (var month in _months)
{
foreach (var type in _appointmentTypes)
{
int count = appointments.Count(a => a.Start.ToString("MMMM") == month && a.AppointmentType == type);
appointmentTypes.Add(new AppointmentTypeByMonth(month, type, count));
}
}
apptByMonthDataGrid.DataSource = appointmentTypes;
}
#endregion
class AppointmentTypeByMonth
{
public string Month { get; set; }
public string AppointmentType { get; set; }
public int Count { get; set; }
public AppointmentTypeByMonth(string month, string appointmentType, int count)
{
Month = month;
AppointmentType = appointmentType;
Count = count;
}
public override string ToString()
{
return $"{Month} - {AppointmentType}: {Count}";
}
}
}