
package vistas;

import bbuvajava.*;

public class jfrmParteDiferencia extends javax.swing.JFrame {
    private Sucursal auxsuc;
    //private Arqueo a;
    private Empleado e;
    public jfrmParteDiferencia(Sucursal aux) {
        auxsuc=aux;
        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();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jbRealizar = new javax.swing.JButton();
        jtxtsaldonuevo = new javax.swing.JTextField();
        jbIdentificar2 = new javax.swing.JButton();
        jtxtsaldoantiguo = new javax.swing.JTextField();
        jtxtdnidirector = new javax.swing.JTextField();
        jtxtdniempleado = new javax.swing.JTextField();
        jtxtlogindirector = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jtxtdespedida = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("PARTE DIFERENCIA");

        jLabel2.setText("dni empleado");

        jLabel3.setText("dni director");

        jLabel4.setText("saldo de caja");

        jLabel5.setText("Nuevo saldo de caja");

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

        jbIdentificar2.setText("Identificar");
        jbIdentificar2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbIdentificar2ActionPerformed(evt);
            }
        });

        jtxtsaldoantiguo.setEditable(false);

        jtxtdnidirector.setText("48944102");

        jtxtdniempleado.setText("48944103");

        jtxtlogindirector.setText("12345");

        jLabel6.setText("login");

        jtxtdespedida.setEditable(false);

        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(191, 191, 191)
                .addComponent(jLabel1)
                .addContainerGap(204, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(371, Short.MAX_VALUE)
                .addComponent(jLabel6)
                .addGap(98, 98, 98))
            .addGroup(layout.createSequentialGroup()
                .addGap(119, 119, 119)
                .addComponent(jtxtdespedida, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(168, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jtxtdnidirector, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
                        .addComponent(jtxtsaldonuevo, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jtxtsaldoantiguo, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
                        .addComponent(jtxtdniempleado, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
                        .addComponent(jbIdentificar2, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
                        .addComponent(jbRealizar, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE))
                    .addGap(44, 44, 44)
                    .addComponent(jtxtlogindirector, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jLabel1)
                .addGap(58, 58, 58)
                .addComponent(jLabel6)
                .addGap(96, 96, 96)
                .addComponent(jtxtdespedida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(69, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(71, 71, 71)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(jtxtdniempleado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel3)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtxtdnidirector, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtxtlogindirector, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGap(9, 9, 9)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel4)
                        .addComponent(jtxtsaldoantiguo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jbIdentificar2)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel5)
                        .addComponent(jtxtsaldonuevo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(31, 31, 31)
                    .addComponent(jbRealizar)
                    .addContainerGap(40, Short.MAX_VALUE)))
        );

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

    private void jbRealizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbRealizarActionPerformed
        String saldonuevo=jtxtsaldonuevo.getText();
        float saldon=Float.parseFloat(saldonuevo);
        if(auxsuc.getEmpleado(jtxtdnidirector.getText())==null||auxsuc.getEmpleado(jtxtdnidirector.getText()).getDirector()==false)
            jtxtdnidirector.setText("Dni incorrecto");
        else{
            if(auxsuc.getEmpleado(jtxtdniempleado.getText()).getCaj().getArqueo().size()==0)
            {
            auxsuc.getActual().RealizarArqueo();
            auxsuc.getEmpleado(jtxtdniempleado.getText()).getCaj().get_Arqueo().ParteDiferencia(saldon);
            jtxtsaldonuevo.setText("Parte ralizado");
            new jfrmPrincipal(auxsuc).setVisible(true);
            this.setVisible(false);
            }
            else{
            auxsuc.getActual().RealizarArqueo();
            auxsuc.getEmpleado(jtxtdniempleado.getText()).getCaj().get_Arqueo().ParteDiferencia(saldon);
            jtxtsaldonuevo.setText("Parte ralizado");
            jtxtdespedida.setText("GRACIAS Y HASTA MAÑANA!!");
            jtxtsaldoantiguo.setText("Gracias hasta mañana!");
            }
        }

    }//GEN-LAST:event_jbRealizarActionPerformed

    private void jbIdentificar2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbIdentificar2ActionPerformed
        String dniempleado=jtxtdniempleado.getText();
        String dnidirector=jtxtdnidirector.getText();
        String logindirector=jtxtlogindirector.getText();
        int login=Integer.parseInt(logindirector);
        e=new Empleado();
        e.Identificarse(dnidirector, login);
        if(auxsuc.getEmpleado(dniempleado)==null)
            jtxtdniempleado.setText("Dni incorrecto");
        else if(auxsuc.getEmpleado(dnidirector)==null||auxsuc.getEmpleado(dnidirector).getDirector()==false)
            jtxtdnidirector.setText("Dni incorrecto");
        else{

            String auxsaldo=String.valueOf(auxsuc.getEmpleado(dniempleado).getCaj().getSaldo());
            jtxtsaldoantiguo.setText(auxsaldo);
        }
}//GEN-LAST:event_jbIdentificar2ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    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 jbIdentificar2;
    private javax.swing.JButton jbRealizar;
    private javax.swing.JTextField jtxtdespedida;
    private javax.swing.JTextField jtxtdnidirector;
    private javax.swing.JTextField jtxtdniempleado;
    private javax.swing.JTextField jtxtlogindirector;
    private javax.swing.JTextField jtxtsaldoantiguo;
    private javax.swing.JTextField jtxtsaldonuevo;
    // End of variables declaration//GEN-END:variables

}
