adding and updating appointments finished
This commit is contained in:
parent
188633b6d3
commit
57359a6260
@ -5,6 +5,8 @@ namespace C969Project;
|
||||
|
||||
public partial class AddOrUpdateAppointmentForm : Form
|
||||
{
|
||||
public event EventHandler UpdateAppointmentsList;
|
||||
|
||||
private Appointment? _currentAppointment;
|
||||
|
||||
private List<string> _appointmentTypes = new ()
|
||||
@ -16,17 +18,16 @@ public partial class AddOrUpdateAppointmentForm : Form
|
||||
|
||||
private List<Customer> _customers = new();
|
||||
|
||||
|
||||
|
||||
|
||||
public AddOrUpdateAppointmentForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
RefreshComponents();
|
||||
|
||||
typeComboBox.DataSource = _appointmentTypes;
|
||||
saveButton.Click += SaveButton_Click;
|
||||
cancelButton.Click += (s, e) => Close();
|
||||
}
|
||||
|
||||
|
||||
private void RefreshComponents()
|
||||
{
|
||||
_customers.Clear();
|
||||
@ -34,12 +35,6 @@ public partial class AddOrUpdateAppointmentForm : Form
|
||||
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";
|
||||
@ -81,4 +76,110 @@ public partial class AddOrUpdateAppointmentForm : Form
|
||||
|
||||
ShowDialog();
|
||||
}
|
||||
|
||||
private bool ValidateForm()
|
||||
{
|
||||
// Ensure all required fields have values
|
||||
if (string.IsNullOrWhiteSpace(titleTextBox.Text) ||
|
||||
string.IsNullOrWhiteSpace(descriptionTextBox.Text) ||
|
||||
string.IsNullOrWhiteSpace(locationTextBox.Text) ||
|
||||
string.IsNullOrWhiteSpace(contactTextBox.Text) ||
|
||||
string.IsNullOrWhiteSpace(textBoxUrl.Text) ||
|
||||
typeComboBox.SelectedIndex == -1 ||
|
||||
customerComboBox.SelectedIndex == -1)
|
||||
{
|
||||
MessageBox.Show("All fields must be filled out.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Convert start and end times to UTC for comparison
|
||||
DateTime start = startPickerDate.Value.Date.Add(startPickerTime.Value.TimeOfDay).ToUniversalTime();
|
||||
DateTime end = endPickerDate.Value.Date.Add(endPickerTime.Value.TimeOfDay).ToUniversalTime();
|
||||
|
||||
// Validate start and end times
|
||||
if (start >= end)
|
||||
{
|
||||
MessageBox.Show("Start time must be before end time.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate business hours (9:00 AM - 5:00 PM EST, Monday-Friday)
|
||||
TimeZoneInfo estZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
|
||||
DateTime startEST = TimeZoneInfo.ConvertTimeFromUtc(start, estZone);
|
||||
DateTime endEST = TimeZoneInfo.ConvertTimeFromUtc(end, estZone);
|
||||
|
||||
if (startEST.Hour < 9 || endEST.Hour > 17 || startEST.DayOfWeek == DayOfWeek.Saturday || startEST.DayOfWeek == DayOfWeek.Sunday)
|
||||
{
|
||||
MessageBox.Show("Appointments must be scheduled during business hours (9:00 AM - 5:00 PM EST, Monday-Friday).", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for overlapping appointments
|
||||
var appointments = DatabaseHelper.RetrieveAppointments(AppState.CurrentUser.UserId);
|
||||
foreach (var appt in appointments)
|
||||
{
|
||||
if (_currentAppointment == null || appt.AppointmentId != _currentAppointment.AppointmentId)
|
||||
{
|
||||
if (start < appt.End && end > appt.Start)
|
||||
{
|
||||
MessageBox.Show("Appointment times cannot overlap with existing appointments.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object? sender, EventArgs e)
|
||||
{
|
||||
if (!ValidateForm())
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
// Gather appointment data from form
|
||||
var selectedCustomer = (Customer)customerComboBox.SelectedItem!;
|
||||
var appointment = new Appointment
|
||||
{
|
||||
AppointmentId = _currentAppointment?.AppointmentId ?? 0,
|
||||
CustomerId = selectedCustomer.CustomerId,
|
||||
UserId = AppState.CurrentUser.UserId,
|
||||
Title = titleTextBox.Text.Trim(),
|
||||
Description = descriptionTextBox.Text.Trim(),
|
||||
Location = locationTextBox.Text.Trim(),
|
||||
Contact = contactTextBox.Text.Trim(),
|
||||
AppointmentType = typeComboBox.SelectedItem!.ToString()!,
|
||||
Url = textBoxUrl.Text.Trim(),
|
||||
Start = startPickerDate.Value.Date.Add(startPickerTime.Value.TimeOfDay).ToUniversalTime(),
|
||||
End = endPickerDate.Value.Date.Add(endPickerTime.Value.TimeOfDay).ToUniversalTime(),
|
||||
CreateDate = DateTime.UtcNow,
|
||||
CreatedBy = AppState.CurrentUser.Username,
|
||||
LastUpdate = DateTime.UtcNow,
|
||||
LastUpdateBy = AppState.CurrentUser.Username
|
||||
};
|
||||
|
||||
if (_currentAppointment == null)
|
||||
{
|
||||
// Add new appointment
|
||||
DatabaseHelper.AddAppointment(appointment);
|
||||
MessageBox.Show("Appointment added successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update existing appointment
|
||||
DatabaseHelper.UpdateAppointment(appointment);
|
||||
MessageBox.Show("Appointment updated successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
UpdateAppointmentsList?.Invoke(this, EventArgs.Empty);
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"An error occurred while saving the appointment:\n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -13,6 +13,7 @@ public partial class AppointmentsForm : Form
|
||||
InitializeComponent();
|
||||
|
||||
Shown += UpdateAppointmentsList;
|
||||
_addOrUpdateAppointmentForm.UpdateAppointmentsList += UpdateAppointmentsList;
|
||||
|
||||
calendar.DateSelected += ShowAppointmentsFromSelectedDay;
|
||||
showAllButton.Click += UpdateAppointmentsList;
|
||||
|
351
C969Project/assignment-reqs.txt
Normal file
351
C969Project/assignment-reqs.txt
Normal file
@ -0,0 +1,351 @@
|
||||
You are working for a software company that has been contracted to develop a scheduling desktop user interface application. The contract is with a global consulting organization that conducts business in multiple languages and has main offices in the following locations: Phoenix, Arizona; New York, New York; and London, England. The consulting organization has provided a MySQL database that your C# application must pull data from. However, this database is used for other systems, so its structure cannot be modified.
|
||||
|
||||
|
||||
|
||||
The organization has outlined specific business requirements that must be included as part of the application. From these requirements, a system analyst at your company created solution statements for you to implement when developing the application. These statements are listed in the “Requirements” section.
|
||||
Requirements
|
||||
|
||||
Your submission must represent your original work and understanding of the course material. Most performance assessment submissions are automatically scanned through the WGU similarity checker. Students are strongly encouraged to wait for the similarity report to generate after uploading their work and then review it to ensure Academic Authenticity guidelines are met before submitting the file for evaluation. See Understanding Similarity Reports for more information.
|
||||
|
||||
Grammarly Note:
|
||||
Professional Communication will be automatically assessed through Grammarly for Education in most performance assessments before a student submits work for evaluation. Students are strongly encouraged to review the Grammarly for Education feedback prior to submitting work for evaluation, as the overall submission will not pass without this aspect passing. See Use Grammarly for Education Effectively for more information.
|
||||
|
||||
Microsoft Files Note:
|
||||
Write your paper in Microsoft Word (.doc or .docx) unless another Microsoft product, or pdf, is specified in the task directions. Tasks may not be submitted as cloud links, such as links to Google Docs, Google Slides, OneDrive, etc. All supporting documentation, such as screenshots and proof of experience, should be collected in a pdf file and submitted separately from the main file. For more information, please see Computer System and Technology Requirements.
|
||||
|
||||
|
||||
You must use the rubric to direct the creation of your submission because it provides detailed criteria that will be used to evaluate your work. Each requirement below may be evaluated by more than one rubric aspect. The rubric aspect titles may contain hyperlinks to relevant portions of the course.
|
||||
|
||||
|
||||
Note: You are not allowed to use frameworks or external libraries, except for the .NET Framework. The database does not contain data, so it needs to be populated. The word “test” must be used as the username and password to login to the C# application.
|
||||
|
||||
|
||||
A. Create an application by completing the following tasks in C#:
|
||||
|
||||
1. Create a login form that has the ability to do the following:
|
||||
|
||||
a. Determine a user’s location.
|
||||
|
||||
b. Translate login and error control messages (e.g., “The username and password do not match.”) into English and one additional language.
|
||||
|
||||
c. Verify the correct username and password.
|
||||
|
||||
2. Provide the ability to add, update, and delete customer records.
|
||||
|
||||
a. Validate each of the following requirements for customer records:
|
||||
|
||||
• that a customer record includes name, address, and phone number fields
|
||||
|
||||
• that fields are trimmed and non-empty
|
||||
|
||||
• that the phone number field allows only digits and dashes
|
||||
|
||||
b. Add exception handling that can be used when performing each of the following operations for customer records:
|
||||
|
||||
• “add” operations
|
||||
|
||||
• “update” operations
|
||||
|
||||
• “delete database” operations
|
||||
|
||||
3. Provide the ability to add, update, and delete appointments, capture the type of appointment, and link to a specific customer record in the database.
|
||||
|
||||
a. Validate each of the following requirements for appointments:
|
||||
|
||||
• Require appointments to be scheduled during the business hours of 9:00 a.m. to 5:00 p.m., Monday–Friday, eastern standard time.
|
||||
|
||||
• Prevent the scheduling of overlapping appointments.
|
||||
|
||||
b. Add exception handling that can be used when performing each of the following operations for appointments:
|
||||
|
||||
• “add” operations
|
||||
|
||||
• “update” operations
|
||||
|
||||
• “delete database” operations
|
||||
|
||||
4. Create a calendar view feature, including the ability to view appointments on a specific day by selecting a day of the month from a calendar of the months of the year.
|
||||
|
||||
5. Provide the ability to automatically adjust appointment times based on user time zones and daylight saving time.
|
||||
|
||||
6. Create a function that generates an alert whenever a user who has an appointment within 15 minutes logs in to their account.
|
||||
|
||||
7. Create a function that allows users to generate the three reports listed using collection classes, incorporating a lambda expression into the code for each of the following reports:
|
||||
|
||||
• the number of appointment types by month
|
||||
|
||||
• the schedule for each user
|
||||
|
||||
• one additional report of your choice
|
||||
|
||||
8. Record the timestamp and the username of each login in a text file named “Login_History.txt,” ensuring that each new record is appended to the log file.
|
||||
|
||||
|
||||
B. Submit the project by doing the following:
|
||||
|
||||
1. Export the project in Visual Studio format.
|
||||
|
||||
2. Export your project from the IDE as a ZIP file.
|
||||
|
||||
|
||||
C. Demonstrate professional communication in the content and presentation of your submission.
|
||||
File Restrictions
|
||||
File name may contain only letters, numbers, spaces, and these symbols: ! - _ . * ' ( )
|
||||
File size limit: 200 MB
|
||||
File types allowed: doc, docx, rtf, xls, xlsx, ppt, pptx, odt, pdf, csv, txt, qt, mov, mpg, avi, mp3, wav, mp4, wma, flv, asf, mpeg, wmv, m4v, svg, tif, tiff, jpeg, jpg, gif, png, zip, rar, tar, 7z
|
||||
Rubric
|
||||
A1a:LOG-IN FORM
|
||||
|
||||
Not Evident
|
||||
|
||||
A log-in form is not provided or the ability to determine a user’s location is not provided.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
The log-in form cannot correctly determine a user’s location.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
The log-in form accurately determines a user’s location.
|
||||
A1b:MESSAGE TRANSLATION
|
||||
|
||||
Not Evident
|
||||
|
||||
An ability to translate log-in or error control messages is not provided.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
The form cannot correctly translate log-in and error control messages into English and 1 additional language. Or the form contains errors.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
The form can translate log-in and error control messages into English and 1 additional language.
|
||||
A1c:CREDENTIAL VERIFICATION
|
||||
|
||||
Not Evident
|
||||
|
||||
An ability to verify the correct username and password is not provided.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
The application cannot correctly verify the correct username or password. Or the functionality contains errors.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
The application consistently and accurately verifies the correct username and password.
|
||||
A2:CUSTOMER RECORDS
|
||||
|
||||
Not Evident
|
||||
|
||||
An ability to add, update, or delete customer records is not provided.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
The application cannot correctly add, update, or delete customer records in the database or is limited. Or the functionality contains errors.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
The application’s ability to add, update, and delete customer records in the database functions properly.
|
||||
A2a:RECORD VALIDATION
|
||||
|
||||
Not Evident
|
||||
|
||||
The submission does not validate any of the given requirements.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
The submission validates only 1 or 2 of the given requirements.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
The submission validates all 3 of the given requirements.
|
||||
A2b:RECORD EXCEPTION HANDLING
|
||||
|
||||
Not Evident
|
||||
|
||||
Exception handling for customer records operations is not provided.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
Exception handling is provided, but it can only be used for 1 or 2 of the given customer records operations.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
Exception handling is provided, and it works properly for all 3 customer records operations.
|
||||
A3:APPOINTMENTS
|
||||
|
||||
Not Evident
|
||||
|
||||
An ability to add, update, or delete appointments is not provided.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
The application cannot correctly add, update or delete appointments, capture the type of appointment, or link appointments to a specific customer record in the database. Or the code is incomplete.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
The application has the functionality to add, update, and delete appointments, capture the type of appointment, and link appointments to a specific customer record in the database. The code functions properly.
|
||||
A3a:APPOINTMENT SCHEDULING
|
||||
|
||||
Not Evident
|
||||
|
||||
The submission does not validate any of the given requirements.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
The submission validates only 1 of the given requirements.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
The submission validates both given requirements.
|
||||
A3b:APPOINTMENT EXCEPTION HANDLING
|
||||
|
||||
Not Evident
|
||||
|
||||
Exception handling for appointments operations is not provided.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
Exception handling is provided, but it can only be used for 1 or 2 of the given appointments operations.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
Exception handling is provided, and it works properly for all 3 appointments operations.
|
||||
A4:CALENDAR VIEWS
|
||||
|
||||
Not Evident
|
||||
|
||||
A calendar view is not provided.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
The calendar view feature cannot correctly allow viewing the calendar by month and when viewing appointments on a specific day. Or the calendar view contains errors.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
The calendar view feature has the functionality to view the calendar by month and to view appointments on a specific day. The calendar view functions properly.
|
||||
A5:TIME ZONES
|
||||
|
||||
Not Evident
|
||||
|
||||
An ability to adjust appointment times based on user time zones or daylight saving time is not provided.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
The application cannot correctly automatically adjust appointment times based on user time zones or daylight saving time. Or the code contains errors.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
The application has the functionality to automatically adjust appointment times based on user time zones and daylight saving time. The code functions properly.
|
||||
A6:ALERTS
|
||||
|
||||
Not Evident
|
||||
|
||||
A function that generates alerts for upcoming appointments is not provided.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
The alerts function is provided, but it cannot correctly provide alerts when a user logs in if the user has an appointment within 15 minutes.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
The alerts function has the functionality to provide alerts when a user logs in if the user has an appointment within 15 minutes.
|
||||
A7:REPORTS
|
||||
|
||||
Not Evident
|
||||
|
||||
The application does not have the ability to generate any of the given reports.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
The application cannot correctly generate the given reports. Or only 1 or 2 of the given reports are generated. Or the code contains errors. Or less than 3 of the reports incorporate a lambda expression.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
The application has the functionality to generate all 3 of the given reports. The code functions properly. All 3 of the reports incorporate a lambda expression.
|
||||
A8:ACTIVITY LOG
|
||||
|
||||
Not Evident
|
||||
|
||||
An ability to record a timestamp or username in a log file is not provided.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
The application cannot correctly track user activity by recording timestamps or usernames in a log file. Or each new record creates a new file instead of being appended to the log file. Or the code contains errors.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
The application has the functionality to track user activity by recording timestamps and usernames for each log-in in a text file with the name “Login_History.txt.” And each new record is appended to the log file. And the code functions properly.
|
||||
B1:VISUAL STUDIO SUBMISSION
|
||||
|
||||
Not Evident
|
||||
|
||||
The project is not saved or exported in Visual Studio format.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
Not applicable.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
The project is saved or exported in Visual Studio format.
|
||||
B2:ZIP FILE SUBMISSION
|
||||
|
||||
Not Evident
|
||||
|
||||
The project is not exported as a ZIP file.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
The project is incompletely exported as a ZIP file.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
The project is completely exported as a ZIP file.
|
||||
C:PROFESSIONAL COMMUNICATION
|
||||
|
||||
Not Evident
|
||||
|
||||
This submission includes pervasive errors in professional communication related to grammar, sentence fluency, contextual spelling, or punctuation, negatively impacting the professional quality and clarity of the writing. Specific errors have been identified by Grammarly for Education under the Correctness category.
|
||||
|
||||
|
||||
Approaching Competence
|
||||
|
||||
This submission includes substantial errors in professional communication related to grammar, sentence fluency, contextual spelling, or punctuation. Specific errors have been identified by Grammarly for Education under the Correctness category.
|
||||
|
||||
|
||||
Competent
|
||||
|
||||
This submission includes satisfactory use of grammar, sentence fluency, contextual spelling, and punctuation, which promote accurate interpretation and understanding.
|
Loading…
Reference in New Issue
Block a user