Appointment types by month report done
This commit is contained in:
parent
4001a1c7e4
commit
0ecd299273
@ -2,16 +2,14 @@ namespace C969Project;
|
||||
|
||||
public partial class DashboardForm : Form
|
||||
{
|
||||
private CustomersForm _customersForm;
|
||||
private AppointmentsForm _appointmentsForm;
|
||||
private CustomersForm _customersForm = new();
|
||||
private AppointmentsForm _appointmentsForm = new();
|
||||
private ReportsForm _reportsForm = new();
|
||||
|
||||
public DashboardForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_customersForm = new CustomersForm();
|
||||
_appointmentsForm = new AppointmentsForm();
|
||||
|
||||
CustomersButton.Click += (sender, args) =>
|
||||
{
|
||||
_customersForm.ShowDialog();
|
||||
@ -22,7 +20,10 @@ public partial class DashboardForm : Form
|
||||
{
|
||||
_appointmentsForm.ShowDialog();
|
||||
};
|
||||
|
||||
|
||||
|
||||
ReportsButton.Click += (sender, args) =>
|
||||
{
|
||||
_reportsForm.ShowDialog();
|
||||
};
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ namespace C969Project
|
||||
{
|
||||
if (AppState.CurrentUser is null)
|
||||
{
|
||||
MessageBox.Show("No user logged in, cannot check for appointments.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("A problem occured retrieving appointments.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
122
C969Project/ReportsForm.Designer.cs
generated
122
C969Project/ReportsForm.Designer.cs
generated
@ -31,11 +31,125 @@ partial class ReportsForm
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "ReportsForm";
|
||||
tabControl1 = new System.Windows.Forms.TabControl();
|
||||
apptByMothTabPage = new System.Windows.Forms.TabPage();
|
||||
refreshButton1 = new System.Windows.Forms.Button();
|
||||
apptByMonthDataGrid = new System.Windows.Forms.DataGridView();
|
||||
userSchedulesTabPage = new System.Windows.Forms.TabPage();
|
||||
customersByCountryTabPage = new System.Windows.Forms.TabPage();
|
||||
scheduleDataGrid = new System.Windows.Forms.DataGridView();
|
||||
refreshButton2 = new System.Windows.Forms.Button();
|
||||
tabControl1.SuspendLayout();
|
||||
apptByMothTabPage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)apptByMonthDataGrid).BeginInit();
|
||||
userSchedulesTabPage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)scheduleDataGrid).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// tabControl1
|
||||
//
|
||||
tabControl1.Controls.Add(apptByMothTabPage);
|
||||
tabControl1.Controls.Add(userSchedulesTabPage);
|
||||
tabControl1.Controls.Add(customersByCountryTabPage);
|
||||
tabControl1.Location = new System.Drawing.Point(12, 12);
|
||||
tabControl1.Name = "tabControl1";
|
||||
tabControl1.SelectedIndex = 0;
|
||||
tabControl1.Size = new System.Drawing.Size(776, 426);
|
||||
tabControl1.TabIndex = 0;
|
||||
//
|
||||
// apptByMothTabPage
|
||||
//
|
||||
apptByMothTabPage.Controls.Add(refreshButton1);
|
||||
apptByMothTabPage.Controls.Add(apptByMonthDataGrid);
|
||||
apptByMothTabPage.Location = new System.Drawing.Point(4, 24);
|
||||
apptByMothTabPage.Name = "apptByMothTabPage";
|
||||
apptByMothTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
apptByMothTabPage.Size = new System.Drawing.Size(768, 398);
|
||||
apptByMothTabPage.TabIndex = 0;
|
||||
apptByMothTabPage.Text = "Appts By Month";
|
||||
apptByMothTabPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// refreshButton1
|
||||
//
|
||||
refreshButton1.Location = new System.Drawing.Point(672, 369);
|
||||
refreshButton1.Name = "refreshButton1";
|
||||
refreshButton1.Size = new System.Drawing.Size(90, 23);
|
||||
refreshButton1.TabIndex = 2;
|
||||
refreshButton1.Text = "Refresh";
|
||||
refreshButton1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// apptByMonthDataGrid
|
||||
//
|
||||
apptByMonthDataGrid.Location = new System.Drawing.Point(6, 6);
|
||||
apptByMonthDataGrid.Name = "apptByMonthDataGrid";
|
||||
apptByMonthDataGrid.ReadOnly = true;
|
||||
apptByMonthDataGrid.Size = new System.Drawing.Size(756, 357);
|
||||
apptByMonthDataGrid.TabIndex = 1;
|
||||
//
|
||||
// userSchedulesTabPage
|
||||
//
|
||||
userSchedulesTabPage.Controls.Add(refreshButton2);
|
||||
userSchedulesTabPage.Controls.Add(scheduleDataGrid);
|
||||
userSchedulesTabPage.Location = new System.Drawing.Point(4, 24);
|
||||
userSchedulesTabPage.Name = "userSchedulesTabPage";
|
||||
userSchedulesTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
userSchedulesTabPage.Size = new System.Drawing.Size(768, 398);
|
||||
userSchedulesTabPage.TabIndex = 1;
|
||||
userSchedulesTabPage.Text = "User Schedules";
|
||||
userSchedulesTabPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// customersByCountryTabPage
|
||||
//
|
||||
customersByCountryTabPage.Location = new System.Drawing.Point(4, 24);
|
||||
customersByCountryTabPage.Name = "customersByCountryTabPage";
|
||||
customersByCountryTabPage.Size = new System.Drawing.Size(768, 398);
|
||||
customersByCountryTabPage.TabIndex = 2;
|
||||
customersByCountryTabPage.Text = "Customers By Country";
|
||||
customersByCountryTabPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// scheduleDataGrid
|
||||
//
|
||||
scheduleDataGrid.Location = new System.Drawing.Point(6, 6);
|
||||
scheduleDataGrid.Name = "scheduleDataGrid";
|
||||
scheduleDataGrid.ReadOnly = true;
|
||||
scheduleDataGrid.Size = new System.Drawing.Size(756, 357);
|
||||
scheduleDataGrid.TabIndex = 2;
|
||||
//
|
||||
// refreshButton2
|
||||
//
|
||||
refreshButton2.Location = new System.Drawing.Point(672, 369);
|
||||
refreshButton2.Name = "refreshButton2";
|
||||
refreshButton2.Size = new System.Drawing.Size(90, 23);
|
||||
refreshButton2.TabIndex = 3;
|
||||
refreshButton2.Text = "Refresh";
|
||||
refreshButton2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ReportsForm
|
||||
//
|
||||
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
ClientSize = new System.Drawing.Size(800, 450);
|
||||
Controls.Add(tabControl1);
|
||||
Text = "ReportsForm";
|
||||
tabControl1.ResumeLayout(false);
|
||||
apptByMothTabPage.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)apptByMonthDataGrid).EndInit();
|
||||
userSchedulesTabPage.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)scheduleDataGrid).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
private System.Windows.Forms.DataGridView scheduleDataGrid;
|
||||
private System.Windows.Forms.Button refreshButton2;
|
||||
|
||||
private System.Windows.Forms.Button refreshButton1;
|
||||
|
||||
private System.Windows.Forms.TabPage customersByCountryTabPage;
|
||||
private System.Windows.Forms.DataGridView apptByMonthDataGrid;
|
||||
|
||||
private System.Windows.Forms.TabControl tabControl1;
|
||||
private System.Windows.Forms.TabPage apptByMothTabPage;
|
||||
private System.Windows.Forms.TabPage userSchedulesTabPage;
|
||||
|
||||
#endregion
|
||||
}
|
@ -1,9 +1,67 @@
|
||||
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}";
|
||||
}
|
||||
}
|
||||
}
|
64
C969Project/ReportsForm.resx
Normal file
64
C969Project/ReportsForm.resx
Normal file
@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="$this.Locked" type="System.Boolean, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user