Skip to content
Snippets Groups Projects
Commit 6030575c authored by Rafi's avatar Rafi
Browse files

Added edit shift method to edit shifts in the database.

parent c0207271
No related branches found
No related tags found
No related merge requests found
......@@ -31,39 +31,30 @@ public class Schedule {
e.printStackTrace();
}
}
/*
Name: removeShift
Name: removeShiftByID
Parameters:
int ID: The employees unique ID.
Date: The date as a string in the form of "yyyy-mm-dd".
start: The employees shift start time.
end: The employees shift end time.
Description: Removes the employees shift matching the date, and shift duration.
int shiftID: The shift unique ID.
Description: Removes the employees shift matching the shift date.
Return: none
*/
protected void removeShift(String ID, String date, int start, int end){
Date newDate = Date.valueOf(date);
protected void removeShiftByID(String shiftID){
try {
Statement myStatement = dbConnection.createStatement();
myStatement.executeUpdate("DELETE FROM shifts WHERE (employee_id =" + ID + ") " +
"AND WHERE (date = " + newDate +") AND WHERE (start_time = " + start + " ) " +
"AND WHERE (end_time = " + end +")");
myStatement.executeUpdate("DELETE FROM shifts WHERE (shift_id =" + shiftID + ")");
} catch (SQLException e) {
e.printStackTrace();
}
}
/*
Name: removeShiftByID
Parameters:
int shiftID: The shift unique ID.
Description: Removes the employees shift matching the shift date.
Return: none
*/
protected void removeShiftByID(String shiftID){
protected void editShift(Integer shift_id, String date, String start,String end){
Date newDate = Date.valueOf(date);
System.out.println(newDate);
try {
Statement myStatement = dbConnection.createStatement();
myStatement.executeUpdate("DELETE FROM shifts WHERE (shift_id =" + shiftID + ")");
myStatement.executeUpdate("update shifts set full_date='" + newDate + "',start_time=" + start + ",end_time=" + end
+ " where shift_id=" + shift_id);
} catch (SQLException e) {
e.printStackTrace();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment