@@ -188,21 +188,25 @@ public void setAppointmentList(ObservableList<Appointment> appointmentList) {
188
188
*/
189
189
private static Boolean hasAppointmentConflicts (Appointment appointment ) {
190
190
String selectStatement = "SELECT Local_Start, Local_End " +
191
- "FROM (SELECT Start + INTERVAL ? HOUR as Local_Start, End + INTERVAL ? HOUR as Local_End " +
191
+ "FROM (SELECT Appointment_ID, Start + INTERVAL ? HOUR as Local_Start, End + INTERVAL ? HOUR as Local_End " +
192
192
"FROM appointments " +
193
- "WHERE Customer_ID = ?) LocalTimeTable " +
194
- "WHERE Local_Start < ? " +
195
- "AND Local_End > ?" ;
193
+ "WHERE Customer_ID = ? " +
194
+ "AND Appointment_ID != ?) LocalTimeTable " +
195
+ "WHERE ? BETWEEN Local_Start AND Local_End " +
196
+ "OR ? BETWEEN Local_Start AND Local_End" ;
196
197
197
198
try {
198
199
DBQuery .setPreparedStatement (connection , selectStatement );
199
200
PreparedStatement preparedStatement = DBQuery .getPreparedStatement ();
200
201
201
- preparedStatement .setInt (1 , TimezoneUtil .getOffsetToLocalTime ());
202
- preparedStatement .setInt (2 , TimezoneUtil .getOffsetToLocalTime ());
202
+ preparedStatement .setInt (1 , 0 );
203
+ preparedStatement .setInt (2 , 0 );
204
+ // preparedStatement.setInt(1, TimezoneUtil.getOffsetToLocalTime());
205
+ // preparedStatement.setInt(2, TimezoneUtil.getOffsetToLocalTime());
203
206
preparedStatement .setInt (3 , appointment .getCustomerId ());
204
- preparedStatement .setTimestamp (4 , appointment .getEnd ());
207
+ preparedStatement .setInt (4 , appointment .getId ());
205
208
preparedStatement .setTimestamp (5 , appointment .getStart ());
209
+ preparedStatement .setTimestamp (6 , appointment .getEnd ());
206
210
207
211
preparedStatement .execute ();
208
212
ResultSet resultSet = preparedStatement .getResultSet ();
@@ -245,7 +249,7 @@ public static void getUpcomingAppointment() {
245
249
int id = resultSet .getInt ("Appointment_ID" );
246
250
Timestamp start = resultSet .getTimestamp ("Start" );
247
251
248
- String appointmentNotification = String .format ("Appointment! ID: %s Starts: %s" ,id , start .toString ());
252
+ String appointmentNotification = String .format ("Appointment! ID: %s Starts: %s" , id , start .toString ());
249
253
Warning .generateMessage (appointmentNotification , Alert .AlertType .INFORMATION );
250
254
} else {
251
255
Warning .generateMessage ("No Appointments Coming Up in 15 Minutes" , Alert .AlertType .INFORMATION );
0 commit comments