Skip to content

Commit

Permalink
Implemented EditEntity.fxml and EditEntityController.java
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsilva010 committed Apr 15, 2024
1 parent a04cf90 commit a4f7828
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
27 changes: 18 additions & 9 deletions src/Controllers/EditEntityController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package Controllers;

import java.time.LocalDate;
import java.util.ArrayList;

import DAOs.MajorDAO;
Expand All @@ -11,7 +10,6 @@
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.ComboBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TextField;

public class EditEntityController {
Expand All @@ -23,7 +21,7 @@ public class EditEntityController {
private ComboBox<String> cbMajorID;

@FXML
private DatePicker dpExpectedGraduation;
private TextField tfExpectedGraduation;

@FXML
private TextField tfCity;
Expand All @@ -37,6 +35,9 @@ public class EditEntityController {
@FXML
private TextField tfLastName;

@FXML
private TextField tfPhone;

@FXML
private TextField tfState;

Expand Down Expand Up @@ -70,16 +71,18 @@ void search(ActionEvent event) {
Students student = StudentDAO.getStudentById(tfID.getText());
if (student != null) {
tfStudentID.setText(student.getStudentID());

tfFirstName.setText(student.getFirstName());
tfLastName.setText(student.getLastName());
tfPhone.setText(student.getPhone());
tfEmail.setText(student.getEmail());
tfStreet.setText(student.getStreet());
tfCity.setText(student.getCity());
tfState.setText(student.getState());
tfZipCode.setText(String.valueOf(student.getZipCode()));
cbMajorID.setValue(String.valueOf(student.getMajorID() + " - " + MajorDAO.getMajorName(student.getMajorID())));
dpExpectedGraduation.setValue(LocalDate.parse(student.getExpectedGraduationDate()));
cbMajorID.setValue(
String.valueOf(student.getMajorID() + " - " + MajorDAO.getMajorName(student.getMajorID())));
tfExpectedGraduation.setText(student.getExpectedGraduationDate());
}
} else {
Alert alert = new Alert(Alert.AlertType.ERROR);
Expand All @@ -103,7 +106,7 @@ private boolean validateFields() {
alert.showAndWait();
return false;
}
if (dpExpectedGraduation.getValue() == null) {
if (tfExpectedGraduation.getText() == null) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("Error");
Expand Down Expand Up @@ -143,6 +146,14 @@ private boolean validateFields() {
alert.showAndWait();
return false;
}
if (tfPhone.getText().isEmpty()) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("Error");
alert.setContentText("Please enter a phone number.");
alert.showAndWait();
return false;
}
if (tfState.getText().isEmpty()) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error");
Expand Down Expand Up @@ -171,5 +182,3 @@ private boolean validateFields() {
}

}


7 changes: 3 additions & 4 deletions src/Views/EditEntityView.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ButtonBar?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.DatePicker?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TextField?>
Expand Down Expand Up @@ -127,12 +126,12 @@
</VBox>
<VBox alignment="CENTER" fillWidth="false" GridPane.columnIndex="1" GridPane.rowIndex="6">
<children>
<TextField onAction="#enter" />
<TextField fx:id="tfZipCode" onAction="#enter" />
</children>
</VBox>
<VBox alignment="CENTER" fillWidth="false" GridPane.columnIndex="1" GridPane.rowIndex="7">
<children>
<TextField fx:id="tfZipCode" onAction="#enter" />
<TextField fx:id="tfPhone" onAction="#enter" />
</children>
</VBox>
<VBox alignment="CENTER" fillWidth="false" GridPane.columnIndex="1" GridPane.rowIndex="8">
Expand All @@ -147,7 +146,7 @@
</VBox>
<VBox alignment="CENTER" fillWidth="false" GridPane.columnIndex="1" GridPane.rowIndex="10">
<children>
<DatePicker fx:id="dpExpectedGraduation" onAction="#enter" />
<TextField fx:id="tfExpectedGraduation" />
</children>
</VBox>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" style="-fx-background-color: grey;" GridPane.columnSpan="2" GridPane.rowIndex="11">
Expand Down

0 comments on commit a4f7828

Please sign in to comment.