diff --git a/C969Project/DashboardForm.cs b/C969Project/DashboardForm.cs index ed98164..2294121 100644 --- a/C969Project/DashboardForm.cs +++ b/C969Project/DashboardForm.cs @@ -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(); + }; } } \ No newline at end of file diff --git a/C969Project/LoginForm.cs b/C969Project/LoginForm.cs index fc3830c..52e487b 100644 --- a/C969Project/LoginForm.cs +++ b/C969Project/LoginForm.cs @@ -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; } diff --git a/C969Project/ReportsForm.Designer.cs b/C969Project/ReportsForm.Designer.cs index f69a728..8f860f8 100644 --- a/C969Project/ReportsForm.Designer.cs +++ b/C969Project/ReportsForm.Designer.cs @@ -31,11 +31,125 @@ partial class ReportsForm /// 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 } \ No newline at end of file diff --git a/C969Project/ReportsForm.cs b/C969Project/ReportsForm.cs index a8ccbe9..3a5b8bb 100644 --- a/C969Project/ReportsForm.cs +++ b/C969Project/ReportsForm.cs @@ -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 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}"; + } } } \ No newline at end of file diff --git a/C969Project/ReportsForm.resx b/C969Project/ReportsForm.resx new file mode 100644 index 0000000..1b59412 --- /dev/null +++ b/C969Project/ReportsForm.resx @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + \ No newline at end of file