

package src;

import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class jfrmRemesaCargos extends javax.swing.JFrame {
    Sucursal auxsuc;
   
    
    /** Creates new form jfrmRemesaCargos */
    public jfrmRemesaCargos(Sucursal suc) {
        auxsuc=suc;
        initComponents();
        jbtnValidar.setEnabled(false);
        setResizable(false); //ASI QUITAMOS QUE SE PUEDA MAXIMIZAR
        jtxaVerRemesa.setEnabled(false);
        
    }


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

        jLabel2 = new javax.swing.JLabel();
        jtxtPathFicheroRemesa = new javax.swing.JTextField();
        jbtnImportar = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtxaVerRemesa = new javax.swing.JTextArea();
        jbtnValidar = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel2.setText("Fichero a tratar:");

        jtxtPathFicheroRemesa.setText("C:\\remesa recibos conceptos.txt");
        jtxtPathFicheroRemesa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtPathFicheroRemesaActionPerformed(evt);
            }
        });

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

        jtxaVerRemesa.setColumns(20);
        jtxaVerRemesa.setRows(5);
        jScrollPane1.setViewportView(jtxaVerRemesa);

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

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/src/InterfazMINI.gif"))); // NOI18N

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel7.setForeground(new java.awt.Color(0, 0, 255));
        jLabel7.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()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel3))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(150, 150, 150)
                                .addComponent(jbtnImportar))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(150, 150, 150)
                                .addComponent(jbtnValidar))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 390, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(11, 11, 11)
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel7)
                                    .addComponent(jtxtPathFicheroRemesa, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                .addContainerGap(24, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addComponent(jLabel7)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtxtPathFicheroRemesa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnImportar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnValidar)
                .addGap(43, 43, 43))
        );

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

    private void jbtnImportarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnImportarActionPerformed
        String mensaje=auxsuc.verRemesa(jtxtPathFicheroRemesa.getText());
        if (mensaje==""){
          jbtnValidar.setEnabled(false);
          jtxaVerRemesa.setText("");
        }
        else{
        jtxaVerRemesa.setText(mensaje);

        jbtnValidar.setEnabled(true);
        }


    }//GEN-LAST:event_jbtnImportarActionPerformed

    private void jbtnValidarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnValidarActionPerformed
       try {
            auxsuc.incorporarRemesa(jtxtPathFicheroRemesa.getText());
        } catch (ParseException ex) {
            Logger.getLogger(jfrmRemesaCargos.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jbtnValidarActionPerformed

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbtnImportar;
    private javax.swing.JButton jbtnValidar;
    private javax.swing.JTextArea jtxaVerRemesa;
    private javax.swing.JTextField jtxtPathFicheroRemesa;
    // End of variables declaration//GEN-END:variables

}
