private void AddAppointmentButton_Click(object sender, EventArgs e) { isDayLight(); SQL sql = new SQL(); try { if (StartDate.Value.TimeOfDay < SQL.Open.TimeOfDay || StartDate.Value.TimeOfDay > SQL.Close.TimeOfDay || EndTime.Value.TimeOfDay > SQL.Close.TimeOfDay || EndTime.Value.TimeOfDay < SQL.Open.TimeOfDay) { sql.HandleOustideBusinessHours(); } else if (CheckForOverlap()) { MessageBox.Show("The Appointment you have tried to schedule overlaps a currently scheduled appointment please try again.", "Appointment Overlap", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int Increment = 1; int ApptID = Convert.ToInt32(AppointmentIDTxtBox.Text); int CustID = Convert.ToInt32(CustomerIDTxtBox.Text); int userID = 1; string nn = "Not Needed"; string Title = nn; string description = nn; string location = nn; string contact = nn; string Type = TypeTxtBox.Text; string url = nn; DateTime startDate = StartDate.Value; DateTime EndDate = EndTime.Value; DateTime Now = DateTime.Now.ToLocalTime(); DateTime CreateDate = Now; string Test = "Test"; string CreatedBy = Test; DateTime LastUpdated = Now; string LastUpdatedBy = Test; SQL.AppointmentIDList.Add(Increment); sql.AddAppointment(new Appointment(ApptID, CustID, userID, Title, description, location, contact, Type, url, startDate, EndDate, CreateDate, CreatedBy, LastUpdated, LastUpdatedBy)); mainForm.Show(); this.Hide(); } } catch (FormatException) { MessageBox.Show("A field did not recieve the correct data type", "Format Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }