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

/*
 * JFVerEmpleados.java
 *
 * Created on 04-nov-2010, 11:24:34
 */

package vistas;

import java.util.List;
import javabbuva.*;

/**
 *
 * @author Adrian
 */
public class JFVerEmpleados extends javax.swing.JFrame {

    Sucursal su;
    JFPrincipal p;

    /** Creates new form JFVerEmpleados */
    public JFVerEmpleados(Sucursal su, JFPrincipal p) {
        initComponents();
        this.su = su;
        this.p = p;
        this.p.setEnabled(false);
        jLSaldo1.setText(String.valueOf(su.getCajaActual().getSaldo()));
    }

    /** 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() {

        jLabel1 = new javax.swing.JLabel();
        jLSaldo1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTmostrar = new javax.swing.JTextArea();
        jBterminar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel1.setText("Visualización de empleados");

        jLSaldo1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLSaldo1.setForeground(new java.awt.Color(102, 102, 102));
        jLSaldo1.setText("0");
        jLSaldo1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel4.setForeground(new java.awt.Color(102, 102, 102));
        jLabel4.setText("Saldo actual en caja:");

        jTmostrar.setColumns(20);
        jTmostrar.setEditable(false);
        jTmostrar.setFont(new java.awt.Font("Monospaced", 1, 13)); // NOI18N
        jTmostrar.setForeground(new java.awt.Color(0, 102, 102));
        jTmostrar.setRows(5);
        jScrollPane1.setViewportView(jTmostrar);

        jBterminar.setText("Terminar");
        jBterminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBterminarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 232, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLSaldo1, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(34, 34, 34)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 450, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jBterminar)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLSaldo1))
                    .addComponent(jLabel1))
                .addGap(34, 34, 34)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 25, Short.MAX_VALUE)
                .addComponent(jBterminar)
                .addContainerGap())
        );

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

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        // TODO add your handling code here:
        this.p.setEnabled(true);
    }//GEN-LAST:event_formWindowClosed

    private void jBterminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBterminarActionPerformed
        // TODO add your handling code here:
        this.dispose();
}//GEN-LAST:event_jBterminarActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:
        List<Empleado> empleados = su.getEmpleado();
        int i = 0;
        String mostrar = "";
        while(i<empleados.size()){
           mostrar+="Nombre: "+empleados.get(i).getNombre()+" "+empleados.get(i).getApellidos()+"\nTelefono: "+empleados.get(i).getTelefono()+"\n\n";
           i++;
        }
        jTmostrar.setText(mostrar);
    }//GEN-LAST:event_formWindowOpened

    /**
    * @param args the command line arguments
    */
    /*public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new JFVerEmpleados().setVisible(true);
            }
        });
    }*/

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBterminar;
    private javax.swing.JLabel jLSaldo1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTmostrar;
    // End of variables declaration//GEN-END:variables

}
