AddOrUpdateAppointmentForm now populates values when modifying appointment

This commit is contained in:
Spudnut2000 2025-06-22 00:04:34 -05:00
parent f496bbbed2
commit 188633b6d3
6 changed files with 254 additions and 119 deletions

View File

@ -31,252 +31,252 @@ partial class AddOrUpdateAppointmentForm
/// </summary>
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;

View File

@ -1,21 +1,84 @@
using C969Project.Data;
using C969Project.Data.Models;
namespace C969Project;
public partial class AddOrUpdateAppointmentForm : Form
{
private Appointment? _currentAppointment;
private List<string> _appointmentTypes = new ()
{
"Scrum",
"Presentation",
"Other"
};
private List<Customer> _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();
}
}

View File

@ -1,5 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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">
@ -58,7 +117,7 @@
<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">
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -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;
}

View File

@ -421,7 +421,7 @@ namespace C969Project.Data
return null;
}
public static List<Appointment> RetrieveAllAppointments(int? userId = null)
public static List<Appointment> RetrieveAppointments(int? userId = null)
{
using MySqlConnection connection = new MySqlConnection(AppSettings.GetSetting("ConnectionStrings", "DefaultConnection"));
try

View File

@ -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;
}
}