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

/*
 * JFramePrestamoHipPersonal.java
 *
 * Created on 07-dic-2009, 18:37:37
 */

package javacgc;

/**
 *
 * @author GabY
 */
public class JFramePrestamoHipPersonal extends javax.swing.JFrame {
    String dni="";
    Sucursal s;
    /** Creates new form JFramePrestamoHipPersonal */
    public JFramePrestamoHipPersonal(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();
        jbttnValidarPtmos = new javax.swing.JButton();
        jtxtnumcta = new javax.swing.JTextField();
        jcbptmohip = new javax.swing.JCheckBox();
        jcbptmoper = new javax.swing.JCheckBox();
        jbttnsalir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setText("Nuevo Prestamo Hipotecario / Personal");

        jLabel2.setText("Nº de la Cuenta asociada: ");

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

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

        buttonGroup1.add(jcbptmohip);
        jcbptmohip.setText("Prestamo Hipotecario");
        jcbptmohip.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbptmohipActionPerformed(evt);
            }
        });

        buttonGroup1.add(jcbptmoper);
        jcbptmoper.setText("Prestamo Personal");

        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(160, 160, 160)
                .addComponent(jLabel1)
                .addContainerGap(165, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(223, 223, 223)
                .addComponent(jbttnValidarPtmos)
                .addGap(51, 51, 51)
                .addComponent(jbttnsalir)
                .addContainerGap(116, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(51, 51, 51)
                        .addComponent(jtxtNombreTitular, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(18, 18, 18)
                        .addComponent(jtxtnumcta, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)))
                .addGap(78, 78, 78))
            .addGroup(layout.createSequentialGroup()
                .addGap(91, 91, 91)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jcbptmoper)
                    .addComponent(jcbptmohip))
                .addContainerGap(294, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(31, 31, 31)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtxtnumcta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .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)
                .addComponent(jcbptmohip)
                .addGap(18, 18, 18)
                .addComponent(jcbptmoper)
                .addGap(16, 16, 16)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbttnValidarPtmos)
                    .addComponent(jbttnsalir))
                .addContainerGap(32, Short.MAX_VALUE))
        );

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

    private void jbttnValidarPtmosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbttnValidarPtmosActionPerformed
        // TODO add your handling code here:
        String ms="";
        if(!jtxtNombreTitular.getText().isEmpty()&&!jtxtnumcta.getText().isEmpty()){
        if(jcbptmohip.isSelected()){
            ms="PrestamoHipotecario";
            if(s.buscarCliente(dni)==null) s.altaCliente(dni, jtxtNombreTitular.getText());
            s.altaproducto(jtxtNombreTitular.getText(), dni, ms, jtxtnumcta.getText());
}
else if (jcbptmoper.isSelected()){
    ms="PrestamoPersonal";
    if(s.buscarCliente(dni)==null) s.altaCliente(dni, jtxtNombreTitular.getText());
         s.altaproducto(jtxtNombreTitular.getText(), dni, ms,jtxtnumcta.getText());
}
}

      
    }//GEN-LAST:event_jbttnValidarPtmosActionPerformed

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

    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 JFramePrestamoHipPersonal().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 jbttnValidarPtmos;
    private javax.swing.JButton jbttnsalir;
    private javax.swing.JCheckBox jcbptmohip;
    private javax.swing.JCheckBox jcbptmoper;
    private javax.swing.JTextField jtxtNombreTitular;
    private javax.swing.JTextField jtxtnumcta;
    // End of variables declaration//GEN-END:variables

}
