Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 31.68 KB | None | 0 0
  1. package sample;
  2. import java.sql.*;
  3. import java.util.Vector;
  4. import model.*;
  5. import java.util.ResourceBundle;
  6. import java.net.URL;
  7. import javafx.fxml.FXML;
  8. import javafx.scene.control.TextField;
  9. import javafx.scene.control.cell.PropertyValueFactory;
  10. import javafx.fxml.Initializable;
  11. import javafx.scene.control.*;
  12. import javafx.collections.FXCollections;
  13. import javafx.collections.ObservableList;
  14.  
  15.    
  16. public class Controller implements Initializable {
  17.  
  18.      static Vector<StringBuffer> CityVec= new Vector<StringBuffer>(1);
  19.      static Vector<StringBuffer> AirportVec= new Vector<StringBuffer>(1);
  20.      static Vector<StringBuffer> FlightVec= new Vector<StringBuffer>(1);
  21.      static Vector<StringBuffer> PlaneVec= new Vector<StringBuffer>(1);
  22.      static Vector<StringBuffer> VoyageVec= new Vector<StringBuffer>(1);
  23.      static Vector<StringBuffer> CarrierVec= new Vector<StringBuffer>(1);
  24.      static Vector<StringBuffer> ScheduleVec= new Vector<StringBuffer>(1);
  25.      static Vector<StringBuffer> PassengerVec= new Vector<StringBuffer>(1);
  26.  
  27.      
  28.      static Vector<Integer> Cityy= new Vector<Integer>(1);
  29.      static Vector<Integer> Countryy= new Vector<Integer>(1);
  30.      
  31.      static Vector<Integer> AirportNamee= new Vector<Integer>(1);
  32.      static Vector<Integer> Cityidd= new Vector<Integer>(1);
  33.      
  34.      static Vector<Integer> FlightIDD= new Vector<Integer>(1);
  35.      static Vector<Integer> FlightDatee= new Vector<Integer>(1);
  36.      static Vector<Integer> Voyageidd= new Vector<Integer>(1);
  37.      static Vector<Integer> PlaneIDD= new Vector<Integer>(1);
  38.      
  39.      static Vector<Integer> PlaneNamee= new Vector<Integer>(1);
  40.      static Vector<Integer> PlaneCapacityy= new Vector<Integer>(1);
  41.      
  42.      static Vector<Integer> DepartureTimee= new Vector<Integer>(1);
  43.      
  44.      static Vector<Integer> Capacityy= new Vector<Integer>(1);
  45.      static Vector<Integer> Pricee= new Vector<Integer>(1);
  46.      static Vector<Integer> Flightidd= new Vector<Integer>(1);
  47.      
  48.      static Vector<Integer> ScheduleIDD= new Vector<Integer>(1);
  49.      static Vector<Integer> DepartureFlightt= new Vector<Integer>(1);
  50.      static Vector<Integer> ArrivalFlightt= new Vector<Integer>(1);
  51.      static Vector<Integer> Class11= new Vector<Integer>(1);
  52.      
  53.      static Vector<Integer> IdPassengerr= new Vector<Integer>(1);
  54.      static Vector<Integer> Namee= new Vector<Integer>(1);
  55.      static Vector<Integer> Surnamee= new Vector<Integer>(1);
  56.      static Vector<Integer> Emaill= new Vector<Integer>(1);
  57.      static Vector<Integer> Phonee= new Vector<Integer>(1);
  58.      
  59.      static  StringBuffer  AirportStringBuffer=null ;
  60.      static  StringBuffer  CityStringBuffer=null ;
  61.      static  StringBuffer  FlightStringBuffer=null ;
  62.      static  StringBuffer  PlaneStringBuffer=null ;
  63.      static  StringBuffer  VoyageStringBuffer=null ;
  64.      static  StringBuffer  CarrierStringBuffer=null ;
  65.      static  StringBuffer  ScheduleStringBuffer=null ;
  66.      static  StringBuffer  PassengerStringBuffer=null ;
  67.      
  68.     public Button Add, Add1, Add2, Add3, Add4, Add5, Add6, Add7;
  69.     public TableView<City> a;
  70.     public TableView<Airport> s;
  71.     public TableView<Flight> f;
  72.     public TableView<Plane> p;
  73.     public TableView<Voyage> v;
  74.     public TableView<Carrier> c;
  75.     public TableView<Schedule> sch;
  76.     public TableView<Passenger> pa;
  77.    
  78.     public TextField CityID, CityName, Country;
  79.     public TextField AirportID, AirportName, Cityid;
  80.     public TextField FlightID, FlightDate, VoyageId, PlaneID;
  81.     public TextField Planeid, PlaneName, PlaneCapacity;
  82.     public TextField VoyageID, StartAirportID, EndAirportID, DepartureTime;
  83.     public TextField CarrierID, Capacity, Price, Flightid;
  84.     public TextField ScheduleID, DepartureFlight, ArrivalFlight, Class1;
  85.     public TextField IdPassenger, Name, Surname, Email, Phone;
  86.    
  87.     static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
  88.     static final String DB_URL = "jdbc:mysql://mysql.agh.edu.pl:3306/gaszlar1";
  89.     static final String USER = "gaszlar1";
  90.     static final String PASS = "G5C9WwjovojKkH0T";
  91.    
  92.     public TableColumn<City, String> colCityID;
  93.     public TableColumn<City, String> colCityName;
  94.     public TableColumn<City, String> colCountry;
  95.     public TableColumn<Airport, String> colAirportID;
  96.     public TableColumn<Airport, String> colAirportName;
  97.     public TableColumn<Airport, String> colCityid;
  98.     public TableColumn<Flight, String> colFlightID;
  99.     public TableColumn<Flight, String> colFlightDate;
  100.     public TableColumn<Flight, String> colVoyageid;
  101.     public TableColumn<Flight, String> colPlaneID;
  102.     public TableColumn<Plane, String> colPlaneid;
  103.     public TableColumn<Plane, String> colPlaneName;
  104.     public TableColumn<Plane, String> colPlaneCapacity;
  105.     public TableColumn<Voyage, String> colVoyageID;
  106.     public TableColumn<Voyage, String> colStartAirportID;
  107.     public TableColumn<Voyage, String> colEndAirportID;
  108.     public TableColumn<Voyage, String> colDepartureTime;
  109.     public TableColumn<Carrier, String> colCarrierID;
  110.     public TableColumn<Carrier, String> colCapacity;
  111.     public TableColumn<Carrier, String> colPrice;
  112.     public TableColumn<Carrier, String> colFlightid;
  113.     public TableColumn<Schedule, String> colScheduleID;
  114.     public TableColumn<Schedule, String> colDepartureFlight;
  115.     public TableColumn<Schedule, String> colArrivalFlight;
  116.     public TableColumn<Schedule, String> colClass11;
  117.     public TableColumn<Passenger, String> colIdPassenger;
  118.     public TableColumn<Passenger, String> colName;
  119.     public TableColumn<Passenger, String> colSurname;
  120.     public TableColumn<Passenger, String> colEmail;
  121.     public TableColumn<Passenger, String> colPhone;
  122.    
  123.     @FXML
  124.     public void Add()
  125.     {
  126.        
  127.         City city = new City (CityID.getText(),CityName.getText(),Country.getText());
  128.         a.getItems().add(city);
  129.         String getText1=CityID.getText();
  130.         String getText2=CityName.getText();
  131.         String getText3=Country.getText();
  132.        
  133.  
  134.                 CityID.clear();
  135.                 CityName.clear();
  136.                 Country.clear();
  137.  
  138.            Connection conn = null;
  139.            Statement stmt = null;
  140.            PreparedStatement stmt1 = null;
  141.            try{
  142.               Class.forName("com.mysql.jdbc.Driver");
  143.               conn = DriverManager.getConnection(DB_URL, USER, PASS);
  144.               stmt = conn.createStatement();
  145.                 stmt.executeUpdate("INSERT INTO `gaszlar1`.`City` (`CityID`, `CityName`, `Country`) VALUES ('"+getText1+"', '"+getText2+"', '"+getText3+"');");
  146.  
  147.               stmt.close();
  148.            }catch(Exception e){
  149.               e.printStackTrace();
  150.            }         
  151. }
  152.    
  153. @FXML
  154.     public void Add1()
  155.     {
  156.        
  157.         Airport airport = new Airport (AirportID.getText(),AirportName.getText(),Cityid.getText());
  158.         s.getItems().add(airport);
  159.         String getText1=AirportID.getText();
  160.         String getText2=AirportName.getText();
  161.         String getText3=Cityid.getText();
  162.        
  163.  
  164.         AirportID.clear();
  165.         AirportName.clear();
  166.         Cityid.clear();
  167.  
  168.    
  169.            Connection conn = null;
  170.            Statement stmt = null;
  171.            PreparedStatement stmt1 = null;
  172.            try{
  173.               Class.forName("com.mysql.jdbc.Driver");
  174.               conn = DriverManager.getConnection(DB_URL, USER, PASS);
  175.               stmt = conn.createStatement();
  176.                 stmt.executeUpdate("INSERT INTO `gaszlar1`.`Airport` (`AirportID`, `AirportName`, `CityID`) VALUES ('"+getText1+"', '"+getText2+"', '"+getText3+"');");
  177.  
  178.                   stmt.close();
  179.                }catch(Exception e){
  180.                   e.printStackTrace();
  181.                }         
  182.     }
  183.      
  184. @FXML
  185.     public void Add2()
  186. {
  187.    
  188.     Flight flight = new Flight (FlightID.getText(),FlightDate.getText(),VoyageId.getText(),PlaneID.getText());
  189.     f.getItems().add(flight);
  190.     String getText1=FlightID.getText();
  191.     String getText2=FlightDate.getText();
  192.     String getText3=VoyageId.getText();
  193.     String getText4=PlaneID.getText();
  194.  
  195.     FlightID.clear();
  196.     FlightDate.clear();
  197.     VoyageId.clear();
  198.     PlaneID.clear();
  199.    
  200.    
  201.        Connection conn = null;
  202.        Statement stmt = null;
  203.        PreparedStatement stmt1 = null;
  204.        try{
  205.           Class.forName("com.mysql.jdbc.Driver");
  206.           conn = DriverManager.getConnection(DB_URL, USER, PASS);
  207.           stmt = conn.createStatement();
  208.             stmt.executeUpdate("INSERT INTO `gaszlar1`.`Flight` (`FlightID`, `FlightDate`, `VoyageID`, `PlaneID`) VALUES ('"+getText1+"', '"+getText2+"', '"+getText3+"','"+getText4+"');");
  209.  
  210.               stmt.close();
  211.            }catch(Exception e){
  212.               e.printStackTrace();
  213.            }         
  214. }
  215.  
  216. @FXML
  217.     public void Add3()
  218.     {
  219.    
  220.     Plane plane = new Plane (Planeid.getText(),PlaneName.getText(),PlaneCapacity.getText());
  221.     p.getItems().add(plane);
  222.     String getText1=PlaneID.getText();
  223.     String getText2=PlaneName.getText();
  224.     String getText3=PlaneCapacity.getText();
  225.  
  226.     PlaneID.clear();
  227.     PlaneName.clear();
  228.     PlaneCapacity.clear();
  229.    
  230.        Connection conn = null;
  231.        Statement stmt = null;
  232.        PreparedStatement stmt1 = null;
  233.        try{
  234.           Class.forName("com.mysql.jdbc.Driver");
  235.           conn = DriverManager.getConnection(DB_URL, USER, PASS);
  236.           stmt = conn.createStatement();
  237.             stmt.executeUpdate("INSERT INTO `gaszlar1`.`Plane` (`PlaneID`, `PlaneName`, `PlaneCapacity`) VALUES ('"+getText1+"', '"+getText2+"', '"+getText3+"');");
  238.  
  239.               stmt.close();
  240.            }catch(Exception e){
  241.               e.printStackTrace();
  242.            }         
  243. }
  244.  
  245. @FXML
  246.     public void Add4()
  247. {
  248.  
  249.     Voyage voyage = new Voyage (VoyageID.getText(), StartAirportID.getText(), EndAirportID.getText(), DepartureTime.getText());
  250. v.getItems().add(voyage);
  251. String getText1=VoyageID.getText();
  252. String getText2=StartAirportID.getText();
  253. String getText3=EndAirportID.getText();
  254. String getText4=DepartureTime.getText();
  255.  
  256. VoyageID.clear();
  257. StartAirportID.clear();
  258. EndAirportID.clear();
  259. DepartureTime.clear();
  260.  
  261.    Connection conn = null;
  262.    Statement stmt = null;
  263.    PreparedStatement stmt1 = null;
  264.    try{
  265.       Class.forName("com.mysql.jdbc.Driver");
  266.       conn = DriverManager.getConnection(DB_URL, USER, PASS);
  267.       stmt = conn.createStatement();
  268.         stmt.executeUpdate("INSERT INTO `gaszlar1`.`Voyage` (`VoyageID`, `StartAirportID`, `EndAirportID`, `DepartureTime`) VALUES ('"+getText1+"', '"+getText2+"', '"+getText3+"', '"+getText4+"');");
  269.  
  270.           stmt.close();
  271.        }catch(Exception e){
  272.           e.printStackTrace();
  273.        }         
  274. }
  275.  
  276.  
  277. @FXML
  278.     public void Add5()
  279. {
  280.  
  281. Carrier carrier = new Carrier (CarrierID.getText(), Capacity.getText(), Price.getText(), Flightid.getText());
  282. c.getItems().add(carrier);
  283. String getText1=CarrierID.getText();
  284. String getText2=Capacity.getText();
  285. String getText3=Price.getText();
  286. String getText4=Flightid.getText();
  287.  
  288. CarrierID.clear();
  289. Capacity.clear();
  290. Price.clear();
  291. Flightid.clear();
  292.  
  293. Connection conn = null;
  294. Statement stmt = null;
  295. PreparedStatement stmt1 = null;
  296. try{
  297.   Class.forName("com.mysql.jdbc.Driver");
  298.   conn = DriverManager.getConnection(DB_URL, USER, PASS);
  299.   stmt = conn.createStatement();
  300.     stmt.executeUpdate("INSERT INTO `gaszlar1`.`Carrier` (`CarrierID`, `Capacity`, `Price`, `Flightid`) VALUES ('"+getText1+"', '"+getText2+"', '"+getText3+"', '"+getText4+"');");
  301.  
  302.     stmt.close();
  303.  }catch(Exception e){
  304.     e.printStackTrace();
  305.  }       
  306. }
  307.  
  308.  
  309. @FXML
  310.     public void Add6()
  311. {
  312.  
  313. Schedule schedule = new Schedule (ScheduleID.getText(), DepartureFlight.getText(), ArrivalFlight.getText(), Class1.getText());
  314. sch.getItems().add(schedule);
  315. String getText1=ScheduleID.getText();
  316. String getText2=DepartureFlight.getText();
  317. String getText3=ArrivalFlight.getText();
  318. String getText4=Class1.getText();
  319.  
  320. ScheduleID.clear();
  321. DepartureFlight.clear();
  322. ArrivalFlight.clear();
  323. Class1.clear();
  324.  
  325. Connection conn = null;
  326. Statement stmt = null;
  327. PreparedStatement stmt1 = null;
  328. try{
  329. Class.forName("com.mysql.jdbc.Driver");
  330. conn = DriverManager.getConnection(DB_URL, USER, PASS);
  331. stmt = conn.createStatement();
  332. stmt.executeUpdate("INSERT INTO `gaszlar1`.`Schedule` (`ScheduleID`, `DepartureFlight`, `ArrivalFlight`, `Class`) VALUES ('"+getText1+"', '"+getText2+"', '"+getText3+"', '"+getText4+"');");
  333.  
  334. stmt.close();
  335. }catch(Exception e){
  336. e.printStackTrace();
  337. }        
  338. }
  339.  
  340. @FXML
  341.     public void Add7()
  342. {
  343.  
  344.     Passenger passenger = new Passenger (IdPassenger.getText(), Name.getText(), Surname.getText(), Email.getText(),Phone.getText());
  345. pa.getItems().add(passenger);
  346. String getText1=IdPassenger.getText();
  347. String getText2=Name.getText();
  348. String getText3=Surname.getText();
  349. String getText4=Email.getText();
  350. String getText4a=Phone.getText();
  351.  
  352. IdPassenger.clear();
  353. Name.clear();
  354. Surname.clear();
  355. Email.clear();
  356. Phone.clear();
  357.  
  358. Connection conn = null;
  359. Statement stmt = null;
  360. PreparedStatement stmt1 = null;
  361. try{
  362. Class.forName("com.mysql.jdbc.Driver");
  363. conn = DriverManager.getConnection(DB_URL, USER, PASS);
  364. stmt = conn.createStatement();
  365. stmt.executeUpdate("INSERT INTO `gaszlar1`.`Passenger` (`IdPassenger`, `Name`, `Surname`, `Email`, `Phone`) VALUES ('"+getText1+"', '"+getText2+"', '"+getText3+"', '"+getText4+"', '"+getText4a+"');");
  366.  
  367. stmt.close();
  368. }catch(Exception e){
  369. e.printStackTrace();
  370. }        
  371. }
  372.  
  373.  
  374. public static Vector<StringBuffer> GetCity() {
  375.    
  376.        Connection conn = null;
  377.        Statement stmt = null;
  378.        try{
  379.           Class.forName("com.mysql.jdbc.Driver");
  380.           conn = DriverManager.getConnection(DB_URL, USER, PASS);
  381.           stmt = conn.createStatement();
  382.           ResultSet rs = stmt.executeQuery("SELECT * FROM City");
  383.  
  384.           while(rs.next()) {
  385.               String getString1=rs.getString("CityID");
  386.               String getString2=rs.getString("CityName");
  387.               Integer Int1=getString2.length();
  388.               Controller.Cityy.addElement(Int1);
  389.              
  390.               String getString3=rs.getString("Country");
  391.               Integer Int2=getString3.length();
  392.               Controller.Countryy.addElement(Int2);
  393.              
  394.              
  395.               Controller.AirportStringBuffer=new StringBuffer(getString1+getString2+getString3);
  396.  
  397.               Controller.CityVec.addElement(AirportStringBuffer);
  398.  
  399.           }
  400.           rs.close();
  401.           stmt.close();
  402.        }catch(Exception e){
  403.           e.printStackTrace();
  404.        }
  405.     return Controller.CityVec;
  406.     }
  407.  
  408.  
  409. public static Vector<StringBuffer> GetAirport() {
  410.    
  411.        Connection conn = null;
  412.        Statement stmt = null;
  413.        try{
  414.           Class.forName("com.mysql.jdbc.Driver");
  415.           conn = DriverManager.getConnection(DB_URL, USER, PASS);
  416.           stmt = conn.createStatement();
  417.           ResultSet rs = stmt.executeQuery("SELECT * FROM Airport");
  418.  
  419.           while(rs.next()) {
  420.               String getString1=rs.getString("AirportID");
  421.              
  422.               String getString2=rs.getString("AirportName");
  423.               Integer Int1=getString2.length();
  424.               Controller.AirportNamee.addElement(Int1);
  425.              
  426.               String getString3=rs.getString("Cityid");
  427.               Integer Int2=getString3.length();
  428.               Controller.Cityidd.addElement(Int2);
  429.              
  430.              
  431.               Controller.AirportStringBuffer=new StringBuffer(getString1+getString2+getString3);
  432.  
  433.               Controller.AirportVec.addElement(AirportStringBuffer);
  434.           }
  435.           rs.close();
  436.           stmt.close();
  437.        }catch(Exception e){
  438.           e.printStackTrace();
  439.        }
  440.     return Controller.AirportVec;
  441.     }
  442.    
  443.  
  444. public static Vector<StringBuffer> GetFlight() {
  445.    
  446.        Connection conn = null;
  447.        Statement stmt = null;
  448.        try{
  449.           Class.forName("com.mysql.jdbc.Driver");
  450.           conn = DriverManager.getConnection(DB_URL, USER, PASS);
  451.           stmt = conn.createStatement();
  452.           ResultSet rs = stmt.executeQuery("SELECT * FROM Flight");
  453.  
  454.           while(rs.next()) {
  455.               String getString1=rs.getString("FlightID");
  456.               Integer Int1=getString1.length();
  457.               Controller.FlightIDD.addElement(Int1);
  458.              
  459.               String getString2=rs.getString("FlightDate");
  460.               Integer Int2=getString2.length();
  461.               Controller.FlightDatee.addElement(Int2);
  462.              
  463.               String getString3=rs.getString("VoyageId");
  464.               Integer Int3=getString3.length();
  465.               Controller.Voyageidd.addElement(Int3);
  466.              
  467.               String getString4=rs.getString("PlaneID");
  468.               Integer Int4=getString4.length();
  469.               Controller.PlaneIDD.addElement(Int4);
  470.              
  471.              
  472.               Controller.FlightStringBuffer=new StringBuffer(getString1+getString2+getString3+getString4);
  473.  
  474.               Controller.FlightVec.addElement(FlightStringBuffer);
  475.  
  476.           }
  477.           rs.close();
  478.           stmt.close();
  479.        }catch(Exception e){
  480.           e.printStackTrace();
  481.        }
  482.     return Controller.FlightVec;
  483.     }
  484.  
  485.  
  486. public static Vector<StringBuffer> GetPlane() {
  487.    
  488.        Connection conn = null;
  489.        Statement stmt = null;
  490.        try{
  491.           Class.forName("com.mysql.jdbc.Driver");
  492.           conn = DriverManager.getConnection(DB_URL, USER, PASS);
  493.           stmt = conn.createStatement();
  494.           ResultSet rs = stmt.executeQuery("SELECT * FROM Plane");
  495.  
  496.           while(rs.next()) {
  497.               String getString1=rs.getString("Planeid");
  498.              
  499.               String getString2=rs.getString("PlaneName");
  500.               Integer Int2=getString2.length();
  501.               Controller.PlaneNamee.addElement(Int2);
  502.              
  503.               String getString3=rs.getString("PlaneCapacity");
  504.               Integer Int3=getString3.length();
  505.               Controller.PlaneCapacityy.addElement(Int3);
  506.              
  507.            
  508.               Controller.PlaneStringBuffer=new StringBuffer(getString1+getString2+getString3);
  509.  
  510.               Controller.PlaneVec.addElement(PlaneStringBuffer);
  511.           }
  512.           rs.close();
  513.           stmt.close();
  514.        }catch(Exception e){
  515.           e.printStackTrace();
  516.        }
  517.     return Controller.PlaneVec;
  518.     }
  519.  
  520.  
  521. public static Vector<StringBuffer> GetVoyage() {
  522.    
  523.        Connection conn = null;
  524.        Statement stmt = null;
  525.        try{
  526.           Class.forName("com.mysql.jdbc.Driver");
  527.           conn = DriverManager.getConnection(DB_URL, USER, PASS);
  528.           stmt = conn.createStatement();
  529.           ResultSet rs = stmt.executeQuery("SELECT * FROM Voyage");
  530.  
  531.           while(rs.next()) {
  532.               String getString1=rs.getString("VoyageID");
  533.              
  534.               String getString2=rs.getString("StartAirportID");
  535.  
  536.               String getString3=rs.getString("EndAirportID");
  537.              
  538.               String getString4=rs.getString("DepartureTime");
  539.               Integer Int1=getString4.length();
  540.               Controller.DepartureTimee.addElement(Int1);
  541.              
  542.            
  543.               Controller.VoyageStringBuffer=new StringBuffer(getString1+getString2+getString3+getString4);
  544.  
  545.               Controller.VoyageVec.addElement(VoyageStringBuffer);
  546.           }
  547.           rs.close();
  548.           stmt.close();
  549.        }catch(Exception e){
  550.           e.printStackTrace();
  551.        }
  552.     return Controller.VoyageVec;
  553.     }
  554.  
  555.  
  556. public static Vector<StringBuffer> GetCarrier() {
  557.    
  558.        Connection conn = null;
  559.        Statement stmt = null;
  560.        try{
  561.           Class.forName("com.mysql.jdbc.Driver");
  562.           conn = DriverManager.getConnection(DB_URL, USER, PASS);
  563.           stmt = conn.createStatement();
  564.           ResultSet rs = stmt.executeQuery("SELECT * FROM Carrier");
  565.  
  566.           while(rs.next()) {
  567.               String getString1=rs.getString("CarrierID");
  568.              
  569.               String getString2=rs.getString("Capacity");
  570.               Integer Int1=getString2.length();
  571.               Controller.Capacityy.addElement(Int1);
  572.              
  573.               String getString3=rs.getString("Price");
  574.               Integer Int2=getString3.length();
  575.               Controller.Pricee.addElement(Int2);
  576.              
  577.               String getString4=rs.getString("Flightid");
  578.               Integer Int3=getString4.length();
  579.               Controller.Flightidd.addElement(Int3);
  580.              
  581.            
  582.               Controller.CarrierStringBuffer=new StringBuffer(getString1+getString2+getString3+getString4);
  583.  
  584.               Controller.CarrierVec.addElement(CarrierStringBuffer);
  585.           }
  586.           rs.close();
  587.           stmt.close();
  588.        }catch(Exception e){
  589.           e.printStackTrace();
  590.        }
  591.     return Controller.CarrierVec;
  592.     }
  593.  
  594.  
  595. public static Vector<StringBuffer> GetSchedule() {
  596.    
  597.        Connection conn = null;
  598.        Statement stmt = null;
  599.        try{
  600.           Class.forName("com.mysql.jdbc.Driver");
  601.           conn = DriverManager.getConnection(DB_URL, USER, PASS);
  602.           stmt = conn.createStatement();
  603.           ResultSet rs = stmt.executeQuery("SELECT * FROM Schedule");
  604.  
  605.           while(rs.next()) {
  606.               String getString1=rs.getString("ScheduleID");
  607.               Integer Int1=getString1.length();
  608.               Controller.ScheduleIDD.addElement(Int1);
  609.              
  610.               String getString2=rs.getString("DepartureFlight");
  611.               Integer Int2=getString2.length();
  612.               Controller.DepartureFlightt.addElement(Int2);
  613.              
  614.               String getString3=rs.getString("ArrivalFlight");
  615.               Integer Int3=getString3.length();
  616.               Controller.ArrivalFlightt.addElement(Int3);
  617.              
  618.               String getString4=rs.getString("Class");
  619.               Integer Int4=getString4.length();
  620.               Controller.Class11.addElement(Int4);
  621.              
  622.            
  623.               Controller.ScheduleStringBuffer=new StringBuffer(getString1+getString2+getString3+getString4);
  624.  
  625.               Controller.ScheduleVec.addElement(ScheduleStringBuffer);
  626.           }
  627.           rs.close();
  628.           stmt.close();
  629.        }catch(Exception e){
  630.           e.printStackTrace();
  631.        }
  632.     return Controller.ScheduleVec;
  633.     }
  634.  
  635.  
  636. public static Vector<StringBuffer> GetPassenger() {
  637.    
  638.        Connection conn = null;
  639.        Statement stmt = null;
  640.        try{
  641.           Class.forName("com.mysql.jdbc.Driver");
  642.           conn = DriverManager.getConnection(DB_URL, USER, PASS);
  643.           stmt = conn.createStatement();
  644.           ResultSet rs = stmt.executeQuery("SELECT * FROM Passenger");
  645.  
  646.           while(rs.next()) {
  647.               String getString1=rs.getString("IdPassenger");
  648.               Integer Int1=getString1.length();
  649.               Controller.IdPassengerr.addElement(Int1);
  650.              
  651.               String getString2=rs.getString("Name");
  652.               Integer Int2=getString2.length();
  653.               Controller.Namee.addElement(Int2);
  654.              
  655.               String getString3=rs.getString("Surname");
  656.               Integer Int3=getString3.length();
  657.               Controller.Surnamee.addElement(Int3);
  658.              
  659.               String getString4=rs.getString("Email");
  660.               Integer Int4=getString4.length();
  661.               Controller.Emaill.addElement(Int4);
  662.              
  663.               String abcd5=rs.getString("Phone");
  664.               Integer Int4x=getString4.length();
  665.               Controller.Phonee.addElement(Int4x);
  666.              
  667.            
  668.               Controller.PassengerStringBuffer=new StringBuffer(getString1+getString2+getString3+getString4+abcd5);
  669.  
  670.               Controller.PassengerVec.addElement(PassengerStringBuffer);
  671.  
  672.          
  673.        }
  674.           rs.close();
  675.           stmt.close();
  676.        }catch(Exception e){
  677.           e.printStackTrace();
  678.        }
  679.     return Controller.PassengerVec;
  680.     }
  681.  
  682.  
  683.     @Override
  684. public void initialize(URL url, ResourceBundle rb)
  685.     {   ObservableList<City> city = FXCollections.observableArrayList();      
  686.         colCityID.setCellValueFactory(new PropertyValueFactory<>("CityID"));
  687.         colCityName.setCellValueFactory(new PropertyValueFactory<>("CityName"));
  688.         colCountry.setCellValueFactory(new PropertyValueFactory<>("Country"));
  689.         a.setItems(city);
  690.        
  691.         ObservableList<Airport> airport = FXCollections.observableArrayList();      
  692.         colAirportID.setCellValueFactory(new PropertyValueFactory<>("AirportID"));
  693.         colAirportName.setCellValueFactory(new PropertyValueFactory<>("AirportName"));
  694.         colCityid.setCellValueFactory(new PropertyValueFactory<>("Cityid"));
  695.         s.setItems(airport);
  696.        
  697.         ObservableList<Flight> flight = FXCollections.observableArrayList();      
  698.         colFlightID.setCellValueFactory(new PropertyValueFactory<Flight, String>("FlightID"));
  699.         colFlightDate.setCellValueFactory(new PropertyValueFactory<Flight, String>("FlightDate"));
  700.         colVoyageid.setCellValueFactory(new PropertyValueFactory<Flight, String>("VoyageId"));
  701.         colPlaneID.setCellValueFactory(new PropertyValueFactory<Flight, String>("PlaneID"));
  702.         f.setItems(flight);
  703.        
  704.         ObservableList<Plane> plane = FXCollections.observableArrayList();      
  705.         colPlaneid.setCellValueFactory(new PropertyValueFactory<Plane, String>("Planeid"));
  706.         colPlaneName.setCellValueFactory(new PropertyValueFactory<Plane, String>("PlaneName"));
  707.         colPlaneCapacity.setCellValueFactory(new PropertyValueFactory<Plane, String>("PlaneCapacity"));
  708.         p.setItems(plane);
  709.        
  710.         ObservableList<Voyage> voyage = FXCollections.observableArrayList();      
  711.         colVoyageID.setCellValueFactory(new PropertyValueFactory<Voyage, String>("VoyageID"));
  712.         colStartAirportID.setCellValueFactory(new PropertyValueFactory<Voyage, String>("StartAirportID"));
  713.         colEndAirportID.setCellValueFactory(new PropertyValueFactory<Voyage, String>("EndAirportID"));
  714.         colDepartureTime.setCellValueFactory(new PropertyValueFactory<Voyage, String>("DepartureTime"));
  715.         v.setItems(voyage);
  716.        
  717.         ObservableList<Carrier> carrier = FXCollections.observableArrayList();      
  718.         colCarrierID.setCellValueFactory(new PropertyValueFactory<Carrier, String>("CarrierID"));
  719.         colCapacity.setCellValueFactory(new PropertyValueFactory<Carrier, String>("Capacity"));
  720.         colPrice.setCellValueFactory(new PropertyValueFactory<Carrier, String>("Price"));
  721.         colFlightid.setCellValueFactory(new PropertyValueFactory<Carrier, String>("Flightid"));
  722.         c.setItems(carrier);
  723.        
  724.         ObservableList<Schedule> schedule = FXCollections.observableArrayList();      
  725.         colScheduleID.setCellValueFactory(new PropertyValueFactory<Schedule, String>("ScheduleID"));
  726.         colDepartureFlight.setCellValueFactory(new PropertyValueFactory<Schedule, String>("DepartureFlight"));
  727.         colArrivalFlight.setCellValueFactory(new PropertyValueFactory<Schedule, String>("ArrivalFlight"));
  728.         colClass11.setCellValueFactory(new PropertyValueFactory<Schedule, String>("Class1"));
  729.         sch.setItems(schedule);
  730.        
  731.         ObservableList<Passenger> passenger = FXCollections.observableArrayList();      
  732.         colIdPassenger.setCellValueFactory(new PropertyValueFactory<Passenger, String>("IdPassenger"));
  733.         colName.setCellValueFactory(new PropertyValueFactory<Passenger, String>("Name"));
  734.         colSurname.setCellValueFactory(new PropertyValueFactory<Passenger, String>("Surname"));
  735.         colEmail.setCellValueFactory(new PropertyValueFactory<Passenger, String>("Email"));
  736.         colPhone.setCellValueFactory(new PropertyValueFactory<Passenger, String>("Phone"));
  737.         pa.setItems(passenger);
  738.        
  739.        
  740.         Controller.GetCity();
  741.         for(int i=0; i<(Controller.CityVec.size());i++)
  742.             {
  743.             String strVec= CityVec.get(i).toString();
  744.             String strvec1=strVec.substring(0, 3);
  745.            
  746.             Integer getText1= Controller.Cityy.get(i);
  747.             String strvec2=strVec.substring(3, 3+getText1);
  748.            
  749.             Integer getText2= Controller.Countryy.get(i);
  750.             String strvec3=strVec.substring(3+getText1,3+ getText1 + getText2);
  751.            
  752.             city.add(new City(strvec1,strvec2,strvec3));
  753.            
  754.             }
  755.        
  756.         Controller.GetAirport();
  757.         for(int i=0; i<(Controller.AirportVec.size());i++)
  758.             {
  759.             String strVec= AirportVec.get(i).toString();
  760.             String strvec1=strVec.substring(0, 3);
  761.            
  762.             Integer getText1= Controller.AirportNamee.get(i);
  763.             String strvec2=strVec.substring(3, 3+getText1);
  764.            
  765.             Integer getText2= Controller.Cityidd.get(i);
  766.             String strvec3=strVec.substring(3+getText1, 3+getText1 + getText2);
  767.            
  768.             airport.add(new Airport(strvec1,strvec2,strvec3));
  769.            
  770.             }
  771.        
  772.         Controller.GetFlight();
  773.         for(int i=0; i<(Controller.FlightVec.size());i++)
  774.             {
  775.             String strVec= FlightVec.get(i).toString();
  776.             Integer getText1= Controller.FlightIDD.get(i);
  777.             String strvec1=strVec.substring(0, getText1);
  778.            
  779.             Integer getText2= Controller.FlightDatee.get(i);
  780.             String strvec2=strVec.substring(getText1, getText1+getText2);
  781.            
  782.             Integer getText3= Controller.Voyageidd.get(i);
  783.             String strvec3=strVec.substring(getText1+getText2, getText1 + getText2+ getText3);
  784.            
  785.             Integer getText4= Controller.PlaneIDD.get(i);
  786.             String strvec4=strVec.substring(getText1+getText2+getText3,getText1+ getText2 + getText3+ getText4);
  787.            
  788.             flight.add(new Flight(strvec1,strvec2,strvec3,strvec4));
  789.            
  790.             }
  791.        
  792.         Controller.GetPlane();
  793.         for(int i=0; i<(Controller.PlaneVec.size());i++)
  794.             {
  795.             String strVec= PlaneVec.get(i).toString();
  796.             String strvec1=strVec.substring(0, 5);
  797.            
  798.             Integer getText2= Controller.PlaneNamee.get(i);
  799.             String strvec2=strVec.substring(5, 5+getText2);
  800.            
  801.             Integer getText3= Controller.PlaneCapacityy.get(i);
  802.             String strvec3=strVec.substring(5+getText2, 5 + getText2+ getText3);
  803.  
  804.             plane.add(new Plane(strvec1,strvec2,strvec3));
  805.            
  806.             }
  807.        
  808.         Controller.GetVoyage();
  809.         for(int i=0; i<(Controller.VoyageVec.size());i++)
  810.             {
  811.             String strVec= VoyageVec.get(i).toString();
  812.             String strvec1=strVec.substring(0, 7);
  813.             String strvec2=strVec.substring(7, 10);
  814.            
  815.             String strvec3=strVec.substring(10, 13);
  816.            
  817.             Integer IntText1= Controller.DepartureTimee.get(i);
  818.             String strvec4=strVec.substring(13, 13+IntText1);
  819.  
  820.             voyage.add(new Voyage(strvec1,strvec2,strvec3,strvec4));
  821.            
  822.             }
  823.        
  824.         Controller.GetCarrier();
  825.         for(int i=0; i<(Controller.CarrierVec.size());i++)
  826.             {
  827.             String strVec= CarrierVec.get(i).toString();
  828.             String strvec1=strVec.substring(0, 7);
  829.            
  830.             Integer IntText1= Controller.Capacityy.get(i);
  831.             String strvec2=strVec.substring(7, 7+IntText1);
  832.            
  833.             Integer getText2= Controller.Pricee.get(i);
  834.             String strvec3=strVec.substring(7+IntText1, 7+IntText1+getText2);
  835.            
  836.             Integer getText3= Controller.Flightidd.get(i);
  837.             String strvec4=strVec.substring(7+IntText1+getText2, 7+IntText1+getText2+getText3);
  838.  
  839.             carrier.add(new Carrier(strvec1,strvec2,strvec3,strvec4));
  840.            
  841.             }
  842.        
  843.         Controller.GetSchedule();
  844.         for(int i=0; i<(Controller.ScheduleVec.size());i++)
  845.             {
  846.             String strVec= ScheduleVec.get(i).toString();
  847.            
  848.             Integer IntText= Controller.ScheduleIDD.get(i);
  849.             String strvec1=strVec.substring(0, IntText);
  850.            
  851.             Integer getText1= Controller.DepartureFlightt.get(i);
  852.             String strvec2=strVec.substring(IntText, IntText+getText1);
  853.            
  854.             Integer getText2= Controller.ArrivalFlightt.get(i);
  855.             String strvec3=strVec.substring(IntText+getText1, IntText+getText1+getText2);
  856.            
  857.             Integer getText3= Controller.Class11.get(i);
  858.             String strvec4=strVec.substring(IntText+getText1+getText2, IntText+getText1+getText2+getText3);
  859.  
  860.             schedule.add(new Schedule(strvec1,strvec2,strvec3,strvec4));
  861.            
  862.             }
  863.        
  864.         Controller.GetPassenger();
  865.         for(int i=0; i<(Controller.PassengerVec.size());i++)
  866.             {
  867.             String strVec= PassengerVec.get(i).toString();
  868.  
  869.             Integer IntText= Controller.IdPassengerr.get(i);
  870.             String strvec1=strVec.substring(0, IntText);
  871.            
  872.             Integer getText1= Controller.Namee.get(i);
  873.             String strvec2=strVec.substring(IntText, IntText+getText1);
  874.            
  875.             Integer getText2= Controller.Surnamee.get(i);
  876.             String strvec3=strVec.substring(IntText+getText1, IntText+getText1+getText2);
  877.            
  878.             Integer getText3= Controller.Emaill.get(i);
  879.             String strvec4=strVec.substring(IntText+getText1+getText2, IntText+getText1+getText2+getText3);
  880.  
  881.             String strvec5=strVec.substring(IntText+getText1+getText2+getText3);
  882.  
  883.             passenger.add(new Passenger(strvec1,strvec2,strvec3,strvec4,strvec5));
  884.            
  885.             }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement