Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package gui.controller;
- import java.io.IOException;
- import java.sql.*;
- import javafx.fxml.FXML;
- import javafx.fxml.FXMLLoader;
- import javafx.scene.control.*;
- import javafx.scene.layout.Pane;
- import javafx.scene.paint.Color;
- import javafx.scene.text.*;
- public class SearchStudentController {
- private MainController mainController;
- private StartScreenController startScreen;
- static String pesel;
- static int tDateFlag;
- static int pDateFlag;
- @FXML
- private Button examRegisterButton, examReRegisterButton;
- @FXML
- private TextField studentPesel;
- @FXML
- private Label studentName,studentLastName,studentAddress,peselNotFound;
- @FXML
- private Text studentCourseStatus,tExamDate,pExamDate,tExamPay,pExamPay,tExamResult,pExamResult;
- public void cleanScene() {
- studentName.setText("");
- studentLastName.setText("");
- studentAddress.setText("");
- studentCourseStatus.setText("");
- tExamDate.setText("");
- pExamDate.setText("");
- tExamPay.setText("");
- pExamPay.setText("");
- tExamResult.setText("");
- pExamResult.setText("");
- }
- @FXML
- public void returnButton() {
- FXMLLoader loader = new FXMLLoader(this.getClass().getResource("/fxml/LoggedIn.fxml"));
- Pane pane = null;
- try {
- pane = loader.load();
- } catch (IOException e) {
- e.printStackTrace();
- }
- LoggedInController loggedInController = loader.getController();
- loggedInController.setMainController(mainController);
- mainController.setScreenPane(pane);
- }
- @FXML
- public void examRegister() {
- FXMLLoader loader = new FXMLLoader(this.getClass().getResource("/fxml/ExamRegister.fxml"));
- Pane pane = null;
- try {
- pane = loader.load();
- } catch (IOException e) {
- e.printStackTrace();
- }
- ExamRegisterController examRegisterController = loader.getController();
- examRegisterController.setMainController(mainController);
- mainController.setScreenPane(pane);
- }
- @FXML
- public void searchStudent() throws SQLException {
- cleanScene();
- startScreen = new StartScreenController();
- startScreen.initialize();
- pesel = studentPesel.getText();
- String res = null;
- try {
- startScreen.getOut().println("searchStudent");
- startScreen.getOut().flush();
- startScreen.getOut().println(pesel);
- startScreen.getOut().flush();
- res = startScreen.getIn().readLine();
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- if(res.equals("correct"))
- {
- try {
- studentName.setText(startScreen.getIn().readLine());
- studentLastName.setText(startScreen.getIn().readLine());
- studentAddress.setText(startScreen.getIn().readLine());
- String status = startScreen.getIn().readLine();
- if(status.equals("1"))
- {
- studentCourseStatus.setText("Zaliczony");
- studentCourseStatus.setFill(Color.GREEN);
- }
- else
- {
- studentCourseStatus.setText("Niezaliczony");
- studentCourseStatus.setFill(Color.RED);
- }
- String tExam = startScreen.getIn().readLine();
- if(tExam.equals("0"))
- {
- tExamDate.setText("Niezapisany");
- }
- else
- {
- String hour = startScreen.getIn().readLine();
- tExamDate.setText(tExam + ", " + hour);
- tDateFlag = 0;
- }
- String tRes = startScreen.getIn().readLine();
- if(tRes.equals("0"))
- {
- tExamResult.setText("Egzamin się nie odbył");
- tExamResult.setFill(Color.BLACK);
- }
- else if(tRes.equals("1"))
- {
- tExamResult.setText("Niezaliczony");
- tExamResult.setFill(Color.RED);
- examReRegisterButton.setDisable(false);
- }
- else if(tRes.equals("2"))
- {
- tExamResult.setText("Zaliczony");
- tExamResult.setFill(Color.GREEN);
- }
- String pExam = startScreen.getIn().readLine();
- if(pExam.equals("0"))
- {
- pExamDate.setText("Niezapisany");
- }
- else
- {
- String hour = startScreen.getIn().readLine();
- pExamDate.setText(pExam + ", " + hour);
- pDateFlag = 0;
- }
- String tPay = startScreen.getIn().readLine();
- if(tPay.equals("1"))
- {
- tExamPay.setText("Zapłacono");
- tExamPay.setFill(Color.GREEN);
- }
- else
- {
- tExamPay.setText("Nie zapłacono");
- tExamPay.setFill(Color.RED);
- }
- String pPay = startScreen.getIn().readLine();
- if(pPay.equals("1"))
- {
- pExamPay.setText("Zapłacono");
- pExamPay.setFill(Color.GREEN);
- }
- else
- {
- pExamPay.setText("Nie zapłacono");
- pExamPay.setFill(Color.RED);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- else
- {
- peselNotFound.setText("Nie znaleziono takiego numeru PESEL");
- peselNotFound.setTextFill(Color.RED);
- }
- }
- public void setMainController(MainController mainController) {
- this.mainController = mainController;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement