diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b5ae98c..2462e3f 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -7,80 +7,17 @@ - - - - - - - - @@ -748,7 +607,15 @@ - diff --git a/clients.dat b/clients.dat index 9710331..6d07e02 100644 Binary files a/clients.dat and b/clients.dat differ diff --git a/orders.dat b/orders.dat index c19d437..5342fd7 100644 Binary files a/orders.dat and b/orders.dat differ diff --git a/src/main/java/com/example/exa863_management_system_2023/controller/OrdersController.java b/src/main/java/com/example/exa863_management_system_2023/controller/OrdersController.java index 974ef19..6cdc9a1 100644 --- a/src/main/java/com/example/exa863_management_system_2023/controller/OrdersController.java +++ b/src/main/java/com/example/exa863_management_system_2023/controller/OrdersController.java @@ -18,6 +18,7 @@ import java.io.IOException; import java.util.List; +import java.util.Objects; public class OrdersController extends MenuController{ @@ -67,6 +68,7 @@ public class OrdersController extends MenuController{ private void initialize(){ selectedOrder = null; initializeTable(); + updateValues(); } private void initializeTable(){ @@ -104,6 +106,28 @@ private void initializeTable(){ } } + public void updateValues() { + int totalOrders = 0; + int canceledOrders = 0; + int pendignOrders = 0; + int openedOrders = 0; + List orderList = DAO.getWorkOrder().findMany(); + for(WorkOrder workOrder : orderList) { + totalOrders += 1; + if (Objects.equals(workOrder.getStatus(), "OPEN")) { + openedOrders += 1; + } else if (Objects.equals(workOrder.getStatus(), "CANCELED")) { + canceledOrders += 1; + } else { + pendignOrders += 1; + } + } + this.numTotalLabel.setText(String.valueOf(totalOrders)); + this.numCanceledLabel.setText(String.valueOf(canceledOrders)); + this.numCompletedLabel.setText(String.valueOf(pendignOrders)); + this.numOrdersLabel.setText(String.valueOf(openedOrders)); + } + @FXML void removeOrder(ActionEvent event) throws IOException { try { diff --git a/src/main/java/com/example/exa863_management_system_2023/controller/UpdateOrderController.java b/src/main/java/com/example/exa863_management_system_2023/controller/UpdateOrderController.java index 802c496..ea4d03c 100644 --- a/src/main/java/com/example/exa863_management_system_2023/controller/UpdateOrderController.java +++ b/src/main/java/com/example/exa863_management_system_2023/controller/UpdateOrderController.java @@ -4,6 +4,7 @@ import com.example.exa863_management_system_2023.dao.DAO; import com.example.exa863_management_system_2023.exceptions.InvalidSatisfactionScore; import com.example.exa863_management_system_2023.exceptions.ObjectNotFoundException; +import com.example.exa863_management_system_2023.exceptions.WorkOrderWithoutTechnician; import com.example.exa863_management_system_2023.model.WorkOrder; import javafx.event.ActionEvent; import javafx.fxml.FXML; @@ -16,35 +17,30 @@ public class UpdateOrderController { - @FXML - private TextField IDField; - + //Button @FXML private Button cancelButton; - @FXML - private TextField clientIDField; + private Button saveButton; - @FXML - private TextField costField; + //Field @FXML private TextField descriptionField; - @FXML - private TextField paymentMethodField; - + private TextField clientIDField; + @FXML + private TextField technicianID; + @FXML + private TextField statusField; @FXML private TextField priceField; - @FXML - private TextField satisfactionScoreField; - + private TextField costField; @FXML - private Button saveButton; - + private TextField satisfactionScoreField; @FXML - private TextField technicianID; + private TextField paymentMethodField; @FXML void cancelOperation(ActionEvent event) throws IOException { @@ -54,7 +50,7 @@ void cancelOperation(ActionEvent event) throws IOException { } @FXML - void saveOrder(ActionEvent event) throws InvalidSatisfactionScore, ObjectNotFoundException, IOException { + void saveOrder(ActionEvent event) throws InvalidSatisfactionScore, ObjectNotFoundException, IOException, WorkOrderWithoutTechnician { WorkOrder order = (WorkOrder) OrdersController.selectedOrder; if (!descriptionField.getText().isEmpty()) { @@ -66,6 +62,17 @@ void saveOrder(ActionEvent event) throws InvalidSatisfactionScore, ObjectNotFoun if (!technicianID.getText().isEmpty()) { order.setTechnicianID(technicianID.getText()); } + if (!statusField.getText().isEmpty()) { + if (statusField.getText().toLowerCase().charAt(0) == 'o') { + order.reopen(); + } + if (statusField.getText().toLowerCase().charAt(0) == 'c') { + order.cancel(); + } + if (statusField.getText().toLowerCase().charAt(0) == 'f') { + order.finish(); + } + } if (!priceField.getText().isEmpty()) { order.setPrice(Double.parseDouble(priceField.getText())); } diff --git a/src/main/resources/com/example/exa863_management_system_2023/UpdateOrderView.fxml b/src/main/resources/com/example/exa863_management_system_2023/UpdateOrderView.fxml index 64e69b1..3339e59 100644 --- a/src/main/resources/com/example/exa863_management_system_2023/UpdateOrderView.fxml +++ b/src/main/resources/com/example/exa863_management_system_2023/UpdateOrderView.fxml @@ -25,14 +25,14 @@ - + - + @@ -49,6 +49,11 @@ + + + + + @@ -100,6 +105,14 @@ +