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

/*
 * jfrArqueoInicial.java
 *
 * Created on 09-ene-2010, 20:09:34
 */

package Vistas;

import Hito4.*;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Ro
 */
public class jfrmArqueoInicial extends javax.swing.JFrame {
    Sucursal AuxSuc;
    Caja AuxCaja;
    Empleado AuxE;
    /** Creates new form jfrArqueoInicial */
    public jfrmArqueoInicial(Sucursal s, Caja c, Empleado e) {
        AuxSuc=s;
        AuxCaja=c;
        AuxE=e;
        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() {

        jLabel3 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jbtnValida = new javax.swing.JButton();
        jtxtSaldo = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel3.setFont(new java.awt.Font("Papyrus", 1, 36));
        jLabel3.setForeground(new java.awt.Color(0, 0, 102));
        jLabel3.setText("Banco ALROMA");

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel1.setText("Saldo Inicial de la Caja:");

        jbtnValida.setText("Valida");
        jbtnValida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnValidaActionPerformed(evt);
            }
        });

        jtxtSaldo.setText("100");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(54, 54, 54)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jbtnValida)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(jtxtSaldo, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(63, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(27, 27, 27)
                    .addComponent(jLabel3)
                    .addContainerGap(28, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtxtSaldo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jbtnValida)
                .addContainerGap(107, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(122, 122, 122)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

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

    private void jbtnValidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnValidaActionPerformed
        Arqueo ar = new Arqueo();
        Caja ca = new Caja();
        ca=ar.ArqueoInicial(AuxCaja,Double.parseDouble(jtxtSaldo.getText()));
        if(ca!=null)//el saldo inicial es el correcto
        {
            this.setEnabled(false);
            jfrmPrincipal pral= new jfrmPrincipal(AuxSuc,AuxCaja);
            ca.addObserver(pral);
            pral.setVisible(true);
            this.dispose();
        }else{
            this.setEnabled(false);
            new jfrmLoginDirector(AuxSuc,AuxCaja,0).setVisible(true);
            AuxSuc.daParteDiferencia(AuxE,AuxCaja.getSaldoFinal(), 1);
            this.dispose();
        }
    }//GEN-LAST:event_jbtnValidaActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JButton jbtnValida;
    private javax.swing.JTextField jtxtSaldo;
    // End of variables declaration//GEN-END:variables

}
