/*
 * 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 VerFichas;

import Calculos_automaticos.CalculosBD;
import Calculos_automaticos.Copiartabla;
import arql2020.ARQL2020;
import static arql2020.ARQL2020.WHERE;
import static arql2020.ARQL2020.capa_nivel;
import static arql2020.ARQL2020.cuadro;
import static arql2020.ARQL2020.episodio_estruct_planta;
import static arql2020.ARQL2020.estruct_arq;
import static arql2020.ARQL2020.localidad;
import static arql2020.ARQL2020.microsector;
import static arql2020.ARQL2020.nombre_estruct_planta;
import static arql2020.ARQL2020.piso_subcapa;
import static arql2020.ARQL2020.siglasitio;
import static arql2020.ARQL2020.sitio;
import static arql2020.ARQL2020.tipo_estruct_planta;
import static arql2020.ARQL2020.zona_ambiental;
import static arql2020.Internal_Formatizados.c32_txt_posicion_sust_adherida;
import clases.InteraccionesBD;
import clases.conexion;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;

/**
 *
 * @author chuen
 */
public class Fichas_generales extends javax.swing.JFrame {





    public Fichas_generales() {
        
        initComponents();
        tbl_general.setSelectionMode(1);

      
//        TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(jtable_pers.getModel());
//        jtable_pers.setRowSorter(sorter);
        

    }

    /**
     * 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() {

        jPopupMenu1 = new javax.swing.JPopupMenu();
        agregarcol = new javax.swing.JMenuItem();
        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtable_pers = new JTableRenderer2();
        scrolltbl = new javax.swing.JScrollPane();
        tbl_general = new JTableRenderer();
        jScrollPane3 = new javax.swing.JScrollPane();
        txt_ampliado = new javax.swing.JTextArea();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        txt_cantidad = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        btn_cargar_general = new javax.swing.JButton();
        btn_Cargar_Estandar = new javax.swing.JButton();
        btn_cargar_puntas = new javax.swing.JButton();
        btn_cargar_nucleos_1PLAT = new javax.swing.JButton();
        btn_cargar_nucleosNplat = new javax.swing.JButton();
        btn_dt_ct = new javax.swing.JButton();
        btn_dtst = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txt_muestra = new javax.swing.JTextField();
        chk_cargarmuestra = new javax.swing.JRadioButton();
        chk_cargarmp = new javax.swing.JRadioButton();
        jButton2 = new javax.swing.JButton();
        cbx_mp = new javax.swing.JComboBox<>();
        jLabel2 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        guardarcsv = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        menu_solosiglas = new javax.swing.JMenuItem();
        ocultarcn = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        menu_ocultar_proc = new javax.swing.JMenuItem();
        menu_ocultar_infogral = new javax.swing.JMenuItem();

        agregarcol.setText("Agregar columna");
        agregarcol.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                agregarcolActionPerformed(evt);
            }
        });
        jPopupMenu1.add(agregarcol);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Tablas de piezas guardadas");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jScrollPane1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jtable_pers.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jtable_pers.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jtable_pers.setRowHeight(20);
        jScrollPane2.setViewportView(jtable_pers);

        scrolltbl.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        scrolltbl.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                scrolltblMouseClicked(evt);
            }
        });

        tbl_general.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        tbl_general.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3"
            }
        ));
        tbl_general.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        tbl_general.setComponentPopupMenu(jPopupMenu1);
        tbl_general.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        tbl_general.setRowHeight(20);
        tbl_general.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbl_generalMouseClicked(evt);
            }
        });
        scrolltbl.setViewportView(tbl_general);
        tbl_general.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

        txt_ampliado.setColumns(20);
        txt_ampliado.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        txt_ampliado.setLineWrap(true);
        txt_ampliado.setRows(5);
        txt_ampliado.setWrapStyleWord(true);
        jScrollPane3.setViewportView(txt_ampliado);

        jButton4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton4.setText("Limpiar");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton5.setText("Abrir en nueva ventana");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton6.setText("Cruzar las primeras dos columnas");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        txt_cantidad.setEditable(false);
        txt_cantidad.setBackground(new java.awt.Color(0, 255, 255));
        txt_cantidad.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/copiar.png"))); // NOI18N
        jButton1.setToolTipText("Copiar tabla 1");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/copiar.png"))); // NOI18N
        jButton3.setToolTipText("copiar tabla personalizada");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Seleccione una ficha", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

        btn_cargar_general.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btn_cargar_general.setText("Generales");
        btn_cargar_general.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_cargar_generalActionPerformed(evt);
            }
        });

        btn_Cargar_Estandar.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btn_Cargar_Estandar.setText("Estándar");
        btn_Cargar_Estandar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_Cargar_EstandarActionPerformed(evt);
            }
        });

        btn_cargar_puntas.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btn_cargar_puntas.setText("Puntas de proy.");
        btn_cargar_puntas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_cargar_puntasActionPerformed(evt);
            }
        });

        btn_cargar_nucleos_1PLAT.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btn_cargar_nucleos_1PLAT.setText("Núcleos 1 plat");
        btn_cargar_nucleos_1PLAT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_cargar_nucleos_1PLATActionPerformed(evt);
            }
        });

        btn_cargar_nucleosNplat.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btn_cargar_nucleosNplat.setText("Núcleos N plat");
        btn_cargar_nucleosNplat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_cargar_nucleosNplatActionPerformed(evt);
            }
        });

        btn_dt_ct.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btn_dt_ct.setText("DT CT");
        btn_dt_ct.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_dt_ctActionPerformed(evt);
            }
        });

        btn_dtst.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btn_dtst.setText("DTST");
        btn_dtst.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_dtstActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btn_cargar_general, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_Cargar_Estandar, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_cargar_puntas)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_cargar_nucleos_1PLAT, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_cargar_nucleosNplat, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(58, 58, 58)
                .addComponent(btn_dt_ct)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_dtst)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btn_cargar_general)
                    .addComponent(btn_Cargar_Estandar)
                    .addComponent(btn_cargar_puntas)
                    .addComponent(btn_cargar_nucleos_1PLAT)
                    .addComponent(btn_dt_ct)
                    .addComponent(btn_dtst)
                    .addComponent(btn_cargar_nucleosNplat))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Criterio de búsqueda", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel1.setText("Muestra");

        txt_muestra.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        chk_cargarmuestra.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        chk_cargarmuestra.setText("Cargar muestra");

        chk_cargarmp.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        chk_cargarmp.setText("Cargar MP");

        jButton2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton2.setText("MP muestra");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        cbx_mp.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        cbx_mp.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Materias primas" }));

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel2.setText("MP");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txt_muestra, javax.swing.GroupLayout.PREFERRED_SIZE, 506, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(cbx_mp, javax.swing.GroupLayout.PREFERRED_SIZE, 371, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(chk_cargarmp)
                    .addComponent(chk_cargarmuestra))
                .addGap(85, 85, 85))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txt_muestra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(chk_cargarmuestra))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbx_mp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(chk_cargarmp)
                    .addComponent(jButton2))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(scrolltbl, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 886, Short.MAX_VALUE))
                        .addGap(0, 12, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(txt_cantidad)
                            .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 343, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jButton4)
                                .addGap(18, 18, 18)
                                .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                .addContainerGap(13, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txt_cantidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(scrolltbl, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 558, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton4)
                            .addComponent(jButton5))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton6)))
                .addContainerGap())
        );

        jScrollPane1.setViewportView(jPanel1);

        jMenu1.setText("Opciones");
        jMenu1.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N

        guardarcsv.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        guardarcsv.setText("Exportar tabla en *.csv");
        guardarcsv.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                guardarcsvActionPerformed(evt);
            }
        });
        jMenu1.add(guardarcsv);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Visualización");
        jMenu2.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jMenu2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu2ActionPerformed(evt);
            }
        });

        jMenuItem1.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N
        jMenuItem1.setText("Nota: seleccione en orden creciente");
        jMenu2.add(jMenuItem1);

        menu_solosiglas.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        menu_solosiglas.setText("1. Solo siglas");
        menu_solosiglas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_solosiglasActionPerformed(evt);
            }
        });
        jMenu2.add(menu_solosiglas);

        ocultarcn.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        ocultarcn.setText("2. Ocultar CN (no se borrarán de la base de datos)");
        ocultarcn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ocultarcnActionPerformed(evt);
            }
        });
        jMenu2.add(ocultarcn);
        jMenu2.add(jSeparator1);

        menu_ocultar_proc.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        menu_ocultar_proc.setText("3. Ocultar columnas de procedencia (no se borrarán de la base de datos)");
        menu_ocultar_proc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_ocultar_procActionPerformed(evt);
            }
        });
        jMenu2.add(menu_ocultar_proc);

        menu_ocultar_infogral.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        menu_ocultar_infogral.setText("4. Ocultar columnas de fichas generales (no se borrarán de la base de datos)");
        menu_ocultar_infogral.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_ocultar_infogralActionPerformed(evt);
            }
        });
        jMenu2.add(menu_ocultar_infogral);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane1)
                .addGap(0, 0, 0))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 653, Short.MAX_VALUE)
                .addGap(0, 0, 0))
        );

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

    private void btn_cargar_generalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_cargar_generalActionPerformed

JTableRenderer modelo_tabla_general  = new JTableRenderer();        
            modelo_tabla_general.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {

    },
    new String [] {
        "Cod.G ARQ.L", "ZONA AMBIENTAL", "LOCALIDAD", "SITIO", "SIGLA SITIO", "CAPA_NIV", "ESTRUC_ARQ", "PISO_SUBCAPA", "ESTRUC_PL", "NOMBRE_ESTRUC_PL", "EPISODIO_EST_PL", "CUADRO", "MICROSECTOR", "NUM FOTO", "NUM INV.MUSEO", "PIEZA", "MP", "ENT/FRAC", "SIMPLE/COMP", "CLASE ARTEF", "FORMA BASE", "N FAC. O EXTRAC.", "ORIGEN EXTRAC", "ALTERAC Y TRATAM TERMICO", "SUP-EST-TALON", "ANCHO TALON", "EJE-LASC", "EJE-MORF", "LONGIT.", "ANCHO", "ESPESOR", "PESO", "TAMAÑO", "MOD LONG/ANCHO", "MOD ANCHO/ESP", "CLASE TECNICA", "SUST.ADHERIDA", "POSIC.SUST.ADHER.", "CORTEZA", "PATINA", "VENTIFACCION", "OBSERV"
    }
));        
        
        
        
String muestra = "";
String MP = "";
        if(chk_cargarmuestra.isSelected()==true){
            if(WHERE.equals("")){
                JOptionPane.showMessageDialog(null, "No hay una muestra seleccionada. Se cargarán todos los datos guardados");
            }else{
            muestra = WHERE;
            }

        }
        
        if(chk_cargarmp.isSelected()==true){
            if((chk_cargarmuestra.isSelected()==true)&&(!WHERE.equals(""))){
            MP = " AND (f.MP='"+cbx_mp.getSelectedItem().toString()+"') ";
        }else{
            MP = " WHERE (f.MP='"+cbx_mp.getSelectedItem().toString()+"') ";
            }
        }
        
        CalculosBD calc = new CalculosBD();
        calc.LIMPIARTABLA(tbl_general);
        calc.LIMPIARTABLA(jtable_pers);
        

        DefaultTableModel dtm0 = (DefaultTableModel) modelo_tabla_general.getModel();
        tbl_general.removeAll();
        tbl_general.setModel(dtm0);
        DefaultTableModel dtm = (DefaultTableModel) tbl_general.getModel();
        
        

        Object [] fila = new Object[42];

        for (int i = 0; i < 42; i++) {
            fila[i]="";
        }
        
        
        java.sql.ResultSet rs=null;  
       
        try {
            conexion c = new conexion();
            c.getConexion();
            
             rs = c.consulta("SELECT * FROM FORMATIZADOS f " + muestra + MP);
             
             while(rs.next()){
                 fila[0]=(String.valueOf(rs.getInt("ID_FORMATIZADOS")));
                 
                 fila[1]=rs.getString("ZONA_AMBIENTAL");
                 fila[2]=rs.getString("LOCALIDAD");
                 fila[3]=rs.getString("SITIO");
                 fila[4]=rs.getString("SIGLA_SITIO");
                 fila[5]=rs.getString("CAPA_NIVEL");
                 fila[6]=rs.getString("ESTRUC_ARQ");
                 fila[7]=rs.getString("PISO_SUBCAPA");
                 fila[8]=rs.getString("ESTRUC_PLANTA");
                 fila[9]=rs.getString("NOMBRE_ESTRUC_PLANTA");
                 fila[10]=rs.getString("EPISODIO_ESTRUC_PLANTA");
                 fila[11]=rs.getString("CUADRO");
                 fila[12]=rs.getString("MICROSECTOR");
                 
                 fila[13]=(String.valueOf(rs.getString("FOTO")));
                 fila[14]=(String.valueOf(rs.getString("INVENTARIO")));
                 fila[15]=(String.valueOf(rs.getString("PIEZA")));
                 fila[16]=(rs.getString("MP"));
                 
                 fila[17]=(rs.getString("ENTERA_FRACTURADA"));
                 fila[18]=(rs.getString("SIMPLE_COMPUESTA"));
                 fila[19]=(rs.getString("CLASE_ARTEF"));

                 fila[20]=(rs.getString("FORMA_BASE"));
                 fila[21]=(rs.getString("NUM_FACETAS_EXTRAC"));
                 fila[22]=(rs.getString("ORIGEN_EXTRAC"));
                 fila[23]=(rs.getString("ALTERAC_TRATAM_TERM"));
                 fila[24]=(rs.getString("SUP_TALON"));
                 fila[25]=(rs.getString("ANCHO_TALON"));
                 boolean aux = false; 
                 if(rs.getString("EJE_LASCADO").equals("false")){
                     fila[26]="NO";
                 }else{
                     fila[26]="SI";
                 }
                 if(rs.getString("EJE_MORFOLOGICO").equals("false")){
                     fila[27]="NO";
                 }else{
                     fila[27]="SI";
                 }
                 fila[28]=(String.valueOf(rs.getString("LONGITUD")));
                 fila[29]=(String.valueOf(rs.getString("ANCHO")));
                 fila[30]=(String.valueOf(rs.getString("ESPESOR")));
                 fila[31]=(String.valueOf(rs.getString("PESO")));
                 fila[32]=(String.valueOf(rs.getString("TAMAÑO")));
                 fila[33]=(String.valueOf(rs.getString("MODULO_LONG_ANCHO")));
                 fila[34]=(String.valueOf(rs.getString("MODULO_ANCHO_ESPESOR")));
                 fila[35]=(rs.getString("CLASE_TECNICA"));
                 fila[36]=(rs.getString("SUSTANCIA_ADHERIDA"));
                 fila[37]=(String.valueOf(rs.getString("POSICION_SUST_ADHERIDA")));
                 fila[38]=(rs.getString("CORTEZA"));
                 fila[39]=(rs.getString("PATINA"));
                 fila[40]=(rs.getString("VENTIFACCION"));
                 fila[41]=(String.valueOf(rs.getString("OBSERVACIONES")));
                 
                dtm.addRow(fila);
        
                }
        
        c.closeconnection();
       } catch (SQLException ex) {
            Logger.getLogger(InteraccionesBD.class.getName()).log(Level.SEVERE, null, ex);
        }
cantidadfilas();
activarfiltro();
tbl_general.setColumnSelectionAllowed(false);
tbl_general.setRowSelectionAllowed(true);
bloquearmenu("a1,2,3");
    }//GEN-LAST:event_btn_cargar_generalActionPerformed
private void activarfiltro(){
//            TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tbl_general.getModel());
//        tbl_general.setRowSorter(sorter);
}
    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        txt_muestra.setText(ARQL2020.etiqueta_muestra);
        CalculosBD c = new CalculosBD();
        c.cargarmp(cbx_mp);
    }//GEN-LAST:event_formWindowOpened

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
          CalculosBD c = new CalculosBD();

        c.cargarmpformdistinct(cbx_mp, WHERE);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void menu_solosiglasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_solosiglasActionPerformed
        menu_solosiglas.setEnabled(false);
        DefaultTableModel dtm = (DefaultTableModel) tbl_general.getModel();
        for (int i = 0; i < dtm.getRowCount(); i++) {
            for (int j = 0; j < dtm.getColumnCount(); j++) {
                String valor = dtm.getValueAt(i, j).toString();
                String [] aux = valor.split("-");
                dtm.setValueAt(aux[0], i, j);
            }
            
        }

    }//GEN-LAST:event_menu_solosiglasActionPerformed

    private void ocultarcnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ocultarcnActionPerformed
   DefaultTableModel dtm = (DefaultTableModel) tbl_general.getModel();
Object val  =".";
        for (int i = 0; i < dtm.getRowCount(); i++) {
            for (int j = 0; j < dtm.getColumnCount(); j++) {
                String valor = dtm.getValueAt(i, j).toString();
                if(valor.equals("CN")){
                    dtm.setValueAt(val, i, j);
                }
                
            }
            
        }
        
        ocultarcn.setEnabled(false);
    }//GEN-LAST:event_ocultarcnActionPerformed

    private void agregarcolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_agregarcolActionPerformed
    DefaultTableModel dtm2 = (DefaultTableModel) jtable_pers.getModel();
    DefaultTableModel dtm1 = (DefaultTableModel) tbl_general.getModel();
    

      Object valor="";  
        int col = tbl_general.getSelectedColumn();
        int auxnuevacol=0;
        
        if(col>-1){
       Object header = tbl_general.getColumnName(col);
       dtm2.addColumn(header);
       auxnuevacol=dtm2.getColumnCount()-1;
       
           if(dtm1.getRowCount()==dtm2.getRowCount()){
        
    }else{
      Object[] fila= new Object[1];    
      fila[0]= "";
        for (int i = 0; i < dtm1.getRowCount(); i++) {
            dtm2.addRow(fila);
        }
    }
    
       
       
       for (int i = 0; i < tbl_general.getRowCount(); i++) {
           Object valorcelda = tbl_general.getValueAt(i, col);
            dtm2.setValueAt(valorcelda, i, auxnuevacol);
            
        }
    }
    }//GEN-LAST:event_agregarcolActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
DefaultTableModel dtm = new DefaultTableModel();
jtable_pers.setModel(dtm);
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
if(jtable_pers.getColumnCount()<2){
    JOptionPane.showMessageDialog(null, "Debe tener al menos dos columnas para analizar");
}else {
     CalculosBD c = new CalculosBD();
JTable tbl = new JTable();
    DefaultTableModel dtm2 = (DefaultTableModel) jtable_pers.getModel();
    tbl.setModel(dtm2);
    CalculoCruzado calcru = new CalculoCruzado();
    calcru.setVisible(true);
    c.TABLA_FRECUENCIAS_DOS_VALORES(jtable_pers.getColumnName(0), tbl, calcru.jTable2);
    }

    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
    CalculosBD c = new CalculosBD();
    JTable tbl = new JTable();
    DefaultTableModel dtm2 = (DefaultTableModel) jtable_pers.getModel();
    tbl.setModel(dtm2);
    CalculoCruzado calcru = new CalculoCruzado();
    calcru.setVisible(true);
    calcru.jTable2.setModel(dtm2);
    }//GEN-LAST:event_jButton5ActionPerformed
private void cantidadfilas(){
    DefaultTableModel dtm2 = (DefaultTableModel) tbl_general.getModel();
    int cant = dtm2.getRowCount();
    txt_cantidad.setText("Total de filas: "+ cant);
}
    private void btn_Cargar_EstandarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_Cargar_EstandarActionPerformed
JTableRenderer modelo_tabla_genseg  = new JTableRenderer();
            modelo_tabla_genseg.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {

    },
    new String [] {
        //generales 10
        "Cod.G ARQ.L", "ZONA AMBIENTAL", "LOCALIDAD", "SITIO", "SIGLA SITIO", "CAPA_NIV", "ESTRUC_ARQ", "PISO_SUBCAPA", "ESTRUC_PL", "NOMBRE_ESTRUC_PL",
        //10
        "EPISODIO_EST_PL", "CUADRO", "MICROSECTOR", "NUM FOTO", "NUM INV.MUSEO", "PIEZA", "MP", "ENT/FRAC", "SIMPLE/COMP", "CLASE ARTEF", 
        //10
        "FORMA BASE", "N FAC. O EXTRAC.", "ORIGEN EXTRAC", "ALTERAC Y TRATAM TERMICO", "SUP-EST-TALON", "ANCHO TALON", "EJE-LASC", "EJE-MORF", "LONGIT.", "ANCHO", 
        //12
        "ESPESOR", "PESO", "TAMAÑO", "MOD LONG/ANCHO", "MOD ANCHO/ESP", "CLASE TECNICA", "SUST.ADHERIDA", "POSIC.SUST.ADHER.", "CORTEZA", "PATINA", "VENTIFACCION", "OBSERV",
        

        //segmentales 10
        "Codigo Seg", "GRUPO", "SUBGRUPO", "FILO-PUNTA-SUP", "FAMILIA","LONG.", "PROF.", "ESP.", "PERIM.FILO", "RED.UNIF.BORDES RETALLA.", 
        //10
        "LS. INV LIM", "TALLA EXT.NO BIP", "RETALLA", "RETOQUE", "MICROR.", "PICADO", "ALISADO", "PULIDO", "ABRADIDO", "TALLA BIP", 
        //10
        "RETALLA BIP", "TALLA EXT+RET BIP", "TEC NO DIF", "TEC NO PERT", "FORMA LS SOBRE CARA", "FORMA GEOM.FILO/CONTORNO", "SECCION PUNTA/BISEL", "ANG MED", "ANG EST", "EST BISEL PAR SEG", 
        //9
        "PART.PASIV.CARACT", "PART.PASIV.VAR", "PART.ACT.POSIC", "PART.PAS.POSIC", "RECIC.", "GRUPO RECIC.", "MANTENIM", "CORTEZA", "OBSERV"
            
    }
));

      

        ///////
String muestra = "";
String MP = "";
        if(chk_cargarmuestra.isSelected()==true){
            if(WHERE.equals("")){
                JOptionPane.showMessageDialog(null, "No hay una muestra seleccionada. Se cargarán todos los datos guardados");
            }else{
            muestra = WHERE;
            }

        }
        
        if(chk_cargarmp.isSelected()==true){
            if((chk_cargarmuestra.isSelected()==true)&&(!WHERE.equals(""))){
            MP = " AND (f.MP='"+cbx_mp.getSelectedItem().toString()+"') ";
        }else{
            MP = " WHERE (f.MP='"+cbx_mp.getSelectedItem().toString()+"') ";
            }
        }
        
        CalculosBD calc = new CalculosBD();
        calc.LIMPIARTABLA(tbl_general);
        calc.LIMPIARTABLA(modelo_tabla_genseg);

        calc.LIMPIARTABLA(jtable_pers);
        

        DefaultTableModel dtm0 = (DefaultTableModel) modelo_tabla_genseg.getModel();
        tbl_general.removeAll();

        tbl_general.setModel(dtm0); 
        DefaultTableModel dtm = (DefaultTableModel) tbl_general.getModel();

       

        Object [] fila = new Object[81];

        for (int i = 0; i < 81; i++) {
            fila[i]="";
        }
        

 
        java.sql.ResultSet rs=null;  
       
        try {
            conexion c = new conexion();
            c.getConexion();
            
             rs = c.consulta("SELECT f.CORTEZA AS CORTEZA_A, "
                     + " f.LONGITUD AS LONGITUD_A,"
                     + " f.ANCHO AS ANCHO_A,"
                     + " f.ESPESOR AS ESPESOR_A,"
                     + " f.OBSERVACIONES AS OBSERVACIONES_A,"
                     + " s.LONGITUD AS LONGITUD_B, "
                     + " s.ESPESOR AS ESPESOR_B, "
                     + " s.CORTEZA AS CORTEZA_B, "
                     + " s.OBSERVACIONES AS OBSERVACIONES_B, "
                     + "f.*, s.* from FORMATIZADOS f INNER JOIN SEGMENTAL_ESTANDAR2 s \n" +
" ON f.ID_FORMATIZADOS = s.ID_FORMATIZADOS " + muestra + MP );
             
             
             while(rs.next()){
                 fila[0]=(String.valueOf(rs.getInt("ID_FORMATIZADOS")));
                 
                 fila[1]=rs.getString("ZONA_AMBIENTAL");
                 fila[2]=rs.getString("LOCALIDAD");
                 fila[3]=rs.getString("SITIO");
                 fila[4]=rs.getString("SIGLA_SITIO");
                 fila[5]=rs.getString("CAPA_NIVEL");
                 fila[6]=rs.getString("ESTRUC_ARQ");
                 fila[7]=rs.getString("PISO_SUBCAPA");
                 fila[8]=rs.getString("ESTRUC_PLANTA");
                 fila[9]=rs.getString("NOMBRE_ESTRUC_PLANTA");
                 fila[10]=rs.getString("EPISODIO_ESTRUC_PLANTA");
                 fila[11]=rs.getString("CUADRO");
                 fila[12]=rs.getString("MICROSECTOR");
                 
                 fila[13]=(String.valueOf(rs.getString("FOTO")));
                 fila[14]=(String.valueOf(rs.getString("INVENTARIO")));
                 fila[15]=(String.valueOf(rs.getString("PIEZA")));
                 fila[16]=(rs.getString("MP"));
                 
                 fila[17]=(rs.getString("ENTERA_FRACTURADA"));
                 fila[18]=(rs.getString("SIMPLE_COMPUESTA"));
                 fila[19]=(rs.getString("CLASE_ARTEF"));

                 fila[20]=(rs.getString("FORMA_BASE"));
                 fila[21]=(rs.getString("NUM_FACETAS_EXTRAC"));
                 fila[22]=(rs.getString("ORIGEN_EXTRAC"));
                 fila[23]=(rs.getString("ALTERAC_TRATAM_TERM"));
                 fila[24]=(rs.getString("SUP_TALON"));
                 fila[25]=(rs.getString("ANCHO_TALON"));
                 boolean aux = false; 
                 if(rs.getString("EJE_LASCADO").equals("false")){
                     fila[26]="NO";
                 }else{
                     fila[26]="SI";
                 }
                 if(rs.getString("EJE_MORFOLOGICO").equals("false")){
                     fila[27]="NO";
                 }else{
                     fila[27]="SI";
                 }
                 fila[28]=(String.valueOf(rs.getString("LONGITUD_A")));
                 fila[29]=(String.valueOf(rs.getString("ANCHO_A")));
                 fila[30]=(String.valueOf(rs.getString("ESPESOR_A")));
                 fila[31]=(String.valueOf(rs.getString("PESO")));
                 fila[32]=(String.valueOf(rs.getString("TAMAÑO")));
                 fila[33]=(String.valueOf(rs.getString("MODULO_LONG_ANCHO")));
                 fila[34]=(String.valueOf(rs.getString("MODULO_ANCHO_ESPESOR")));
                 fila[35]=(rs.getString("CLASE_TECNICA"));
                 fila[36]=(rs.getString("SUSTANCIA_ADHERIDA"));
                 fila[37]=(String.valueOf(rs.getString("POSICION_SUST_ADHERIDA")));
                 fila[38]=(rs.getString("CORTEZA_A"));
                 fila[39]=(rs.getString("PATINA"));
                 fila[40]=(rs.getString("VENTIFACCION"));
                 fila[41]=(String.valueOf(rs.getString("OBSERVACIONES_A")));
                 
                 fila[42]=(String.valueOf(rs.getInt("ID_ESTANDAR")));
                 fila[43]=(rs.getString("GRUPO"));
                 fila[44]=(rs.getString("SUBGRUPO"));
                 fila[45]=(rs.getString("FILO_PUNTA_SUP"));
                 fila[46]=(rs.getString("FAMILIA"));
                 fila[47]=(rs.getString("LONGITUD_B"));
                 fila[48]=(rs.getString("PROFUNDIDAD"));
                 fila[49]=(rs.getString("ESPESOR_B"));
                 fila[50]=(rs.getString("PERIMETRO_FILO"));
                 fila[51]=(rs.getString("REDUCCION_UNIFACIAL_RETALLA"));
                 fila[52]=(rs.getString("LASCADOS_INVERSOS"));
                 fila[53]=tecnicas_0_1(rs.getString("TALLA_EXT_NOBIP"));
                 fila[54]=tecnicas_0_1(rs.getString("RETALLA"));
                 fila[55]=tecnicas_0_1(rs.getString("RETOQUE"));
                 fila[56]=tecnicas_0_1(rs.getString("MICRORRETOQUE"));
                 fila[57]=tecnicas_0_1(rs.getString("PICADO"));
                 fila[58]=tecnicas_0_1(rs.getString("ALISADO"));
                 fila[59]=tecnicas_0_1(rs.getString("PULIDO"));
                 fila[60]=tecnicas_0_1(rs.getString("ABRASION"));
                 fila[61]=tecnicas_0_1(rs.getString("TALLA_BIPOLAR"));
                 fila[62]=tecnicas_0_1(rs.getString("RETALLA_BIPOLAR"));
                 fila[63]=tecnicas_0_1(rs.getString("TALLA_EXTRACCION"));
                 fila[64]=tecnicas_0_1(rs.getString("NO_DIFERENCIADO"));
                 fila[65]=tecnicas_0_1(rs.getString("TEC_NO_PER"));
                 fila[66]=(rs.getString("FORMA_LASCADOS_SOBRE_CARA"));
                 
                 fila[67]=(rs.getString("FORMA_GEOM_FILO_PUNTA"));
                 fila[68]=(rs.getString("SECCION_PUNTA"));
                 fila[69]=(rs.getString("ANGULO_MEDIDO"));
                 fila[70]=(rs.getString("ANGULO_ESTIMADO"));
                 fila[71]=(rs.getString("ESTADO_BISEL"));
                 fila[72]=(rs.getString("PARTE_PASIVA_CARACTER"));
                 fila[73]=(rs.getString("PARTE_PASIVA_VARIANTE"));
                 fila[74]=(rs.getString("PARTE_ACTIVA_POSICION"));
                 fila[75]=(rs.getString("PARTE_PASIVA_POSICION"));
                 fila[76]=(rs.getString("RECICLADO"));
                 fila[77]=(rs.getString("RECICLADO_GRUPO"));
                 fila[78]=(rs.getString("MANTENIMIENTO"));
                 fila[79]=(rs.getString("CORTEZA_B"));
                 fila[80]=(rs.getString("OBSERVACIONES_B"));

                dtm.addRow(fila);
        
                }
        
        c.closeconnection();
       } catch (SQLException ex) {
            Logger.getLogger(InteraccionesBD.class.getName()).log(Level.SEVERE, null, ex);
        }
cantidadfilas();
 bloquearmenu("a1,2,3,4");
//activarfiltro();
        
        
        
        
        
    }//GEN-LAST:event_btn_Cargar_EstandarActionPerformed
   private String tecnicas_0_1(String tecnica){
     String aux = "NS";

        
        if(tecnica.equals("true")){
            aux="Sí";
        }else{
            if(tecnica.equals("false")){
            aux="No";
        }
        }
        


        
        
        return aux;
    }
    private String tecnicas_0_1(){
     String aux = "CN";

        
        return aux;
    }
    private void btn_cargar_puntasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_cargar_puntasActionPerformed
    JTableRenderer modelo_tabla_genseg  = new JTableRenderer();
            modelo_tabla_genseg.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {

    },
    new String [] {
        //generales 10
        "Cod.G ARQ.L", "ZONA AMBIENTAL", "LOCALIDAD", "SITIO", "SIGLA SITIO", "CAPA_NIV", "ESTRUC_ARQ", "PISO_SUBCAPA", "ESTRUC_PL", "NOMBRE_ESTRUC_PL",
        //10
        "EPISODIO_EST_PL", "CUADRO", "MICROSECTOR", "NUM FOTO", "NUM INV.MUSEO", "PIEZA", "MP", "ENT/FRAC", "SIMPLE/COMP", "CLASE ARTEF", 
        //10
        "FORMA BASE", "N FAC. O EXTRAC.", "ORIGEN EXTRAC", "ALTERAC Y TRATAM TERMICO", "SUP-EST-TALON", "ANCHO TALON", "EJE-LASC", "EJE-MORF", "LONGIT.", "ANCHO", 
        //12
        "ESPESOR", "PESO", "TAMAÑO", "MOD LONG/ANCHO", "MOD ANCHO/ESP", "CLASE TECNICA", "SUST.ADHERIDA", "POSIC.SUST.ADHER.", "CORTEZA", "PATINA", "VENTIFACCION", "OBSERV",
        

        //segmentales 10
        "Codigo PP", "GRUPO", "SUBGRUPO", "FORMA_PUNTA", "FORMA_LIMBO","LIMBO_ANGULO_MEDIDO", "LIMBO_ANGULO_ESTIMADO", "LIMBOIZQ_ESTADO_BORDE", "LIMBOIZQ_FORMA_BORDE", "LIMBOIZQ_LONGITUD", 
        //10
        "LIMBOIZQ_PROF", "LIMBO_IZQ_FORMA_ARISTA", "LIMBODER_ESTADO_BORDE", "LIMBODER_FORMA_BORDE", "LIMBODER_LONGITUD", "LIMBODER_PROF", "LIMBO_DER_FORMA_ARISTA", "PEDUNCULO_ESTADO", "PEDUNCULO_LONG", "PEDUNCULO_TRATAM", 
        //10
        "PEDUNCULO_FORMA", "BASE_ESTADO", "BASE_ANCHO", "BASE_PROF", "BASE_FORMA", "BASE_TRATAM", "ALETAIZQ_ESTADO", "ALETAIZQ_ANCHO", "ALETAIZQ_ANG_MED", "ALETAIZQ_ANG_EST", 
        //10
        "ALETAIZQ_FORMA", "ALETADER_ESTADO", "ALETADER_ANCHO", "ALETADER_ANG_MED", "ALETADER_ANG_EST", "ALETADER_FORMA",         "TALLA_EXT_NO_BIP", "RETALLA", "RETOQUE","MICRORRETOQUE", 
        //6
        "PULIDO", "ABRASION", "NO_DIFERENCIADO", "MANTENIM.", "CORTEZA", "OBSERVACIONES"
            
    }
));

      

        ///////
String muestra = "";
String MP = "";
        if(chk_cargarmuestra.isSelected()==true){
            if(WHERE.equals("")){
                JOptionPane.showMessageDialog(null, "No hay una muestra seleccionada. Se cargarán todos los datos guardados");
            }else{
            muestra = WHERE;
            }

        }
        
        if(chk_cargarmp.isSelected()==true){
            if((chk_cargarmuestra.isSelected()==true)&&(!WHERE.equals(""))){
            MP = " AND (f.MP='"+cbx_mp.getSelectedItem().toString()+"') ";
        }else{
            MP = " WHERE (f.MP='"+cbx_mp.getSelectedItem().toString()+"') ";
            }
        }
        
        CalculosBD calc = new CalculosBD();
        calc.LIMPIARTABLA(tbl_general);
        calc.LIMPIARTABLA(modelo_tabla_genseg);

        calc.LIMPIARTABLA(jtable_pers);
        

        DefaultTableModel dtm0 = (DefaultTableModel) modelo_tabla_genseg.getModel();
        tbl_general.removeAll();

        tbl_general.setModel(dtm0); 
        DefaultTableModel dtm = (DefaultTableModel) tbl_general.getModel();

       

        Object [] fila = new Object[88];

        for (int i = 0; i < 88; i++) {
            fila[i]="";
        }
        

 
        java.sql.ResultSet rs=null;  
       
        try {
            conexion c = new conexion();
            c.getConexion();
            
             rs = c.consulta("SELECT f.CORTEZA AS CORTEZA_A, "
                     + " f.LONGITUD AS LONGITUD_A,"
                     + " f.ANCHO AS ANCHO_A,"
                     + " f.ESPESOR AS ESPESOR_A,"
                     + " f.OBSERVACIONES AS OBSERVACIONES_A,"
                    
                     + " s.CORTEZA AS CORTEZA_B, "
                     + " s.OBSERVACIONES AS OBSERVACIONES_B, "
                     + "f.*, s.* from FORMATIZADOS f INNER JOIN PUNTAS_DE_PROYECTIL2 s \n" +
" ON f.ID_FORMATIZADOS = s.ID_FORMATIZADOS " + muestra + MP );
             
             
             while(rs.next()){
                 fila[0]=(String.valueOf(rs.getInt("ID_FORMATIZADOS")));
                 
                 fila[1]=rs.getString("ZONA_AMBIENTAL");
                 fila[2]=rs.getString("LOCALIDAD");
                 fila[3]=rs.getString("SITIO");
                 fila[4]=rs.getString("SIGLA_SITIO");
                 fila[5]=rs.getString("CAPA_NIVEL");
                 fila[6]=rs.getString("ESTRUC_ARQ");
                 fila[7]=rs.getString("PISO_SUBCAPA");
                 fila[8]=rs.getString("ESTRUC_PLANTA");
                 fila[9]=rs.getString("NOMBRE_ESTRUC_PLANTA");
                 fila[10]=rs.getString("EPISODIO_ESTRUC_PLANTA");
                 fila[11]=rs.getString("CUADRO");
                 fila[12]=rs.getString("MICROSECTOR");
                 
                 fila[13]=(String.valueOf(rs.getString("FOTO")));
                 fila[14]=(String.valueOf(rs.getString("INVENTARIO")));
                 fila[15]=(String.valueOf(rs.getString("PIEZA")));
                 fila[16]=(rs.getString("MP"));
                 
                 fila[17]=(rs.getString("ENTERA_FRACTURADA"));
                 fila[18]=(rs.getString("SIMPLE_COMPUESTA"));
                 fila[19]=(rs.getString("CLASE_ARTEF"));

                 fila[20]=(rs.getString("FORMA_BASE"));
                 fila[21]=(rs.getString("NUM_FACETAS_EXTRAC"));
                 fila[22]=(rs.getString("ORIGEN_EXTRAC"));
                 fila[23]=(rs.getString("ALTERAC_TRATAM_TERM"));
                 fila[24]=(rs.getString("SUP_TALON"));
                 fila[25]=(rs.getString("ANCHO_TALON"));
                 boolean aux = false; 
                 if(rs.getString("EJE_LASCADO").equals("false")){
                     fila[26]="NO";
                 }else{
                     fila[26]="SI";
                 }
                 if(rs.getString("EJE_MORFOLOGICO").equals("false")){
                     fila[27]="NO";
                 }else{
                     fila[27]="SI";
                 }
                 fila[28]=(String.valueOf(rs.getString("LONGITUD_A")));
                 fila[29]=(String.valueOf(rs.getString("ANCHO_A")));
                 fila[30]=(String.valueOf(rs.getString("ESPESOR_A")));
                 fila[31]=(String.valueOf(rs.getString("PESO")));
                 fila[32]=(String.valueOf(rs.getString("TAMAÑO")));
                 fila[33]=(String.valueOf(rs.getString("MODULO_LONG_ANCHO")));
                 fila[34]=(String.valueOf(rs.getString("MODULO_ANCHO_ESPESOR")));
                 fila[35]=(rs.getString("CLASE_TECNICA"));
                 fila[36]=(rs.getString("SUSTANCIA_ADHERIDA"));
                 fila[37]=(String.valueOf(rs.getString("POSICION_SUST_ADHERIDA")));
                 fila[38]=(rs.getString("CORTEZA_A"));
                 fila[39]=(rs.getString("PATINA"));
                 fila[40]=(rs.getString("VENTIFACCION"));
                 fila[41]=(String.valueOf(rs.getString("OBSERVACIONES_A")));
                 
                 
                 
                 fila[42]=(String.valueOf(rs.getInt("ID_PUNTAS")));
                 fila[43]=(rs.getString("GRUPO"));
                 fila[44]=(rs.getString("SUBGRUPO"));
                 fila[45]=(rs.getString("FORMA_PUNTA"));
                 fila[46]=(rs.getString("FORMA_LIMBO"));
                 
                 fila[47]=(rs.getString("LIMBO_ANGULO_MEDIDO"));
                 fila[48]=(rs.getString("LIMBO_ANGULO_ESTIMADO"));
                 
                 
                 fila[49]=(rs.getString("LIMBOIZQ_ESTADO_BORDE"));
                 fila[50]=(rs.getString("LIMBOIZQ_FORMA_BORDE"));
                 fila[51]=(rs.getString("LIMBOIZQ_LONGITUD"));
                 fila[52]=(rs.getString("LIMBOIZQ_PROF"));
                 fila[53]=(rs.getString("LIMBOIZQ_FORMA_ARISTA"));
                 
                 fila[54]=(rs.getString("LIMBODER_ESTADO_BORDE"));
                 fila[55]=(rs.getString("LIMBODER_FORMA_BORDE"));
                 fila[56]=(rs.getString("LIMBODER_LONGITUD"));
                 fila[57]=(rs.getString("LIMBODER_PROF"));
                 fila[58]=(rs.getString("LIMBODER_FORMA_ARISTA"));
                 
                 
                 fila[59]=(rs.getString("PEDUNCULO_ESTADO"));
                 fila[60]=(rs.getString("PEDUNCULO_LONGITUD"));
                 fila[61]=(rs.getString("PEDUNCULO_TRATAMIENTO"));
                 fila[62]=(rs.getString("PEDUNCULO_FORMA"));
                 
                 fila[63]=(rs.getString("BASE_ESTADO"));
                 fila[64]=(rs.getString("BASE_ANCHO"));
                 fila[65]=(rs.getString("BASE_PROF"));
                 fila[66]=(rs.getString("BASE_FORMA"));
                 fila[67]=(rs.getString("BASE_TRATAM"));
                 
                 fila[68]=(rs.getString("ALETAIZQ_ESTADO"));
                 fila[69]=(rs.getString("ALETAIZQ_ANCHO"));
                 fila[70]=(rs.getString("ALETAIZQ_ANGULO_MEDIDO"));
                 fila[71]=(rs.getString("ALETAIZQ_ANGULO_ESTIMADO"));
                 fila[72]=(rs.getString("ALETAIZQ_FORMA"));
                 
                 fila[73]=(rs.getString("ALETADER_ESTADO"));
                 fila[74]=(rs.getString("ALETADER_ANCHO"));
                 fila[75]=(rs.getString("ALETADER_ANGULO_MEDIDO"));
                 fila[76]=(rs.getString("ALETADER_ANGULO_ESTIMADO"));
                 fila[77]=(rs.getString("ALETADER_FORMA"));
                 
                 
                 fila[78]=tecnicas_0_1(rs.getString("TALLA_EXT_NOBIP"));
                 fila[79]=tecnicas_0_1(rs.getString("RETALLA"));
                 fila[80]=tecnicas_0_1(rs.getString("RETOQUE"));
                 fila[81]=tecnicas_0_1(rs.getString("MICRORRETOQUE"));
                 fila[82]=tecnicas_0_1(rs.getString("PULIDO"));
                 fila[83]=tecnicas_0_1(rs.getString("ABRASION"));
                 fila[84]=tecnicas_0_1(rs.getString("NO_DIFERENCIADO"));
                 fila[85]=(rs.getString("MANTENIMIENTO"));
                 fila[86]=(rs.getString("CORTEZA_B"));
                 fila[87]=(rs.getString("OBSERVACIONES_B"));

                dtm.addRow(fila);
        
                }
        
        c.closeconnection();
       } catch (SQLException ex) {
            Logger.getLogger(InteraccionesBD.class.getName()).log(Level.SEVERE, null, ex);
        }
cantidadfilas();
 bloquearmenu("a1,2,3,4");

    }//GEN-LAST:event_btn_cargar_puntasActionPerformed

    private void btn_cargar_nucleos_1PLATActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_cargar_nucleos_1PLATActionPerformed
JOptionPane.showMessageDialog(null, "Se cargarán solo las plataformas de Nu. con el N° 1 (N° de plataforma)");
        
        JTableRenderer modelo_tabla_nu  = new JTableRenderer();
            modelo_tabla_nu.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {

    },
    new String [] {
        //generales 10
        "Cod.G ARQ.L", "ZONA AMBIENTAL", "LOCALIDAD", "SITIO", "SIGLA SITIO", "CAPA_NIV", "ESTRUC_ARQ", "PISO_SUBCAPA", "ESTRUC_PL", "NOMBRE_ESTRUC_PL",
        //10
        "EPISODIO_EST_PL", "CUADRO", "MICROSECTOR", "NUM FOTO", "NUM INV.MUSEO", "PIEZA", "MP", "ENT/FRAC", "SIMPLE/COMP", "CLASE ARTEF", 
        //10
        "FORMA BASE", "N FAC. O EXTRAC.", "ORIGEN EXTRAC", "ALTERAC Y TRATAM TERMICO", "SUP-EST-TALON", "ANCHO TALON", "EJE-LASC", "EJE-MORF", "LONGIT.", "ANCHO", 
        //12
        "ESPESOR", "PESO", "TAMAÑO", "MOD LONG/ANCHO", "MOD ANCHO/ESP", "CLASE TECNICA", "SUST.ADHERIDA", "POSIC.SUST.ADHER.", "CORTEZA", "PATINA", "VENTIFACCION", "OBSERV",
        

        //NU 3
        "Codigo Nu", "GRUPO", "SUBGRUPO", "N_PLAT"
    }
));

      

        ///////
String muestra = "";
String MP = "";
        if(chk_cargarmuestra.isSelected()==true){
            if(WHERE.equals("")){
                JOptionPane.showMessageDialog(null, "No hay una muestra seleccionada. Se cargarán todos los datos guardados");
            }else{
            muestra = WHERE;
            }

        }
        
        if(chk_cargarmp.isSelected()==true){
            if((chk_cargarmuestra.isSelected()==true)&&(!WHERE.equals(""))){
            MP = " AND (f.MP='"+cbx_mp.getSelectedItem().toString()+"') ";
        }else{
            MP = " WHERE (f.MP='"+cbx_mp.getSelectedItem().toString()+"') ";
            }
        }
        
        CalculosBD calc = new CalculosBD();
        calc.LIMPIARTABLA(tbl_general);
        calc.LIMPIARTABLA(modelo_tabla_nu);

        calc.LIMPIARTABLA(jtable_pers);
        

        DefaultTableModel dtm0 = (DefaultTableModel) modelo_tabla_nu.getModel();
        tbl_general.removeAll();

        tbl_general.setModel(dtm0); 
        DefaultTableModel dtm = (DefaultTableModel) tbl_general.getModel();

       

        Object [] fila = new Object[46];

        for (int i = 0; i < 46; i++) {
            fila[i]="";
        }
        
       
               
 
        java.sql.ResultSet rs=null;  
       
        try {
            conexion c = new conexion();
            c.getConexion();
            
             rs = c.consulta("SELECT  DISTINCT (f.ID_FORMATIZADOS), f.*, s.*  from FORMATIZADOS f INNER JOIN NUCLEOS s \n" +
" ON f.ID_FORMATIZADOS = s.ID_FORMATIZADOS " + muestra + MP + " AND (N_PLAT='1') ");
             
             
             while(rs.next()){
                 fila[0]=(String.valueOf(rs.getInt("ID_FORMATIZADOS")));
                 
                 fila[1]=rs.getString("ZONA_AMBIENTAL");
                 fila[2]=rs.getString("LOCALIDAD");
                 fila[3]=rs.getString("SITIO");
                 fila[4]=rs.getString("SIGLA_SITIO");
                 fila[5]=rs.getString("CAPA_NIVEL");
                 fila[6]=rs.getString("ESTRUC_ARQ");
                 fila[7]=rs.getString("PISO_SUBCAPA");
                 fila[8]=rs.getString("ESTRUC_PLANTA");
                 fila[9]=rs.getString("NOMBRE_ESTRUC_PLANTA");
                 fila[10]=rs.getString("EPISODIO_ESTRUC_PLANTA");
                 fila[11]=rs.getString("CUADRO");
                 fila[12]=rs.getString("MICROSECTOR");
                 
                 fila[13]=(String.valueOf(rs.getString("FOTO")));
                 fila[14]=(String.valueOf(rs.getString("INVENTARIO")));
                 fila[15]=(String.valueOf(rs.getString("PIEZA")));
                 fila[16]=(rs.getString("MP"));
                 
                 fila[17]=(rs.getString("ENTERA_FRACTURADA"));
                 fila[18]=(rs.getString("SIMPLE_COMPUESTA"));
                 fila[19]=(rs.getString("CLASE_ARTEF"));

                 fila[20]=(rs.getString("FORMA_BASE"));
                 fila[21]=(rs.getString("NUM_FACETAS_EXTRAC"));
                 fila[22]=(rs.getString("ORIGEN_EXTRAC"));
                 fila[23]=(rs.getString("ALTERAC_TRATAM_TERM"));
                 fila[24]=(rs.getString("SUP_TALON"));
                 fila[25]=(rs.getString("ANCHO_TALON"));
                 boolean aux = false; 
                 if(rs.getString("EJE_LASCADO").equals("false")){
                     fila[26]="NO";
                 }else{
                     fila[26]="SI";
                 }
                 if(rs.getString("EJE_MORFOLOGICO").equals("false")){
                     fila[27]="NO";
                 }else{
                     fila[27]="SI";
                 }
                 fila[28]=(String.valueOf(rs.getString("LONGITUD")));
                 fila[29]=(String.valueOf(rs.getString("ANCHO")));
                 fila[30]=(String.valueOf(rs.getString("ESPESOR")));
                 fila[31]=(String.valueOf(rs.getString("PESO")));
                 fila[32]=(String.valueOf(rs.getString("TAMAÑO")));
                 fila[33]=(String.valueOf(rs.getString("MODULO_LONG_ANCHO")));
                 fila[34]=(String.valueOf(rs.getString("MODULO_ANCHO_ESPESOR")));
                 fila[35]=(rs.getString("CLASE_TECNICA"));
                 fila[36]=(rs.getString("SUSTANCIA_ADHERIDA"));
                 fila[37]=(String.valueOf(rs.getString("POSICION_SUST_ADHERIDA")));
                 fila[38]=(rs.getString("CORTEZA"));
                 fila[39]=(rs.getString("PATINA"));
                 fila[40]=(rs.getString("VENTIFACCION"));
                 fila[41]=(String.valueOf(rs.getString("OBSERVACIONES")));
//                 
                 fila[42]=(String.valueOf(rs.getInt("ID_NUCLEOS")));
                 fila[43]=(rs.getString("GRUPO"));
                 fila[44]=(rs.getString("SUBGRUPO"));
                 fila[45]=(rs.getString("N_PLAT"));
                 


//
                dtm.addRow(fila);
//        
                }
//        
        c.closeconnection();
       } catch (SQLException ex) {
            Logger.getLogger(InteraccionesBD.class.getName()).log(Level.SEVERE, null, ex);
        }
cantidadfilas();
 
 bloquearmenu("a1,2,3,4");
    }//GEN-LAST:event_btn_cargar_nucleos_1PLATActionPerformed

    private void btn_dt_ctActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_dt_ctActionPerformed

JTableRenderer modelo_tabla_general  = new JTableRenderer();        
            modelo_tabla_general.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {

    },
    new String [] {
        //13
        "Cod.DTCT", "ZONA AMBIENTAL", "LOCALIDAD", "SITIO", "SIGLA SITIO", "CAPA_NIV", "ESTRUC_ARQ", "PISO_SUBCAPA", "ESTRUC_PL", "NOMBRE_ESTRUC_PL", 
        "EPISODIO_EST_PL", "CUADRO", "MICROSECTOR", 
        //10
        "LOTE", "PIEZA", "MP", "ENT/FRAC", "LARGO", "ANCHO", "ESPESOR_MAX", "ESP_TALON", "ANCHO_TALON", "RANGO_ANCHO_TALON", 
        
        //10
        "PESO", "TAMAÑO",  "MOD_LONG_ANCHO", "MOD_ANCHO_ESP", "FORMA SUP TALON", "N_FACETAS_LASC", 
        "N_INTERV_FAC_LASC", "FORMA_BASE", "ORIGEN_EXT", "CORTEZA_CARA_DORSAL", 
      //2
        "CORTEZA TALON", "OBSERV" 
    }
));        
        
        
        
String muestra = "";
String MP = "";
        if(chk_cargarmuestra.isSelected()==true){
            if(WHERE.equals("")){
                JOptionPane.showMessageDialog(null, "No hay una muestra seleccionada. Se cargarán todos los datos guardados");
            }else{
            muestra = WHERE;
            }

        }
        
        if(chk_cargarmp.isSelected()==true){
            if((chk_cargarmuestra.isSelected()==true)&&(!WHERE.equals(""))){
            MP = " AND (f.MP='"+cbx_mp.getSelectedItem().toString()+"') ";
        }else{
            MP = " WHERE (f.MP='"+cbx_mp.getSelectedItem().toString()+"') ";
            }
        }
        
        CalculosBD calc = new CalculosBD();
        calc.LIMPIARTABLA(tbl_general);
        calc.LIMPIARTABLA(jtable_pers);
        

        DefaultTableModel dtm0 = (DefaultTableModel) modelo_tabla_general.getModel();
        tbl_general.removeAll();
        tbl_general.setModel(dtm0);
        DefaultTableModel dtm = (DefaultTableModel) tbl_general.getModel();
        
        

        Object [] fila = new Object[35];

        for (int i = 0; i < 35; i++) {
            fila[i]="";
        }
        
        
        java.sql.ResultSet rs=null;  
       
        try {
            conexion c = new conexion();
            c.getConexion();
            
             rs = c.consulta("SELECT * FROM DT_CONTALON2 f " + muestra + MP);
             
             while(rs.next()){
                 fila[0]=(String.valueOf(rs.getInt("ID_DT_CONTALON")));
                 
                 fila[1]=rs.getString("ZONA_AMBIENTAL");
                 fila[2]=rs.getString("LOCALIDAD");
                 fila[3]=rs.getString("SITIO");
                 fila[4]=rs.getString("SIGLA_SITIO");
                 fila[5]=rs.getString("CAPA_NIVEL");
                 fila[6]=rs.getString("ESTRUC_ARQ");
                 fila[7]=rs.getString("PISO_SUBCAPA");
                 fila[8]=rs.getString("ESTRUC_PLANTA");
                 fila[9]=rs.getString("NOMBRE_ESTRUC_PLANTA");
                 fila[10]=rs.getString("EPISODIO_ESTRUC_PLANTA");
                 fila[11]=rs.getString("CUADRO");
                 fila[12]=rs.getString("MICROSECTOR");
                 
                
                 fila[13]=(String.valueOf(rs.getString("LOTE")));
                 fila[14]=(String.valueOf(rs.getString("PIEZA")));
                 fila[16]=(rs.getString("MP"));
                 
                 fila[16]=(rs.getString("ENTERO_FRACTURADO"));
                 fila[17]=(rs.getString("LARGO"));
                 fila[18]=(rs.getString("ANCHO"));

                 fila[19]=(rs.getString("ESPESOR_MAX"));
                 fila[20]=(rs.getString("ESPESOR_TALON"));
                 fila[21]=(rs.getString("ANCHO_TALON"));
                 fila[22]=(rs.getString("RANGO_ANCHO_TALON"));
                 fila[23]=(rs.getString("PESO"));
                 fila[24]=(rs.getString("TAMAÑO"));
                
                 fila[25]=(String.valueOf(rs.getString("MODULO_LONG_ANCHO")));
                 fila[26]=(String.valueOf(rs.getString("MODULO_ANCHO_ESPESOR")));
                 fila[27]=(String.valueOf(rs.getString("FORMA_SUP_TALON")));
                 fila[28]=(String.valueOf(rs.getString("N_FACETAS_LASCADO")));
                 fila[29]=(String.valueOf(rs.getString("N_INTERVALO_FACETAS_LASCADO")));
                 fila[30]=(String.valueOf(rs.getString("FORMA_BASE")));
                 fila[31]=(String.valueOf(rs.getString("ORIGEN_EXTRACCION")));
                 fila[32]=(rs.getString("CORTEZA_CARA_DORSAL"));
                 fila[33]=(rs.getString("CORTEZA_TALON"));
                 fila[34]=(String.valueOf(rs.getString("OBSERVACIONES")));

                 
                dtm.addRow(fila);
        
                }
        
        c.closeconnection();
       } catch (SQLException ex) {
            Logger.getLogger(InteraccionesBD.class.getName()).log(Level.SEVERE, null, ex);
        }
cantidadfilas();
activarfiltro();
tbl_general.setColumnSelectionAllowed(false);
tbl_general.setRowSelectionAllowed(true);
 bloquearmenu("a1,2,3");
    }//GEN-LAST:event_btn_dt_ctActionPerformed

    private void btn_dtstActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_dtstActionPerformed

JTableRenderer modelo_tabla_general  = new JTableRenderer();        
            modelo_tabla_general.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {

    },
    new String [] {
        //13
        "Cod.DTCT", "ZONA AMBIENTAL", "LOCALIDAD", "SITIO", "SIGLA SITIO", "CAPA_NIV", "ESTRUC_ARQ", "PISO_SUBCAPA", "ESTRUC_PL", "NOMBRE_ESTRUC_PL", 
        "EPISODIO_EST_PL", "CUADRO", "MICROSECTOR", 
        //10
        "LOTE", "MP", "N", "PESO", 
      //2
        "CORTEZA", "OBSERV" 
    }
));        
        
        
        
String muestra = "";
String MP = "";
        if(chk_cargarmuestra.isSelected()==true){
            if(WHERE.equals("")){
                JOptionPane.showMessageDialog(null, "No hay una muestra seleccionada. Se cargarán todos los datos guardados");
            }else{
            muestra = WHERE;
            }

        }
        
        if(chk_cargarmp.isSelected()==true){
            if((chk_cargarmuestra.isSelected()==true)&&(!WHERE.equals(""))){
            MP = " AND (f.MP='"+cbx_mp.getSelectedItem().toString()+"') ";
        }else{
            MP = " WHERE (f.MP='"+cbx_mp.getSelectedItem().toString()+"') ";
            }
        }
        
        CalculosBD calc = new CalculosBD();
        calc.LIMPIARTABLA(tbl_general);
        calc.LIMPIARTABLA(jtable_pers);
        

        DefaultTableModel dtm0 = (DefaultTableModel) modelo_tabla_general.getModel();
        tbl_general.removeAll();
        tbl_general.setModel(dtm0);
        DefaultTableModel dtm = (DefaultTableModel) tbl_general.getModel();
        
        

        Object [] fila = new Object[19];

        for (int i = 0; i < 19; i++) {
            fila[i]="";
        }
        
        
        java.sql.ResultSet rs=null;  
       
        try {
            conexion c = new conexion();
            c.getConexion();
            
             rs = c.consulta("SELECT * FROM DT_SINTALON2 f " + muestra + MP);
             
             while(rs.next()){
                 fila[0]=(String.valueOf(rs.getInt("ID_DT_SINTALON")));
                 
                 fila[1]=rs.getString("ZONA_AMBIENTAL");
                 fila[2]=rs.getString("LOCALIDAD");
                 fila[3]=rs.getString("SITIO");
                 fila[4]=rs.getString("SIGLA_SITIO");
                 fila[5]=rs.getString("CAPA_NIVEL");
                 fila[6]=rs.getString("ESTRUC_ARQ");
                 fila[7]=rs.getString("PISO_SUBCAPA");
                 fila[8]=rs.getString("ESTRUC_PLANTA");
                 fila[9]=rs.getString("NOMBRE_ESTRUC_PLANTA");
                 fila[10]=rs.getString("EPISODIO_ESTRUC_PLANTA");
                 fila[11]=rs.getString("CUADRO");
                 fila[12]=rs.getString("MICROSECTOR");
                 
                
                 fila[13]=(String.valueOf(rs.getString("LOTE")));
                 fila[14]=(rs.getString("MP"));
                 
                 fila[15]=(rs.getString("N"));
                 fila[16]=(rs.getString("PESO"));
                 fila[17]=(rs.getString("CORTEZA"));
                 fila[18]=(String.valueOf(rs.getString("OBSERVACIONES")));

                 
                dtm.addRow(fila);
        
                }
        
        c.closeconnection();
       } catch (SQLException ex) {
            Logger.getLogger(InteraccionesBD.class.getName()).log(Level.SEVERE, null, ex);
        }
cantidadfilas();
activarfiltro();
tbl_general.setColumnSelectionAllowed(false);
tbl_general.setRowSelectionAllowed(true);
 bloquearmenu("a1,2,3");

    }//GEN-LAST:event_btn_dtstActionPerformed

    private void scrolltblMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_scrolltblMouseClicked
   
    }//GEN-LAST:event_scrolltblMouseClicked

    private void tbl_generalMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbl_generalMouseClicked
int filaselec = tbl_general.getSelectedRow();
int colselec = tbl_general.getSelectedColumn();
if((filaselec>-1)&&(colselec>-1)){
    String valorcol = tbl_general.getValueAt(filaselec, colselec).toString();
    String columna = (tbl_general.getColumnName(colselec).toString()).toUpperCase();
    txt_ampliado.setText(columna+": "+valorcol);
}
        
    }//GEN-LAST:event_tbl_generalMouseClicked

    private void btn_cargar_nucleosNplatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_cargar_nucleosNplatActionPerformed
JOptionPane.showMessageDialog(null, "Se cargarán todas las plataformas de Nu.");
        
        JTableRenderer modelo_tabla_nu  = new JTableRenderer();
            modelo_tabla_nu.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {

    },
    new String [] {
        //generales 10
        "Cod.G ARQ.L", "ZONA AMBIENTAL", "LOCALIDAD", "SITIO", "SIGLA SITIO", "CAPA_NIV", "ESTRUC_ARQ", "PISO_SUBCAPA", "ESTRUC_PL", "NOMBRE_ESTRUC_PL",
        //10
        "EPISODIO_EST_PL", "CUADRO", "MICROSECTOR", "NUM FOTO", "NUM INV.MUSEO", "PIEZA", "MP", "ENT/FRAC", "SIMPLE/COMP", "CLASE ARTEF", 
        //10
        "FORMA BASE", "N FAC. O EXTRAC.", "ORIGEN EXTRAC", "ALTERAC Y TRATAM TERMICO", "SUP-EST-TALON", "ANCHO TALON", "EJE-LASC", "EJE-MORF", "LONGIT.", "ANCHO", 
        //12
        "ESPESOR", "PESO", "TAMAÑO", "MOD LONG/ANCHO", "MOD ANCHO/ESP", "CLASE TECNICA", "SUST.ADHERIDA", "POSIC.SUST.ADHER.", "CORTEZA", "PATINA", "VENTIFACCION", "OBSERV",
        

        //NU 11
        "Codigo Nu", "GRUPO", "SUBGRUPO", "ANG. PLAT", "N. PLAT", "PLAT ANCHO", "PLAT ESPESOR", "PLAT FORMA_SUP", "ESTADO FRENTE EXT", "ESTADO BORDE EXT", "LS. MAY. ANCHO TALON",
        //10
        "LS.MAY.LARGO", "LS. MAY.ANCHO LASC", "LS.MAY.TAMAÑO", "LS.MAY. MOD.", "LS.MEN.LARGO", "LS.MEN.ANCHO", "LS.MEN.TAMAÑO", "LS.MEN.MOD", "PATINA", "VENTIFACCION",
        //3
        "ACTIVACION_PLAT", "CORTEZA", "OBSERV."
    }
));

      

        ///////
String muestra = "";
String MP = "";
        if(chk_cargarmuestra.isSelected()==true){
            if(WHERE.equals("")){
                JOptionPane.showMessageDialog(null, "No hay una muestra seleccionada. Se cargarán todos los datos guardados");
            }else{
            muestra = WHERE;
            }

        }
        
        if(chk_cargarmp.isSelected()==true){
            if((chk_cargarmuestra.isSelected()==true)&&(!WHERE.equals(""))){
            MP = " AND (f.MP='"+cbx_mp.getSelectedItem().toString()+"') ";
        }else{
            MP = " WHERE (f.MP='"+cbx_mp.getSelectedItem().toString()+"') ";
            }
        }
        
        CalculosBD calc = new CalculosBD();
        calc.LIMPIARTABLA(tbl_general);
        calc.LIMPIARTABLA(modelo_tabla_nu);

        calc.LIMPIARTABLA(jtable_pers);
        

        DefaultTableModel dtm0 = (DefaultTableModel) modelo_tabla_nu.getModel();
        tbl_general.removeAll();

        tbl_general.setModel(dtm0); 
        DefaultTableModel dtm = (DefaultTableModel) tbl_general.getModel();

       

        Object [] fila = new Object[66];

        for (int i = 0; i < 66; i++) {
            fila[i]="";
        }
        
       
               
 
        java.sql.ResultSet rs=null;  
       
        try {
            conexion c = new conexion();
            c.getConexion();
            
             rs = c.consulta("SELECT f.CORTEZA AS CORTEZA_A, "
                     + " f.LONGITUD AS LONGITUD_A,"
                     + " f.ANCHO AS ANCHO_A,"
                     + " f.ESPESOR AS ESPESOR_A,"
                     + " f.OBSERVACIONES AS OBSERVACIONES_A,"
                     
                     
                     + " s.PATINA AS PATINA_B, "
                     + " s.VENTIFACCION AS VENTIFACCION_B, "
                     + " s.CORTEZA AS CORTEZA_B, "
                     + " s.OBSERVACIONES AS OBSERVACIONES_B, "
                     + "f.*, s.* from FORMATIZADOS f INNER JOIN NUCLEOS s \n" +
" ON f.ID_FORMATIZADOS = s.ID_FORMATIZADOS " + muestra + MP + " ORDER BY f.ID_FORMATIZADOS " );
             
             
             while(rs.next()){
                 fila[0]=(String.valueOf(rs.getInt("ID_FORMATIZADOS")));
                 
                 fila[1]=rs.getString("ZONA_AMBIENTAL");
                 fila[2]=rs.getString("LOCALIDAD");
                 fila[3]=rs.getString("SITIO");
                 fila[4]=rs.getString("SIGLA_SITIO");
                 fila[5]=rs.getString("CAPA_NIVEL");
                 fila[6]=rs.getString("ESTRUC_ARQ");
                 fila[7]=rs.getString("PISO_SUBCAPA");
                 fila[8]=rs.getString("ESTRUC_PLANTA");
                 fila[9]=rs.getString("NOMBRE_ESTRUC_PLANTA");
                 fila[10]=rs.getString("EPISODIO_ESTRUC_PLANTA");
                 fila[11]=rs.getString("CUADRO");
                 fila[12]=rs.getString("MICROSECTOR");
                 
                 fila[13]=(String.valueOf(rs.getString("FOTO")));
                 fila[14]=(String.valueOf(rs.getString("INVENTARIO")));
                 fila[15]=(String.valueOf(rs.getString("PIEZA")));
                 fila[16]=(rs.getString("MP"));
                 
                 fila[17]=(rs.getString("ENTERA_FRACTURADA"));
                 fila[18]=(rs.getString("SIMPLE_COMPUESTA"));
                 fila[19]=(rs.getString("CLASE_ARTEF"));

                 fila[20]=(rs.getString("FORMA_BASE"));
                 fila[21]=(rs.getString("NUM_FACETAS_EXTRAC"));
                 fila[22]=(rs.getString("ORIGEN_EXTRAC"));
                 fila[23]=(rs.getString("ALTERAC_TRATAM_TERM"));
                 fila[24]=(rs.getString("SUP_TALON"));
                 fila[25]=(rs.getString("ANCHO_TALON"));
                 boolean aux = false; 
                 if(rs.getString("EJE_LASCADO").equals("false")){
                     fila[26]="NO";
                 }else{
                     fila[26]="SI";
                 }
                 if(rs.getString("EJE_MORFOLOGICO").equals("false")){
                     fila[27]="NO";
                 }else{
                     fila[27]="SI";
                 }
                 fila[28]=(String.valueOf(rs.getString("LONGITUD_A")));
                 fila[29]=(String.valueOf(rs.getString("ANCHO_A")));
                 fila[30]=(String.valueOf(rs.getString("ESPESOR_A")));
                 fila[31]=(String.valueOf(rs.getString("PESO")));
                 fila[32]=(String.valueOf(rs.getString("TAMAÑO")));
                 fila[33]=(String.valueOf(rs.getString("MODULO_LONG_ANCHO")));
                 fila[34]=(String.valueOf(rs.getString("MODULO_ANCHO_ESPESOR")));
                 fila[35]=(rs.getString("CLASE_TECNICA"));
                 fila[36]=(rs.getString("SUSTANCIA_ADHERIDA"));
                 fila[37]=(String.valueOf(rs.getString("POSICION_SUST_ADHERIDA")));
                 fila[38]=(rs.getString("CORTEZA_A"));
                 fila[39]=(rs.getString("PATINA"));
                 fila[40]=(rs.getString("VENTIFACCION"));
                 fila[41]=(String.valueOf(rs.getString("OBSERVACIONES_A")));
//                 
                 fila[42]=(String.valueOf(rs.getInt("ID_NUCLEOS")));
                 fila[43]=(rs.getString("GRUPO"));
                 fila[44]=(rs.getString("SUBGRUPO"));
                 fila[45]=(rs.getString("ANGULO_PLAT"));
                 fila[46]=(rs.getString("N_PLAT"));
                 fila[47]=(rs.getString("PLAT_ANCHO"));
                 fila[48]=(rs.getString("PLAT_ESPESOR"));
                 fila[49]=(rs.getString("PLAT_FORMA_SUP"));
                 fila[50]=(rs.getString("ESTADO_FRENTE_EXTRAC"));
                 fila[51]=(rs.getString("ESTADO_BORDE_EXT"));
                 fila[52]=(rs.getString("LSMAY_ANCHO_TALON"));
                 fila[53]=(rs.getString("LSMAY_LARGO"));
                 fila[54]=(rs.getString("LSMAY_ANCHO_LASC"));
                 fila[55]=(rs.getString("LSMAY_TAMAÑO"));
                 fila[56]=(rs.getString("LSMAY_MODULO"));
                 fila[57]=(rs.getString("LSMEN_LARGO"));
                 fila[58]=(rs.getString("LSMEN_ANCHO"));
                 fila[59]=(rs.getString("LSMEN_TAMAÑO"));
                 fila[60]=(rs.getString("LSMEN_MODULO"));
                 fila[61]=(rs.getString("PATINA_B"));
                 fila[62]=(rs.getString("VENTIFACCION_B"));
                 fila[63]=(rs.getString("ACTIVACION_PLAT"));
                 fila[64]=(rs.getString("CORTEZA_B"));
                 fila[65]=(rs.getString("OBSERVACIONES_B"));


//
                dtm.addRow(fila);
//        
                }
//        
        c.closeconnection();
       } catch (SQLException ex) {
            Logger.getLogger(InteraccionesBD.class.getName()).log(Level.SEVERE, null, ex);
        }
cantidadfilas();
 
//activarfiltro();
 bloquearmenu("a1,2,3,4");    
        
        
    }//GEN-LAST:event_btn_cargar_nucleosNplatActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
     Copiartabla copy = new Copiartabla();
  copy.copiartabla(tbl_general, txt_muestra.getText(), WHERE, "", "");
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
      Copiartabla copy = new Copiartabla();
  copy.copiartabla(jtable_pers, txt_muestra.getText(), WHERE, "", "");
    }//GEN-LAST:event_jButton3ActionPerformed

    private void guardarcsvActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_guardarcsvActionPerformed
    writeCSVfile(tbl_general);
    }//GEN-LAST:event_guardarcsvActionPerformed
private void bloquearmenu(String solo){
    switch(solo){
        case "d1,2,4":
           menu_solosiglas.setEnabled(false);
           ocultarcn.setEnabled(false);
           menu_ocultar_proc.setEnabled(true);
           menu_ocultar_infogral.setEnabled(false);
           
            break;
        case "d1,2,3":    
           menu_solosiglas.setEnabled(false);
           ocultarcn.setEnabled(false);
           menu_ocultar_infogral.setEnabled(false); 
           menu_ocultar_infogral.setEnabled(true); 
           break;
        case "a1,2,3,4":
                menu_solosiglas.setEnabled(true);
                ocultarcn.setEnabled(true);
                menu_ocultar_proc.setEnabled(true);
                menu_ocultar_infogral.setEnabled(true); 
        break;
        case "d1,2,3,4":
                menu_solosiglas.setEnabled(false);
                ocultarcn.setEnabled(false);
                menu_ocultar_proc.setEnabled(false);
                menu_ocultar_infogral.setEnabled(false); 
        break;
        case "a1,2,3":
                menu_solosiglas.setEnabled(true);
                ocultarcn.setEnabled(true);
                menu_ocultar_proc.setEnabled(true);
                menu_ocultar_infogral.setEnabled(false); 
        default:   
            break;
    }
//    if(bloquear==true){
//       
////        menu_solosiglas.setEnabled(false);
////        ocultarcn.setEnabled(false);
//        menu_ocultar_proc.setEnabled(false);
//        menu_ocultar_infogral.setEnabled(false);
//    }else{
//       
////        menu_solosiglas.setEnabled(true);
////        ocultarcn.setEnabled(true);
//        menu_ocultar_proc.setEnabled(true);
//        menu_ocultar_infogral.setEnabled(true);        
//    }
}
    
    private void menu_ocultar_procActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_ocultar_procActionPerformed
bloquearmenu("d1,2,3,4");
if(tbl_general.getColumnCount()>12){
           
tbl_general.removeColumn(tbl_general.getColumnModel().getColumn(1));
tbl_general.removeColumn(tbl_general.getColumnModel().getColumn(1));
tbl_general.removeColumn(tbl_general.getColumnModel().getColumn(1));
tbl_general.removeColumn(tbl_general.getColumnModel().getColumn(1));
tbl_general.removeColumn(tbl_general.getColumnModel().getColumn(1));
tbl_general.removeColumn(tbl_general.getColumnModel().getColumn(1));
tbl_general.removeColumn(tbl_general.getColumnModel().getColumn(1));
tbl_general.removeColumn(tbl_general.getColumnModel().getColumn(1));
tbl_general.removeColumn(tbl_general.getColumnModel().getColumn(1));
tbl_general.removeColumn(tbl_general.getColumnModel().getColumn(1));
tbl_general.removeColumn(tbl_general.getColumnModel().getColumn(1));
tbl_general.removeColumn(tbl_general.getColumnModel().getColumn(1));
}

    }//GEN-LAST:event_menu_ocultar_procActionPerformed

    private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu2ActionPerformed

    }//GEN-LAST:event_jMenu2ActionPerformed

    private void menu_ocultar_infogralActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_ocultar_infogralActionPerformed
//bloquearmenu(true);

bloquearmenu("d1,2,3,4");
if(tbl_general.getColumnCount()>42){
           for (int i = 0; i < 41; i++) {
        tbl_general.removeColumn(tbl_general.getColumnModel().getColumn(1));        
    }


}
    }//GEN-LAST:event_menu_ocultar_infogralActionPerformed
    public void writeCSVfile(JTable table) {
       JFileChooser guardar = new JFileChooser();
    guardar.showSaveDialog(null);
    guardar.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    File archivo = guardar.getSelectedFile();
    File ruta = guardar.getCurrentDirectory();
    String path = archivo.getAbsolutePath();
    
        try {
            
        
        Writer writer = null;
        DefaultTableModel dtm = (DefaultTableModel) table.getModel();
        int nRow = dtm.getRowCount();
        int nCol = dtm.getColumnCount();
        try {
            writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path+".txt"), "utf-8"));

            //write the header information
            StringBuffer bufferHeader = new StringBuffer();
            for (int j = 0; j < nCol; j++) {
                bufferHeader.append(dtm.getColumnName(j));
                if (j!=nCol) bufferHeader.append("; ");
            }
            writer.write(bufferHeader.toString() + "\r\n");

           //write row information
            for (int i = 0 ; i < nRow ; i++){
                 StringBuffer buffer = new StringBuffer();
                for (int j = 0 ; j < nCol ; j++){
                    buffer.append(dtm.getValueAt(i,j));
                    if (j!=nCol) buffer.append("; ");
                }
                writer.write(buffer.toString() + "\r\n");
            }
        } finally {
              writer.close();
              JOptionPane.showMessageDialog(null, "Archivo guardado");
        }
        }
        catch (Exception e) {

              JOptionPane.showMessageDialog(null, "No se pudo guardar el archivo");
        }
    }
    /**
     * @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(Fichas_generales.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Fichas_generales.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Fichas_generales.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Fichas_generales.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem agregarcol;
    private javax.swing.JButton btn_Cargar_Estandar;
    private javax.swing.JButton btn_cargar_general;
    private javax.swing.JButton btn_cargar_nucleosNplat;
    private javax.swing.JButton btn_cargar_nucleos_1PLAT;
    private javax.swing.JButton btn_cargar_puntas;
    private javax.swing.JButton btn_dt_ct;
    private javax.swing.JButton btn_dtst;
    private javax.swing.JComboBox<String> cbx_mp;
    private javax.swing.JRadioButton chk_cargarmp;
    private javax.swing.JRadioButton chk_cargarmuestra;
    private javax.swing.JMenuItem guardarcsv;
    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.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JTable jtable_pers;
    private javax.swing.JMenuItem menu_ocultar_infogral;
    private javax.swing.JMenuItem menu_ocultar_proc;
    private javax.swing.JMenuItem menu_solosiglas;
    private javax.swing.JMenuItem ocultarcn;
    private javax.swing.JScrollPane scrolltbl;
    private javax.swing.JTable tbl_general;
    private javax.swing.JTextArea txt_ampliado;
    private javax.swing.JTextField txt_cantidad;
    private javax.swing.JTextField txt_muestra;
    // End of variables declaration//GEN-END:variables
}
