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

/*
 * jfrmReintegro.java
 *
 * Created on 21-nov-2009, 17:27:17
 */

package interfaz;

import com.sun.java.swing.plaf.windows.resources.windows;
import daial.Caja;
import daial.Producto;
import daial.Sucursal;
import java.awt.Dialog;
import java.awt.Dialog.ModalityType;
import javax.swing.JDialog;
import javax.swing.JOptionPane;

/**
 *
 * @author Aida
 */
public class jfrmReintegro extends javax.swing.JFrame {

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

    /** Creates new form jfrmReintegro */

    public jfrmReintegro(Sucursal suc, String cta, jfrmPrincipal principal, Caja caj) {

        initComponents();
        this.setLocationRelativeTo(null);
        s = suc;
        ctaActiva = cta;
        caja_activa = caj;
        p = new jfrmPrincipal(suc,caj);
        p = principal;

    }

    /** 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();
        jTxt_cantidad = new javax.swing.JTextField();
        jBtn_reintegro = new javax.swing.JButton();
        jBtn_atrasR = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Reintegro");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jLabel1.setText("REINTEGRO");

        jLabel2.setText("Cantidad a reintegrar:");

        jBtn_reintegro.setText("Aceptar");
        jBtn_reintegro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_reintegroActionPerformed(evt);
            }
        });

        jBtn_atrasR.setText("Atrás");
        jBtn_atrasR.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtn_atrasRActionPerformed(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()
                        .addGap(65, 65, 65)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jBtn_reintegro)
                            .addComponent(jLabel2))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(54, 54, 54)
                                .addComponent(jBtn_atrasR, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(jTxt_cantidad, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(161, 161, 161)
                        .addComponent(jLabel1)))
                .addContainerGap(87, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addComponent(jLabel1)
                .addGap(52, 52, 52)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTxt_cantidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(63, 63, 63)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBtn_atrasR, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jBtn_reintegro, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(77, Short.MAX_VALUE))
        );

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

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



    private void jBtn_reintegroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtn_reintegroActionPerformed


        if(jTxt_cantidad.getText().compareTo("") != 0) {

            double reintegro = Double.parseDouble(jTxt_cantidad.getText());
            s.buscarCuenta(ctaActiva).reintegrar_enCta(reintegro, caja_activa);
            p.actualizar_info();
            JOptionPane dialogo = new JOptionPane();
            JOptionPane.showMessageDialog(rootPane, "Reintegro realizado con éxito", "Aviso", JOptionPane.INFORMATION_MESSAGE);            
            p.setEnabled(true);
            this.dispose();
        }




    }//GEN-LAST:event_jBtn_reintegroActionPerformed

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

    /**
    * @param args the command line arguments
    */





   /* public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new jfrmReintegro().setVisible(true);
            }
        });
    }*/



    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBtn_atrasR;
    private javax.swing.JButton jBtn_reintegro;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JTextField jTxt_cantidad;
    // End of variables declaration//GEN-END:variables

}
