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

/*
 * jfrmIngresoReintegro.java
 *
 * Created on 21-nov-2009, 1:15:06
 */

package Vistas;

import Hito4.*;
import java.text.ParseException;
import java.util.Date;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;

/**
 *
 * @author Ro
 */



public class jfrmIngresoReintegro extends javax.swing.JFrame  implements Observer {
    Sucursal auxsuc;
    JFrame auxjf;
    Caja auxca;
    /** Creates new form jfrmIngresoReintegro */
    public jfrmIngresoReintegro(Sucursal suc, Caja ca, JFrame ppal) {
        auxsuc=suc;
        auxjf=ppal;
        auxca=ca;
        initComponents();

        jlblSaldoCaja.setText(String.valueOf(auxca.getSaldoFinal()));
    }

    /** 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();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jlblresultado = new javax.swing.JLabel();
        jbtningreso = new javax.swing.JButton();
        jbtnreintegro = new javax.swing.JButton();
        jtxtnumcta = new javax.swing.JTextField();
        jtxtimporte = new javax.swing.JTextField();
        jtxtfecha = new javax.swing.JTextField();
        jtxtconcepto = new javax.swing.JTextField();
        jbtnSalir = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jlblSaldoCaja = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Papyrus", 0, 24));
        jLabel1.setText("Ingreso / Reintegro en Cuenta");

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

        jLabel3.setText("Numero de Cuenta");

        jLabel4.setText("Importe");

        jLabel5.setText("Fecha");

        jLabel6.setText("Concepto");

        jbtningreso.setText("Ingreso");
        jbtningreso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtningresoActionPerformed(evt);
            }
        });

        jbtnreintegro.setText("Reintegro");
        jbtnreintegro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnreintegroActionPerformed(evt);
            }
        });

        jtxtnumcta.setText("20984002161000015263");

        jtxtimporte.setText("20");

        jtxtfecha.setText("20-11-09");
        jtxtfecha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtfechaActionPerformed(evt);
            }
        });

        jtxtconcepto.setText("Regalo");
        jtxtconcepto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtconceptoActionPerformed(evt);
            }
        });

        jbtnSalir.setText("Salir");
        jbtnSalir.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnSalirMouseClicked(evt);
            }
        });
        jbtnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnSalirActionPerformed(evt);
            }
        });

        jLabel7.setFont(new java.awt.Font("Papyrus", 0, 14)); // NOI18N
        jLabel7.setText("Saldo en Caja");

        jlblSaldoCaja.setFont(new java.awt.Font("Papyrus", 1, 18)); // NOI18N
        jlblSaldoCaja.setForeground(new java.awt.Color(0, 153, 51));

        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(157, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(122, 122, 122))
            .addGroup(layout.createSequentialGroup()
                .addGap(39, 39, 39)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jbtningreso)
                        .addGap(49, 49, 49)
                        .addComponent(jbtnreintegro))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jtxtimporte, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel6))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jtxtnumcta, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(111, 111, 111)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxtfecha, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxtconcepto, javax.swing.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE)))
                .addGap(66, 66, 66))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jlblresultado, javax.swing.GroupLayout.PREFERRED_SIZE, 305, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(106, 106, 106)
                .addComponent(jbtnSalir)
                .addContainerGap(128, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel7)
                .addGap(28, 28, 28)
                .addComponent(jlblSaldoCaja, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 145, Short.MAX_VALUE)
                .addComponent(jLabel2)
                .addGap(24, 24, 24))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jLabel3)
                    .addComponent(jtxtnumcta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtxtfecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(17, 17, 17)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jtxtimporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jtxtconcepto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(37, 37, 37)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbtningreso)
                            .addComponent(jbtnreintegro))
                        .addGap(29, 29, 29)
                        .addComponent(jlblresultado, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbtnSalir)
                        .addGap(18, 18, 18)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jlblSaldoCaja, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7)))))
        );

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

    private void jbtningresoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtningresoActionPerformed
        boolean valor = false;
        try {
            valor = auxsuc.hazingreso(auxca,jtxtnumcta.getText(), Double.parseDouble(jtxtimporte.getText()), jtxtconcepto.getText(), jtxtfecha.getText());
        } catch (ParseException ex) {
            Logger.getLogger(jfrmIngresoReintegro.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (valor==true) {
                jlblresultado.setText("Operacion de Ingreso Realizada con Éxito.");
        } else {
                jlblresultado.setText("ERROR. Operacion NO Realizada.");
        }
        
    }//GEN-LAST:event_jbtningresoActionPerformed

    private void jbtnreintegroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnreintegroActionPerformed
        boolean valor = false;
        try {
            valor = auxsuc.hazreintegro(auxca,jtxtnumcta.getText(), Double.parseDouble(jtxtimporte.getText()), jtxtconcepto.getText(), jtxtfecha.getText());
        } catch (ParseException ex) {
            Logger.getLogger(jfrmIngresoReintegro.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (valor) {
                jlblresultado.setText("Operacion de Ingreso Realizada con Éxito.");
        } else {
                jlblresultado.setText("ERROR. Operacion NO Realizada.");
        }
    }//GEN-LAST:event_jbtnreintegroActionPerformed
    private void jtxtfechaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtfechaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtxtfechaActionPerformed
    private void jbtnSalirMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnSalirMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jbtnSalirMouseClicked

    private void jbtnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSalirActionPerformed
        auxjf.setEnabled(true);
        this.dispose();
    }//GEN-LAST:event_jbtnSalirActionPerformed

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

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    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.JButton jbtnSalir;
    private javax.swing.JButton jbtningreso;
    private javax.swing.JButton jbtnreintegro;
    private javax.swing.JLabel jlblSaldoCaja;
    private javax.swing.JLabel jlblresultado;
    private javax.swing.JTextField jtxtconcepto;
    private javax.swing.JTextField jtxtfecha;
    private javax.swing.JTextField jtxtimporte;
    private javax.swing.JTextField jtxtnumcta;
    // End of variables declaration//GEN-END:variables

    public void update(Observable o, Object arg) {
        jlblSaldoCaja.setText(String.valueOf(auxca.getSaldoFinal()));}
}
