com.gnadenheimer.mg.frames.admin.FrameConfigAdmin.java Source code

Java tutorial

Introduction

Here is the source code for com.gnadenheimer.mg.frames.admin.FrameConfigAdmin.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gnadenheimer.mg.frames.admin;

import com.gnadenheimer.mg.domain.TblAsientos;
import com.gnadenheimer.mg.domain.TblCuentasContablesPorDefecto;
import com.gnadenheimer.mg.domain.TblEventoDetalle;
import com.gnadenheimer.mg.domain.TblFacturas;
import com.gnadenheimer.mg.domain.TblTransferencias;
import com.gnadenheimer.mg.domain.miembros.TblEntidades;
import com.gnadenheimer.mg.utils.CurrentUser;
import com.gnadenheimer.mg.utils.Utils;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.prefs.Preferences;
import java.util.zip.ZipInputStream;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.Query;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.logging.log4j.LogManager;

/**
 *
 * @author Industria
 */
public class FrameConfigAdmin extends javax.swing.JInternalFrame implements PropertyChangeListener {

    private static final org.apache.logging.log4j.Logger LOGGER = LogManager.getLogger(FrameConfigAdmin.class);
    TaskUpdate taskUpdate;

    public FrameConfigAdmin() {
        super("Configuracion", true, //resizable
                true, //closable
                true, //maximizable
                true);//iconifiable
        try {
            initComponents();

            final File jarFile = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath());

            if (jarFile.isFile()) { // Run with JAR file
                final JarFile jar = new JarFile(jarFile);
                final Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
                while (entries.hasMoreElements()) {
                    final String name = entries.nextElement().getName();
                    if (name.startsWith("sql/")) { //filter according to the path
                        cboSqlFiles.addItem("/" + name);
                    }
                }
                jar.close();
            } else { // Run with IDE
                final URL url = getClass().getResource("/sql");
                if (url != null) {
                    try {
                        final File apps = new File(url.toURI());
                        for (File app : apps.listFiles()) {
                            cboSqlFiles.addItem("/sql/" + app.getName());
                        }
                    } catch (URISyntaxException ex) {
                        // never happens
                    }
                }
            }
            /*CurrentUser currentUser = CurrentUser.getInstance();
            if (currentUser.getUser().getId() == 9999) {
            cmdReset.setEnabled(true);
            jButton3.setEnabled(true);
            } else {
            cmdReset.setEnabled(false);
            jButton3.setEnabled(false);
            }*/

            /*
                       File[] files = (new File(getClass().getResource("/sql").toURI())).listFiles();
                       for (File f : files) {
            cboSqlFiles.addItem(f.getName());
                       }*/
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null,
                    Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage());
            LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        bgCobrarAC = new javax.swing.ButtonGroup();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        txtIP = new javax.swing.JTextField();
        rbServidor = new javax.swing.JRadioButton();
        rbRemoto = new javax.swing.JRadioButton();
        panelDatadir = new java.awt.Panel();
        txtDatadir = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        cmdDatadir = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        cboModoImpresion = new javax.swing.JComboBox();
        cmdReset = new javax.swing.JButton();
        cmdFacturaPrintTest = new javax.swing.JButton();
        cboSqlFiles = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        cboFormatoFactura = new javax.swing.JComboBox();
        jButton3 = new javax.swing.JButton();
        updateSETbutton = new javax.swing.JButton();
        lblStatusSET = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        rbCobrarACPorMes = new javax.swing.JRadioButton();
        rbCobrarACPorEvento = new javax.swing.JRadioButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jspAnoActivo = new javax.swing.JSpinner();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setEnabled(false);
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameActivated(evt);
            }

            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }

            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }

            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }

            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }

            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }

            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });

        jLabel2.setText("Direccion IP de Base de datos:");

        jButton1.setText("Cancelar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Guardar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        buttonGroup1.add(rbServidor);
        rbServidor.setText("Servidor");
        rbServidor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbServidorActionPerformed(evt);
            }
        });

        buttonGroup1.add(rbRemoto);
        rbRemoto.setSelected(true);
        rbRemoto.setText("Remoto");
        rbRemoto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbRemotoActionPerformed(evt);
            }
        });

        txtDatadir.setText("C:\\mgdb");

        jLabel3.setText("Carpeta de Base de datos:");

        cmdDatadir.setText("...");
        cmdDatadir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdDatadirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelDatadirLayout = new javax.swing.GroupLayout(panelDatadir);
        panelDatadir.setLayout(panelDatadirLayout);
        panelDatadirLayout.setHorizontalGroup(panelDatadirLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelDatadirLayout.createSequentialGroup().addContainerGap().addComponent(jLabel3)
                        .addGap(38, 38, 38)
                        .addComponent(txtDatadir, javax.swing.GroupLayout.DEFAULT_SIZE, 171, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cmdDatadir).addGap(17, 17, 17)));
        panelDatadirLayout.setVerticalGroup(panelDatadirLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelDatadirLayout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(panelDatadirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel3)
                                .addComponent(txtDatadir, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(cmdDatadir))
                        .addContainerGap()));

        jLabel4.setText("Impresion de Transferencias");

        cboModoImpresion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Normal", "Triplicado" }));

        cmdReset.setBackground(new java.awt.Color(255, 102, 102));
        cmdReset.setText("Actualizar Base");
        cmdReset.setEnabled(false);
        cmdReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdResetActionPerformed(evt);
            }
        });

        cmdFacturaPrintTest.setText("Impresion de Prueba");
        cmdFacturaPrintTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdFacturaPrintTestActionPerformed(evt);
            }
        });

        jLabel7.setText("Impresion de Facturas");

        cboFormatoFactura.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Preimpreso con rejilla",
                "Preimpreso sin rejilla", "Preimpreso sin rejilla - CREDITO",
                "Preimpreso con rejilla modelo especial Bethel Theodor", "Preimpreso sin rejilla Bethel" }));
        cboFormatoFactura.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboFormatoFacturaActionPerformed(evt);
            }
        });

        jButton3.setBackground(new java.awt.Color(255, 0, 153));
        jButton3.setText("Actualizar Asientos");
        jButton3.setEnabled(false);
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        updateSETbutton.setText("Actualizar Base de Datos SET");
        updateSETbutton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updateSETbuttonActionPerformed(evt);
            }
        });

        lblStatusSET.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

        jButton4.setText("Dividir Miembros por comma");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setBackground(new java.awt.Color(255, 0, 153));
        jButton5.setText("Corregir Asientos Pagos");
        jButton5.setEnabled(false);
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setBackground(new java.awt.Color(255, 0, 153));
        jButton6.setText("Informe de Pagos incoherentes");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jButton7.setBackground(new java.awt.Color(255, 0, 153));
        jButton7.setText("Informe de Facturas incoherentes");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        bgCobrarAC.add(rbCobrarACPorMes);
        rbCobrarACPorMes.setText("Por Mes");

        bgCobrarAC.add(rbCobrarACPorEvento);
        rbCobrarACPorEvento.setText("Por Evento");

        jLabel1.setText("Cobrar Aportes y Colectas:");

        jLabel21.setText("Ao fiscal activo:");

        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().addGap(0, 0, Short.MAX_VALUE).addComponent(jButton7))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(updateSETbutton).addComponent(jButton4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jButton3).addComponent(jButton6).addComponent(jButton5)
                                .addGroup(layout.createSequentialGroup().addComponent(jButton2)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jButton1)))
                        .addContainerGap())
                .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup().addComponent(jLabel2).addGap(18, 18, 18)
                                .addComponent(txtIP).addGap(275, 275, 275))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addGroup(layout.createSequentialGroup().addGap(154, 154, 154)
                                                .addComponent(cboFormatoFactura, 0, 1, Short.MAX_VALUE))
                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout
                                                .createSequentialGroup().addComponent(jLabel1)
                                                .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(rbCobrarACPorMes).addGap(18, 18, 18)
                                                .addComponent(rbCobrarACPorEvento).addGap(133, 133, 133)
                                                .addComponent(lblStatusSET, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                .addGap(181, 181, 181))
                        .addGroup(layout.createSequentialGroup().addGroup(layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(cmdFacturaPrintTest, javax.swing.GroupLayout.PREFERRED_SIZE, 239,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(panelDatadir, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(layout.createSequentialGroup().addComponent(rbServidor).addGap(18, 18, 18)
                                        .addComponent(rbRemoto))
                                .addGroup(layout.createSequentialGroup().addComponent(jLabel4).addGap(18, 18, 18)
                                        .addComponent(cboModoImpresion, javax.swing.GroupLayout.PREFERRED_SIZE, 177,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                        .addComponent(cboSqlFiles, javax.swing.GroupLayout.PREFERRED_SIZE, 146,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18).addComponent(cmdReset,
                                                javax.swing.GroupLayout.PREFERRED_SIZE, 131,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jLabel7))
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(
                                layout.createSequentialGroup().addComponent(jLabel21)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jspAnoActivo, javax.swing.GroupLayout.PREFERRED_SIZE, 70,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(0, 0, Short.MAX_VALUE)))));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel2).addComponent(txtIP, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(34, 34, 34)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(rbServidor).addComponent(rbRemoto))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(panelDatadir, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(29, 29, 29)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel4)
                                .addComponent(cboModoImpresion, 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(jLabel7).addComponent(cboFormatoFactura,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(71, 71, 71).addComponent(cmdFacturaPrintTest)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup().addGap(26, 26, 26).addComponent(
                                        lblStatusSET, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup().addGap(19, 19, 19).addGroup(layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(rbCobrarACPorMes).addComponent(rbCobrarACPorEvento))
                                        .addComponent(jLabel1))))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel21).addComponent(jspAnoActivo,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup().addGap(47, 47, 47)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jButton1).addComponent(jButton2))
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(layout.createSequentialGroup().addGap(3, 3, 3)
                                                        .addComponent(jButton4))
                                                .addGroup(layout.createSequentialGroup().addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                        .addComponent(jButton3)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(cmdReset, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(cboSqlFiles, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        23, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jButton5))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jButton6)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jButton7))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                        layout.createSequentialGroup()
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        185, Short.MAX_VALUE)
                                                .addComponent(updateSETbutton)))
                        .addGap(18, 18, 18)));

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

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        try {
            //            prefs.put("PrinterName", cboPrinter.getSelectedItem().toString());
            Preferences.userRoot().node("MG").put("DatabaseIP", txtIP.getText());
            Preferences.userRoot().node("MG").put("Datadir", txtDatadir.getText());
            Preferences.userRoot().node("MG").put("isServer", String.valueOf(rbServidor.isSelected()));
            Preferences.userRoot().node("MG").put("modoImpresion", cboModoImpresion.getSelectedItem().toString());
            Preferences.userRoot().node("MG").put("formatoFactura", cboFormatoFactura.getSelectedItem().toString());
            Preferences.userRoot().node("MG").put("cobrarAC", String.valueOf(rbCobrarACPorMes.isSelected()));
            Preferences.userRoot().node("MG").put("anoActivo", String.valueOf(jspAnoActivo.getValue()));

            this.setVisible(false);

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null,
                    Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage());
            LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
        }

    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        this.setVisible(false);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void formInternalFrameActivated(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameActivated
        txtIP.setText(Preferences.userRoot().node("MG").get("DatabaseIP", "127.0.0.1"));
        txtDatadir.setText(Preferences.userRoot().node("MG").get("Datadir", "C:\\javadb"));
        rbServidor.setSelected(Boolean.parseBoolean(Preferences.userRoot().node("MG").get("isServer", "true")));
        cboModoImpresion.setSelectedItem(Preferences.userRoot().node("MG").get("modoImpresion", "Normal"));
        cboFormatoFactura
                .setSelectedItem(Preferences.userRoot().node("MG").get("formatoFactura", "Preimpreso sin rejilla"));
        rbCobrarACPorMes
                .setSelected(Boolean.parseBoolean(Preferences.userRoot().node("MG").get("cobrarAC", "true")));
        jspAnoActivo.setValue(Integer.parseInt(
                Preferences.userRoot().node("MG").get("anoActivo", String.valueOf(LocalDate.now().getYear()))));
    }//GEN-LAST:event_formInternalFrameActivated

    private void cmdDatadirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdDatadirActionPerformed
        try {
            JFileChooser chooser = new JFileChooser();
            chooser.setCurrentDirectory(new java.io.File("."));
            chooser.setDialogTitle("Eligir ubicacin de la base de datos.");
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            chooser.setAcceptAllFileFilterUsed(false);

            if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
                txtDatadir.setText(chooser.getSelectedFile().getPath());
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null,
                    Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage());
            LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
        }
    }//GEN-LAST:event_cmdDatadirActionPerformed

    private void rbServidorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbServidorActionPerformed
        panelDatadir.setVisible(rbServidor.isSelected());
    }//GEN-LAST:event_rbServidorActionPerformed

    private void rbRemotoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbRemotoActionPerformed
        panelDatadir.setVisible(rbServidor.isSelected());
    }//GEN-LAST:event_rbRemotoActionPerformed

    private void cmdResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdResetActionPerformed
        try {

            Integer reply = JOptionPane.showConfirmDialog(null,
                    "Realmente desea borrar todos los datos y limpiar la base de datos?", title,
                    JOptionPane.YES_NO_OPTION);
            if (reply == JOptionPane.YES_OPTION) {
                Utils.getInstance().executeSQL(cboSqlFiles.getSelectedItem().toString());
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null,
                    Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage());
            LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
        }
    }//GEN-LAST:event_cmdResetActionPerformed

    private void cmdFacturaPrintTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdFacturaPrintTestActionPerformed
        try {
            TblFacturas testF = new TblFacturas();
            testF.setNro(1234567);
            testF.setFechahora(LocalDateTime.now());
            testF.setRazonSocial("Empresa SA");
            testF.setRuc("8888888-9");
            testF.setDomicilio("Loma Plata");
            testF.setCasillaDeCorreo(1158);
            testF.setIdUser(CurrentUser.getInstance().getUser());
            testF.setImporteAporte(10775520);
            testF.setImporteDonacion(25700000);

            Utils.getInstance().printFactura(testF);

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null,
                    Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage());
            LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
        }
    }//GEN-LAST:event_cmdFacturaPrintTestActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        try {
            CurrentUser currentUser = CurrentUser.getInstance();
            Map<String, String> persistenceMap = Utils.getInstance().getPersistenceMap();
            EntityManager entityManager = Persistence.createEntityManagerFactory("mg_PU", persistenceMap)
                    .createEntityManager();
            entityManager.getTransaction().begin();
            Query queryEventoDetalle = entityManager.createQuery("SELECT t FROM TblEventoDetalle t ORDER BY t.id");
            List<TblEventoDetalle> listEventoDetalle = org.jdesktop.observablecollections.ObservableCollections
                    .observableList(queryEventoDetalle.getResultList());
            TblCuentasContablesPorDefecto cuentasContablesPorDefecto = entityManager
                    .find(TblCuentasContablesPorDefecto.class, 1);
            for (TblEventoDetalle evd : listEventoDetalle) {
                if (evd.getTblAsientosList().size() == 2) {
                    Integer indexAsientoAporte = -1;
                    Integer indexAsientoDonacion = -1;
                    if (((List<TblAsientos>) evd.getTblAsientosList()).get(0).getIdCuentaContableHaber()
                            .equals(cuentasContablesPorDefecto.getIdCuentaAportes())) {
                        indexAsientoAporte = 0;
                        indexAsientoDonacion = 1;
                    } else if (((List<TblAsientos>) evd.getTblAsientosList()).get(1).getIdCuentaContableHaber()
                            .equals(cuentasContablesPorDefecto.getIdCuentaAportes())) {
                        indexAsientoAporte = 1;
                        indexAsientoDonacion = 0;
                    }
                    ((List<TblAsientos>) evd
                            .getTblAsientosList())
                                    .get(indexAsientoAporte)
                                    .setMonto(((Long) (evd.getMonto().longValue()
                                            * evd.getIdEvento().getPorcentajeAporte().longValue() / 100))
                                                    .intValue());
                    ((List<TblAsientos>) evd.getTblAsientosList()).get(indexAsientoDonacion).setMonto(evd.getMonto()
                            - ((List<TblAsientos>) evd.getTblAsientosList()).get(indexAsientoAporte).getMonto());
                    entityManager.merge(evd);
                } else if (evd.getTblAsientosList().isEmpty()) {

                    List<TblAsientos> ts = evd.getTblAsientosList();
                    if (ts == null) {
                        ts = new LinkedList<>();
                        evd.setTblAsientosList((List) ts);
                    }
                    TblAsientos asientoAporte = new TblAsientos();
                    asientoAporte.setFechahora(evd.getIdEvento().getFecha().atStartOfDay());
                    asientoAporte.setIdCentroDeCostoDebe(evd.getIdEvento().getIdCentroDeCosto());
                    asientoAporte.setIdCentroDeCostoHaber(evd.getIdEvento().getIdCentroDeCosto());
                    asientoAporte.setIdCuentaContableDebe(cuentasContablesPorDefecto.getIdCuentaACobrar());
                    asientoAporte.setIdCuentaContableHaber(cuentasContablesPorDefecto.getIdCuentaAportes());
                    asientoAporte.setMonto(((Long) (evd.getMonto().longValue()
                            * evd.getIdEvento().getPorcentajeAporte().longValue() / 100)).intValue());
                    asientoAporte.setIdUser(currentUser.getUser());

                    ts.add(asientoAporte);

                    TblAsientos asientoDonacion = new TblAsientos();
                    asientoDonacion.setFechahora(evd.getIdEvento().getFecha().atStartOfDay());
                    asientoDonacion.setIdCentroDeCostoDebe(evd.getIdEvento().getIdCentroDeCosto());
                    asientoDonacion.setIdCentroDeCostoHaber(evd.getIdEvento().getIdCentroDeCosto());
                    asientoDonacion.setIdCuentaContableDebe(cuentasContablesPorDefecto.getIdCuentaACobrar());
                    asientoDonacion.setIdCuentaContableHaber(cuentasContablesPorDefecto.getIdCuentaDonaciones());
                    asientoDonacion.setMonto(evd.getMonto() - asientoAporte.getMonto());
                    asientoDonacion.setIdUser(currentUser.getUser());

                    ts.add(asientoDonacion);

                    entityManager.merge(evd);
                }
            }
            /*
            List<TblTransferencias> listT = (List<TblTransferencias>) entityManager.createQuery("select t from TblTransferencias t").getResultList();
            for (TblTransferencias t : listT) {
            Query queryEvd = entityManager.createQuery("select e from TblEventoDetalle e where e.idEvento.idEventoTipo = :eventoTipo and EXTRACT(MONTH FROM e.idEvento.fecha) = :mes and EXTRACT(YEAR FROM e.idEvento.fecha) = :ano and e.idEntidad = :entidad");
            Calendar c = Calendar.getInstance();
            c.setTime(t.getFechahora());
            queryEvd.setParameter("mes", c.get(Calendar.MONTH) + 1);
            queryEvd.setParameter("ano", c.get(Calendar.YEAR));
            queryEvd.setParameter("entidad", t.getIdEntidad());
            queryEvd.setParameter("eventoTipo", t.getIdEventoTipo());
                
            List<TblEventoDetalle> listEvd = queryEvd.getResultList();
            List<TblAsientos> listAsientos = new ArrayList<>();
            for (TblEventoDetalle evd : listEvd) {
                listAsientos.addAll(evd.getTblAsientosList());
            }
            List<TblAsientosTemporales> listAsientosTemporales = t.getTblAsientosTemporalesList();
            if (listAsientosTemporales == null) {
                listAsientosTemporales = new LinkedList<>();
                t.setTblAsientosTemporalesList(listAsientosTemporales);
            }
            if (t.getTblAsientosTemporalesList().isEmpty()) {
                for (TblAsientos asiento : listAsientos) {
                    TblAsientosTemporales aT = new TblAsientosTemporales();
                    entityManager.persist(aT);
                    aT.setFacturado(false);
                    aT.setFechahora(t.getFechahora());
                    aT.setIdCentroDeCosto(asiento.getIdCentroDeCosto());
                    aT.setIdCuentaContableDebe(asiento.getIdCentroDeCosto().getIdCuentaContableCtaCtePorDefecto());
                    aT.setIdCuentaContableHaber(asiento.getIdCuentaContableDebe());
                    if (asiento.getIdCuentaContableHaber().equals(cuentasContablesPorDefecto.getIdCuentaAportes())) {
                        aT.setEsAporte(true);
                    } else {
                        aT.setEsAporte(false);
                    }
                    aT.setMonto(asiento.getMonto());
                    listAsientosTemporales.add(aT);
                }
                entityManager.merge(t);
            }
            }*/
            entityManager.getTransaction().commit();
            entityManager.getTransaction().begin();
            JOptionPane.showMessageDialog(null, "Actualizacion satisfactoria!");
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null,
                    Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage());
            LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void updateSETbuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateSETbuttonActionPerformed
        try {
            taskUpdate = new TaskUpdate();
            taskUpdate.addPropertyChangeListener(this);
            taskUpdate.execute();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null,
                    Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage());
            LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
        }
    }//GEN-LAST:event_updateSETbuttonActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        try {
            CurrentUser currentUser = CurrentUser.getInstance();
            Map<String, String> persistenceMap = Utils.getInstance().getPersistenceMap();
            EntityManager entityManager = Persistence.createEntityManagerFactory("mg_PU", persistenceMap)
                    .createEntityManager();
            entityManager.getTransaction().begin();

            List<TblEntidades> list = (List<TblEntidades>) entityManager.createQuery("select e from TblEntidades e")
                    .getResultList();

            for (TblEntidades e : list) {
                String nombreviejo = e.getNombres();
                if (nombreviejo.contains(",")) {
                    String[] parts = nombreviejo.split(",");
                    e.setNombres(parts[0].trim());
                    e.setApellidos(parts[1].trim());
                    entityManager.merge(e);
                }
            }

            entityManager.getTransaction().commit();
            entityManager.getTransaction().begin();
            JOptionPane.showMessageDialog(null, "Nombres actualizados!");
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null,
                    Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage());
            LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
        }
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        Map<String, String> persistenceMap = Utils.getInstance().getPersistenceMap();
        EntityManager entityManager = Persistence.createEntityManagerFactory("mg_PU", persistenceMap)
                .createEntityManager();
        entityManager.getTransaction().begin();
        int suma = 0;
        List<TblTransferencias> listT = (List<TblTransferencias>) entityManager
                .createQuery("select t from TblTransferencias t").getResultList();
        for (TblTransferencias t : listT) {
            Integer sumAtAporte = t.getTblAsientosTemporalesList().stream()
                    .filter(x -> x.getEsAporte().equals(true)).mapToInt(l -> l.getMonto()).sum();
            Integer sumAtDonacion = t.getTblAsientosTemporalesList().stream()
                    .filter(x -> x.getEsAporte().equals(false)).mapToInt(l -> l.getMonto()).sum();
            if (t.getMontoAporte() < sumAtAporte) {
                for (int i = 0; i < t.getTblAsientosTemporalesList().size(); i++) {
                    if (t.getTblAsientosTemporalesList().get(i).getEsAporte()) {
                        if (sumAtAporte - t.getTblAsientosTemporalesList().get(i).getMonto()
                                - t.getMontoAporte() == 0) {
                            System.out.println(t.getTblAsientosTemporalesList().get(i).getId());
                            suma += t.getTblAsientosTemporalesList().get(i).getMonto();
                            t.getTblAsientosTemporalesList().get(i).setMonto(0);
                            sumAtAporte = t.getTblAsientosTemporalesList().stream()
                                    .filter(x -> x.getEsAporte().equals(true)).mapToInt(l -> l.getMonto()).sum();
                            System.out.println(suma);
                            entityManager.merge(t);
                        }
                    }
                }
            }
            if (t.getMontoDonacion() < sumAtDonacion) {
                for (int i = 0; i < t.getTblAsientosTemporalesList().size(); i++) {
                    if (!t.getTblAsientosTemporalesList().get(i).getEsAporte()) {
                        if (sumAtDonacion - t.getTblAsientosTemporalesList().get(i).getMonto()
                                - t.getMontoDonacion() == 0) {
                            System.out.println(t.getTblAsientosTemporalesList().get(i).getId());
                            suma += t.getTblAsientosTemporalesList().get(i).getMonto();
                            t.getTblAsientosTemporalesList().get(i).setMonto(0);
                            sumAtDonacion = t.getTblAsientosTemporalesList().stream()
                                    .filter(x -> x.getEsAporte().equals(false)).mapToInt(l -> l.getMonto()).sum();
                            System.out.println(suma);
                            entityManager.merge(t);
                        }
                    }
                }
            }

        }
        for (TblTransferencias t : listT) {
            Integer sumAtAporte = t.getTblAsientosTemporalesList().stream()
                    .filter(x -> x.getEsAporte().equals(true)).mapToInt(l -> l.getMonto()).sum();
            Integer sumAtDonacion = t.getTblAsientosTemporalesList().stream()
                    .filter(x -> x.getEsAporte().equals(false)).mapToInt(l -> l.getMonto()).sum();
            if (t.getMontoAporte() < sumAtAporte) {
                int asientoValido = -1;
                for (int i = 0; i < t.getTblAsientosTemporalesList().size(); i++) {
                    if (t.getTblAsientosTemporalesList().get(i).getEsAporte()) {
                        if (t.getTblAsientosTemporalesList().get(i).getMonto().equals(t.getMontoAporte())) {
                            asientoValido = t.getTblAsientosTemporalesList().get(i).getId();
                            for (int ii = 0; ii < t.getTblAsientosTemporalesList().size(); ii++) {
                                if (t.getTblAsientosTemporalesList().get(ii).getEsAporte()
                                        && t.getTblAsientosTemporalesList().get(ii).getId() != asientoValido) {
                                    suma += t.getTblAsientosTemporalesList().get(ii).getMonto();
                                    t.getTblAsientosTemporalesList().get(ii).setMonto(0);
                                }
                            }
                            entityManager.merge(t);
                        }
                    }
                }
            }
            if (t.getMontoDonacion() < sumAtDonacion) {
                int asientoValido = -1;
                for (int i = 0; i < t.getTblAsientosTemporalesList().size(); i++) {
                    if (!t.getTblAsientosTemporalesList().get(i).getEsAporte()) {
                        if (t.getTblAsientosTemporalesList().get(i).getMonto().equals(t.getMontoDonacion())) {
                            asientoValido = t.getTblAsientosTemporalesList().get(i).getId();
                            for (int ii = 0; ii < t.getTblAsientosTemporalesList().size(); ii++) {
                                if (!t.getTblAsientosTemporalesList().get(ii).getEsAporte()
                                        && t.getTblAsientosTemporalesList().get(ii).getId() != asientoValido) {
                                    suma += t.getTblAsientosTemporalesList().get(ii).getMonto();
                                    t.getTblAsientosTemporalesList().get(ii).setMonto(0);
                                }
                            }
                            entityManager.merge(t);
                        }
                    }
                }
            }
        }
        entityManager.getTransaction().commit();
        entityManager.getTransaction().begin();
        JOptionPane.showMessageDialog(null, suma);
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        try {
            Map parameters = new HashMap();
            Utils.getInstance().showReport("lista_pagos_no_coherentes", parameters, false);
        } catch (Exception ex) {
            LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
            JOptionPane.showMessageDialog(null,
                    Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage());
        }
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        try {
            Map parameters = new HashMap();
            Utils.getInstance().showReport("lista_pagos_no_coherentes_facturas", parameters, false);
        } catch (Exception ex) {
            LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
            JOptionPane.showMessageDialog(null,
                    Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage());
        }
    }//GEN-LAST:event_jButton7ActionPerformed

    private void cboFormatoFacturaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboFormatoFacturaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cboFormatoFacturaActionPerformed

    public void propertyChange(PropertyChangeEvent evt) {
        if ("statusUpdate".equals(evt.getPropertyName())) {
            lblStatusSET.setText(taskUpdate.getStatus());
        }
    }

    class TaskUpdate extends SwingWorker<Void, Void> {

        @Override
        public Void doInBackground() {
            try {
                Map<String, String> persistenceMap = Utils.getInstance().getPersistenceMap();
                //EntityManager entityManager = Persistence.createEntityManagerFactory("mg_PU", persistenceMap).createEntityManager();
                //entityManager.getTransaction().begin();

                Connection conn = null;
                Statement stmt = null;
                Class.forName(persistenceMap.get("javax.persistence.jdbc.driver"));
                conn = DriverManager.getConnection(persistenceMap.get("javax.persistence.jdbc.url"),
                        persistenceMap.get("user"), persistenceMap.get("password"));
                stmt = conn.createStatement();
                stmt.executeUpdate("TRUNCATE TABLE MG.TBL_CONTRIBUYENTES");
                String temp = "";
                Integer count = 0;
                //entityManager.createQuery("delete from TblContribuyentes t").executeUpdate();
                for (Integer i = 0; i <= 9; i++) {
                    URL url = new URL(
                            "http://www.set.gov.py/rest/contents/download/collaboration/sites/PARAGUAY-SET/documents/informes-periodicos/ruc/ruc"
                                    + String.valueOf(i) + ".zip");
                    ZipInputStream zipStream = new ZipInputStream(url.openStream(), StandardCharsets.UTF_8);
                    zipStream.getNextEntry();

                    Scanner sc = new Scanner(zipStream, "UTF-8");

                    PreparedStatement prepStmt = conn
                            .prepareStatement("INSERT INTO MG.TBL_CONTRIBUYENTES VALUES (?, ?, ?)");
                    //StringJoiner joiner = new StringJoiner("");
                    int a = 0;
                    while (sc.hasNextLine() && a <= 50000) {
                        String[] ruc = sc.nextLine().split("\\|");
                        temp = ruc[0] + " - " + ruc[1] + " - " + ruc[2];

                        //System.out.println(ruc[1]);
                        //System.out.println(StringEscapeUtils.escapeJava(ruc[1]));
                        if (ruc[0].length() > 0 && ruc[1].length() > 0 && ruc[2].length() == 1) {
                            /*TblContribuyentes c = new TblContribuyentes();
                            c.setRucSinDv(ruc[0]);
                            c.setRazonSocial(StringEscapeUtils.escapeSql(ruc[1]));
                            c.setDv(ruc[2]);
                            entityManager.persist(c);*/
                            prepStmt.setString(1, ruc[0]);
                            prepStmt.setString(2, ruc[2]);
                            prepStmt.setString(3, StringEscapeUtils.escapeSql(ruc[1]));
                            prepStmt.addBatch();
                            a++;
                            //joiner.add("INSERT INTO MG.TBL_CONTRIBUYENTES VALUES ('" + ruc[0] + "','" + ruc[2] + "', '" + StringEscapeUtils.escapeSql(ruc[1]) + "');");
                            if (a == 50000) {
                                int[] numUpdates = prepStmt.executeBatch();
                                //stmt.executeUpdate(joiner.toString());
                                //joiner = new StringJoiner("");
                                a = 0;
                                setStatus("Guardando en base...");
                            }

                            setStatus("Descargando listado de RUC con terminacion " + String.valueOf(i)
                                    + " - Cantidad de contribuyentes procesada: " + String.format("%,d", count)
                                    + " de aprox. 850.000.");
                            count++;
                        } else {
                            setStatus(temp);
                        }

                    }
                    setStatus("Guardando en base...");
                    int[] numUpdates = prepStmt.executeBatch();
                    //
                    //setStatus(numUpdates.);
                    //setStatus("Procesando datos...");
                    //entityManager.getTransaction().commit();
                    //entityManager.getTransaction().begin();
                }
                if (stmt != null) {
                    conn.close();
                }
                setStatus("Lista de RUC actualizada...");
                return null;
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null,
                        Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage());
                LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
                return null;
            }
        }

        private String status;

        public final void setStatus(String set) {
            String oldStatus = status;
            status = set;
            firePropertyChange("statusUpdate", oldStatus, status);
        }

        public final String getStatus() {
            return status;
        }

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;

                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrameConfigAdmin.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrameConfigAdmin.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrameConfigAdmin.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrameConfigAdmin.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        }
        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrameConfigAdmin().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup bgCobrarAC;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JComboBox cboFormatoFactura;
    private javax.swing.JComboBox cboModoImpresion;
    private javax.swing.JComboBox cboSqlFiles;
    private javax.swing.JButton cmdDatadir;
    private javax.swing.JButton cmdFacturaPrintTest;
    private javax.swing.JButton cmdReset;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JSpinner jspAnoActivo;
    private javax.swing.JLabel lblStatusSET;
    private java.awt.Panel panelDatadir;
    private javax.swing.JRadioButton rbCobrarACPorEvento;
    private javax.swing.JRadioButton rbCobrarACPorMes;
    private javax.swing.JRadioButton rbRemoto;
    private javax.swing.JRadioButton rbServidor;
    private javax.swing.JTextField txtDatadir;
    private javax.swing.JTextField txtIP;
    private javax.swing.JButton updateSETbutton;
    // End of variables declaration//GEN-END:variables
}