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

/*
 * jfrmMovCajaCentral.java
 *
 * Created on 08-ene-2010, 20:07:46
 */

package interfaz;

import daial.Caja;
import daial.Sucursal;

/**
 *
 * @author FeNiX
 */
public class jfrmMovCajaCentral extends javax.swing.JFrame {

    private Sucursal s = new Sucursal();
    private String ctaActiva = "";
    jfrmPrincipal p;
    Caja caja_activa;
    Caja caja_central;

    /** Creates new form jfrmMovCajaCentral */
    public jfrmMovCajaCentral(Sucursal suc, jfrmPrincipal principal, Caja caj,Caja central) {
        initComponents();
        this.setLocationRelativeTo(null);
        s = suc;
        caja_activa = caj;
        caja_central = central;
        p = new jfrmPrincipal(suc,caja_activa,caja_central);
        p = principal;
        jTxt_saldoCA.setText(String.valueOf(caja_activa.getSaldo()));
        jTxt_saldoCC.setText(String.valueOf(caja_central.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();
        jTxt_saldoCA = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jTxt_saldoCC = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jTxt_cantidad = new javax.swing.JTextField();
        jCbx_ingresoRetiro = new javax.swing.JComboBox();
        jBtn_atras = new javax.swing.JButton();
        JBtn_aceptar = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel1.setText("Saldo de caja activa:");

        jTxt_saldoCA.setEditable(false);
        jTxt_saldoCA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTxt_saldoCAActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel2.setText("Saldo de caja central:");

        jTxt_saldoCC.setEditable(false);
        jTxt_saldoCC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTxt_saldoCCActionPerformed(evt);
            }
        });

        jLabel3.setText("Cantidad:");

        jCbx_ingresoRetiro.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "INGRESAR EN CAJA CENTRAL", "RETIRAR DE CAJA CENTRAL" }));
        jCbx_ingresoRetiro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCbx_ingresoRetiroActionPerformed(evt);
            }
        });

        jBtn_atras.setText("Atras");
        jBtn_atras.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_atrasActionPerformed(evt);
            }
        });

        JBtn_aceptar.setText("ACEPTAR");
        JBtn_aceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JBtn_aceptarActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel4.setText("MOVIMIENTOS A CAJA CENTRAL");

        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(43, 43, 43)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jTxt_saldoCA, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jTxt_saldoCC)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jTxt_cantidad, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(34, 34, 34)
                        .addComponent(jCbx_ingresoRetiro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(28, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(119, 119, 119)
                .addComponent(JBtn_aceptar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 132, Short.MAX_VALUE)
                .addComponent(jBtn_atras)
                .addGap(22, 22, 22))
            .addGroup(layout.createSequentialGroup()
                .addGap(39, 39, 39)
                .addComponent(jLabel4)
                .addContainerGap(80, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(jLabel4)
                .addGap(33, 33, 33)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTxt_saldoCA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(41, 41, 41)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTxt_saldoCC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(42, 42, 42)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTxt_cantidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(jCbx_ingresoRetiro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
                        .addComponent(jBtn_atras)
                        .addGap(17, 17, 17))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addComponent(JBtn_aceptar)
                        .addContainerGap())))
        );

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

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

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

    private void jBtn_atrasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_atrasActionPerformed
        p.setEnabled(true);
        this.dispose();
}//GEN-LAST:event_jBtn_atrasActionPerformed

    private void JBtn_aceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBtn_aceptarActionPerformed
        if(jTxt_cantidad.getText().compareTo("")!=0){
            String cadena = (String)jCbx_ingresoRetiro.getSelectedItem();
            if(cadena.compareTo("INGRESAR EN CAJA CENTRAL")==0){
                caja_activa.setSaldo(caja_activa.getSaldo() - Double.valueOf(jTxt_cantidad.getText()));
                caja_central.setSaldo(caja_central.getSaldo() + Double.valueOf(jTxt_cantidad.getText()));
            }else{
                caja_activa.setSaldo(caja_activa.getSaldo() + Double.valueOf(jTxt_cantidad.getText()));
                caja_central.setSaldo(caja_central.getSaldo() - Double.valueOf(jTxt_cantidad.getText()));
            }
        }
        p.setEnabled(true);
        this.dispose();
}//GEN-LAST:event_JBtn_aceptarActionPerformed

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

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton JBtn_aceptar;
    private javax.swing.JButton jBtn_atras;
    private javax.swing.JComboBox jCbx_ingresoRetiro;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JTextField jTxt_cantidad;
    private javax.swing.JTextField jTxt_saldoCA;
    private javax.swing.JTextField jTxt_saldoCC;
    // End of variables declaration//GEN-END:variables

}
