/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * RPrenotazioneV.java
 *
 * Created on 9-lug-2011, 22.26.58
 */

package app.gui;

import app.Main;
import archive.data.Volo;
import archive.interfacce.RichiestaPrenotazioneVolo;
import archive.system.PRequestVoloManager;
import javax.swing.JOptionPane;

public class RPrenotazioneV extends javax.swing.JFrame {
    private RichiestaPrenotazioneVolo prenV=new PRequestVoloManager();

    /** Creates new form RPrenotazioneV */
    public RPrenotazioneV() {
        Main.gui.setVisible(false);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTFLPartenza = new javax.swing.JTextField();
        jTFLArrivo = new javax.swing.JTextField();
        jTFOrario = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jBDisp = new javax.swing.JButton();
        jBPrenotare = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jLabel1.setText("Luogo Di Partenza");

        jLabel2.setText("Luogo di Arrivo");

        jLabel3.setText("Orario");

        jBDisp.setText("Verifica Disponibilità");
        jBDisp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBDispActionPerformed(evt);
            }
        });

        jBPrenotare.setText("Prenotare");
        jBPrenotare.setEnabled(false);
        jBPrenotare.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBPrenotareActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(50, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3))
                .addGap(57, 57, 57)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jBPrenotare)
                    .addComponent(jBDisp)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jTFLArrivo)
                        .addComponent(jTFLPartenza)
                        .addComponent(jTFOrario, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(100, 100, 100))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(59, 59, 59)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTFLPartenza, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTFLArrivo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTFOrario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(34, 34, 34)
                .addComponent(jBDisp)
                .addGap(18, 18, 18)
                .addComponent(jBPrenotare)
                .addContainerGap(54, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBDispActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBDispActionPerformed
        Volo volo=prenV.isAvaible(jTFLPartenza.getText(),jTFLArrivo.getText(), jTFOrario.getText());
          if(volo!=null){
              jBPrenotare.setEnabled(true);
          }else
              JOptionPane.showMessageDialog(rootPane,"Volo non Presente","",JOptionPane.ERROR_MESSAGE);

    }//GEN-LAST:event_jBDispActionPerformed

    private void jBPrenotareActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBPrenotareActionPerformed
         java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new DatiClienteV().setVisible(true);
            }
        });
    }//GEN-LAST:event_jBPrenotareActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
Main.gui.setVisible(true);        // TODO add your handling code here:
    }//GEN-LAST:event_formWindowClosing

    /**
    * @param args the command line arguments
    */
   

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBDisp;
    private javax.swing.JButton jBPrenotare;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    public static javax.swing.JTextField jTFLArrivo;
    public static javax.swing.JTextField jTFLPartenza;
    public static javax.swing.JTextField jTFOrario;
    // End of variables declaration//GEN-END:variables

}
