com.proyecto.vista.MantenimientoInventario.java Source code

Java tutorial

Introduction

Here is the source code for com.proyecto.vista.MantenimientoInventario.java

Source

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

import com.proyecto.beans.Ambiente;
import com.proyecto.beans.Bien;
import com.proyecto.beans.DetalleBienCampo;
import com.proyecto.beans.Factura;
import com.proyecto.beans.Inventario;
import com.proyecto.beans.Periodo;
import com.proyecto.beans.Proveedor;
import com.proyecto.control.Controlador;
import com.proyecto.control.BienControlador;
import com.proyecto.control.DetalleBienCampoControlador;
import com.proyecto.control.InventarioControlador;
import com.proyecto.control.PeriodoControlador;
import java.awt.Image;
import java.awt.event.KeyEvent;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.SpinnerNumberModel;
import org.apache.commons.beanutils.BeanUtils;
import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.BeanProperty;
import org.jdesktop.observablecollections.ObservableCollections;
import org.jdesktop.swingbinding.JTableBinding;
import org.jdesktop.swingbinding.SwingBindings;

/**
 *
 * @author Documentos
 */
public class MantenimientoInventario extends javax.swing.JInternalFrame {

    /**
     * Creates new form MantenimientoInventario
     */
    private static MantenimientoInventario instancia;

    public MantenimientoInventario() {
        initComponents();
        cargarCombos();
        listar();

        FormularioUtil.activarComponente(panelDatos, true);
        FormularioUtil.activarComponente(panelFoto, true);
        FormularioUtil.activarComponente(panelDatosB, true);
    }

    public static MantenimientoInventario getInstancia() {
        if (instancia == null) {
            instancia = new MantenimientoInventario();
        }
        return instancia;
    }

    private List<Inventario> lista = new ArrayList();
    private final BienControlador bienControlador = new BienControlador();
    private final InventarioControlador inventarioControlador = new InventarioControlador();
    private Bien bien;

    /**
     * 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() {
        java.awt.GridBagConstraints gridBagConstraints;

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtBuscar = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        panelDatosB = new javax.swing.JPanel();
        nombreField = new javax.swing.JTextField();
        idLabel1 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblDetalle = new javax.swing.JTable();
        jLabel11 = new javax.swing.JLabel();
        panelDatos = new javax.swing.JPanel();
        nombreLabel1 = new javax.swing.JLabel();
        cmbEstado = new javax.swing.JComboBox();
        spnPrecio = new javax.swing.JSpinner();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        serieField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        proveedorField = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        facturaField = new javax.swing.JTextField();
        jButton6 = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        codFabField = new javax.swing.JTextField();
        chckBaja = new javax.swing.JCheckBox();
        jLabel15 = new javax.swing.JLabel();
        jDateIngreso = new com.toedter.calendar.JDateChooser();
        cmbPeriodo1 = new javax.swing.JComboBox();
        nombreLabel3 = new javax.swing.JLabel();
        chckImpresion = new javax.swing.JCheckBox();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        ambienteField = new javax.swing.JTextField();
        jButton10 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        descripcionField1 = new javax.swing.JTextArea();
        jLabel16 = new javax.swing.JLabel();
        panelFoto = new javax.swing.JPanel();
        lblFoto = new javax.swing.JLabel();
        panelGuardar = new javax.swing.JPanel();
        btnguardar = new javax.swing.JButton();
        btncancelar = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        cmbPeriodo = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        jdateInicio = new com.toedter.calendar.JDateChooser();
        jDateFin = new com.toedter.calendar.JDateChooser();
        jLabel7 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblInventario = new javax.swing.JTable();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        btnPrimero = new javax.swing.JButton();
        btnAnterior = new javax.swing.JButton();
        spPagina = new javax.swing.JSpinner();
        txtTotal = new javax.swing.JTextField();
        btnSiguiente = new javax.swing.JButton();
        btnUltimo = new javax.swing.JButton();
        cboTamanio = new javax.swing.JComboBox();

        setClosable(true);
        setTitle("Mantenimiento Inventario");

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel1.setText("Buscar Serie ");

        txtBuscar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtBuscarKeyPressed(evt);
            }
        });

        jButton3.setIcon(new javax.swing.ImageIcon("img/iconos/Search.png"));
        jButton3.setText("Buscar");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        panelDatosB.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos del bien",
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 10))); // NOI18N
        panelDatosB.setToolTipText("");

        idLabel1.setText("Nombre");

        tblDetalle
                .setModel(new javax.swing.table.DefaultTableModel(
                        new Object[][] { { null, null, null, null }, { null, null, null, null },
                                { null, null, null, null }, { null, null, null, null } },
                        new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
        jScrollPane3.setViewportView(tblDetalle);

        jLabel11.setText("Caracteristicas:");

        javax.swing.GroupLayout panelDatosBLayout = new javax.swing.GroupLayout(panelDatosB);
        panelDatosB.setLayout(panelDatosBLayout);
        panelDatosBLayout.setHorizontalGroup(panelDatosBLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelDatosBLayout.createSequentialGroup().addContainerGap()
                        .addGroup(panelDatosBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                                .addGroup(panelDatosBLayout.createSequentialGroup()
                                        .addGroup(panelDatosBLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel11).addComponent(idLabel1))
                                        .addGap(0, 193, Short.MAX_VALUE))
                                .addComponent(nombreField))
                        .addContainerGap()));
        panelDatosBLayout.setVerticalGroup(panelDatosBLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelDatosBLayout.createSequentialGroup().addComponent(idLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(nombreField, 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(jLabel11).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap()));

        panelDatos.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos del Inventario",
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 10))); // NOI18N

        nombreLabel1.setText("Estado");

        cmbEstado.setEditable(true);
        cmbEstado.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbEstado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbEstadoActionPerformed(evt);
            }
        });

        spnPrecio.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(0.0d), Double.valueOf(0.0d), null,
                Double.valueOf(1.0d)));

        jLabel5.setText("Precio");

        jLabel6.setText("Serie");

        serieField.setEditable(false);

        jLabel3.setText("Ambiente");

        jLabel9.setText("Proveedor");

        jButton2.setIcon(new javax.swing.ImageIcon("img/iconos/Search.png"));
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel12.setText("Factura");

        jButton6.setIcon(new javax.swing.ImageIcon("img/iconos/Search.png"));
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jLabel14.setText("Codigo Fbrica");

        chckBaja.setText("Baja");

        jLabel15.setText("Fecha Ingreso");

        cmbPeriodo1.setEditable(true);
        cmbPeriodo1.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbPeriodo1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cmbPeriodo1ItemStateChanged(evt);
            }
        });
        cmbPeriodo1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cmbPeriodo1KeyPressed(evt);
            }
        });

        nombreLabel3.setText("Periodo");

        chckImpresion.setText("Impresin pendiente?");

        jButton7.setIcon(new javax.swing.ImageIcon("img/iconos/clear.png"));
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jButton8.setIcon(new javax.swing.ImageIcon("img/iconos/clear.png"));
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jButton10.setIcon(new javax.swing.ImageIcon("img/iconos/clear.png"));
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        jButton11.setIcon(new javax.swing.ImageIcon("img/iconos/Search.png"));
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        descripcionField1.setColumns(20);
        descripcionField1.setRows(5);
        jScrollPane4.setViewportView(descripcionField1);

        jLabel16.setText("Observacin");

        javax.swing.GroupLayout panelDatosLayout = new javax.swing.GroupLayout(panelDatos);
        panelDatos.setLayout(panelDatosLayout);
        panelDatosLayout.setHorizontalGroup(panelDatosLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelDatosLayout.createSequentialGroup().addGap(130, 130, 130).addComponent(chckBaja)
                        .addGap(226, 226, 226))
                .addGroup(panelDatosLayout.createSequentialGroup().addContainerGap()
                        .addGroup(panelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(panelDatosLayout.createSequentialGroup()
                                        .addGroup(panelDatosLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(
                                                        jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(
                                                        nombreLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 54,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGroup(panelDatosLayout.createSequentialGroup().addGroup(panelDatosLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(panelDatosLayout.createSequentialGroup().addGroup(panelDatosLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel14)
                                                .addGroup(panelDatosLayout.createParallelGroup(
                                                        javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                        .addComponent(jLabel12,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE)
                                                        .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                75, Short.MAX_VALUE)
                                                        .addComponent(
                                                                jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE))
                                                .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 79,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addGroup(panelDatosLayout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                                panelDatosLayout.createSequentialGroup()
                                                                        .addComponent(jButton2,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                47,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addPreferredGap(
                                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                        .addComponent(jButton7))
                                                        .addGroup(panelDatosLayout
                                                                .createSequentialGroup()
                                                                .addComponent(jButton11,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 47,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(jButton10))))
                                        .addGroup(panelDatosLayout.createSequentialGroup().addGroup(panelDatosLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel15).addComponent(nombreLabel3))
                                                .addGap(28, 28, 28)
                                                .addGroup(panelDatosLayout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addGroup(panelDatosLayout.createSequentialGroup()
                                                                .addGroup(panelDatosLayout.createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                        .addComponent(codFabField,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                170,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addComponent(serieField,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                170,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addComponent(ambienteField,
                                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                214, Short.MAX_VALUE)
                                                                        .addComponent(proveedorField)
                                                                        .addComponent(facturaField))
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(
                                                                        jButton6,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 47,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(jButton8))
                                                        .addComponent(jScrollPane4)
                                                        .addGroup(panelDatosLayout.createSequentialGroup()
                                                                .addGroup(panelDatosLayout.createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                        .addComponent(cmbPeriodo1,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                117,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addComponent(jDateIngreso,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                130,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addComponent(spnPrecio,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                94,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addComponent(cmbEstado,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                170,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                                                .addGap(0, 0, Short.MAX_VALUE)))))
                                        .addContainerGap())
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                        panelDatosLayout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                                .addComponent(chckImpresion)))));
        panelDatosLayout.setVerticalGroup(panelDatosLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelDatosLayout.createSequentialGroup()
                        .addGroup(panelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(cmbPeriodo1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(nombreLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(nombreLabel1)
                                .addComponent(cmbEstado, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel5).addComponent(spnPrecio,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel6).addComponent(serieField,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel14)
                                .addComponent(codFabField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jButton10)
                                .addGroup(panelDatosLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel3).addComponent(ambienteField,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jButton11))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(panelDatosLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel9).addComponent(proveedorField,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jButton2).addComponent(jButton7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jButton6)
                                .addGroup(panelDatosLayout.createSequentialGroup().addGroup(panelDatosLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(panelDatosLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel12).addComponent(facturaField,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(jButton8))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(panelDatosLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel15).addComponent(jDateIngreso,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(panelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel16)
                                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 85,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(panelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(chckBaja).addComponent(chckImpresion))));

        panelFoto.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Foto",
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 10))); // NOI18N

        javax.swing.GroupLayout panelFotoLayout = new javax.swing.GroupLayout(panelFoto);
        panelFoto.setLayout(panelFotoLayout);
        panelFotoLayout.setHorizontalGroup(panelFotoLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelFotoLayout.createSequentialGroup().addContainerGap().addComponent(lblFoto,
                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap()));
        panelFotoLayout.setVerticalGroup(
                panelFotoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(lblFoto,
                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE));

        panelGuardar.setBorder(javax.swing.BorderFactory.createTitledBorder("Acciones"));

        btnguardar.setIcon(new javax.swing.ImageIcon("img/iconos/Save.png"));
        btnguardar.setText("Guardar");
        btnguardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnguardarActionPerformed(evt);
            }
        });

        btncancelar.setIcon(new javax.swing.ImageIcon("img/iconos/Delete.png"));
        btncancelar.setText("Cancelar");
        btncancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btncancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelGuardarLayout = new javax.swing.GroupLayout(panelGuardar);
        panelGuardar.setLayout(panelGuardarLayout);
        panelGuardarLayout
                .setHorizontalGroup(
                        panelGuardarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(panelGuardarLayout.createSequentialGroup().addContainerGap()
                                        .addComponent(btnguardar, javax.swing.GroupLayout.PREFERRED_SIZE, 99,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(btncancelar, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addContainerGap()));
        panelGuardarLayout.setVerticalGroup(panelGuardarLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelGuardarLayout.createSequentialGroup().addContainerGap()
                        .addGroup(panelGuardarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(btnguardar).addComponent(btncancelar))
                        .addContainerGap(13, Short.MAX_VALUE)));

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(jPanel4Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(panelDatosB, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap()
                                        .addComponent(jLabel1).addGap(18, 18, 18).addComponent(txtBuscar))
                                .addComponent(panelFoto, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(panelDatos, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(panelGuardar, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButton3, javax.swing.GroupLayout.Alignment.LEADING))));
        jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup().addGroup(jPanel4Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER).addComponent(jButton3)
                        .addComponent(txtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel1)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addComponent(panelDatos, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(panelGuardar, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(0, 0, Short.MAX_VALUE))
                                .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addComponent(panelDatosB, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(panelFoto, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addContainerGap()));

        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()
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(35, Short.MAX_VALUE)));

        jTabbedPane1.addTab("Mantenimiento", jPanel3);

        jLabel2.setText("Periodo");

        cmbPeriodo.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbPeriodo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbPeriodoActionPerformed(evt);
            }
        });
        cmbPeriodo.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                cmbPeriodoPropertyChange(evt);
            }
        });

        jLabel8.setText("Rango de Fechas");

        jLabel7.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
        jLabel7.setText("-");

        jButton1.setIcon(new javax.swing.ImageIcon("img/iconos/Search.png"));
        jButton1.setText("Buscar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        tblInventario
                .setModel(new javax.swing.table.DefaultTableModel(
                        new Object[][] { { null, null, null, null }, { null, null, null, null },
                                { null, null, null, null }, { null, null, null, null } },
                        new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
        tblInventario.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                tblInventarioMouseReleased(evt);
            }
        });
        jScrollPane1.setViewportView(tblInventario);

        jPanel1.setLayout(new java.awt.GridBagLayout());

        jPanel2.setLayout(new java.awt.GridLayout(1, 0));

        btnPrimero.setText("<<");
        btnPrimero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPrimeroActionPerformed(evt);
            }
        });
        jPanel2.add(btnPrimero);

        btnAnterior.setText("<");
        btnAnterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAnteriorActionPerformed(evt);
            }
        });
        jPanel2.add(btnAnterior);

        spPagina.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null,
                Integer.valueOf(1)));
        spPagina.setMinimumSize(new java.awt.Dimension(60, 20));
        spPagina.setPreferredSize(new java.awt.Dimension(60, 20));
        spPagina.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                spPaginaStateChanged(evt);
            }
        });
        jPanel2.add(spPagina);

        txtTotal.setEditable(false);
        txtTotal.setColumns(3);
        txtTotal.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtTotal.setText("1");
        jPanel2.add(txtTotal);

        btnSiguiente.setText(">");
        btnSiguiente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSiguienteActionPerformed(evt);
            }
        });
        jPanel2.add(btnSiguiente);

        btnUltimo.setText(">>");
        btnUltimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUltimoActionPerformed(evt);
            }
        });
        jPanel2.add(btnUltimo);

        cboTamanio.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "5", "10", "15", "20", "25", "40", "50" }));
        cboTamanio.setMinimumSize(new java.awt.Dimension(53, 24));
        cboTamanio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboTamanioActionPerformed(evt);
            }
        });
        jPanel2.add(cboTamanio);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        jPanel1.add(jPanel2, gridBagConstraints);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout
                .setHorizontalGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel6Layout.createSequentialGroup().addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cmbPeriodo, javax.swing.GroupLayout.PREFERRED_SIZE, 130,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel6Layout.createSequentialGroup()
                                .addGroup(jPanel6Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel6Layout.createSequentialGroup().addComponent(jLabel8)
                                                .addGap(18, 18, 18)
                                                .addComponent(jdateInicio, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        130, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 12,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jDateFin, javax.swing.GroupLayout.PREFERRED_SIZE, 130,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(18, 18, 18)
                                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 97,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(0, 252, Short.MAX_VALUE))
                                        .addGroup(jPanel6Layout.createSequentialGroup().addContainerGap()
                                                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 790,
                                                        Short.MAX_VALUE)))
                                .addContainerGap()));
        jPanel6Layout.setVerticalGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel6Layout.createSequentialGroup().addGroup(jPanel6Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel2)
                        .addComponent(cmbPeriodo, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(
                                jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jDateFin, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jdateInicio, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 344,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE)));

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout
                .setHorizontalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                jPanel5Layout.createSequentialGroup().addContainerGap()
                                        .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addContainerGap()));
        jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap().addComponent(jPanel6,
                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE)));

        jTabbedPane1.addTab("Bsqueda por parmetros", jPanel5);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jTabbedPane1));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                javax.swing.GroupLayout.PREFERRED_SIZE));

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

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        //        Periodo periodo = (Periodo) cmbPeriodo.getSelectedItem();
        Date inicio = jdateInicio.getDate();
        Date fin = jDateFin.getDate();

        Calendar cal = Calendar.getInstance();

        if (inicio == null) {
            cal.set(cal.get(Calendar.YEAR), cal.getActualMinimum(Calendar.MONTH),
                    cal.getActualMinimum(Calendar.DAY_OF_MONTH));
            Date ini = cal.getTime();
            jdateInicio.setDate(ini);
        }
        if (fin == null) {
            cal.set(cal.get(Calendar.YEAR), cal.getActualMaximum(Calendar.MONTH),
                    cal.getActualMaximum(Calendar.DAY_OF_MONTH));

            Date finals = cal.getTime();

            jDateFin.setDate(finals);
        }

        //        System.out.println("DATE 1: "+ jdateInicio.getDate());
        //        System.out.println("DATE 2: "+ jDateFin.getDate());
        paginaActual = 1;
        buscar();
        actualizarControlesNavegacion();
    }//GEN-LAST:event_jButton1ActionPerformed

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

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

    private void spPaginaStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spPaginaStateChanged
        // TODO add your handling code here:
        this.seleccionPagina();
    }//GEN-LAST:event_spPaginaStateChanged

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

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

    private void cboTamanioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboTamanioActionPerformed
        // TODO add your handling code here:
        this.paginaActual = 1;
        buscar();
        this.actualizarControlesNavegacion();
    }//GEN-LAST:event_cboTamanioActionPerformed

    private void tblInventarioMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblInventarioMouseReleased
        // TODO add your handling code here:
    }//GEN-LAST:event_tblInventarioMouseReleased

    private void cmbPeriodoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbPeriodoActionPerformed
        // TODO add your handling code here:

    }//GEN-LAST:event_cmbPeriodoActionPerformed

    private void txtBuscarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtBuscarKeyPressed
        // TODO add your handling code here:
        int code = evt.getKeyCode();
        if (!(txtBuscar.getText().equals("")) && code == KeyEvent.VK_ENTER) {
            buscarInventario();
        }

    }//GEN-LAST:event_txtBuscarKeyPressed

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

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

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        DlgProveedorBusqueda proveedorDialogo = new DlgProveedorBusqueda(this);

        //        if (inventarioControlador.getSeleccionado() == null) {
        //            Inventario contratoProv = new Inventario();
        //            inventarioControlador.setSeleccionado(contratoProv);
        //        }
        inventarioControlador.getSeleccionado().setProveedor(proveedorDialogo.getProveedor());
        if (inventarioControlador.getSeleccionado().getProveedor() != null) {
            this.proveedorField.setText(
                    this.inventarioControlador.getSeleccionado().getProveedor().getNombreProveedor().toUpperCase());
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:

        DlgFactura facturaDialogo = new DlgFactura(this);
        //
        //        if (inventarioControlador.getSeleccionado() == null) {
        //            Inventario contratoProv = new Inventario();
        //            inventarioControlador.setSeleccionado(contratoProv);
        //        }

        if (accion == 2) {
            //            facturaDialogo.setFacturas(factura);
        }

        this.inventarioControlador.getSeleccionado().setFactura(facturaDialogo.getFactura());

        this.facturaField.setText(
                this.inventarioControlador.getSeleccionado().getFactura().getNumeroFactura().toUpperCase());
    }//GEN-LAST:event_jButton6ActionPerformed

    private void cmbPeriodo1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmbPeriodo1ItemStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_cmbPeriodo1ItemStateChanged

    private void cmbPeriodo1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbPeriodo1KeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_cmbPeriodo1KeyPressed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
        proveedorField.setText(null);
        inventarioControlador.getSeleccionado().setProveedor(null);
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:
        facturaField.setText(null);
        inventarioControlador.getSeleccionado().setFactura(null);
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        // TODO add your handling code here:
        ambienteField.setText(null);
        inventarioControlador.getSeleccionado().setAmbiente(null);
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        // TODO add your handling code here:
        DlgAmbienteBusqueda ambienteDialog = new DlgAmbienteBusqueda(this);

        inventarioControlador.getSeleccionado().setAmbiente(ambienteDialog.getAmbiente());

        if (inventarioControlador.getSeleccionado().getAmbiente() != null) {
            ambienteField.setText(inventarioControlador.getSeleccionado().getAmbiente().toString());
        }
    }//GEN-LAST:event_jButton11ActionPerformed

    private void cmbPeriodoPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_cmbPeriodoPropertyChange
        // TODO add your handling code here:
        flag = 1;
        buscar();
    }//GEN-LAST:event_cmbPeriodoPropertyChange

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

    private void btncancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btncancelarActionPerformed
        // TODO add your handling code here:
        FormularioUtil.activarComponente(panelDatosB, false);
        FormularioUtil.limpiarComponente(panelDatosB);
        FormularioUtil.limpiarComponente(panelDatos);
        FormularioUtil.limpiarComponente(panelFoto);
        //        FormularioUtil.activarComponente(panelOpciones, true);
        //        FormularioUtil.activarComponente(panelGuardar, false);
        FormularioUtil.activarComponente(panelDatos, false);
        FormularioUtil.activarComponente(panelDatosB, false);
        FormularioUtil.activarComponente(panelFoto, false);
        spnPrecio.setValue(0);
        //        descripcionField.setText(null);
        lblFoto.setIcon(null);
        //        lblStock.setText(null);
        //        lblbuscar.setText(null);
        chckBaja.setSelected(false);
        chckImpresion.setSelected(false);
        listaDetalle.clear();
        this.txtBuscar.requestFocusInWindow();
    }//GEN-LAST:event_btncancelarActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField ambienteField;
    private javax.swing.JButton btnAnterior;
    private javax.swing.JButton btnPrimero;
    private javax.swing.JButton btnSiguiente;
    private javax.swing.JButton btnUltimo;
    private javax.swing.JButton btncancelar;
    private javax.swing.JButton btnguardar;
    private javax.swing.JComboBox cboTamanio;
    private javax.swing.JCheckBox chckBaja;
    private javax.swing.JCheckBox chckImpresion;
    private javax.swing.JComboBox cmbEstado;
    private javax.swing.JComboBox cmbPeriodo;
    private javax.swing.JComboBox cmbPeriodo1;
    private javax.swing.JTextField codFabField;
    private javax.swing.JTextArea descripcionField1;
    private javax.swing.JTextField facturaField;
    private javax.swing.JLabel idLabel1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private com.toedter.calendar.JDateChooser jDateFin;
    private com.toedter.calendar.JDateChooser jDateIngreso;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    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.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private com.toedter.calendar.JDateChooser jdateInicio;
    private javax.swing.JLabel lblFoto;
    private javax.swing.JTextField nombreField;
    private javax.swing.JLabel nombreLabel1;
    private javax.swing.JLabel nombreLabel3;
    private javax.swing.JPanel panelDatos;
    private javax.swing.JPanel panelDatosB;
    private javax.swing.JPanel panelFoto;
    private javax.swing.JPanel panelGuardar;
    private javax.swing.JTextField proveedorField;
    private javax.swing.JTextField serieField;
    private javax.swing.JSpinner spPagina;
    private javax.swing.JSpinner spnPrecio;
    private javax.swing.JTable tblDetalle;
    private javax.swing.JTable tblInventario;
    private javax.swing.JTextField txtBuscar;
    private javax.swing.JTextField txtTotal;
    // End of variables declaration//GEN-END:variables

    int accion;

    private void listar() {

        lista = ObservableCollections.observableList(lista);

        JTableBinding binding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, lista,
                tblInventario);

        BeanProperty bBienId = BeanProperty.create("bien");
        BeanProperty bSerie = BeanProperty.create("serie");
        BeanProperty bAmbienteId = BeanProperty.create("ambiente");
        BeanProperty bPeriodoId = BeanProperty.create("periodo");
        BeanProperty bBaja = BeanProperty.create("baja");

        binding.addColumnBinding(bBienId).setColumnName("BIEN").setEditable(false);
        binding.addColumnBinding(bSerie).setColumnName("SERIE").setEditable(false);
        binding.addColumnBinding(bAmbienteId).setColumnName("AMBIENTE").setEditable(false);
        binding.addColumnBinding(bPeriodoId).setColumnName("PERIODO").setEditable(false);
        binding.addColumnBinding(bBaja).setColumnName("BAJA").setEditable(false).setColumnClass(Boolean.class);

        binding.bind();

    }

    private void listarCampos() {
        listaDetalle = ObservableCollections.observableList(listaDetalle);

        JTableBinding binding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, listaDetalle,
                tblDetalle);

        BeanProperty bId = BeanProperty.create("campo");
        BeanProperty bValor = BeanProperty.create("valor");

        binding.addColumnBinding(bId).setColumnName("CAMPO").setEditable(false);
        binding.addColumnBinding(bValor).setColumnName("VALOR").setEditable(false);

        binding.bind();

    }

    private void cargarComboPeriodo() {
        PeriodoControlador periodoControlador = new PeriodoControlador();
        List<Periodo> periodos = periodoControlador.buscarTodos();
        cmbPeriodo1.setModel(new DefaultComboBoxModel(periodos.toArray()));
    }

    private void cargarComboPeriodo1() {
        PeriodoControlador periodoControlador = new PeriodoControlador();
        List<Periodo> periodos = periodoControlador.buscarTodos();
        cmbPeriodo.setModel(new DefaultComboBoxModel(periodos.toArray()));
    }

    /*
     PARA TRABAJAR LAZY MODEL
     */
    private int paginaActual = 1;
    private int totalPaginas = 0;
    private int tamanioPagina = 0;

    private int flag = 0;

    private void buscar() {
        Date inicio = jdateInicio.getDate();
        Date fin = jDateFin.getDate();
        Periodo periodos = (Periodo) cmbPeriodo.getSelectedItem();

        tamanioPagina = Integer.parseInt(cboTamanio.getSelectedItem().toString());

        lista.clear();
        if (flag == 0) {
            lista.addAll(this.listar(inicio, fin, paginaActual, tamanioPagina));
        } else if (flag == 1) {
            lista.addAll(this.listarPeriodo(periodos, paginaActual, tamanioPagina));
            flag = 0;
        }

    }

    private List<Inventario> listar(Date inicio, Date fin, int pagina, int tamanio) {
        int total = this.inventarioControlador.totalXFechas(inicio, fin);
        if (total % tamanio == 0) {
            totalPaginas = total / tamanio;
        } else {
            totalPaginas = (total / tamanio) + 1;
        }
        return this.inventarioControlador.buscarLazyXFechas(inicio, fin, (pagina - 1) * tamanio, tamanio);

    }

    private List<Inventario> listarPeriodo(Periodo periodo, int pagina, int tamanio) {
        int total = this.inventarioControlador.totalXFechasPeriodo(periodo);
        if (total % tamanio == 0) {
            totalPaginas = total / tamanio;
        } else {
            totalPaginas = (total / tamanio) + 1;
        }
        return this.inventarioControlador.buscarLazyXFechasPeriodo(periodo, (pagina - 1) * tamanio, tamanio);

    }

    private void siguiente() {
        paginaActual++;
        buscar();
        this.actualizarControlesNavegacion();
    }

    private void ultimo() {
        paginaActual = totalPaginas;
        buscar();
        this.actualizarControlesNavegacion();
    }

    private void primero() {
        paginaActual = 1;
        buscar();
        this.actualizarControlesNavegacion();
    }

    private void anterior() {
        paginaActual--;
        buscar();
        this.actualizarControlesNavegacion();
    }

    private void seleccionPagina() {
        paginaActual = (int) spPagina.getValue();
        buscar();
        this.actualizarControlesNavegacion();
    }

    private void actualizarControlesNavegacion() {
        spPagina.setValue(paginaActual);
        txtTotal.setText(totalPaginas + "");

        SpinnerNumberModel modeloSP = (SpinnerNumberModel) spPagina.getModel();
        Comparable<Integer> maximo = totalPaginas;
        modeloSP.setMaximum(maximo);

        this.btnSiguiente.setEnabled(paginaActual != totalPaginas);
        this.btnUltimo.setEnabled(paginaActual != totalPaginas);

        this.btnAnterior.setEnabled(paginaActual != 1);
        this.btnPrimero.setEnabled(paginaActual != 1);
    }

    private List<DetalleBienCampo> listaDetalle = new ArrayList();
    private final DetalleBienCampoControlador detalleControlador = new DetalleBienCampoControlador();

    private Bien bienGlobal;
    private Periodo periodo;
    private Proveedor proveedor;
    private Factura factura;

    private void buscarInventario() {
        accion = Controlador.MODIFICAR;
        //        cargarCombos();
        //        cantidadField.setEditable(false);

        FormularioUtil.activarComponente(panelDatos, true);
        FormularioUtil.activarComponente(panelDatosB, true);
        FormularioUtil.activarComponente(panelFoto, true);
        //        FormularioUtil.activarComponente(panelOpciones, false);
        //        FormularioUtil.activarComponente(panelGuardar, true);

        //        lblbuscar.setText(txtBuscar.getText());
        List<Inventario> listaB = this.inventarioControlador.buscarXSerie(txtBuscar.getText().toUpperCase());

        this.txtBuscar.setText(null);
        this.txtBuscar.requestFocusInWindow();

        if (listaB.isEmpty()) {
            JOptionPane.showMessageDialog(null, "No se encontr el elemento", "Mensaje del Sistema",
                    JOptionPane.ERROR_MESSAGE);
        } else {

            inventarioControlador.setSeleccionado(listaB.get(0));

            //            String serie = inventarioControlador.obtenerUltimaSerie(inventarioControlador.getSeleccionado().getBien().getClase().getCodigo());
            //            System.out.println("ULTIMO: "+ inventarioControlador.obtenerUltimaSerie(inventarioControlador.getSeleccionado().getBien().getClase().getCodigo()));
            //            int numero = Integer.valueOf(serie);
            //            System.out.println("ULTIMO NUMERO: "+ numero);
            nombreField.setText(inventarioControlador.getSeleccionado().getBien().getNombre());

            bienGlobal = inventarioControlador.getSeleccionado().getBien();
            //            descripcionField.setText(inventarioControlador.getSeleccionado().getBien().getDescripcion());
            //            fotoField.setText(inventarioControlador.getSeleccionado().getBien().getFoto());
            ImageIcon fot = new ImageIcon(inventarioControlador.getSeleccionado().getBien().getFoto());
            Icon icono = new ImageIcon(
                    fot.getImage().getScaledInstance(lblFoto.getWidth(), lblFoto.getHeight(), Image.SCALE_DEFAULT));
            lblFoto.setIcon(icono);

            listaDetalle.clear();
            listaDetalle
                    .addAll(detalleControlador.buscarXBienFull(inventarioControlador.getSeleccionado().getBien()));
            listarCampos();
            //INFO INVENTARIO
            cmbEstado.setSelectedItem(inventarioControlador.getSeleccionado().getEstado());

            cmbPeriodo1.setSelectedItem(inventarioControlador.getSeleccionado().getPeriodo());
            periodo = inventarioControlador.getSeleccionado().getPeriodo();

            //            cmbAmbiente.setSelectedItem(inventarioControlador.getSeleccionado().getAmbiente());
            if (inventarioControlador.getSeleccionado().getAmbiente() != null) {
                ambienteField.setText(inventarioControlador.getSeleccionado().getAmbiente().toString());
            }

            if (inventarioControlador.getSeleccionado().getProveedor() != null) {
                proveedorField.setText(inventarioControlador.getSeleccionado().getProveedor().getNombreProveedor());
                proveedor = inventarioControlador.getSeleccionado().getProveedor();
            }

            facturaField.setText(null);

            if (inventarioControlador.getSeleccionado().getFactura() != null) {
                facturaField.setText(inventarioControlador.getSeleccionado().getFactura().getNumeroFactura());
                factura = inventarioControlador.getSeleccionado().getFactura();
            }

            List<Inventario> conteo = inventarioControlador
                    .buscarXBien3(inventarioControlador.getSeleccionado().getBien());
            int contar = conteo.size();

            //            lblStock.setText(String.valueOf(contar));
            //            lblUnidades.setVisible(true);
            if (inventarioControlador.getSeleccionado().getImpresionPendiente() != null) {
                chckImpresion.setSelected(inventarioControlador.getSeleccionado().getImpresionPendiente());
            }

            if (inventarioControlador.getSeleccionado().getPrecio() != null) {
                spnPrecio.setValue(inventarioControlador.getSeleccionado().getPrecio());
            }
            serieField.setText(inventarioControlador.getSeleccionado().getSerie());
            serieField.setEditable(false);
            if (inventarioControlador.getSeleccionado().getFechaIngreso() != null) {
                jDateIngreso.setDate(inventarioControlador.getSeleccionado().getFechaIngreso());
            }
            if (inventarioControlador.getSeleccionado().getCodigoFabrica() != null) {
                codFabField.setText(inventarioControlador.getSeleccionado().getCodigoFabrica());
            }
        }
    }

    private void cargarComboEstado() {
        List<String> estado = new ArrayList();
        estado.add("BUENO");
        estado.add("REGULAR");
        estado.add("MALO");
        cmbEstado.setModel(new DefaultComboBoxModel(estado.toArray()));
    }

    private void cargarCombos() {
        cargarComboEstado();
        cargarComboPeriodo();
        cargarComboPeriodo1();
    }

    private void guardar() {
        String palabra = "";
        String palabra2 = "";
        //        if (accion == 1) {
        //            palabra = "registrar";
        //            palabra2 = "registrado";
        //
        //            if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " la Clase?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
        //
        //                //CALCULAR SERIE
        //                int cantidad = 1;
        //                if (!cantidadField.getText().isEmpty()) {
        //                    cantidad = Integer.valueOf(cantidadField.getText());
        //                }
        //
        //                System.out.println("CANTIDAD: " + cantidad);
        //                for (int i = 0; i < cantidad; i++) {
        //                    String ultimaSerie = inventarioControlador.obtenerUltimaSerie(inventarioControlador.getSeleccionado().getBien().getClase().getCodigo());
        //
        //                    Inventario inventarioFinal = new Inventario();
        //
        ////                    inventarioFinal.setAmbiente((Ambiente) cmbAmbiente.getSelectedItem());
        //                    inventarioFinal.setEstado(cmbEstado.getSelectedItem().toString());
        //                    inventarioFinal.setPrecio((Double) spnPrecio.getModel().getValue());
        //                    inventarioFinal.setPeriodo((Periodo) cmbPeriodo.getSelectedItem());
        //                    inventarioFinal.setBien(bienGlobal);
        //                    inventarioFinal.setBaja(chckBaja.isSelected());
        //                    inventarioFinal.setImpresionPendiente(chckImpresion.isSelected());
        //                    inventarioFinal.setFechaIngreso(jDateIngreso.getDate());
        //                    inventarioFinal.setCodigoFabrica(codFabField.getText());
        //                    inventarioFinal.setProveedor(inventarioControlador.getSeleccionado().getProveedor());
        //                    inventarioFinal.setFactura(inventarioControlador.getSeleccionado().getFactura());
        //
        //                    int numero = Integer.valueOf(ultimaSerie);
        //                    String suma = 1000000 + numero + 1 + "";
        //                    String serie = suma.substring(1, suma.length());
        //                    inventarioFinal.setSerie(serie);
        //
        //                    inventarioControlador.setSeleccionado(inventarioFinal);
        //
        ////                    listarCamposNoMod(bienGlobal);
        ////                    crearDetalleInventario();
        ////                    for (DetalleBienCampo detalle : listaDetalle) {
        ////
        ////                        detalleControlador.setSeleccionado(detalle);
        ////                        detalleControlador.accion(AbstractControlador.MODIFICAR);
        ////                    }
        //                    inventarioControlador.accion(accion);
        //                }
        //                // FIN CALCULO SERIE
        ////                lista.add(inventarioControlador.getSeleccionado());
        //
        //                if (accion == 1) {
        //                    JOptionPane.showMessageDialog(null, "Clase " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);
        //                    FormularioUtil.limpiarComponente(panelDatosB);
        //                } else {
        //                    JOptionPane.showMessageDialog(null, "Clase no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE);
        //                }
        //            } else {
        //                FormularioUtil.limpiarComponente(panelDatosB);
        //                JOptionPane.showMessageDialog(null, "Clase no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE);
        //            }
        //        } else 
        if (accion == 2) {
            palabra = "modificar";
            palabra2 = "modificado";

            if (JOptionPane.showConfirmDialog(null, "Desea " + palabra2 + " el Inventario?",
                    "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

                if (accion == 2) {
                    JOptionPane.showMessageDialog(null, "Inventario " + palabra2 + " correctamente",
                            "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);

                    if (!periodo.equals((Periodo) cmbPeriodo1.getSelectedItem())) {
                        Inventario nuevoPeriodoInventario = new Inventario();
                        inventarioControlador.setSeleccionado(nuevoPeriodoInventario);
                        inventarioControlador.getSeleccionado().setSerie(serieField.getText());
                    }

                    inventarioControlador.getSeleccionado().setPeriodo((Periodo) cmbPeriodo1.getSelectedItem());
                    //                    inventarioControlador.getSeleccionado().setAmbiente((Ambiente) cmbAmbiente.getSelectedItem());
                    inventarioControlador.getSeleccionado().setBien(bienGlobal);
                    inventarioControlador.getSeleccionado().setEstado(cmbEstado.getSelectedItem().toString());
                    inventarioControlador.getSeleccionado().setPrecio((Double) spnPrecio.getModel().getValue());
                    inventarioControlador.getSeleccionado().setProveedor(proveedor);
                    inventarioControlador.getSeleccionado().setCodigoFabrica(codFabField.getText());
                    inventarioControlador.getSeleccionado().setFactura(factura);
                    inventarioControlador.getSeleccionado().setBaja(chckBaja.isSelected());
                    inventarioControlador.getSeleccionado().setImpresionPendiente(chckImpresion.isSelected());
                    inventarioControlador.getSeleccionado().setFechaIngreso(jDateIngreso.getDate());

                    inventarioControlador.accion(accion);

                    FormularioUtil.limpiarComponente(panelDatosB);

                } else {
                    JOptionPane.showMessageDialog(null, "Inventario no " + palabra2, "Mensaje del Sistema",
                            JOptionPane.ERROR_MESSAGE);
                }
            } else {
                FormularioUtil.limpiarComponente(panelDatosB);
                JOptionPane.showMessageDialog(null, "Inventario no " + palabra2, "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        }

        //        FormularioUtil.activarComponente(panelOpciones, true);
        FormularioUtil.activarComponente(panelGuardar, false);
        FormularioUtil.activarComponente(panelDatosB, false);
        FormularioUtil.activarComponente(panelDatos, false);
        FormularioUtil.activarComponente(panelFoto, false);
        FormularioUtil.limpiarComponente(panelDatosB);
        FormularioUtil.limpiarComponente(panelDatos);
        FormularioUtil.limpiarComponente(panelFoto);
        //        descripcionField.setText(null);
        spnPrecio.setValue(0);
        lblFoto.setIcon(null);
        //        lblStock.setText(null);
        //        lblbuscar.setText(null);
        chckBaja.setSelected(false);
        chckImpresion.setSelected(false);

        listaDetalle.clear();
        this.txtBuscar.requestFocusInWindow();
    }
}