package vistas;

import bbuvajava.*;
import java.io.IOException;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class jfrmRemesas extends javax.swing.JFrame {
    private Sucursal auxsuc;
    public jfrmRemesas(Sucursal suc) {
        auxsuc=suc;
        initComponents();
    }

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

        Bvalidar = new javax.swing.JButton();
        Bimportar = new javax.swing.JButton();
        TBPath = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        Tarea = new javax.swing.JTextArea();
        Label2 = new java.awt.Label();
        LabelPrincipal = new javax.swing.JLabel();

        Bvalidar.setText("Validar");
        Bvalidar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BvalidarActionPerformed(evt);
            }
        });

        Bimportar.setText("Importar");
        Bimportar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BimportarActionPerformed(evt);
            }
        });

        TBPath.setText("D:/r.txt");

        Tarea.setColumns(20);
        Tarea.setEditable(false);
        Tarea.setRows(5);
        jScrollPane1.setViewportView(Tarea);

        Label2.setFont(new java.awt.Font("Dialog", 1, 12));
        Label2.setText("Fichero:");

        LabelPrincipal.setFont(new java.awt.Font("Tahoma", 0, 14));
        LabelPrincipal.setForeground(new java.awt.Color(255, 0, 0));
        LabelPrincipal.setText("TRATAMIENTO REMESA DE CARGOS");

        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(194, 194, 194)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(Bvalidar)
                    .addComponent(Bimportar))
                .addContainerGap(204, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(134, Short.MAX_VALUE)
                .addComponent(LabelPrincipal)
                .addGap(115, 115, 115))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 398, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(Label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(TBPath, javax.swing.GroupLayout.PREFERRED_SIZE, 364, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(40, 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(32, 32, 32)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(Label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TBPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addComponent(Bimportar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(Bvalidar)
                .addContainerGap())
        );

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

    private void BimportarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BimportarActionPerformed
        try {
            String mensaje = auxsuc.verRemesaCargos(TBPath.getText());
            Tarea.setText(mensaje);
        } catch (IOException ex) {
            Logger.getLogger(jfrmRemesas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_BimportarActionPerformed

    private void BvalidarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BvalidarActionPerformed
              try {
                    if(auxsuc.incorporarRemesaCargos(TBPath.getText())==true){
                        TBPath.setText("FICHERO DE REMESA VALIDADO");
                    }
                    else{
                        Tarea.setText("NO CUADRA EL TOTAL DEL FICHERO DE LA REMESA");
                    }
              } catch (ParseException ex) {
                Logger.getLogger(jfrmRemesas.class.getName()).log(Level.SEVERE, null, ex);
                }
}//GEN-LAST:event_BvalidarActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Bimportar;
    private javax.swing.JButton Bvalidar;
    private java.awt.Label Label2;
    private javax.swing.JLabel LabelPrincipal;
    private javax.swing.JTextField TBPath;
    private javax.swing.JTextArea Tarea;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables

}
