
package bbuvajava;

public class jfrmCajaCentral extends javax.swing.JFrame {
    Sucursal auxsuc;
    public jfrmCajaCentral(Sucursal s) {
        auxsuc=s;
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        TBcantidad = new javax.swing.JTextField();
        TBcc = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        Bingreso = new javax.swing.JButton();
        Breintegro = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        TBdni = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        TBcc1 = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();

        jLabel1.setText("CAJA CENTRAL");

        jLabel2.setText("Cantidad : ");

        jLabel3.setText("Saldo CC:");

        TBcc.setEditable(false);

        jLabel4.setText("€");

        jLabel5.setText("€");

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

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

        jLabel6.setText("Dni Empleado: ");

        TBdni.setText("48944103");

        jLabel7.setText("Saldo Caja");

        TBcc1.setEditable(false);

        jLabel8.setText("€");

        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()
                        .addGap(63, 63, 63)
                        .addComponent(Breintegro)
                        .addGap(36, 36, 36)
                        .addComponent(Bingreso))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(113, 113, 113)
                                .addComponent(jLabel1))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(29, 29, 29)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel7))
                                .addGap(38, 38, 38)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(TBcc1, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
                                    .addComponent(TBcc, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
                                    .addComponent(TBcantidad, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
                                    .addComponent(TBdni, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(59, 59, 59))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(TBdni, 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(jLabel2)
                    .addComponent(TBcantidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(TBcc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel7)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(TBcc1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel8)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Bingreso)
                    .addComponent(Breintegro))
                .addGap(21, 21, 21))
        );

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

    private void BingresoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BingresoActionPerformed
           String ax=TBdni.getText();
           String cantidad=TBcantidad.getText();
           Caja CC=new Caja();
           CC=auxsuc.getCaja(1);
           float c = Float.parseFloat(cantidad);
           if(c<=auxsuc.getEmpleado(ax).getCaj().getSaldo()){
           auxsuc.getEmpleado(ax).getCaj().setSaldo(auxsuc.getEmpleado(ax).getCaj().getSaldo()-c);
           auxsuc.getEmpleado(ax).getCaj().get_Arqueo().setSaldofin(auxsuc.getEmpleado(ax).getCaj().getSaldo());
           CC.setSaldo(CC.getSaldo()+c);
           float s=CC.getSaldo();
           String cad=String.valueOf(s);
           String cad2=String.valueOf(auxsuc.getEmpleado(ax).getCaj().getSaldo());
           TBcc.setText(cad);
           TBcc1.setText(cad2);
           }
           else{
               TBcc.setText("No hay esa cantidad en caja corriente");
               TBcc1.setText("indique otra cantidad");
           }
}//GEN-LAST:event_BingresoActionPerformed

    private void BreintegroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BreintegroActionPerformed
           String ax=TBdni.getText();
           String cantidad=TBcantidad.getText();
           float c = Float.parseFloat(cantidad);
           Caja CC=new Caja();
           CC=auxsuc.getCaja(1);
           if(c<=CC.getSaldo()){
           auxsuc.getEmpleado(ax).getCaj().setSaldo(auxsuc.getEmpleado(ax).getCaj().getSaldo()+c);
           auxsuc.getEmpleado(ax).getCaj().get_Arqueo().setSaldofin(auxsuc.getEmpleado(ax).getCaj().getSaldo());
           CC.setSaldo(CC.getSaldo()-c);
           float s=CC.getSaldo();
           String cad=String.valueOf(s);
           String cad2=String.valueOf(auxsuc.getEmpleado(ax).getCaj().getSaldo());
           TBcc.setText(cad);
           TBcc1.setText(cad2);
           }
    }//GEN-LAST:event_BreintegroActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Bingreso;
    private javax.swing.JButton Breintegro;
    private javax.swing.JTextField TBcantidad;
    private javax.swing.JTextField TBcc;
    private javax.swing.JTextField TBcc1;
    private javax.swing.JTextField TBdni;
    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.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    // End of variables declaration//GEN-END:variables

}
