package src;



/*
 * JfrmArqueo.java
 *
 * Created on 08-ene-2010, 13:27:24
 */

/**
 *
 * @author Carlos
 */
public class JfrmArqueo extends javax.swing.JFrame
{
    Arqueo a=new Arqueo();
    Cuentas c=new CuentaCorriente();
    Sucursal auxsuc=new Sucursal();
    JFrmPrincipal pri=new JFrmPrincipal(auxsuc);
    
    
    /** Creates new form JfrmArqueo */
    public JfrmArqueo(Sucursal suc)
    {
        auxsuc=suc;
        initComponents();
        
        jComCajas.setEnabled(false);
        jbtnCrearArqueo.setEnabled(false);
        jtxtsaldoini.setEnabled(false);
        jButton1.setEnabled(true);
    }

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

        jLabel6 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jtxtsaldoini = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jbtnCrearArqueo = new javax.swing.JButton();
        jtxtidemple = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jpcontraseña = new javax.swing.JPasswordField();
        jButton1 = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jComCajas = new javax.swing.JComboBox();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel8 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/src/InterfazMINI.gif"))); // NOI18N

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel1.setText("   Arqueo Inicial");

        jLabel2.setText("SALDO INICIAL");

        jtxtsaldoini.setText("2000");
        jtxtsaldoini.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtsaldoiniActionPerformed(evt);
            }
        });

        jLabel3.setText("€");

        jbtnCrearArqueo.setText("CREAR ARQUEO");
        jbtnCrearArqueo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnCrearArqueoActionPerformed(evt);
            }
        });

        jtxtidemple.setText("111");
        jtxtidemple.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtidempleActionPerformed(evt);
            }
        });

        jLabel4.setText("CONTRASEÑA");

        jLabel5.setText("ID EMPLEADO");

        jpcontraseña.setText("111");

        jButton1.setText("VALIDAR EMPLEADO");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel7.setText("NUMERO DE CAJA");

        jComCajas.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Elija caja", "Caja 1", "Caja 2", "Caja 3", "Caja 4", "Caja 5" }));
        jComCajas.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComCajasItemStateChanged(evt);
            }
        });
        jComCajas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComCajasActionPerformed(evt);
            }
        });

        jLabel8.setForeground(new java.awt.Color(102, 102, 102));
        jLabel8.setText("Elija la caja en la cual esta situado");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(50, 50, 50)
                                .addComponent(jLabel1))
                            .addGroup(layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel4))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jpcontraseña, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                                    .addComponent(jtxtidemple, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(22, 22, 22)
                                .addComponent(jButton1))))
                    .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(82, 82, 82)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(203, 203, 203)
                        .addComponent(jbtnCrearArqueo, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addGap(18, 18, 18)
                                .addComponent(jComCajas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(32, 32, 32)
                                .addComponent(jtxtsaldoini, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(158, 158, 158)))
                .addGap(25, 25, 25))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel8)
                .addContainerGap(268, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addComponent(jLabel1)
                        .addGap(27, 27, 27)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel5)
                            .addComponent(jtxtidemple, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jpcontraseña, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton1))))
                .addGap(18, 18, 18)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jComCajas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jtxtsaldoini, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtnCrearArqueo))
                .addGap(29, 29, 29))
        );

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

    //Boton Crear Arqueo
    private void jbtnCrearArqueoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnCrearArqueoActionPerformed
        // TODO add your handling code here:
        
        auxsuc.asignarSaldoInicial(auxsuc.DevuelveEmpleado(jtxtidemple.getText()),jtxtsaldoini.getText() );
}//GEN-LAST:event_jbtnCrearArqueoActionPerformed

    private void jtxtsaldoiniActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtsaldoiniActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtxtsaldoiniActionPerformed

    private void jtxtidempleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtidempleActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jtxtidempleActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        boolean log;

        log=a.ComprobarEmpleado(auxsuc,jtxtidemple.getText(),jpcontraseña.getText());
        auxsuc.setIdE(jtxtidemple.getText());
        if(log==true)
        {
            jComCajas.setEnabled(true);
            jbtnCrearArqueo.setEnabled(true);
            jtxtsaldoini.setEnabled(true);
            jtxtidemple.setEditable(false);
            jpcontraseña.setEditable(false);
            jbtnCrearArqueo.setEnabled(false);
        } 
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jComCajasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComCajasActionPerformed
    // TODO add your handling code here:

        //a.guardaId(auxsuc,jtxtidemple.getText());

        
        int selectedIndex = jComCajas.getSelectedIndex();
        switch (selectedIndex)
        {
            case 0:
                jbtnCrearArqueo.setEnabled(false);
                break;
            case 1: 
                 a.insertaCajaEmpleado(selectedIndex,auxsuc,jtxtidemple.getText());
                 jbtnCrearArqueo.setEnabled(true);
                break;
            case 2: 
                    a.insertaCajaEmpleado(selectedIndex,auxsuc,jtxtidemple.getText());
                    jbtnCrearArqueo.setEnabled(true);
                break;
            case 3: 
                    a.insertaCajaEmpleado(selectedIndex,auxsuc,jtxtidemple.getText());
                    jbtnCrearArqueo.setEnabled(true);
                break;
            case 4: 
                    a.insertaCajaEmpleado(selectedIndex,auxsuc,jtxtidemple.getText());
                    jbtnCrearArqueo.setEnabled(true);
                break;
            case 5:
                a.insertaCajaEmpleado(selectedIndex,auxsuc,jtxtidemple.getText());
                jbtnCrearArqueo.setEnabled(true);
            break;
        }
}//GEN-LAST:event_jComCajasActionPerformed

    private void jComCajasItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComCajasItemStateChanged
        // TODO add your handling code here:
       
    }//GEN-LAST:event_jComCajasItemStateChanged

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComCajas;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JButton jbtnCrearArqueo;
    private javax.swing.JPasswordField jpcontraseña;
    private javax.swing.JTextField jtxtidemple;
    private javax.swing.JTextField jtxtsaldoini;
    // End of variables declaration//GEN-END:variables

}
