From 188633b6d322a66b0a8334fa8a4817ecb2c282f6 Mon Sep 17 00:00:00 2001 From: Spudnut2000 Date: Sun, 22 Jun 2025 00:04:34 -0500 Subject: [PATCH] AddOrUpdateAppointmentForm now populates values when modifying appointment --- .../AddOrUpdateAppointmentForm.Designer.cs | 229 +++++++++--------- C969Project/AddOrUpdateAppointmentForm.cs | 63 +++++ C969Project/AddOrUpdateAppointmentForm.resx | 61 ++++- C969Project/AppointmentsForm.cs | 13 +- C969Project/Data/DatabaseHelper.cs | 2 +- C969Project/Data/Models/Customer.cs | 5 + 6 files changed, 254 insertions(+), 119 deletions(-) diff --git a/C969Project/AddOrUpdateAppointmentForm.Designer.cs b/C969Project/AddOrUpdateAppointmentForm.Designer.cs index db1409b..97e5641 100644 --- a/C969Project/AddOrUpdateAppointmentForm.Designer.cs +++ b/C969Project/AddOrUpdateAppointmentForm.Designer.cs @@ -31,252 +31,252 @@ partial class AddOrUpdateAppointmentForm /// private void InitializeComponent() { - cancelButton = new System.Windows.Forms.Button(); - saveButton = new System.Windows.Forms.Button(); - label1 = new System.Windows.Forms.Label(); - label2 = new System.Windows.Forms.Label(); - textBox1 = new System.Windows.Forms.TextBox(); - descriptionTextBox = new System.Windows.Forms.TextBox(); - label3 = new System.Windows.Forms.Label(); - locationTextBox = new System.Windows.Forms.TextBox(); - label4 = new System.Windows.Forms.Label(); - contactTextBox = new System.Windows.Forms.TextBox(); - label5 = new System.Windows.Forms.Label(); - textBox2 = new System.Windows.Forms.TextBox(); - urlTextBox = new System.Windows.Forms.Label(); - label6 = new System.Windows.Forms.Label(); - typeComboBox = new System.Windows.Forms.ComboBox(); - customerComboBox = new System.Windows.Forms.ComboBox(); - customerLabel = new System.Windows.Forms.Label(); - startPickerDate = new System.Windows.Forms.DateTimePicker(); - label7 = new System.Windows.Forms.Label(); - label8 = new System.Windows.Forms.Label(); - endPickerDate = new System.Windows.Forms.DateTimePicker(); - startPickerTime = new System.Windows.Forms.DateTimePicker(); - endPickerTime = new System.Windows.Forms.DateTimePicker(); + cancelButton = new Button(); + saveButton = new Button(); + label1 = new Label(); + label2 = new Label(); + titleTextBox = new TextBox(); + descriptionTextBox = new TextBox(); + label3 = new Label(); + locationTextBox = new TextBox(); + label4 = new Label(); + contactTextBox = new TextBox(); + label5 = new Label(); + textBoxUrl = new TextBox(); + urlTextBox = new Label(); + label6 = new Label(); + typeComboBox = new ComboBox(); + customerComboBox = new ComboBox(); + customerLabel = new Label(); + startPickerDate = new DateTimePicker(); + label7 = new Label(); + label8 = new Label(); + endPickerDate = new DateTimePicker(); + startPickerTime = new DateTimePicker(); + endPickerTime = new DateTimePicker(); SuspendLayout(); // // cancelButton // - cancelButton.Location = new System.Drawing.Point(856, 761); + cancelButton.Location = new Point(856, 761); cancelButton.Name = "cancelButton"; - cancelButton.Size = new System.Drawing.Size(75, 23); + cancelButton.Size = new Size(75, 23); cancelButton.TabIndex = 0; cancelButton.Text = "Cancel"; cancelButton.UseVisualStyleBackColor = true; // // saveButton // - saveButton.Location = new System.Drawing.Point(775, 761); + saveButton.Location = new Point(775, 761); saveButton.Name = "saveButton"; - saveButton.Size = new System.Drawing.Size(75, 23); + saveButton.Size = new Size(75, 23); saveButton.TabIndex = 1; saveButton.Text = "Save"; saveButton.UseVisualStyleBackColor = true; // // label1 // - label1.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)0)); - label1.Location = new System.Drawing.Point(12, 9); + label1.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + label1.Location = new Point(12, 9); label1.Name = "label1"; - label1.Size = new System.Drawing.Size(159, 23); + label1.Size = new Size(159, 23); label1.TabIndex = 2; label1.Text = "Update Appointment"; // // label2 // - label2.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((byte)0)); - label2.Location = new System.Drawing.Point(12, 69); + label2.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point, 0); + label2.Location = new Point(12, 69); label2.Name = "label2"; - label2.RightToLeft = System.Windows.Forms.RightToLeft.No; - label2.Size = new System.Drawing.Size(100, 23); + label2.RightToLeft = RightToLeft.No; + label2.Size = new Size(100, 23); label2.TabIndex = 3; label2.Text = "Title"; - label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + label2.TextAlign = ContentAlignment.MiddleLeft; // - // textBox1 + // titleTextBox // - textBox1.Location = new System.Drawing.Point(12, 95); - textBox1.Name = "textBox1"; - textBox1.Size = new System.Drawing.Size(520, 23); - textBox1.TabIndex = 4; + titleTextBox.Location = new Point(12, 95); + titleTextBox.Name = "titleTextBox"; + titleTextBox.Size = new Size(520, 23); + titleTextBox.TabIndex = 4; // // descriptionTextBox // - descriptionTextBox.Location = new System.Drawing.Point(12, 147); + descriptionTextBox.Location = new Point(12, 147); descriptionTextBox.Multiline = true; descriptionTextBox.Name = "descriptionTextBox"; - descriptionTextBox.Size = new System.Drawing.Size(520, 100); + descriptionTextBox.Size = new Size(520, 100); descriptionTextBox.TabIndex = 6; // // label3 // - label3.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((byte)0)); - label3.Location = new System.Drawing.Point(12, 121); + label3.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point, 0); + label3.Location = new Point(12, 121); label3.Name = "label3"; - label3.RightToLeft = System.Windows.Forms.RightToLeft.No; - label3.Size = new System.Drawing.Size(100, 23); + label3.RightToLeft = RightToLeft.No; + label3.Size = new Size(100, 23); label3.TabIndex = 5; label3.Text = "Description"; - label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + label3.TextAlign = ContentAlignment.MiddleLeft; // // locationTextBox // - locationTextBox.Location = new System.Drawing.Point(12, 276); + locationTextBox.Location = new Point(12, 276); locationTextBox.Name = "locationTextBox"; - locationTextBox.Size = new System.Drawing.Size(520, 23); + locationTextBox.Size = new Size(520, 23); locationTextBox.TabIndex = 8; // // label4 // - label4.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((byte)0)); - label4.Location = new System.Drawing.Point(12, 250); + label4.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point, 0); + label4.Location = new Point(12, 250); label4.Name = "label4"; - label4.RightToLeft = System.Windows.Forms.RightToLeft.No; - label4.Size = new System.Drawing.Size(100, 23); + label4.RightToLeft = RightToLeft.No; + label4.Size = new Size(100, 23); label4.TabIndex = 7; label4.Text = "Location"; - label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + label4.TextAlign = ContentAlignment.MiddleLeft; // // contactTextBox // - contactTextBox.Location = new System.Drawing.Point(12, 328); + contactTextBox.Location = new Point(12, 328); contactTextBox.Name = "contactTextBox"; - contactTextBox.Size = new System.Drawing.Size(520, 23); + contactTextBox.Size = new Size(520, 23); contactTextBox.TabIndex = 10; // // label5 // - label5.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((byte)0)); - label5.Location = new System.Drawing.Point(12, 302); + label5.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point, 0); + label5.Location = new Point(12, 302); label5.Name = "label5"; - label5.RightToLeft = System.Windows.Forms.RightToLeft.No; - label5.Size = new System.Drawing.Size(100, 23); + label5.RightToLeft = RightToLeft.No; + label5.Size = new Size(100, 23); label5.TabIndex = 9; label5.Text = "Contact"; - label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + label5.TextAlign = ContentAlignment.MiddleLeft; // - // textBox2 + // textBoxUrl // - textBox2.Location = new System.Drawing.Point(12, 380); - textBox2.Name = "textBox2"; - textBox2.Size = new System.Drawing.Size(520, 23); - textBox2.TabIndex = 12; + textBoxUrl.Location = new Point(12, 380); + textBoxUrl.Name = "textBoxUrl"; + textBoxUrl.Size = new Size(520, 23); + textBoxUrl.TabIndex = 12; // // urlTextBox // - urlTextBox.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((byte)0)); - urlTextBox.Location = new System.Drawing.Point(12, 354); + urlTextBox.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point, 0); + urlTextBox.Location = new Point(12, 354); urlTextBox.Name = "urlTextBox"; - urlTextBox.RightToLeft = System.Windows.Forms.RightToLeft.No; - urlTextBox.Size = new System.Drawing.Size(100, 23); + urlTextBox.RightToLeft = RightToLeft.No; + urlTextBox.Size = new Size(100, 23); urlTextBox.TabIndex = 11; urlTextBox.Text = "Url"; - urlTextBox.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + urlTextBox.TextAlign = ContentAlignment.MiddleLeft; // // label6 // - label6.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((byte)0)); - label6.Location = new System.Drawing.Point(12, 406); + label6.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point, 0); + label6.Location = new Point(12, 406); label6.Name = "label6"; - label6.RightToLeft = System.Windows.Forms.RightToLeft.No; - label6.Size = new System.Drawing.Size(100, 23); + label6.RightToLeft = RightToLeft.No; + label6.Size = new Size(100, 23); label6.TabIndex = 13; label6.Text = "Type"; - label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + label6.TextAlign = ContentAlignment.MiddleLeft; // // typeComboBox // typeComboBox.FormattingEnabled = true; - typeComboBox.Location = new System.Drawing.Point(12, 432); + typeComboBox.Location = new Point(12, 432); typeComboBox.Name = "typeComboBox"; - typeComboBox.Size = new System.Drawing.Size(324, 23); + typeComboBox.Size = new Size(324, 23); typeComboBox.TabIndex = 14; // // customerComboBox // customerComboBox.FormattingEnabled = true; - customerComboBox.Location = new System.Drawing.Point(12, 484); + customerComboBox.Location = new Point(12, 484); customerComboBox.Name = "customerComboBox"; - customerComboBox.Size = new System.Drawing.Size(324, 23); + customerComboBox.Size = new Size(324, 23); customerComboBox.TabIndex = 16; // // customerLabel // - customerLabel.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((byte)0)); - customerLabel.Location = new System.Drawing.Point(12, 458); + customerLabel.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point, 0); + customerLabel.Location = new Point(12, 458); customerLabel.Name = "customerLabel"; - customerLabel.RightToLeft = System.Windows.Forms.RightToLeft.No; - customerLabel.Size = new System.Drawing.Size(100, 23); + customerLabel.RightToLeft = RightToLeft.No; + customerLabel.Size = new Size(100, 23); customerLabel.TabIndex = 15; customerLabel.Text = "Customer"; - customerLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + customerLabel.TextAlign = ContentAlignment.MiddleLeft; // // startPickerDate // startPickerDate.CustomFormat = "dddd MMMM dd @ hh:mm tt"; - startPickerDate.Format = System.Windows.Forms.DateTimePickerFormat.Short; - startPickerDate.Location = new System.Drawing.Point(12, 536); + startPickerDate.Format = DateTimePickerFormat.Short; + startPickerDate.Location = new Point(12, 536); startPickerDate.Name = "startPickerDate"; - startPickerDate.Size = new System.Drawing.Size(159, 23); + startPickerDate.Size = new Size(159, 23); startPickerDate.TabIndex = 17; // // label7 // - label7.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((byte)0)); - label7.Location = new System.Drawing.Point(12, 510); + label7.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point, 0); + label7.Location = new Point(12, 510); label7.Name = "label7"; - label7.RightToLeft = System.Windows.Forms.RightToLeft.No; - label7.Size = new System.Drawing.Size(100, 23); + label7.RightToLeft = RightToLeft.No; + label7.Size = new Size(100, 23); label7.TabIndex = 18; label7.Text = "Start Time"; - label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + label7.TextAlign = ContentAlignment.MiddleLeft; // // label8 // - label8.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((byte)0)); - label8.Location = new System.Drawing.Point(12, 562); + label8.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point, 0); + label8.Location = new Point(12, 562); label8.Name = "label8"; - label8.RightToLeft = System.Windows.Forms.RightToLeft.No; - label8.Size = new System.Drawing.Size(100, 23); + label8.RightToLeft = RightToLeft.No; + label8.Size = new Size(100, 23); label8.TabIndex = 20; label8.Text = "End Time"; - label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + label8.TextAlign = ContentAlignment.MiddleLeft; // // endPickerDate // endPickerDate.CustomFormat = "dddd MMMM dd @ hh:mm tt"; - endPickerDate.Format = System.Windows.Forms.DateTimePickerFormat.Short; - endPickerDate.Location = new System.Drawing.Point(12, 588); + endPickerDate.Format = DateTimePickerFormat.Short; + endPickerDate.Location = new Point(12, 588); endPickerDate.Name = "endPickerDate"; - endPickerDate.Size = new System.Drawing.Size(159, 23); + endPickerDate.Size = new Size(159, 23); endPickerDate.TabIndex = 19; // // startPickerTime // startPickerTime.CustomFormat = "dddd MMMM dd @ hh:mm tt"; - startPickerTime.Format = System.Windows.Forms.DateTimePickerFormat.Time; - startPickerTime.Location = new System.Drawing.Point(177, 536); + startPickerTime.Format = DateTimePickerFormat.Time; + startPickerTime.Location = new Point(177, 536); startPickerTime.Name = "startPickerTime"; startPickerTime.ShowUpDown = true; - startPickerTime.Size = new System.Drawing.Size(159, 23); + startPickerTime.Size = new Size(159, 23); startPickerTime.TabIndex = 21; // // endPickerTime // endPickerTime.CustomFormat = "dddd MMMM dd @ hh:mm tt"; - endPickerTime.Format = System.Windows.Forms.DateTimePickerFormat.Time; - endPickerTime.Location = new System.Drawing.Point(177, 588); + endPickerTime.Format = DateTimePickerFormat.Time; + endPickerTime.Location = new Point(177, 588); endPickerTime.Name = "endPickerTime"; endPickerTime.ShowUpDown = true; - endPickerTime.Size = new System.Drawing.Size(159, 23); + endPickerTime.Size = new Size(159, 23); endPickerTime.TabIndex = 22; // // AddOrUpdateAppointmentForm // - AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - ClientSize = new System.Drawing.Size(943, 796); + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(943, 796); Controls.Add(endPickerTime); Controls.Add(startPickerTime); Controls.Add(label8); @@ -287,7 +287,7 @@ partial class AddOrUpdateAppointmentForm Controls.Add(customerLabel); Controls.Add(typeComboBox); Controls.Add(label6); - Controls.Add(textBox2); + Controls.Add(textBoxUrl); Controls.Add(urlTextBox); Controls.Add(contactTextBox); Controls.Add(label5); @@ -295,11 +295,12 @@ partial class AddOrUpdateAppointmentForm Controls.Add(label4); Controls.Add(descriptionTextBox); Controls.Add(label3); - Controls.Add(textBox1); + Controls.Add(titleTextBox); Controls.Add(label2); Controls.Add(label1); Controls.Add(saveButton); Controls.Add(cancelButton); + Name = "AddOrUpdateAppointmentForm"; Text = "Update Appointment"; ResumeLayout(false); PerformLayout(); @@ -325,14 +326,14 @@ partial class AddOrUpdateAppointmentForm private System.Windows.Forms.Label label4; private System.Windows.Forms.TextBox contactTextBox; private System.Windows.Forms.Label label5; - private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.TextBox textBoxUrl; private System.Windows.Forms.Label urlTextBox; private System.Windows.Forms.TextBox descriptionTextBox; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label2; - private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox titleTextBox; private System.Windows.Forms.Label label1; diff --git a/C969Project/AddOrUpdateAppointmentForm.cs b/C969Project/AddOrUpdateAppointmentForm.cs index 03d2f77..2eb62cd 100644 --- a/C969Project/AddOrUpdateAppointmentForm.cs +++ b/C969Project/AddOrUpdateAppointmentForm.cs @@ -1,21 +1,84 @@ +using C969Project.Data; using C969Project.Data.Models; namespace C969Project; public partial class AddOrUpdateAppointmentForm : Form { + private Appointment? _currentAppointment; + + private List _appointmentTypes = new () + { + "Scrum", + "Presentation", + "Other" + }; + + private List _customers = new(); + + + + public AddOrUpdateAppointmentForm() { InitializeComponent(); + RefreshComponents(); + + typeComboBox.DataSource = _appointmentTypes; + } + + private void RefreshComponents() + { + _customers.Clear(); + _customers.AddRange(DatabaseHelper.RetrieveCustomers()); + customerComboBox.DataSource = _customers; + } + + private bool ValidateForm() + { + // Check that everything has a value -> Check if start-end is between 9am and 5pm EST MON-FRI && does NOT overlap with existing appt for AppState.CurrentUser + return false; } public void InitAdd() { + label1.Text = "Add New Appointment"; + _currentAppointment = null; + titleTextBox.Text = string.Empty; + descriptionTextBox.Text = string.Empty; + locationTextBox.Text = string.Empty; + contactTextBox.Text = string.Empty; + textBoxUrl.Text = string.Empty; + typeComboBox.SelectedIndex = -1; + customerComboBox.SelectedIndex = -1; + startPickerDate.Value = DateTime.Now.Date; + startPickerTime.Value = DateTime.Now; + endPickerDate.Value = DateTime.Now.Date; + endPickerTime.Value = DateTime.Now.AddHours(1); + + ShowDialog(); } public void InitUpdate(Appointment appointment) { + label1.Text = "Update Appointment"; + _currentAppointment = appointment; + titleTextBox.Text = appointment.Title; + descriptionTextBox.Text = appointment.Description; + locationTextBox.Text = appointment.Location; + contactTextBox.Text = appointment.Contact; + textBoxUrl.Text = appointment.Url; + + typeComboBox.SelectedItem = appointment.AppointmentType; + customerComboBox.SelectedItem = _customers.FirstOrDefault(c => c.CustomerId == appointment.CustomerId); + + startPickerDate.Value = appointment.Start.ToLocalTime().Date; + startPickerTime.Value = appointment.Start.ToLocalTime(); + endPickerDate.Value = appointment.End.ToLocalTime().Date; + endPickerTime.Value = appointment.End.ToLocalTime(); + + ShowDialog(); } } \ No newline at end of file diff --git a/C969Project/AddOrUpdateAppointmentForm.resx b/C969Project/AddOrUpdateAppointmentForm.resx index 1b59412..3dbb517 100644 --- a/C969Project/AddOrUpdateAppointmentForm.resx +++ b/C969Project/AddOrUpdateAppointmentForm.resx @@ -1,5 +1,64 @@ + @@ -58,7 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + True \ No newline at end of file diff --git a/C969Project/AppointmentsForm.cs b/C969Project/AppointmentsForm.cs index fa8d7ca..0eaceb4 100644 --- a/C969Project/AppointmentsForm.cs +++ b/C969Project/AppointmentsForm.cs @@ -23,12 +23,19 @@ public partial class AppointmentsForm : Form private void ModifyButtonOnClick(object? sender, EventArgs e) { - _addOrUpdateAppointmentForm.ShowDialog(); + if (appointmentDataView.CurrentRow?.DataBoundItem is Appointment selectedAppointment) + { + _addOrUpdateAppointmentForm.InitUpdate(selectedAppointment); + } + else + { + MessageBox.Show("Error while trying to modify appointment"); + } } private void AddButtonOnClick(object? sender, EventArgs e) { - _addOrUpdateAppointmentForm.ShowDialog(); + _addOrUpdateAppointmentForm.InitAdd(); } private void DeleteButtonOnClick(object? sender, EventArgs e) @@ -56,7 +63,7 @@ public partial class AppointmentsForm : Form { appointmentDataView.DataSource = null; _appointments.Clear(); - _appointments.AddRange(DatabaseHelper.RetrieveAllAppointments(AppState.CurrentUser.UserId)); + _appointments.AddRange(DatabaseHelper.RetrieveAppointments(AppState.CurrentUser.UserId)); appointmentDataView.DataSource = _appointments; } diff --git a/C969Project/Data/DatabaseHelper.cs b/C969Project/Data/DatabaseHelper.cs index 347c2dc..d54e5ab 100644 --- a/C969Project/Data/DatabaseHelper.cs +++ b/C969Project/Data/DatabaseHelper.cs @@ -421,7 +421,7 @@ namespace C969Project.Data return null; } - public static List RetrieveAllAppointments(int? userId = null) + public static List RetrieveAppointments(int? userId = null) { using MySqlConnection connection = new MySqlConnection(AppSettings.GetSetting("ConnectionStrings", "DefaultConnection")); try diff --git a/C969Project/Data/Models/Customer.cs b/C969Project/Data/Models/Customer.cs index edb568f..2fa6517 100644 --- a/C969Project/Data/Models/Customer.cs +++ b/C969Project/Data/Models/Customer.cs @@ -10,4 +10,9 @@ public class Customer public string CreatedBy { get; set; } public DateTime LastUpdate { get; set; } public string LastUpdateBy { get; set; } + + public override string ToString() + { + return CustomerName; + } } \ No newline at end of file