From 78675fdee3240db2c0dbc6136218f03758cdea70 Mon Sep 17 00:00:00 2001 From: Yasmin Cordeiro <67525293+yasmincsme@users.noreply.github.com> Date: Sun, 18 Jun 2023 01:46:36 -0300 Subject: [PATCH] :books: docs: Atualizando arquivo --- .idea/workspace.xml | 659 +++++++----------- clients.dat | Bin 645 -> 554 bytes orders.dat | Bin 987 -> 1023 bytes .../controller/OrdersController.java | 24 + .../controller/UpdateOrderController.java | 41 +- .../UpdateOrderView.fxml | 17 +- 6 files changed, 326 insertions(+), 415 deletions(-) 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 9710331d0d33fb2f1158a6ce4cd96b2ae9c87133..6d07e02eff7deb04ad14136746b95e264ee5620d 100644 GIT binary patch delta 22 dcmZo=UBxoNh@H8dg@J*Ad7|Z#%@&Nli~v1N1uFmm delta 111 zcmZ3*(#kr)h@GXJg@J*AWuoPhNRH&hlEk9Syu=a)*3{g@%$yPil{8ax)07lbQ(Z%o zBtu;jV>4r23uDtnT|-NQGy^jOVR{E+FGR0)H)p@pu2nXZw6k+Fh-p_Pf5m4S(#iHYFg<^ R9B!U|p1~fjE+q^M6#!)!5e@(V delta 29 lcmey*ew%&6113g>$uF3WF&0cd!K}r};veAZSHi$h0RXF83F80& 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 @@ +