private void cancelBtn_Click(object sender, EventArgs e) { this.Hide(); AppointmentsListScreen appointmentsListScreen = new AppointmentsListScreen(); appointmentsListScreen.Show(); }
private void saveBtn_Click(object sender, EventArgs e) { int appointmentId = Int32.Parse(appointmentIDTextBox.Text); int customerId = Int32.Parse(customerIDComboBox.Text); string appointmentType = appointmentTypeComboBox.Text; DateTime startTimeDateLocal = startDateTimePicker.Value; DateTime endTimeDateLocal = endDateTimePicker.Value; DateTime startTimeUTC = TimeZoneInfo.ConvertTimeToUtc(startTimeDateLocal, TimeZoneInfo.Local); DateTime endTimeUTC = TimeZoneInfo.ConvertTimeToUtc(endTimeDateLocal, TimeZoneInfo.Local); string startTimeUTCstring = startTimeUTC.ToString("yyyy-M-dd HH:mm:ss"); string endTimeUTCstring = endTimeUTC.ToString("yyyy-M-dd HH:mm:ss"); try { appointmentType = getAppointmentType(); } catch (AppointmentTypeException appointmentTypeException) { Console.WriteLine("\n" + appointmentTypeException.Message); return; } try { checkCustomerName(); } catch (CustomerIDDoesNotMatchException customerIdDoesNotMatchException) { Console.WriteLine("\n" + customerIdDoesNotMatchException.Message); return; } try { if (outsideBusinessHoursCheck()) { ; } } catch (AppointmentSchedulingException outsideBusinessHoursException) { Console.WriteLine("\n" + outsideBusinessHoursException.Message); return; } try { if (!overLappingAppointmentsCheck()) { ; } } catch (AppointmentSchedulingException appointmentOverlappingException) { Console.WriteLine("\n" + appointmentOverlappingException.Message); return; } con.Open(); string query = "insert into appointment values ( " + appointmentId + ", " + customerId + ", " + CurrentOnlineUser.currentOnlineUserID + ", 'not needed', 'not needed', 'not needed', 'not needed', '" + appointmentType + "', 'not needed', '" + startTimeUTCstring + "', '" + endTimeUTCstring + "', '" + DateTime.UtcNow.ToString("yyyy-M-dd HH:mm:ss") + "', '" + CurrentOnlineUser.currentOnlineUserName + "', '" + DateTime.UtcNow.ToString("yyyy-M-dd HH:mm:ss") + "', '" + CurrentOnlineUser.currentOnlineUserName + "' )"; MySqlDataReader row; row = con.ExecuteReader(query); con.Close(); this.Hide(); AppointmentsListScreen appointmentsListScreen = new AppointmentsListScreen(); appointmentsListScreen.Show(); }