package UI;

import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import javax.sql.DataSource;
import org.postgresql.ds.PGSimpleDataSource;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import RDG.*;

/**
 *
 * @author Marcel
 */
public class AircraftChange {
    /**
    * Print menu for aircraft change
    * @throws SQLException
    * @throws Exception
    */
    static public void Menu() throws SQLException, Exception{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        try{
            FlightsMenu.print();
            System.out.println("Ktorý let?");
            Integer flight_id=Integer.valueOf(input.readLine());
            AircraftMenu.printAircrafts();
            System.out.println("Za ktoré lietadlo?");
            Integer new_aircraft_id=Integer.valueOf(input.readLine());
            AircraftType.canReplaceAirplane(new_aircraft_id, flight_id);
            System.out.println("Ok, viem ich vymeniť.");
            if(TS.AircraftChangeTS.transactionAircraftChange(flight_id, new_aircraft_id))
                System.out.println("Vymenené");
            else
                System.out.println("Nepodarilo sa");
        }catch(Exception e){
            System.out.println(e);
        }
    }
}
