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

        LabelPrincipal = new javax.swing.JLabel();
        jbvercuentas = new javax.swing.JButton();
        Brealizar = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        TBtipo = new javax.swing.JTextField();
        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();

        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 :");

        jLabel5.setText("(CuentaCorriente,PrestamoHipotecario,PrestamoPersonal,LibretaAhorro)");

        jLabel2.setText("NOMBRE TITULAR :");

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

        jLabel6.setText("DNI :");

        jLabel1.setText("Euros");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(4, 4, 4))
                    .addComponent(jLabel6)
                    .addComponent(jLabel2))
                .addGap(44, 44, 44)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(TBtipo, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)
                    .addComponent(TBdni, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)
                    .addComponent(TBnombre, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE))
                .addGap(145, 145, 145))
            .addGroup(layout.createSequentialGroup()
                .addGap(96, 96, 96)
                .addComponent(Brealizar, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 92, Short.MAX_VALUE)
                .addComponent(jbvercuentas)
                .addGap(97, 97, 97))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addGap(39, 39, 39)
                .addComponent(TBsaldo, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel1)
                .addContainerGap(110, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(55, Short.MAX_VALUE)
                .addComponent(jLabel5)
                .addGap(49, 49, 49))
            .addGroup(layout.createSequentialGroup()
                .addGap(162, 162, 162)
                .addComponent(LabelPrincipal)
                .addContainerGap(172, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .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))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel5)
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(TBsaldo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Brealizar)
                    .addComponent(jbvercuentas))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {TBdni, TBtipo});

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

    private void jbvercuentasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbvercuentasActionPerformed
        auxsuc.VerCuentas();
}//GEN-LAST:event_jbvercuentasActionPerformed
 
    private void BrealizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BrealizarActionPerformed
        String nombre=TBnombre.getText();
        String saldo=TBsaldo.getText();
        String tipo=TBtipo.getText();
        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


    // 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.JTextField 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 jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JButton jbvercuentas;
    // End of variables declaration//GEN-END:variables

}
