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(); } }