Advertisement
reage

Untitled

Jan 3rd, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.80 KB | None | 0 0
  1. package gui.controller;
  2.  
  3. import java.io.IOException;
  4. import java.sql.*;
  5. import javafx.fxml.FXML;
  6. import javafx.fxml.FXMLLoader;
  7. import javafx.scene.control.*;
  8. import javafx.scene.layout.Pane;
  9. import javafx.scene.paint.Color;
  10. import javafx.scene.text.*;
  11.  
  12.  
  13. public class SearchStudentController {
  14.    
  15.     private MainController mainController;
  16.     private StartScreenController startScreen;
  17.     static String pesel;
  18.     static int tDateFlag;
  19.     static int pDateFlag;
  20.    
  21.     @FXML
  22.     private Button examRegisterButton, examReRegisterButton;
  23.    
  24.     @FXML
  25.     private TextField studentPesel;
  26.    
  27.     @FXML
  28.     private Label studentName,studentLastName,studentAddress,peselNotFound;
  29.    
  30.     @FXML
  31.     private Text studentCourseStatus,tExamDate,pExamDate,tExamPay,pExamPay,tExamResult,pExamResult;
  32.    
  33.     public void cleanScene() {
  34.         studentName.setText("");
  35.         studentLastName.setText("");
  36.         studentAddress.setText("");
  37.         studentCourseStatus.setText("");
  38.         tExamDate.setText("");
  39.         pExamDate.setText("");
  40.         tExamPay.setText("");
  41.         pExamPay.setText("");
  42.         tExamResult.setText("");
  43.         pExamResult.setText("");
  44.     }
  45.    
  46.     @FXML
  47.     public void returnButton() {
  48.         FXMLLoader loader = new FXMLLoader(this.getClass().getResource("/fxml/LoggedIn.fxml"));
  49.         Pane pane = null;
  50.         try {
  51.             pane = loader.load();
  52.         } catch (IOException e) {
  53.             e.printStackTrace();
  54.         }
  55.         LoggedInController loggedInController = loader.getController();
  56.         loggedInController.setMainController(mainController);
  57.         mainController.setScreenPane(pane);
  58.     }
  59.  
  60.     @FXML
  61.     public void examRegister() {
  62.         FXMLLoader loader = new FXMLLoader(this.getClass().getResource("/fxml/ExamRegister.fxml"));
  63.         Pane pane = null;
  64.         try {
  65.             pane = loader.load();
  66.         } catch (IOException e) {
  67.             e.printStackTrace();
  68.         }
  69.         ExamRegisterController examRegisterController = loader.getController();
  70.         examRegisterController.setMainController(mainController);
  71.         mainController.setScreenPane(pane);
  72.     }
  73.  
  74.  
  75.     @FXML
  76.     public void searchStudent() throws SQLException {
  77.         cleanScene();
  78.         startScreen = new StartScreenController();
  79.         startScreen.initialize();
  80.        
  81.         pesel = studentPesel.getText();
  82.         String res = null;
  83.        
  84.         try {
  85.             startScreen.getOut().println("searchStudent");
  86.             startScreen.getOut().flush();
  87.            
  88.             startScreen.getOut().println(pesel);
  89.             startScreen.getOut().flush();
  90.            
  91.             res = startScreen.getIn().readLine();
  92.            
  93.             }
  94.          catch (IOException e) {
  95.             e.printStackTrace();
  96.         }
  97.        
  98.         if(res.equals("correct"))
  99.         {
  100.             try {
  101.                 studentName.setText(startScreen.getIn().readLine());
  102.                 studentLastName.setText(startScreen.getIn().readLine());
  103.                 studentAddress.setText(startScreen.getIn().readLine());
  104.                
  105.                 String status = startScreen.getIn().readLine();
  106.                 if(status.equals("1"))
  107.                 {
  108.                     studentCourseStatus.setText("Zaliczony");
  109.                     studentCourseStatus.setFill(Color.GREEN);
  110.                 }
  111.                 else
  112.                 {
  113.                     studentCourseStatus.setText("Niezaliczony");
  114.                     studentCourseStatus.setFill(Color.RED);
  115.                 }
  116.                 String tExam = startScreen.getIn().readLine();
  117.                 if(tExam.equals("0"))
  118.                 {
  119.                     tExamDate.setText("Niezapisany");
  120.                 }
  121.                 else
  122.                 {
  123.                     String hour = startScreen.getIn().readLine();
  124.                     tExamDate.setText(tExam + ", " + hour);
  125.                     tDateFlag = 0;
  126.                 }
  127.                 String tRes = startScreen.getIn().readLine();
  128.                 if(tRes.equals("0"))
  129.                 {
  130.                     tExamResult.setText("Egzamin się nie odbył");
  131.                     tExamResult.setFill(Color.BLACK);
  132.                 }
  133.                 else if(tRes.equals("1"))
  134.                 {
  135.                     tExamResult.setText("Niezaliczony");
  136.                     tExamResult.setFill(Color.RED);
  137.                     examReRegisterButton.setDisable(false);
  138.                 }
  139.                 else if(tRes.equals("2"))
  140.                 {
  141.                     tExamResult.setText("Zaliczony");
  142.                     tExamResult.setFill(Color.GREEN);
  143.                 }
  144.                 String pExam = startScreen.getIn().readLine();
  145.                 if(pExam.equals("0"))
  146.                 {
  147.                     pExamDate.setText("Niezapisany");
  148.                 }
  149.                 else
  150.                 {
  151.                     String hour = startScreen.getIn().readLine();
  152.                     pExamDate.setText(pExam + ", " + hour);
  153.                     pDateFlag = 0;
  154.                 }
  155.                
  156.                 String tPay = startScreen.getIn().readLine();
  157.                 if(tPay.equals("1"))
  158.                 {
  159.                     tExamPay.setText("Zapłacono");
  160.                     tExamPay.setFill(Color.GREEN);
  161.                 }
  162.                 else
  163.                 {
  164.                     tExamPay.setText("Nie zapłacono");
  165.                     tExamPay.setFill(Color.RED);
  166.                 }
  167.                
  168.                 String pPay = startScreen.getIn().readLine();
  169.                 if(pPay.equals("1"))
  170.                 {
  171.                     pExamPay.setText("Zapłacono");
  172.                     pExamPay.setFill(Color.GREEN);
  173.                 }
  174.                 else
  175.                 {
  176.                     pExamPay.setText("Nie zapłacono");
  177.                     pExamPay.setFill(Color.RED);
  178.                 }
  179.            
  180.                
  181.                
  182.             } catch (IOException e) {
  183.                 e.printStackTrace();
  184.             }
  185.         }
  186.        
  187.         else
  188.         {
  189.             peselNotFound.setText("Nie znaleziono takiego numeru PESEL");
  190.             peselNotFound.setTextFill(Color.RED);
  191.         }
  192.    
  193.     }
  194.    
  195.     public void setMainController(MainController mainController) {
  196.         this.mainController = mainController;
  197.     }
  198.    
  199. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement