Skip to content
Snippets Groups Projects
Commit 5ff1f1a3 authored by eyan_'s avatar eyan_
Browse files
 Conflicts:
	SchedulerApp/src/main/java/com/example/schedulerapp/Controller.java
	SchedulerApp/src/main/java/com/example/schedulerapp/Model.java
parents 1163de3a ca61bfe2
No related branches found
No related tags found
No related merge requests found
......@@ -52,7 +52,6 @@ public class Controller {
Scene popupScene;
RafisWeirdClass rafisWeirdClass = new RafisWeirdClass();
Model model = new Model("10.237.93.139" ,8989);
String IP = "10.237.93.139";
DailyView dailyView;
WeeklyView weeklyView;
BorderPane root;
......@@ -122,8 +121,8 @@ public class Controller {
ObservableList<String> list = FXCollections.observableArrayList();
aList.forEach(employee-> list.add(employee));
ComboBox box = (ComboBox) event.getSource();
box.setItems(list);
ComboBox test = (ComboBox) event.getSource();
test.setItems(list);
}
public void addShiftSubmitClicked(MouseEvent event){
......
......@@ -129,8 +129,8 @@ public class Model {
writer.println("addShift/"+id+"/"+date+"/"+start+"/"+end);
}
void removeShift(int id, String date, int start, int end){
writer.println("removeShift/"+id+"/"+date+"/"+start+"/"+end);
void removeShift(int shiftID){
writer.println("removeShift/"+shiftID);
}
void printAllShifts() {
......@@ -212,12 +212,12 @@ public class Model {
}
return convertToShift(getShiftsByWeek(start, end));
/*
/*
ArrayList<String> test = new ArrayList<>();
test.add("123.2022-03-10.0800.1600");
//return convertToShift(test);
*/
return convertToShift(test);
*/
}
//for view
......@@ -233,6 +233,8 @@ public class Model {
for (String dbShift : input){
String[] strings = dbShift.split("\\.");
int id = Integer.parseInt(strings[0]);
if (strings[2].length() == 3) strings[2] = "0" + strings[2];
if (strings[3].length() == 3) strings[3] = "0" + strings[3];
LocalDateTime start = LocalDateTime.parse(strings[1] + strings[2], formatter);
LocalDateTime end = LocalDateTime.parse(strings[1] + strings[3], formatter);
output.add(new Shift(id, start, end));
......
......@@ -53,6 +53,22 @@ public class Schedule {
}
}
/*
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){
try {
Statement myStatement = dbConnection.createStatement();
myStatement.executeUpdate("DELETE FROM shifts WHERE (shift_id =" + shiftID + ")");
} catch (SQLException e) {
e.printStackTrace();
}
}
/*
Name: getShifts
Parameters:
......@@ -126,7 +142,7 @@ public class Schedule {
while (myRs.next()) {
response = response + "/" + myRs.getString("employee_id" ) + "." +
myRs.getString("full_date") + "." + myRs.getString("start_time") +
"." + myRs.getString("end_time");
"." + myRs.getString("end_time") + "." + myRs.getString("shift_id");
}
} catch (SQLException e) {
e.printStackTrace();
......
......@@ -69,7 +69,7 @@ public class UserThread extends Thread {
break;
case "removeShift":
try {
rafisWeirdClass.schedule.removeShift(args[1], args[2], Integer.parseInt(args[3]), Integer.parseInt(args[4]));
rafisWeirdClass.schedule.removeShiftByID(args[1]);
serverMessage = rafisWeirdClass.schedule.allShifts();
server.broadcast(serverMessage);
} catch (NumberFormatException exception) {
......
No preview for this file type
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