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

/*
 * JFrameCCorriente.java
 *
 * Created on 07-dic-2009, 18:06:45
 */

package javacgc;

/**
 *
 * @author GabY
 */
public class JFrameNuevaCCorrienteLibreta extends javax.swing.JFrame {
        String dni="";
        Sucursal s;
    /** Creates new form JFrameCCorriente */
    public JFrameNuevaCCorrienteLibreta(String d,Sucursal su) {
        dni=d;
        s=su;
        initComponents();
        Cliente cl;
        if((cl=su.buscarCliente(d))!=null){
            jtxtNombreTitular.setText(cl.getNombreCliente());
            jtxtNombreTitular.setEnabled(false);
        }
    }

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

        buttonGroup1 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jtxtNombreTitular = new javax.swing.JTextField();
        jlblNumeroCCorriente = new javax.swing.JLabel();
        jbttnValidarNuevaCCorrienteLibreta = new javax.swing.JButton();
        jcbccorriente = new javax.swing.JCheckBox();
        jcblibreta = new javax.swing.JCheckBox();
        jbttnSalir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setText("Nueva Cuenta Corriente / Libreta");

        jLabel2.setText("Nº Cuenta :");

        jLabel3.setText("Nombre del Titular: ");

        jtxtNombreTitular.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtNombreTitularActionPerformed(evt);
            }
        });

        jbttnValidarNuevaCCorrienteLibreta.setText("Validar");
        jbttnValidarNuevaCCorrienteLibreta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbttnValidarNuevaCCorrienteLibretaActionPerformed(evt);
            }
        });

        buttonGroup1.add(jcbccorriente);
        jcbccorriente.setText("Cuenta Corriente");
        jcbccorriente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbccorrienteActionPerformed(evt);
            }
        });

        buttonGroup1.add(jcblibreta);
        jcblibreta.setText("Libreta");

        jbttnSalir.setText("Salir");
        jbttnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbttnSalirActionPerformed(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()
                .addGap(115, 115, 115)
                .addComponent(jLabel1)
                .addContainerGap(127, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(153, 153, 153)
                .addComponent(jlblNumeroCCorriente)
                .addContainerGap(249, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3))
                .addGap(18, 18, 18)
                .addComponent(jtxtNombreTitular, javax.swing.GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE)
                .addGap(26, 26, 26))
            .addGroup(layout.createSequentialGroup()
                .addGap(61, 61, 61)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jcbccorriente)
                    .addComponent(jcblibreta))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 98, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jbttnValidarNuevaCCorrienteLibreta)
                    .addComponent(jbttnSalir))
                .addContainerGap(67, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(25, 25, 25)
                .addComponent(jlblNumeroCCorriente)
                .addGap(10, 10, 10)
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtNombreTitular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcbccorriente)
                    .addComponent(jbttnValidarNuevaCCorrienteLibreta))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jcblibreta)
                    .addComponent(jbttnSalir))
                .addContainerGap(40, Short.MAX_VALUE))
        );

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

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

    private void jbttnValidarNuevaCCorrienteLibretaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbttnValidarNuevaCCorrienteLibretaActionPerformed
        // TODO add your handling code here:
        String ms="";
if(!jtxtNombreTitular.getText().isEmpty()){
        if(jcblibreta.isSelected()){
            ms="LibretaAhorro";
        jlblNumeroCCorriente.setText(s.getNumofic()+s.getNcta());
        if(s.buscarCliente(dni)==null) s.altaCliente(dni, jtxtNombreTitular.getText());
        s.altaproducto(jtxtNombreTitular.getText(), dni, ms,jlblNumeroCCorriente.getText());
}
else if (jcbccorriente.isSelected()){
    ms="CuentaCorriente";
        jlblNumeroCCorriente.setText(s.getNumofic()+s.getNcta());
        if(s.buscarCliente(dni)==null) s.altaCliente(dni, jtxtNombreTitular.getText());
         s.altaproducto(jtxtNombreTitular.getText(), dni, ms, jlblNumeroCCorriente.getText());
}
}
    }//GEN-LAST:event_jbttnValidarNuevaCCorrienteLibretaActionPerformed

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

    private void jbttnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbttnSalirActionPerformed
        // TODO add your handling code here
        this.setVisible(false);
    }//GEN-LAST:event_jbttnSalirActionPerformed

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JButton jbttnSalir;
    private javax.swing.JButton jbttnValidarNuevaCCorrienteLibreta;
    private javax.swing.JCheckBox jcbccorriente;
    private javax.swing.JCheckBox jcblibreta;
    private javax.swing.JLabel jlblNumeroCCorriente;
    private javax.swing.JTextField jtxtNombreTitular;
    // End of variables declaration//GEN-END:variables

}
