
/*
  <ARQ.L> (actual versión: '2.0' o 'v2.0') es un software destinado al registro y procesamiento de información referida a material lítico. Se trata de una vesión digital basada en la propuesta teórico-metodológica del Lic. Carlos Aschero [1975,1983,2020-2021].

    Copyright (C) 2020-2021. Aschero Carlos y Agustina Ponce.

    Este programa es software gratuito; puedes redistribuirlo y / o modificarlo
    bajo los términos de la Licencia Pública General GNU publicada por Free
    Fundación de software; ya sea la versión 2 de la licencia, o (a su elección)
    cualquier versión posterior.

    Este programa se distribuye con la esperanza de que sea útil, pero SIN
    CUALQUIER GARANTIA; incluso sin la garantía implícita de COMERCIABILIDAD o
    APTITUD PARA UN PROPÓSITO PARTICULAR. Consulte la Licencia pública general GNU para
    más detalles.

    Debería haber recibido una copia de la Licencia Pública General GNU junto con
    con este programa; si no es así, escriba a Free Software Foundation, Inc., 59
    Temple Place, Suite 330, Boston, MA 02111-1307 EE. UU.

Para contactarse con el equipo de ARQ.L, escriba un correo electrónico a la dirección:
arqlsoftware@gmail.com


 */
package arql2020;

import Calculos_automaticos.B_Composicion_puntasfilossup;
import Calculos_automaticos.Calculos;
import Calculos_automaticos.Muestras;
import static arql2020.ARQL2020.WHERE;
import static arql2020.ARQL2020.indexMP;
import static arql2020.ARQL2020.tabla_o_filtro;
import static arql2020.ARQL2020.ventanamuestra;
import static arql2020.FORMATIZADOS_frame.jTree1;
import static arql2020.Internal_DT_contalon.btn_eliminarregistro_Dt_contalon;
import static arql2020.Internal_DT_sintalon.btn_eliminarregistro_Dt_sintalon;
import clases.Cargar_procedencia_formularios;
import clases.InteraccionesBD;
import clases.conexion;
import static java.awt.Frame.MAXIMIZED_BOTH;
import javax.swing.JOptionPane;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;

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

DefaultMutableTreeNode selectednode2;
public static DefaultMutableTreeNode selectednodeparaeliminar;
    
    public DT_frame() {
        initComponents();
           this.setExtendedState(MAXIMIZED_BOTH);
    }

    /**
     * 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();
        Editar = new javax.swing.JMenuItem();
        Escritorio = new javax.swing.JDesktopPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        f_zona_ambiental = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        f_localidad = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        f_sitio = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        f_siglasitio = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        f_capa = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        f_estructura_arq = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        f_piso_capa_estruc_arq = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        f_denominacion_estructuraPl = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        f_tipo_estructuraPl = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        f_episodio_estructuraPl = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        f_cuadro = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        f_microsector = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        arbol_DT = new javax.swing.JTree();
        jLabel14 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        txt_muestra_DT = new javax.swing.JTextField();
        btn_okmuestra = new javax.swing.JButton();
        jLabel15 = new javax.swing.JLabel();
        txt_ndt = new javax.swing.JTextField();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem5 = new javax.swing.JMenuItem();

        Editar.setText("Editar");
        Editar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EditarActionPerformed(evt);
            }
        });
        jPopupMenu1.add(Editar);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Desechos de talla");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        Escritorio.setBackground(new java.awt.Color(255, 255, 255));

        javax.swing.GroupLayout EscritorioLayout = new javax.swing.GroupLayout(Escritorio);
        Escritorio.setLayout(EscritorioLayout);
        EscritorioLayout.setHorizontalGroup(
            EscritorioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 656, Short.MAX_VALUE)
        );
        EscritorioLayout.setVerticalGroup(
            EscritorioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        jPanel1.setBackground(new java.awt.Color(0, 0, 0));

        jLabel1.setBackground(new java.awt.Color(255, 255, 255));
        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("PROCEDENCIA");

        jLabel2.setBackground(new java.awt.Color(255, 255, 255));
        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Zona ambiental");

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

        jLabel3.setBackground(new java.awt.Color(255, 255, 255));
        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Localidad");

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

        jLabel4.setBackground(new java.awt.Color(255, 255, 255));
        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("Sitio");

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

        jLabel13.setBackground(new java.awt.Color(255, 255, 255));
        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel13.setForeground(new java.awt.Color(255, 255, 255));
        jLabel13.setText("Sigla sitio");

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

        jLabel5.setBackground(new java.awt.Color(255, 255, 255));
        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("Capa o nivel");

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

        jLabel6.setBackground(new java.awt.Color(255, 255, 255));
        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel6.setForeground(new java.awt.Color(255, 255, 0));
        jLabel6.setText("Estructura arq.");

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

        jLabel11.setBackground(new java.awt.Color(255, 255, 255));
        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel11.setForeground(new java.awt.Color(255, 255, 0));
        jLabel11.setText("Piso o sucbapa de la est. arq.");

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

        jLabel8.setBackground(new java.awt.Color(255, 255, 255));
        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(255, 102, 0));
        jLabel8.setText("Denominación de estructura en planta");

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

        jLabel7.setBackground(new java.awt.Color(255, 255, 255));
        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel7.setForeground(new java.awt.Color(255, 102, 0));
        jLabel7.setText("Tipo de estruc. en pl.");

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

        jLabel12.setBackground(new java.awt.Color(255, 255, 255));
        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel12.setForeground(new java.awt.Color(255, 102, 0));
        jLabel12.setText("Episodio de estruc. en pl.");

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

        jLabel10.setBackground(new java.awt.Color(255, 255, 255));
        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel10.setForeground(new java.awt.Color(0, 255, 204));
        jLabel10.setText("Cuadro");

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

        jLabel9.setBackground(new java.awt.Color(255, 255, 255));
        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel9.setForeground(new java.awt.Color(0, 255, 204));
        jLabel9.setText("Microsector");

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

        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, false)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8)
                    .addComponent(jLabel9)
                    .addComponent(jLabel10)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(96, 96, 96)
                        .addComponent(jLabel1))
                    .addComponent(jLabel11)
                    .addComponent(jLabel6)
                    .addComponent(jLabel12)
                    .addComponent(jLabel13)
                    .addComponent(f_localidad, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)
                    .addComponent(f_sitio)
                    .addComponent(f_siglasitio)
                    .addComponent(f_capa)
                    .addComponent(f_estructura_arq)
                    .addComponent(f_piso_capa_estruc_arq)
                    .addComponent(f_denominacion_estructuraPl)
                    .addComponent(f_tipo_estructuraPl)
                    .addComponent(f_episodio_estructuraPl)
                    .addComponent(f_cuadro)
                    .addComponent(f_microsector)
                    .addComponent(f_zona_ambiental))
                .addContainerGap(140, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(27, 27, 27)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(f_zona_ambiental, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(4, 4, 4)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(f_localidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(3, 3, 3)
                .addComponent(jLabel4)
                .addGap(2, 2, 2)
                .addComponent(f_sitio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel13)
                .addGap(2, 2, 2)
                .addComponent(f_siglasitio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(f_capa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(12, 12, 12)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(f_estructura_arq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(f_piso_capa_estruc_arq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(f_denominacion_estructuraPl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel7)
                .addGap(9, 9, 9)
                .addComponent(f_tipo_estructuraPl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel12)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(f_episodio_estructuraPl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(f_cuadro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(f_microsector, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(49, Short.MAX_VALUE))
        );

        jScrollPane1.setViewportView(jPanel1);

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));

        jButton1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton1.setText("Nuevo ST");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

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

        arbol_DT.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("DT");
        javax.swing.tree.DefaultMutableTreeNode treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Sin talón");
        treeNode1.add(treeNode2);
        treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Con talón");
        treeNode1.add(treeNode2);
        arbol_DT.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
        arbol_DT.setComponentPopupMenu(jPopupMenu1);
        jScrollPane2.setViewportView(arbol_DT);

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel14.setText("Piezas");

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

        jButton4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton4.setText("+");
        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("Buscar");
        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("Muestra");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jButton7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton7.setText("Todas las piezas");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

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

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

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel15.setText("N:");

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

        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()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton4))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel15)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(txt_ndt, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel14)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(txt_muestra_DT, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btn_okmuestra))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jButton5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton7)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(8, 8, 8)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton5)
                    .addComponent(jButton6)
                    .addComponent(jButton7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(txt_muestra_DT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_okmuestra))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(txt_ndt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2)
                    .addComponent(jButton3)
                    .addComponent(jButton4))
                .addContainerGap())
        );

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

        jMenuItem3.setText("Ir a Inicio");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);

        jMenuBar1.add(jMenu1);

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

        jMenuItem1.setText("Editar procedencia");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem1);

        jMenuBar1.add(jMenu2);

        jMenu3.setForeground(new java.awt.Color(255, 0, 0));
        jMenu3.setText("TABLAS");
        jMenu3.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N

        jMenuItem2.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jMenuItem2.setText("De útiles y núcleos");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem2);

        jMenuBar1.add(jMenu3);

        jMenu4.setForeground(new java.awt.Color(204, 0, 0));
        jMenu4.setText("Análisis predeterminados");
        jMenu4.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N

        jMenuItem5.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jMenuItem5.setText("Ir a centro de analisis");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem5);

        jMenuBar1.add(jMenu4);

        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(Escritorio)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(Escritorio)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 733, Short.MAX_VALUE))
        );

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

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
 
Escritorio.removeAll();
Internal_DT_sintalon sintalon = new Internal_DT_sintalon();
Escritorio.add(sintalon);
sintalon.show();
selectednodeparaeliminar=null;
btn_eliminarregistro_Dt_sintalon.setEnabled(false);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
Escritorio.removeAll();
Internal_DT_contalon contalon = new Internal_DT_contalon();
Escritorio.add(contalon);
contalon.show();
selectednodeparaeliminar=null;
btn_eliminarregistro_Dt_contalon.setEnabled(false);

    }//GEN-LAST:event_jButton2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
presentacion pres = new presentacion();
pres.setVisible(true);
this.dispose();
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
FORMATIZADOS_frame form = new FORMATIZADOS_frame();
form.setVisible(true);
this.dispose();
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
Calculos calc = new Calculos();
calc.setVisible(true);
this.dispose();
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
//Cargar_procedencia_formularios cp = new Cargar_procedencia_formularios();
//cp.setearprocedencia(f_zona_ambiental, f_localidad, f_sitio, f_siglasitio, f_capa, f_estructura_arq, f_piso_capa_estruc_arq, f_denominacion_estructuraPl, f_tipo_estructuraPl, f_episodio_estructuraPl, f_cuadro, f_microsector);
//
//if(tabla_o_filtro.equals("tabla")){
//    
//InteraccionesBD inter = new InteraccionesBD();
//inter.cargartodaslashojas(arbol_DT, 0, "DT_SINTALON2","ID_DT_SINTALON","LOTE", "ST");
//inter.cargartodaslashojas(arbol_DT, 1, "DT_CONTALON2","ID_DT_CONTALON","PIEZA", "CT");
//}
//if(ARQL2020.zona_ambiental.equals("zona ambiental")){
//    JOptionPane.showMessageDialog(null, "Recuerde indicar la procedencia antes de cargar las fichas");
//}

    }//GEN-LAST:event_formWindowOpened

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
Cargar_procedencia_formularios cp = new Cargar_procedencia_formularios();
cp.setearprocedencia(f_zona_ambiental, f_localidad, f_sitio, f_siglasitio, f_capa, f_estructura_arq, f_piso_capa_estruc_arq, f_denominacion_estructuraPl, f_tipo_estructuraPl, f_episodio_estructuraPl, f_cuadro, f_microsector);

    }//GEN-LAST:event_formWindowActivated

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
Procedencia_scroll p = new Procedencia_scroll();
p.setVisible(true);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void EditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EditarActionPerformed
int contador= 0;
        selectednode2 = (DefaultMutableTreeNode) arbol_DT.getLastSelectedPathComponent();
             
        int nivel = selectednode2.getLevel();
//        System.out.println("level:" +nivel);
//        System.out.println("depht:" +selectednode2.getDepth());



        if (nivel == 2) {
            if (selectednode2.getDepth() == 0) {
                String ficha = selectednode2.toString();
                System.out.println("ficha sintalon:" + ficha);
                    String[] parts = ficha.split("/");
                    String partecodigoarq = parts[0];
                    String codigoinv = parts[1];
                    
                    String[] parts2 = partecodigoarq.split("-");
                    String tipoficha= parts2[0];
                    String codigoarq_l= parts2[1];
                    System.out.println("codigo arql: " +tipoficha + " codigoarq 2: " +codigoarq_l);
                    
                    if(tipoficha.equals("ST")){
                        Escritorio.removeAll();
                        Internal_DT_sintalon sintalon = new Internal_DT_sintalon();
                        Escritorio.add(sintalon);
                        sintalon.show();
                        sintalon.cargaridDT_sintalon(Integer.parseInt(codigoarq_l));
                        Cargar_procedencia_formularios cp = new Cargar_procedencia_formularios();
                        cp.setearprocedencia(f_zona_ambiental, f_localidad, f_sitio, f_siglasitio, f_capa, f_estructura_arq, f_piso_capa_estruc_arq, f_denominacion_estructuraPl, f_tipo_estructuraPl, f_episodio_estructuraPl, f_cuadro, f_microsector);
                        selectednodeparaeliminar = selectednode2;
                        btn_eliminarregistro_Dt_sintalon.setEnabled(true);
                    }
                    if(tipoficha.equals("CT")){
                        Escritorio.removeAll();
                        Internal_DT_contalon contalon = new Internal_DT_contalon();
                        Escritorio.add(contalon);
                        contalon.show();
                        contalon.cargaridDT_contalon(Integer.parseInt(codigoarq_l));
                        Cargar_procedencia_formularios cp = new Cargar_procedencia_formularios();
                        cp.setearprocedencia(f_zona_ambiental, f_localidad, f_sitio, f_siglasitio, f_capa, f_estructura_arq, f_piso_capa_estruc_arq, f_denominacion_estructuraPl, f_tipo_estructuraPl, f_episodio_estructuraPl, f_cuadro, f_microsector);
                        selectednodeparaeliminar = selectednode2;
                        btn_eliminarregistro_Dt_contalon.setEnabled(true);
                    }

            }
        }

    }//GEN-LAST:event_EditarActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        DefaultTreeModel model = (DefaultTreeModel) arbol_DT.getModel();
      model.reload();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        DefaultTreeModel model = (DefaultTreeModel) arbol_DT.getModel();
      model.reload();
      
      
int j = arbol_DT.getRowCount();
       int i = 0;
       while(i < j) {
           arbol_DT.expandRow(i);
           i += 1;
           j = arbol_DT.getRowCount();
       }
    }//GEN-LAST:event_jButton4ActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
              try {
    conexion c = new conexion();
    c.getConexion();
    c.closeconnection();
    c.apagar();
        } catch (Exception e) {
        }
    }//GEN-LAST:event_formWindowClosing

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
    String entradaUsuario = "";
     entradaUsuario = JOptionPane.showInputDialog("Introduzca el numero del ROTULO de la pieza buscada");
    InteraccionesBD inter = new InteraccionesBD();
    if(entradaUsuario == null){
        
    }else{
    String contalon= inter.obtener_id_por_rotulo("DT_CONTALON2", "ID_DT_CONTALON", entradaUsuario, "PIEZA");
    String sintalon= inter.obtener_id_por_rotulo("DT_SINTALON2", "ID_DT_SINTALON", entradaUsuario, "LOTE");
    Buscar_rotulos busc = new Buscar_rotulos();
    busc.setVisible(true);
    
    busc.txt_busqueda.setText(entradaUsuario);
    String resultados = "DT CON TALÓN QUE PRESENTAN EL RÓTULO INDIVIDUAL: " + entradaUsuario + ": \n" +contalon 
            +"\n "
            +"\n DT SIN TALÓN QUE PRESENTAN EL RÓTULO DE LOTE: " + entradaUsuario + ": \n" +sintalon;
    busc.txt_resultado_busqueda.setText(resultados);
    
    }
    
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
ventanamuestra= "DT";
Muestras mu = new Muestras();
mu.setVisible(true);
    }//GEN-LAST:event_jButton6ActionPerformed

    private void btn_okmuestraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_okmuestraActionPerformed
Cargar_procedencia_formularios cp = new Cargar_procedencia_formularios();
cp.setearprocedencia(f_zona_ambiental, f_localidad, f_sitio, f_siglasitio, f_capa, f_estructura_arq, f_piso_capa_estruc_arq, f_denominacion_estructuraPl, f_tipo_estructuraPl, f_episodio_estructuraPl, f_cuadro, f_microsector);

if(tabla_o_filtro.equals("tabla")){
    
InteraccionesBD inter = new InteraccionesBD();
inter.cargartodaslashojas(WHERE, arbol_DT, 0, "DT_SINTALON2","ID_DT_SINTALON","LOTE", "ST");
inter.cargartodaslashojas(WHERE, arbol_DT, 1, "DT_CONTALON2","ID_DT_CONTALON","PIEZA", "CT");
}
if(ARQL2020.zona_ambiental.equals("Sin datos_ZA")){
    JOptionPane.showMessageDialog(null, "Recuerde indicar la procedencia antes de cargar las fichas");
}
    }//GEN-LAST:event_btn_okmuestraActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
 Cargar_procedencia_formularios cp = new Cargar_procedencia_formularios();
cp.setearprocedencia(f_zona_ambiental, f_localidad, f_sitio, f_siglasitio, f_capa, f_estructura_arq, f_piso_capa_estruc_arq, f_denominacion_estructuraPl, f_tipo_estructuraPl, f_episodio_estructuraPl, f_cuadro, f_microsector);

if(tabla_o_filtro.equals("tabla")){
    
InteraccionesBD inter = new InteraccionesBD();
inter.cargartodaslashojas("",arbol_DT, 0, "DT_SINTALON2","ID_DT_SINTALON","LOTE", "ST");
inter.cargartodaslashojas("",arbol_DT, 1, "DT_CONTALON2","ID_DT_CONTALON","PIEZA", "CT");
}
if(ARQL2020.zona_ambiental.equals("Sin datos_ZA")){
    JOptionPane.showMessageDialog(null, "Recuerde indicar la procedencia antes de cargar las fichas");
}
    }//GEN-LAST:event_jButton7ActionPerformed

    /**
     * @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(DT_frame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(DT_frame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(DT_frame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(DT_frame.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 DT_frame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem Editar;
    private javax.swing.JDesktopPane Escritorio;
    public static javax.swing.JTree arbol_DT;
    private javax.swing.JButton btn_okmuestra;
    private javax.swing.JTextField f_capa;
    private javax.swing.JTextField f_cuadro;
    private javax.swing.JTextField f_denominacion_estructuraPl;
    private javax.swing.JTextField f_episodio_estructuraPl;
    private javax.swing.JTextField f_estructura_arq;
    private javax.swing.JTextField f_localidad;
    private javax.swing.JTextField f_microsector;
    private javax.swing.JTextField f_piso_capa_estruc_arq;
    private javax.swing.JTextField f_siglasitio;
    private javax.swing.JTextField f_sitio;
    private javax.swing.JTextField f_tipo_estructuraPl;
    private javax.swing.JTextField f_zona_ambiental;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    public static javax.swing.JTextField txt_muestra_DT;
    public static javax.swing.JTextField txt_ndt;
    // End of variables declaration//GEN-END:variables
}
