package bbuvajava;

public class jfrmIngreso extends javax.swing.JFrame {
    Sucursal Auxsuc;
    public jfrmIngreso(Sucursal suc) {
        Auxsuc=suc;
        initComponents();
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Label7 = new javax.swing.JLabel();
        Label2 = new javax.swing.JLabel();
        Label4 = new javax.swing.JLabel();
        TBncuenta = new javax.swing.JTextField();
        TBcantidad = new javax.swing.JTextField();
        Label5 = new javax.swing.JLabel();
        Breintegro = new javax.swing.JButton();
        Baceptar = new javax.swing.JButton();
        Tsaldo = new javax.swing.JTextField();
        Label6 = new javax.swing.JLabel();
        Label8 = new javax.swing.JLabel();
        LabelPrincipal = new javax.swing.JLabel();

        Label7.setText("CANTIDAD:");

        Label2.setText("NUMERO DE CUENTA");

        Label4.setText("IMPORTE:");

        TBncuenta.setText("20984002161000015263");
        TBncuenta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TBncuentaActionPerformed(evt);
            }
        });

        Label5.setFont(new java.awt.Font("Tahoma", 0, 14));
        Label5.setText("€");

        Breintegro.setText("Reintegro");
        Breintegro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BreintegroActionPerformed(evt);
            }
        });

        Baceptar.setText("Ingreso");
        Baceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BaceptarActionPerformed(evt);
            }
        });

        Tsaldo.setEnabled(false);
        Tsaldo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TsaldoActionPerformed(evt);
            }
        });

        Label6.setFont(new java.awt.Font("Tahoma", 0, 14));
        Label6.setText("€");

        Label8.setText("SALDO TRAS OPBasica:");

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

        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()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(Breintegro)
                        .addGap(27, 27, 27)
                        .addComponent(Baceptar))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(Label2)
                            .addComponent(Label4)
                            .addComponent(Label8))
                        .addGap(58, 58, 58)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(TBncuenta)
                            .addComponent(Tsaldo)
                            .addComponent(TBcantidad, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE)
                            .addComponent(LabelPrincipal))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 109, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(Label5, javax.swing.GroupLayout.DEFAULT_SIZE, 10, Short.MAX_VALUE)
                        .addGap(20, 20, 20))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(Label6, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(LabelPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(39, 39, 39)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TBncuenta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Label2))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TBcantidad)
                    .addComponent(Label5)
                    .addComponent(Label4))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Tsaldo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Label6)
                    .addComponent(Label8))
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Baceptar)
                    .addComponent(Breintegro))
                .addContainerGap())
        );

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

    private void TBncuentaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TBncuentaActionPerformed
        
}//GEN-LAST:event_TBncuentaActionPerformed

    private void BaceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BaceptarActionPerformed
           String n=TBncuenta.getText();
           Producto P=Auxsuc.get_Producto(n);
           if(P!=null){
           String cantidad=TBcantidad.getText();
           float c = Float.parseFloat(cantidad);
           P.ingreso(c);
           float s=P.getSaldo();
           String cad=String.valueOf(s);
           Tsaldo.setText(cad);
           }
        else{
             TBcantidad.setText("");
             TBncuenta.setText("NUMERO DE CUENTA NO EXISTE");
             Tsaldo.setText("");
        }
        
    }//GEN-LAST:event_BaceptarActionPerformed

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

    private void BreintegroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BreintegroActionPerformed
           String n=TBncuenta.getText();
           Producto P=Auxsuc.get_Producto(n);
           if(P!=null){
           String cantidad=TBcantidad.getText();
           float c = Float.parseFloat(cantidad);
           P.reintegro(c);
           float s=P.getSaldo();
           String cad=String.valueOf(s);
           Tsaldo.setText(cad);
           }
        else{
             TBcantidad.setText("");
             TBncuenta.setText("NUMERO DE CUENTA NO EXISTE");
             Tsaldo.setText("");
        }

}//GEN-LAST:event_BreintegroActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Baceptar;
    private javax.swing.JButton Breintegro;
    private javax.swing.JLabel Label2;
    private javax.swing.JLabel Label4;
    private javax.swing.JLabel Label5;
    private javax.swing.JLabel Label6;
    private javax.swing.JLabel Label7;
    private javax.swing.JLabel Label8;
    private javax.swing.JLabel LabelPrincipal;
    private javax.swing.JTextField TBcantidad;
    private javax.swing.JTextField TBncuenta;
    private javax.swing.JTextField Tsaldo;
    // End of variables declaration//GEN-END:variables

}
