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

Added a remove all shifts by employee id method to the Schedule class. Now...

Added a remove all shifts by employee id method to the Schedule class. Now when an employee is removed there shifts are deleted first from the database then they're deleted after.
parent 881dde2b
No related branches found
No related tags found
1 merge request!6Changed update implementation for employees so rather than sending the whole...
......@@ -90,6 +90,23 @@ public class Schedule {
return editedShift;
}
/*
Name: removeAllShiftsByID
Parameters:
intI ID: Employee ID
Description: Removes all shifts in the database for a specific employee
Return: void
*/
protected void removeAllShiftsByID(int ID) {
try {
Statement myStatement = dbConnection.createStatement();
myStatement.executeUpdate("DELETE FROM shifts WHERE (employee_ID =" + ID + ")");
} catch (SQLException exception) {
System.out.println("Error removing all shifts by id.");
exception.printStackTrace();
}
}
/*
Name: allShifts
Parameters:
......
......@@ -60,7 +60,6 @@ public class Staff {
protected int removeEmployee(int ID){
try {
Statement myStatement = dbConnection.createStatement();
myStatement.executeUpdate("DELETE FROM shifts WHERE (employee_ID =" + ID + ")");
myStatement.executeUpdate("delete from Employees where employee_id = " + ID);
} catch (Exception exception) {
exception.printStackTrace();
......
......@@ -53,6 +53,7 @@ public class UserThread extends Thread {
case "removeEmployee":
try {
int employeeID = Integer.parseInt(args[1]);
rafisWeirdClass.schedule.removeAllShiftsByID(employeeID);
if (employeeID == rafisWeirdClass.staff.removeEmployee(employeeID)) {
server.broadcast("removeEmployee/" + employeeID);
}
......
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