
package bbuvajava;

public class jfrmArqueo extends javax.swing.JFrame {
    private Sucursal auxsuc;
    private Empleado e;
    
    public jfrmArqueo(Sucursal aux) {
        auxsuc=aux;
        initComponents();
    }


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

        jLabel2 = new javax.swing.JLabel();
        jtxtdni = new javax.swing.JTextField();
        jtxtlogin = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jbrealizaridentificacion = new javax.swing.JButton();
        jtxtsaldo = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jbConfirmar = new javax.swing.JButton();
        jbParte = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();

        jLabel2.setText("dni");

        jtxtdni.setText("48944103");

        jtxtlogin.setText("12345");

        jLabel3.setText("login");

        jbrealizaridentificacion.setText("Identificarse");
        jbrealizaridentificacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbrealizaridentificacionActionPerformed(evt);
            }
        });

        jtxtsaldo.setEditable(false);

        jLabel4.setText("saldo en caja");

        jbConfirmar.setText("Confirmar");
        jbConfirmar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbConfirmarActionPerformed(evt);
            }
        });

        jbParte.setText("ParteDiferencia");
        jbParte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbParteActionPerformed(evt);
            }
        });

        jLabel5.setText("¡BUENOS DIAS!, Por favor, proceda a realizar el Arqueo de su caja");

        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(46, 46, 46)
                .addComponent(jLabel5)
                .addContainerGap(97, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(59, 59, 59)
                        .addComponent(jbConfirmar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jbParte))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(77, 77, 77)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(28, 28, 28)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jbrealizaridentificacion, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                                    .addComponent(jtxtsaldo, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(30, 30, 30)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jtxtdni, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
                                    .addComponent(jtxtlogin, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE))))))
                .addGap(213, 213, 213))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(jLabel5)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtdni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtlogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(18, 18, 18)
                .addComponent(jbrealizaridentificacion)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtsaldo, 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(jbParte)
                    .addComponent(jbConfirmar))
                .addGap(38, 38, 38))
        );

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

    private void jbrealizaridentificacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbrealizaridentificacionActionPerformed
        String dni=jtxtdni.getText();
        String login=jtxtlogin.getText();
        int aux=Integer.parseInt(login);
        e= new Empleado();
        e.Identificarse(dni,aux);
        if(auxsuc.getEmpleado(dni)==null||auxsuc.getEmpleado(dni).getLogin()!=aux)
            jtxtdni.setText("Este empleado no es correcto");
        else{
            if(auxsuc.getEmpleado(dni).getCaj().getArqueo().size()==0){
                String auxsaldo=String.valueOf(auxsuc.getEmpleado(dni).getCaj().getSaldo());
                jtxtsaldo.setText(auxsaldo);
                
            }

            else{
                String auxsaldoant=String.valueOf(auxsuc.getEmpleado(dni).getCaj().get_Arqueo().getSaldofin());
                jtxtsaldo.setText(auxsaldoant);
            }
 
        }
    }//GEN-LAST:event_jbrealizaridentificacionActionPerformed

    private void jbConfirmarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbConfirmarActionPerformed
        String dni=jtxtdni.getText();
        int log=Integer.parseInt(jtxtlogin.getText());
        
        if(auxsuc.getEmpleado(dni)!=null && auxsuc.getEmpleado(dni).getLogin()==log){
            
            auxsuc.getEmpleado(jtxtdni.getText()).getCaj().RealizarArqueo();
            jtxtlogin.setText("Arqueo realizado");
            jtxtdni.setText("Arqueo realizado");
            new jfrmPrincipal(auxsuc).setVisible(true);
            this.setVisible(false);
        }
        else
            jtxtdni.setText("Empleado identificado incorrectamente");
}//GEN-LAST:event_jbConfirmarActionPerformed

    private void jbParteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbParteActionPerformed
          auxsuc.getEmpleado(jtxtdni.getText()).getCaj().RealizarArqueo();
          new jfrmParteDiferencia(auxsuc).setVisible(true);
}//GEN-LAST:event_jbParteActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JButton jbConfirmar;
    private javax.swing.JButton jbParte;
    private javax.swing.JButton jbrealizaridentificacion;
    private javax.swing.JTextField jtxtdni;
    private javax.swing.JTextField jtxtlogin;
    private javax.swing.JTextField jtxtsaldo;
    // End of variables declaration//GEN-END:variables

}
