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 SeatChoose {
    
    /**
    * Print menu for seat choose
    * @throws SQLException
    * @throws Exception
    */
    static public void Menu() throws SQLException, Exception{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        
        System.out.println("Vyberáme sedadlo. Na ktorý let?:");
        int flight_id=Integer.valueOf(input.readLine());
        System.out.println("Na ktorý lístok?:");
        BoughtTickets.print(flight_id);
        Integer ticket_id = Integer.valueOf(input.readLine());
        if(BoughtTicket.ticketCanceled(ticket_id)){
            System.out.println("Lístok už bol zrušený");
            return;
        }
        if(SeatCount.seatExists(ticket_id)){
            System.out.println("K tomuto lístku už sedadlo existuje..");
            return;
        }
        BoughtTicket b = new BoughtTicket();
        b.findById(ticket_id);
        System.out.println("Ok, ktoré sedadlo?");

        SeatStuff.printFree(b.getClass_id(), b.getAircraft_type_id(), b.getFlight_id());
        Integer seat_id = Integer.valueOf(input.readLine());

        if(TS.SeatChooseTS.transactionSeatChoose(ticket_id, seat_id)){
            System.out.println("Sedadlo rezervované");
        }else{
            System.out.println("Nepodarilo sa");
        }
        
    }
}
