Valuacion.Importa.java Source code

Java tutorial

Introduction

Here is the source code for Valuacion.Importa.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Valuacion;

import Hibernate.Util.HibernateUtil;
import Hibernate.entidades.Catalogo;
import Hibernate.entidades.Ejemplar;
import Hibernate.entidades.Especialidad;
import Hibernate.entidades.Orden;
import Hibernate.entidades.Partida;
import Hibernate.entidades.Proveedor;
import Hibernate.entidades.Pedido;
import Hibernate.entidades.Usuario;
import Integral.ExtensionFileFilter;
import Integral.Herramientas;
import java.io.File;
import java.io.FileInputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

/**
 *
 * @author salvador
 */
public class Importa extends javax.swing.JPanel {

    int menu = 0;
    String sessionPrograma = "";
    public Orden orden_act = null;
    Herramientas h;
    Usuario usr;

    /**
     * Creates new form Importa
     */
    public Importa(Usuario usuario, int opcion, String programa) {
        usr = usuario;
        menu = opcion;
        sessionPrograma = programa;
        initComponents();
    }

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

        aviso = new javax.swing.JFileChooser();
        jPanel1 = new javax.swing.JPanel();
        b_busca_orden = new javax.swing.JButton();
        t_archivo = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        t_tipo_cliente = new javax.swing.JTextField();
        t_siniestro = new javax.swing.JTextField();
        t_orden = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        t_tipo = new javax.swing.JTextField();
        t_reporte = new javax.swing.JTextField();
        t_aseguradora = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        t_fecha = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        t_marca = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        t_inciso = new javax.swing.JTextField();
        t_cliente = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        t_modelo = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        t_poliza = new javax.swing.JTextField();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabla_especialidad = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        tabla_catalogo = new javax.swing.JTable();
        jScrollPane3 = new javax.swing.JScrollPane();
        tabla_marca = new javax.swing.JTable();
        jScrollPane4 = new javax.swing.JScrollPane();
        tabla_tipo = new javax.swing.JTable();
        jScrollPane5 = new javax.swing.JScrollPane();
        tabla_ejemplar = new javax.swing.JTable();
        jScrollPane6 = new javax.swing.JScrollPane();
        tabla_partidas = new javax.swing.JTable();

        aviso.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG);
        aviso.setDialogTitle("Examinar");

        setBackground(new java.awt.Color(254, 254, 254));
        setBorder(javax.swing.BorderFactory.createTitledBorder(
                new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Importar Valuacin",
                javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP));
        setLayout(new java.awt.BorderLayout());

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

        b_busca_orden.setBackground(new java.awt.Color(2, 135, 242));
        b_busca_orden.setIcon(new ImageIcon("imagenes/buscar.png"));
        b_busca_orden.setMaximumSize(new java.awt.Dimension(32, 8));
        b_busca_orden.setMinimumSize(new java.awt.Dimension(32, 8));
        b_busca_orden.setPreferredSize(new java.awt.Dimension(32, 8));
        b_busca_orden.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                b_busca_ordenActionPerformed(evt);
            }
        });

        t_archivo.setEnabled(false);

        jLabel1.setText("Seleccione el archivo de origen:");

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

        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().addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(t_archivo, javax.swing.GroupLayout.PREFERRED_SIZE, 352,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(b_busca_orden, javax.swing.GroupLayout.PREFERRED_SIZE, 28,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 329, Short.MAX_VALUE)
                        .addComponent(jButton1).addContainerGap()));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(jButton1)
                        .addComponent(b_busca_orden, javax.swing.GroupLayout.PREFERRED_SIZE, 24,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel1).addComponent(t_archivo,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        add(jPanel1, java.awt.BorderLayout.NORTH);

        jPanel2.setBackground(new java.awt.Color(254, 254, 254));
        jPanel2.setLayout(new java.awt.BorderLayout());

        jPanel3.setBackground(new java.awt.Color(254, 254, 254));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(
                new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Datos de la Orden",
                javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP));

        jLabel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(51, 0, 255));
        jLabel2.setText("No Orden:");

        jLabel6.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel6.setForeground(new java.awt.Color(51, 0, 255));
        jLabel6.setText("Siniestro:");

        jLabel11.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel11.setForeground(new java.awt.Color(51, 0, 255));
        jLabel11.setText("Tipo cliente:");

        t_tipo_cliente.setBackground(new java.awt.Color(204, 255, 255));
        t_tipo_cliente.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        t_tipo_cliente.setEnabled(false);
        t_tipo_cliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                t_tipo_clienteActionPerformed(evt);
            }
        });

        t_siniestro.setBackground(new java.awt.Color(204, 255, 255));
        t_siniestro.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        t_siniestro.setEnabled(false);
        t_siniestro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                t_siniestroActionPerformed(evt);
            }
        });

        t_orden.setBackground(new java.awt.Color(204, 255, 255));
        t_orden.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        t_orden.setEnabled(false);

        jLabel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(51, 0, 255));
        jLabel4.setText("Aseguradora:");

        jLabel8.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(51, 0, 255));
        jLabel8.setText("Reporte:");

        jLabel12.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel12.setForeground(new java.awt.Color(51, 0, 255));
        jLabel12.setText("Tipo:");

        t_tipo.setBackground(new java.awt.Color(204, 255, 255));
        t_tipo.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        t_tipo.setEnabled(false);
        t_tipo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                t_tipoActionPerformed(evt);
            }
        });

        t_reporte.setBackground(new java.awt.Color(204, 255, 255));
        t_reporte.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        t_reporte.setEnabled(false);
        t_reporte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                t_reporteActionPerformed(evt);
            }
        });

        t_aseguradora.setBackground(new java.awt.Color(204, 255, 255));
        t_aseguradora.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        t_aseguradora.setEnabled(false);
        t_aseguradora.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                t_aseguradoraActionPerformed(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel9.setForeground(new java.awt.Color(51, 0, 255));
        jLabel9.setText("Fecha:");

        t_fecha.setBackground(new java.awt.Color(204, 255, 255));
        t_fecha.setText("DD-MM-AAAA");
        t_fecha.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        t_fecha.setEnabled(false);
        t_fecha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                t_fechaActionPerformed(evt);
            }
        });

        jLabel13.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel13.setForeground(new java.awt.Color(51, 0, 255));
        jLabel13.setText("Marca:");

        t_marca.setBackground(new java.awt.Color(204, 255, 255));
        t_marca.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        t_marca.setEnabled(false);
        t_marca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                t_marcaActionPerformed(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel10.setForeground(new java.awt.Color(51, 0, 255));
        jLabel10.setText("Cliente:");

        jLabel7.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel7.setForeground(new java.awt.Color(51, 0, 255));
        jLabel7.setText("Inciso:");

        t_inciso.setBackground(new java.awt.Color(204, 255, 255));
        t_inciso.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        t_inciso.setEnabled(false);
        t_inciso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                t_incisoActionPerformed(evt);
            }
        });

        t_cliente.setBackground(new java.awt.Color(204, 255, 255));
        t_cliente.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        t_cliente.setEnabled(false);
        t_cliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                t_clienteActionPerformed(evt);
            }
        });

        jLabel14.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel14.setForeground(new java.awt.Color(51, 0, 255));
        jLabel14.setText("Modelo:");

        t_modelo.setBackground(new java.awt.Color(204, 255, 255));
        t_modelo.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        t_modelo.setEnabled(false);
        t_modelo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                t_modeloActionPerformed(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(51, 0, 255));
        jLabel5.setText("Poliza:");

        t_poliza.setBackground(new java.awt.Color(204, 255, 255));
        t_poliza.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        t_poliza.setEnabled(false);
        t_poliza.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                t_polizaActionPerformed(evt);
            }
        });

        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.TRAILING)
                        .addGroup(jPanel3Layout.createSequentialGroup().addComponent(jLabel11).addGap(2, 2, 2)
                                .addComponent(t_tipo_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel3Layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(jLabel2)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(t_orden, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(jLabel6)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(t_siniestro, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(jLabel4)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(t_aseguradora, javax.swing.GroupLayout.PREFERRED_SIZE, 328,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18).addComponent(jLabel7)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(t_inciso, javax.swing.GroupLayout.PREFERRED_SIZE, 54,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 61,
                                                Short.MAX_VALUE)
                                        .addComponent(jLabel5)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(t_poliza, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(jLabel8)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(t_reporte, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel9)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(t_fecha, javax.swing.GroupLayout.PREFERRED_SIZE, 130,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel10)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(t_cliente))
                                .addGroup(
                                        jPanel3Layout.createSequentialGroup().addComponent(jLabel12).addGap(2, 2, 2)
                                                .addComponent(t_tipo, javax.swing.GroupLayout.PREFERRED_SIZE, 206,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLabel13).addGap(2, 2, 2)
                                                .addComponent(t_marca, javax.swing.GroupLayout.PREFERRED_SIZE, 206,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jLabel14)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(t_modelo, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap()));
        jPanel3Layout
                .setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                                .addGroup(jPanel3Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel3Layout.createSequentialGroup().addGap(2, 2, 2)
                                                .addComponent(jLabel2))
                                        .addGroup(jPanel3Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(t_orden, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel4)
                                                .addComponent(t_aseguradora, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel5)
                                                .addComponent(t_poliza, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel7).addComponent(t_inciso,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(
                                        jPanel3Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel6)
                                                .addComponent(t_siniestro, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel8)
                                                .addComponent(t_reporte, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel9)
                                                .addComponent(t_fecha, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel10)
                                                .addComponent(t_cliente, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel3Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel3Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel14).addComponent(t_modelo,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(jPanel3Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel13).addComponent(t_marca,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(jPanel3Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel12)
                                                .addComponent(t_tipo, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(jPanel3Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel11).addComponent(t_tipo_cliente,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        jPanel2.add(jPanel3, java.awt.BorderLayout.NORTH);

        jTabbedPane1.setBackground(new java.awt.Color(254, 254, 254));

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

        }, new String[] { "CLAVE", "GRUPO MECANICO", "REGISTRO" }) {
            Class[] types = new Class[] { java.lang.Integer.class, java.lang.String.class, java.lang.String.class };
            boolean[] canEdit = new boolean[] { false, false, false };

            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        tabla_especialidad.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(tabla_especialidad);

        jTabbedPane1.addTab("Especialidad", jScrollPane1);

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

        }, new String[] { "ID", "NOMBRE", "ESPECIALIDAD", "REGISTRO" }) {
            Class[] types = new Class[] { java.lang.Integer.class, java.lang.String.class, java.lang.Integer.class,
                    java.lang.String.class };
            boolean[] canEdit = new boolean[] { false, false, false, false };

            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        tabla_catalogo.getTableHeader().setReorderingAllowed(false);
        jScrollPane2.setViewportView(tabla_catalogo);

        jTabbedPane1.addTab("Catalogo", jScrollPane2);

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

        }, new String[] { "ID", "NOMBRE", "REGISTRO" }) {
            Class[] types = new Class[] { java.lang.String.class, java.lang.String.class, java.lang.String.class };
            boolean[] canEdit = new boolean[] { false, false, false };

            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        tabla_marca.getTableHeader().setReorderingAllowed(false);
        jScrollPane3.setViewportView(tabla_marca);

        jTabbedPane1.addTab("Marca", jScrollPane3);

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

        }, new String[] { "TIPO", "E. PESADO" }) {
            Class[] types = new Class[] { java.lang.String.class, java.lang.Integer.class };
            boolean[] canEdit = new boolean[] { false, false };

            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        tabla_tipo.getTableHeader().setReorderingAllowed(false);
        jScrollPane4.setViewportView(tabla_tipo);

        jTabbedPane1.addTab("Tipo", jScrollPane4);

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

        }, new String[] { "NO PARTE", "MARCA", "TIPO", "MODELO", "CATALOGO", "COMENTARIO", "REGISTRO" }) {
            Class[] types = new Class[] { java.lang.String.class, java.lang.String.class, java.lang.String.class,
                    java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class,
                    java.lang.String.class };
            boolean[] canEdit = new boolean[] { false, false, false, false, false, false, false };

            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        tabla_ejemplar.getTableHeader().setReorderingAllowed(false);
        jScrollPane5.setViewportView(tabla_ejemplar);

        jTabbedPane1.addTab("Ejemplar", jScrollPane5);

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

        }, new String[] { "ID", "NO", "#", "ESP HOJ", "ESP MEC", "ESP SUS", "ESP ELE", "DM", "CAM", "REP MIN",
                "REP MED", "REP MAX", "PIN", "CANT", "MED", "CATALOGO", "NO PARTE", "INCLUIDA", "ORI", "NAL",
                "DESM", "PD", "TOT", "I DESM", "I CAM", "I REP MIN", "I REP MED", "I REP MAX", "I PIN MIN",
                "I PIN MED", "I PIN MAX", "INSTRUCCION", "TIPO", "ENLAZADA", "A VAL", "C/U", "PORCENTAJE", "P CIA",
                "CANT AUT", "P AUT", "AUT", "HRS", "REF COTI", "REF COM", "SO", "PEDIDO", "ENTREGA", "ORDEN", "PCP",
                "REGISTRO" }) {
            Class[] types = new Class[] { java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class,
                    java.lang.Boolean.class, java.lang.Boolean.class, java.lang.Boolean.class,
                    java.lang.Boolean.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class,
                    java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class,
                    java.lang.String.class, java.lang.Integer.class, java.lang.String.class,
                    java.lang.Boolean.class, java.lang.Boolean.class, java.lang.Boolean.class,
                    java.lang.Boolean.class, java.lang.Boolean.class, java.lang.String.class,
                    java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class,
                    java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class,
                    java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Boolean.class,
                    java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class,
                    java.lang.Double.class, java.lang.Boolean.class, java.lang.Double.class,
                    java.lang.Boolean.class, java.lang.Boolean.class, java.lang.Boolean.class,
                    java.lang.String.class, java.lang.Object.class, java.lang.String.class, java.lang.Double.class,
                    java.lang.String.class };
            boolean[] canEdit = new boolean[] { false, false, false, false, false, false, false, false, false,
                    false, false, false, false, false, false, false, false, false, false, false, false, false,
                    false, false, false, false, false, false, false, false, false, false, false, false, false,
                    false, false, false, false, false, false, false, false, false, false, false, false, false,
                    false, false };

            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        tabla_partidas.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        tabla_partidas.getTableHeader().setReorderingAllowed(false);
        jScrollPane6.setViewportView(tabla_partidas);

        jTabbedPane1.addTab("Partidas", jScrollPane6);

        jPanel2.add(jTabbedPane1, java.awt.BorderLayout.CENTER);

        add(jPanel2, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents

    private void b_busca_ordenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_busca_ordenActionPerformed
        h = new Herramientas(usr, menu);
        h.session(sessionPrograma);
        aviso.setFileFilter(new ExtensionFileFilter("Excel document (*.xls)", new String[] { "xls" }));
        int resp = aviso.showOpenDialog(null);
        if (resp == aviso.APPROVE_OPTION) {
            File archivoXLS = aviso.getSelectedFile();
            if (archivoXLS.exists() == true) {
                t_archivo.setText(archivoXLS.getAbsolutePath());
                Session session = HibernateUtil.getSessionFactory().openSession();
                try {
                    FileInputStream archivo = new FileInputStream(archivoXLS);
                    POIFSFileSystem fsFileSystem = new POIFSFileSystem(archivo);
                    Workbook libro1 = new HSSFWorkbook(fsFileSystem);
                    Sheet especialidad = libro1.getSheetAt(0);
                    Sheet catalogo = libro1.getSheetAt(1);
                    Sheet marca = libro1.getSheetAt(2);
                    Sheet tipo = libro1.getSheetAt(3);
                    Sheet ejemplar = libro1.getSheetAt(4);
                    Sheet orden = libro1.getSheetAt(5);
                    Sheet partida = libro1.getSheetAt(6);
                    Sheet compania = libro1.getSheetAt(7);
                    Iterator rowIterator;
                    int r = 0;

                    //**********cargamos orden************************
                    rowIterator = orden.rowIterator();
                    r = 0;
                    while (rowIterator.hasNext()) {
                        HSSFRow renglon = (HSSFRow) rowIterator.next();
                        if (r > 0) {
                            this.t_orden.setText("" + ((int) renglon.getCell(0).getNumericCellValue()));//id_orden
                            this.t_aseguradora.setText("" + ((int) renglon.getCell(1).getNumericCellValue()));//compaia
                            this.t_poliza.setText(renglon.getCell(2).getStringCellValue());//poliza
                            this.t_siniestro.setText(renglon.getCell(3).getStringCellValue());//siniestro
                            this.t_inciso.setText(renglon.getCell(4).getStringCellValue());//inciso
                            this.t_reporte.setText(renglon.getCell(5).getStringCellValue());//no reporte
                            this.t_fecha.setText("" + renglon.getCell(6).getDateCellValue());//fecha
                            this.t_cliente.setText(renglon.getCell(7).getStringCellValue());//nombre
                            this.t_tipo_cliente.setText(renglon.getCell(8).getStringCellValue());//tipo cliente
                            this.t_marca.setText(renglon.getCell(9).getStringCellValue().toUpperCase());//marca
                            this.t_tipo.setText(renglon.getCell(10).getStringCellValue());//tipo
                            this.t_modelo.setText("" + ((int) renglon.getCell(11).getNumericCellValue()));//modelo
                        } else
                            r = 1;
                    }

                    //***********cargamos especialidades************************
                    rowIterator = especialidad.rowIterator();
                    r = 0;
                    DefaultTableModel t_e = (DefaultTableModel) tabla_especialidad.getModel();
                    t_e.getDataVector().removeAllElements();
                    while (rowIterator.hasNext()) {
                        HSSFRow renglon = (HSSFRow) rowIterator.next();
                        if (r > 0) {
                            Object[] row_e = new Object[3];
                            row_e[0] = (int) renglon.getCell(0).getNumericCellValue();
                            //if(renglon.getCell(1).getStringCellValue().compareTo("")!=0)
                            row_e[1] = renglon.getCell(1).getStringCellValue();
                            row_e[2] = renglon.getCell(2).getStringCellValue();
                            t_e.addRow(row_e);
                        } else
                            r = 1;
                    }

                    //***********cargamos catalogos************************
                    rowIterator = catalogo.rowIterator();
                    r = 0;
                    DefaultTableModel t_c = (DefaultTableModel) tabla_catalogo.getModel();
                    t_c.getDataVector().removeAllElements();
                    while (rowIterator.hasNext()) {
                        HSSFRow renglon = (HSSFRow) rowIterator.next();
                        if (r > 0) {
                            Object[] row_c = new Object[4];
                            row_c[0] = (int) renglon.getCell(0).getNumericCellValue();
                            //if(renglon.getCell(1).getStringCellValue().compareTo("")!=0)
                            row_c[1] = renglon.getCell(1).getStringCellValue();
                            row_c[2] = (int) renglon.getCell(2).getNumericCellValue();
                            row_c[3] = renglon.getCell(3).getStringCellValue();
                            t_c.addRow(row_c);
                        } else
                            r = 1;
                    }

                    //***********cargamos marcas************************
                    rowIterator = marca.rowIterator();
                    r = 0;
                    tabla_marca.removeAll();
                    DefaultTableModel t_m = (DefaultTableModel) tabla_marca.getModel();
                    t_m.getDataVector().removeAllElements();
                    while (rowIterator.hasNext()) {
                        HSSFRow renglon = (HSSFRow) rowIterator.next();
                        if (r > 0) {
                            Object[] row_m = new Object[3];
                            row_m[0] = renglon.getCell(0).getStringCellValue();
                            row_m[1] = renglon.getCell(1).getStringCellValue();
                            row_m[2] = renglon.getCell(2).getStringCellValue();
                            t_m.addRow(row_m);
                        } else
                            r = 1;
                    }

                    //**********cargamos tipos************************
                    rowIterator = tipo.rowIterator();
                    r = 0;
                    tabla_tipo.removeAll();
                    DefaultTableModel t_t = (DefaultTableModel) tabla_tipo.getModel();
                    t_t.getDataVector().removeAllElements();
                    while (rowIterator.hasNext()) {
                        HSSFRow renglon = (HSSFRow) rowIterator.next();
                        if (r > 0) {
                            Object[] row_t = new Object[3];
                            row_t[0] = renglon.getCell(0).getStringCellValue();
                            if (renglon.getCell(1)
                                    .getCellType() == org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC)
                                row_t[1] = (int) renglon.getCell(1).getNumericCellValue();
                            row_t[2] = renglon.getCell(2).getStringCellValue();
                            t_t.addRow(row_t);
                        } else
                            r = 1;
                    }

                    //**********cargamos ejemplares************************
                    rowIterator = ejemplar.rowIterator();
                    r = 0;
                    DefaultTableModel t_eje = (DefaultTableModel) tabla_ejemplar.getModel();
                    t_eje.getDataVector().removeAllElements();
                    while (rowIterator.hasNext()) {
                        HSSFRow renglon = (HSSFRow) rowIterator.next();
                        if (r > 0) {
                            Object[] row_eje = new Object[7];
                            row_eje[0] = renglon.getCell(0).getStringCellValue();
                            row_eje[1] = renglon.getCell(1).getStringCellValue();
                            row_eje[2] = renglon.getCell(2).getStringCellValue();
                            if (renglon.getCell(3)
                                    .getCellType() == org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC)
                                row_eje[3] = (int) renglon.getCell(3).getNumericCellValue();
                            else
                                row_eje[3] = renglon.getCell(3).getStringCellValue();
                            if (renglon.getCell(4)
                                    .getCellType() == org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC)
                                row_eje[4] = (int) renglon.getCell(4).getNumericCellValue();
                            else
                                row_eje[4] = renglon.getCell(4).getStringCellValue();
                            row_eje[5] = renglon.getCell(5).getStringCellValue();
                            row_eje[6] = renglon.getCell(6).getStringCellValue();
                            t_eje.addRow(row_eje);
                        } else
                            r = 1;
                    }

                    //**********cargamos partidas************************
                    rowIterator = partida.rowIterator();
                    r = 0;
                    DefaultTableModel t_p = (DefaultTableModel) tabla_partidas.getModel();
                    t_p.getDataVector().removeAllElements();
                    while (rowIterator.hasNext()) {
                        HSSFRow renglon = (HSSFRow) rowIterator.next();
                        if (r > 0) {
                            Object[] row_par = new Object[50];
                            row_par[0] = (int) renglon.getCell(0).getNumericCellValue();
                            row_par[1] = (int) renglon.getCell(1).getNumericCellValue();
                            row_par[2] = (int) renglon.getCell(2).getNumericCellValue();
                            row_par[3] = renglon.getCell(3).getBooleanCellValue();
                            row_par[4] = renglon.getCell(4).getBooleanCellValue();
                            row_par[5] = renglon.getCell(5).getBooleanCellValue();
                            row_par[6] = renglon.getCell(6).getBooleanCellValue();
                            row_par[7] = renglon.getCell(7).getNumericCellValue();
                            row_par[8] = renglon.getCell(8).getNumericCellValue();
                            row_par[9] = renglon.getCell(9).getNumericCellValue();
                            row_par[10] = renglon.getCell(10).getNumericCellValue();
                            row_par[11] = renglon.getCell(11).getNumericCellValue();
                            row_par[12] = renglon.getCell(12).getNumericCellValue();
                            row_par[13] = renglon.getCell(13).getNumericCellValue();
                            row_par[14] = renglon.getCell(14).getStringCellValue();
                            if (renglon.getCell(15)
                                    .getCellType() == org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC)
                                row_par[15] = (int) renglon.getCell(15).getNumericCellValue();
                            if (renglon.getCell(16).getStringCellValue().compareTo("") != 0)
                                row_par[16] = renglon.getCell(16).getStringCellValue();
                            row_par[17] = renglon.getCell(17).getBooleanCellValue();
                            row_par[18] = renglon.getCell(18).getBooleanCellValue();
                            row_par[19] = renglon.getCell(19).getBooleanCellValue();
                            row_par[20] = renglon.getCell(20).getBooleanCellValue();
                            row_par[21] = renglon.getCell(21).getBooleanCellValue();
                            if (renglon.getCell(22)
                                    .getCellType() == org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC)
                                row_par[22] = (int) renglon.getCell(22).getNumericCellValue();
                            row_par[23] = renglon.getCell(23).getNumericCellValue();
                            row_par[24] = renglon.getCell(24).getNumericCellValue();
                            row_par[25] = renglon.getCell(25).getNumericCellValue();
                            row_par[26] = renglon.getCell(26).getNumericCellValue();
                            row_par[27] = renglon.getCell(27).getNumericCellValue();
                            row_par[28] = renglon.getCell(28).getNumericCellValue();
                            row_par[29] = renglon.getCell(29).getNumericCellValue();
                            row_par[30] = renglon.getCell(30).getNumericCellValue();
                            row_par[31] = renglon.getCell(31).getStringCellValue();
                            row_par[32] = renglon.getCell(32).getStringCellValue();
                            if (renglon.getCell(33)
                                    .getCellType() == org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC)
                                row_par[33] = renglon.getCell(33).getNumericCellValue();
                            row_par[34] = renglon.getCell(34).getBooleanCellValue();
                            row_par[35] = renglon.getCell(35).getNumericCellValue();
                            row_par[36] = renglon.getCell(36).getNumericCellValue();
                            row_par[37] = renglon.getCell(37).getNumericCellValue();
                            row_par[38] = renglon.getCell(38).getNumericCellValue();
                            row_par[39] = renglon.getCell(39).getNumericCellValue();
                            row_par[40] = renglon.getCell(40).getBooleanCellValue();
                            row_par[41] = renglon.getCell(41).getNumericCellValue();
                            row_par[42] = renglon.getCell(42).getBooleanCellValue();
                            row_par[43] = renglon.getCell(43).getBooleanCellValue();
                            row_par[44] = renglon.getCell(44).getBooleanCellValue();
                            if (renglon.getCell(45)
                                    .getCellType() == org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC)
                                row_par[45] = (int) renglon.getCell(45).getNumericCellValue();
                            if (renglon.getCell(46)
                                    .getCellType() != org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING)
                                row_par[46] = renglon.getCell(46).getDateCellValue();
                            row_par[47] = (int) renglon.getCell(47).getNumericCellValue();
                            row_par[48] = renglon.getCell(48).getNumericCellValue();
                            row_par[49] = renglon.getCell(49).getStringCellValue();
                            t_p.addRow(row_par);
                        } else
                            r = 1;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(this, "No se pudo abrir el archivo");
                }
                if (session != null)
                    if (session.isOpen() == true)
                        session.close();
            }
        }
    }//GEN-LAST:event_b_busca_ordenActionPerformed

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

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

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

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

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

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

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

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

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

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

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

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        if (this.t_orden.getText().compareTo("") != 0) {
            Session session = HibernateUtil.getSessionFactory().openSession();
            try {
                Orden orden = (Orden) session.get(Orden.class, Integer.parseInt(t_orden.getText()));
                if (orden != null) {
                    if (orden.getPartidasForIdOrden().isEmpty() == true)//la orden no tiene partidas
                    {
                        for (int r = 0; r < tabla_partidas.getRowCount(); r++) {
                            Partida part = new Partida();
                            part.setOrdenByIdOrden(orden);
                            part.setIdEvaluacion((int) tabla_partidas.getValueAt(r, 1));
                            part.setSubPartida((int) tabla_partidas.getValueAt(r, 2));
                            part.setEspHoj((boolean) tabla_partidas.getValueAt(r, 3));
                            part.setEspMec((boolean) tabla_partidas.getValueAt(r, 4));
                            part.setEspSus((boolean) tabla_partidas.getValueAt(r, 5));
                            part.setEspEle((boolean) tabla_partidas.getValueAt(r, 6));
                            part.setDm((double) tabla_partidas.getValueAt(r, 7));
                            part.setCam((double) tabla_partidas.getValueAt(r, 8));
                            part.setRepMin((double) tabla_partidas.getValueAt(r, 9));
                            part.setRepMed((double) tabla_partidas.getValueAt(r, 10));
                            part.setRepMax((double) tabla_partidas.getValueAt(r, 11));
                            part.setPint((double) tabla_partidas.getValueAt(r, 12));
                            part.setCant((double) tabla_partidas.getValueAt(r, 13));
                            part.setMed((String) tabla_partidas.getValueAt(r, 14));
                            part.setFacturado(false);
                            part.setD(0.0);
                            part.setR(0.0);
                            part.setM(0.0);
                            List auxCat = buscaCatalogo("" + ((int) tabla_partidas.getValueAt(r, 15)));
                            Catalogo cat = (Catalogo) session.createCriteria(Catalogo.class)
                                    .add(Restrictions.eq("nombre", (String) auxCat.get(1))).setMaxResults(1)
                                    .uniqueResult();
                            if (cat != null) {
                                part.setCatalogo(cat);
                            } else {
                                Catalogo nuevo = new Catalogo();
                                List auxEsp = buscaEspecialidad(auxCat.get(2).toString());
                                Especialidad esp = (Especialidad) session.createCriteria(Especialidad.class)
                                        .add(Restrictions.eq("descripcion", (String) auxEsp.get(1)))
                                        .setMaxResults(1).uniqueResult();
                                if (esp != null) {
                                    nuevo.setEspecialidad(esp);
                                } else {
                                    Especialidad nEsp = new Especialidad();
                                    nEsp.setDescripcion((String) auxEsp.get(1));
                                    session.save(nEsp);
                                    nuevo.setEspecialidad(nEsp);
                                }
                                nuevo.setNombre((String) auxCat.get(1));
                                session.save(nuevo);
                                part.setCatalogo(nuevo);
                            }
                            if (tabla_partidas.getValueAt(r, 16) != null) {
                                Ejemplar eje = (Ejemplar) session.get(Ejemplar.class,
                                        Integer.parseInt(tabla_partidas.getValueAt(r, 16).toString()));
                                if (eje != null)
                                    part.setEjemplar(eje);//16
                            }
                            part.setIncluida((boolean) tabla_partidas.getValueAt(r, 17));
                            part.setOri((boolean) tabla_partidas.getValueAt(r, 18));
                            part.setNal((boolean) tabla_partidas.getValueAt(r, 19));
                            part.setDesm((boolean) tabla_partidas.getValueAt(r, 20));
                            part.setPd((boolean) tabla_partidas.getValueAt(r, 21));
                            if (tabla_partidas.getValueAt(r, 22) != null) {
                                Proveedor prov = (Proveedor) session.get(Proveedor.class,
                                        Integer.parseInt(tabla_partidas.getValueAt(r, 22).toString()));
                                part.setProveedor(prov);//22
                            }
                            part.setIntDesm((double) tabla_partidas.getValueAt(r, 23));
                            part.setIntCamb((double) tabla_partidas.getValueAt(r, 24));
                            part.setIntRepMin((double) tabla_partidas.getValueAt(r, 25));
                            part.setIntRepMed((double) tabla_partidas.getValueAt(r, 26));
                            part.setIntRepMax((double) tabla_partidas.getValueAt(r, 27));
                            part.setIntPinMin((double) tabla_partidas.getValueAt(r, 28));
                            part.setIntPinMed((double) tabla_partidas.getValueAt(r, 29));
                            part.setIntPinMax((double) tabla_partidas.getValueAt(r, 30));
                            part.setInstruccion((String) tabla_partidas.getValueAt(r, 31));
                            part.setTipo((String) tabla_partidas.getValueAt(r, 32));
                            if (tabla_partidas.getValueAt(r, 33) != null) {
                                Orden enlazada = (Orden) session.get(Orden.class,
                                        Integer.parseInt(tabla_partidas.getValueAt(r, 33).toString()));
                                part.setOrdenByEnlazada(enlazada);
                            }
                            part.setAutorizadoValuacion((boolean) tabla_partidas.getValueAt(r, 34));//34
                            part.setCU((double) tabla_partidas.getValueAt(r, 35));//35
                            part.setPorcentaje((double) tabla_partidas.getValueAt(r, 36));//36
                            part.setPrecioCiaSegurosCU((double) tabla_partidas.getValueAt(r, 37));//37
                            part.setCantidadAut((double) tabla_partidas.getValueAt(r, 38));//38
                            part.setPrecioAutCU((double) tabla_partidas.getValueAt(r, 39));//39
                            part.setAutorizado((boolean) tabla_partidas.getValueAt(r, 40));//40
                            //part.setHoras();//41
                            part.setRefCoti((boolean) tabla_partidas.getValueAt(r, 42));//42
                            part.setRefComp((boolean) tabla_partidas.getValueAt(r, 43));//43
                            part.setSo((boolean) tabla_partidas.getValueAt(r, 44));//44
                            part.setCantPcp(0.0);
                            if (tabla_partidas.getValueAt(r, 45) != null) {
                                Pedido ped = (Pedido) session.get(Pedido.class,
                                        Integer.parseInt(tabla_partidas.getValueAt(r, 45).toString()));
                                part.setPedido(ped);//45
                            }
                            if (tabla_partidas.getValueAt(r, 46) != null) {
                                SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
                                Date date = formatter.parse(tabla_partidas.getValueAt(r, 46).toString());
                                part.setPlazo(date);//46
                            }
                            if (tabla_partidas.getValueAt(r, 47) != null) {
                                if (t_orden.getText().compareTo(tabla_partidas.getValueAt(r, 47).toString()) != 0) {
                                    Orden enlaza = (Orden) session.get(Orden.class,
                                            Integer.parseInt(tabla_partidas.getValueAt(r, 47).toString()));
                                    part.setOrdenByEnlazada(enlaza);
                                }
                            }
                            if (tabla_partidas.getValueAt(r, 48) != null) {
                                part.setCantPcp((double) tabla_partidas.getValueAt(r, 48));//48
                            }
                            session.saveOrUpdate(part);
                            session.beginTransaction().commit();
                        }
                        JOptionPane.showMessageDialog(this, "Listo");
                    } else {
                        JOptionPane.showMessageDialog(this,
                                "La orden ya tiene partidas necesita eliminarlas primero");
                    }
                } else
                    JOptionPane.showMessageDialog(this, "La orden no existe");
            } catch (Exception e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(this, "No se pudo abrir el archivo");
            }
            if (session != null)
                if (session.isOpen() == true)
                    session.close();
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JFileChooser aviso;
    public javax.swing.JButton b_busca_orden;
    private javax.swing.JButton jButton1;
    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 jLabel2;
    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.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField t_archivo;
    public javax.swing.JTextField t_aseguradora;
    public javax.swing.JTextField t_cliente;
    public javax.swing.JTextField t_fecha;
    public javax.swing.JTextField t_inciso;
    public javax.swing.JTextField t_marca;
    public javax.swing.JTextField t_modelo;
    public javax.swing.JTextField t_orden;
    public javax.swing.JTextField t_poliza;
    public javax.swing.JTextField t_reporte;
    public javax.swing.JTextField t_siniestro;
    public javax.swing.JTextField t_tipo;
    public javax.swing.JTextField t_tipo_cliente;
    private javax.swing.JTable tabla_catalogo;
    private javax.swing.JTable tabla_ejemplar;
    private javax.swing.JTable tabla_especialidad;
    private javax.swing.JTable tabla_marca;
    private javax.swing.JTable tabla_partidas;
    private javax.swing.JTable tabla_tipo;
    // End of variables declaration//GEN-END:variables

    public List buscaCatalogo(String busca) {
        List aux = new ArrayList();
        for (int x = 0; x <= tabla_catalogo.getRowCount(); x++) {
            if (tabla_catalogo.getValueAt(x, 0).toString().compareTo(busca) == 0) {
                aux.add(tabla_catalogo.getValueAt(x, 0).toString());
                aux.add(tabla_catalogo.getValueAt(x, 1).toString());
                aux.add(tabla_catalogo.getValueAt(x, 2).toString());
                aux.add(tabla_catalogo.getValueAt(x, 3).toString());
                x = tabla_catalogo.getRowCount();
            }
        }
        return aux;
    }

    public List buscaEspecialidad(String busca) {
        List aux = new ArrayList();
        for (int x = 0; x <= tabla_especialidad.getRowCount(); x++) {
            if (tabla_especialidad.getValueAt(x, 0).toString().compareTo(busca) == 0) {
                aux.add(tabla_especialidad.getValueAt(x, 0).toString());
                aux.add(tabla_especialidad.getValueAt(x, 1).toString());
                aux.add(tabla_especialidad.getValueAt(x, 2).toString());
                x = tabla_especialidad.getRowCount();
            }
        }
        return aux;
    }
}