package bbuvajava;

public class jfrmCrearProducto extends javax.swing.JFrame {
    private Sucursal auxsuc;
    public jfrmCrearProducto(Sucursal suc) {
        auxsuc=new Sucursal();
        auxsuc=suc;
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        LabelPrincipal = new javax.swing.JLabel();
        jbvercuentas = new javax.swing.JButton();
        Brealizar = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        TBnombre = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        TBdni = new javax.swing.JTextField();
        TBsaldo = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        TBtipo = new javax.swing.JComboBox();

        LabelPrincipal.setFont(new java.awt.Font("Tahoma", 0, 14));
        LabelPrincipal.setForeground(new java.awt.Color(255, 0, 0));
        LabelPrincipal.setText("NUEVO PRODUCTO");

        jbvercuentas.setText("VerCuentas");
        jbvercuentas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbvercuentasActionPerformed(evt);
            }
        });

        Brealizar.setText("Realizar");
        Brealizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BrealizarActionPerformed(evt);
            }
        });

        jLabel3.setText("SALDO DE CUENTA :");

        jLabel2.setText("NOMBRE TITULAR :");

        jLabel4.setText("TIPO DE CUENTA :");

        jLabel6.setText("DNI :");

        jLabel1.setText("Euros");

        TBtipo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "CuentaCorriente", "PrestamoHipotecario", "PrestamoPersonal", "LibretaAhorro" }));

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jLabel1, org.jdesktop.beansbinding.ObjectProperty.create(), TBtipo, org.jdesktop.beansbinding.BeanProperty.create("selectedItem"), "Cuenta Corriente");
        bindingGroup.addBinding(binding);

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

        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()
                .addGap(98, 98, 98)
                .addComponent(Brealizar, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(55, 55, 55)
                .addComponent(jbvercuentas)
                .addContainerGap(62, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(162, 162, 162)
                .addComponent(LabelPrincipal)
                .addContainerGap(102, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel4)
                            .addGap(4, 4, 4))
                        .addComponent(jLabel6)
                        .addComponent(jLabel2))
                    .addComponent(jLabel3))
                .addGap(39, 39, 39)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(TBsaldo, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TBdni, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                    .addComponent(TBnombre, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                    .addComponent(TBtipo, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel1)
                .addGap(40, 40, 40))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(LabelPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(34, 34, 34)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TBnombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(34, 34, 34)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TBdni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addGap(33, 33, 33)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(TBtipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TBsaldo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel3))
                .addGap(32, 32, 32)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Brealizar)
                    .addComponent(jbvercuentas))
                .addGap(42, 42, 42))
        );

        bindingGroup.bind();

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

    private void BrealizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BrealizarActionPerformed
        String nombre=TBnombre.getText();
        String saldo=TBsaldo.getText();
        String tipo=(String) TBtipo.getSelectedItem();
        float auxsaldo=Float.parseFloat(saldo);
        String dni=TBdni.getText();
        if(auxsaldo>0){
            auxsuc.AltaProducto(auxsaldo,nombre,dni,tipo);
            TBsaldo.setText("cuenta creada tipo "+tipo);
            TBnombre.setText("Cuenta creada");

        } else System.out.println("Error de saldo");
}//GEN-LAST:event_BrealizarActionPerformed

    private void jbvercuentasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbvercuentasActionPerformed
        auxsuc.VerCuentas();
}//GEN-LAST:event_jbvercuentasActionPerformed

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Brealizar;
    private javax.swing.JLabel LabelPrincipal;
    private javax.swing.JTextField TBdni;
    private javax.swing.JTextField TBnombre;
    private javax.swing.JTextField TBsaldo;
    private javax.swing.JComboBox TBtipo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JButton jbvercuentas;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

}
