appArriendos.frmReservaEquipo.java Source code

Java tutorial

Introduction

Here is the source code for appArriendos.frmReservaEquipo.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 appArriendos;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

import javax.swing.*;
import javax.swing.table.*;
import java.io.File;
import java.util.List;
import javax.swing.JTable;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import java.util.ArrayList;
import javax.swing.filechooser.FileNameExtensionFilter;

import java.io.FileOutputStream;

import com.itextpdf.text.Document;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.Image;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import java.time.Instant;
import java.util.Date;

/**
 *
 * @author Phobos
 */
public class frmReservaEquipo extends javax.swing.JInternalFrame {

    /**
     * Creates new form frmReservaEquipo
     */
    public frmReservaEquipo() {
        initComponents();
        DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
        modelo.addColumn("NUM");
        modelo.addColumn("CODIGO");
        modelo.addColumn("DESCRIPCION");

    }

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

        dateChooserDialog1 = new datechooser.beans.DateChooserDialog();
        btnLimpiarPersona = new javax.swing.JButton();
        cboxAdmin = new javax.swing.JComboBox<>();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        cboxInstalador = new javax.swing.JComboBox<>();
        txtCodigo = new javax.swing.JTextField();
        txtDescripcion = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txtRut = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        txtNombre = new javax.swing.JTextField();
        btnIngresarReserva = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        txtTelefono = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        btnLimpiarReserva = new javax.swing.JButton();
        txtCelular = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        txtEmail = new javax.swing.JTextField();
        txtFolio = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        btnAgregarProducto = new javax.swing.JButton();
        btnLimpiarProducto = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtObservacion = new javax.swing.JTextArea();
        jLabel13 = new javax.swing.JLabel();
        chHora = new java.awt.Choice();
        chHora2 = new java.awt.Choice();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        btnBuscarPersona = new javax.swing.JButton();
        btnBuscarProducto = new javax.swing.JButton();
        btnExportarExcel = new javax.swing.JButton();
        btnAnularReserva = new javax.swing.JButton();
        lblEstado = new javax.swing.JLabel();
        btnExportarApdf = new javax.swing.JButton();
        dtpFechaIngreso = new com.toedter.calendar.JDateChooser();
        dtpFechaTermino = new com.toedter.calendar.JDateChooser();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/imagen/png32/clock.png"))); // NOI18N
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }

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

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

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

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

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

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

        btnLimpiarPersona.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagen/png32/tool.png"))); // NOI18N
        btnLimpiarPersona.setText("LIMPIAR");
        btnLimpiarPersona.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiarPersonaActionPerformed(evt);
            }
        });

        jLabel3.setText("ADMINISTRATIVO");

        jLabel4.setText("INSTALADOR");

        txtCodigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtCodigoActionPerformed(evt);
            }
        });

        jLabel5.setText("CODIGO");

        jLabel6.setText("DESCRIPCION");

        txtRut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtRutActionPerformed(evt);
            }
        });

        jScrollPane1.setViewportView(jTable1);

        btnIngresarReserva
                .setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagen/png32/icon-45874.png"))); // NOI18N
        btnIngresarReserva.setText("INGRESAR");
        btnIngresarReserva.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIngresarReservaActionPerformed(evt);
            }
        });

        jLabel9.setText("TELEFONO");

        jLabel10.setText("CELULAR");

        jLabel7.setText("RUT CLIENTE");

        txtTelefono.setEnabled(false);

        jLabel8.setText("NOMBRE");

        btnLimpiarReserva.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagen/png32/tool.png"))); // NOI18N
        btnLimpiarReserva.setText("LIMPIAR");
        btnLimpiarReserva.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiarReservaActionPerformed(evt);
            }
        });

        txtCelular.setEnabled(false);

        jLabel11.setText("EMAIL");

        jLabel1.setText("FOLIO");

        txtEmail.setEnabled(false);

        txtFolio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtFolioActionPerformed(evt);
            }
        });

        jLabel2.setText("FECHA SOLICITADA");

        jLabel12.setText("FECHA TERMINO");

        btnAgregarProducto
                .setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagen/png32/icon-72145.png"))); // NOI18N
        btnAgregarProducto.setText("AGREGAR");
        btnAgregarProducto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarProductoActionPerformed(evt);
            }
        });

        btnLimpiarProducto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagen/png32/tool.png"))); // NOI18N
        btnLimpiarProducto.setText("LIMPIAR");
        btnLimpiarProducto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiarProductoActionPerformed(evt);
            }
        });

        txtObservacion.setColumns(20);
        txtObservacion.setRows(5);
        jScrollPane2.setViewportView(txtObservacion);

        jLabel13.setText("OBSERVACION");

        jLabel14.setText("HORA SOLICITADA");

        jLabel15.setText("HORA ENTREGA");

        btnBuscarPersona.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagen/png32/tool-1.png"))); // NOI18N
        btnBuscarPersona.setText("BUSCAR");
        btnBuscarPersona.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarPersonaActionPerformed(evt);
            }
        });

        btnBuscarProducto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagen/png32/tool-1.png"))); // NOI18N
        btnBuscarProducto.setText("BUSCAR");
        btnBuscarProducto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarProductoActionPerformed(evt);
            }
        });

        btnExportarExcel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagen/png32/icon-1396.png"))); // NOI18N
        btnExportarExcel.setText("EXPORTAR EXCEL");
        btnExportarExcel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExportarExcelActionPerformed(evt);
            }
        });

        btnAnularReserva
                .setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagen/png32/icon-108504.png"))); // NOI18N
        btnAnularReserva.setText("ANULAR");
        btnAnularReserva.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAnularReservaActionPerformed(evt);
            }
        });

        lblEstado.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        lblEstado.setText("NUEVO");

        btnExportarApdf.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagen/png32/symbol.png"))); // NOI18N
        btnExportarApdf.setText("EXPORTAR A PDF");
        btnExportarApdf.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExportarApdfActionPerformed(evt);
            }
        });

        dtpFechaIngreso.setDateFormatString("dd/MM/yy");

        dtpFechaTermino.setDateFormatString("dd/MM/yy");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup().addGap(19, 19, 19).addGroup(layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
                                        .createSequentialGroup().addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                        .addComponent(txtTelefono,
                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addComponent(
                                                                txtRut, javax.swing.GroupLayout.Alignment.LEADING,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 175,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addComponent(jLabel9)
                                                .addComponent(dtpFechaTermino,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 155,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel12))
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(layout.createSequentialGroup().addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                        .addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addGroup(layout.createSequentialGroup()
                                                                        .addComponent(txtNombre,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                272,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addGap(18, 18, 18)
                                                                        .addComponent(btnLimpiarPersona))
                                                                .addGroup(layout.createSequentialGroup()
                                                                        .addGroup(layout.createParallelGroup(
                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                .addComponent(jLabel10)
                                                                                .addComponent(txtCelular,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                        272,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                                                        .addGap(18, 18, 18)
                                                                        .addComponent(btnBuscarPersona))))
                                                .addGroup(layout
                                                        .createSequentialGroup().addGap(10, 10, 10).addComponent(
                                                                chHora2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                155, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(
                                                        txtEmail, javax.swing.GroupLayout.Alignment.LEADING,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 457,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout
                                                        .createSequentialGroup()
                                                        .addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(jLabel5).addComponent(txtCodigo,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 178,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                                        .addGap(22, 22, 22)
                                                        .addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(
                                                                        txtDescripcion,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 269,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addComponent(jLabel6))))
                                        .addGap(0, 0, Short.MAX_VALUE))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                        layout.createSequentialGroup().addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(jScrollPane1,
                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                        layout.createSequentialGroup().addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(
                                                                        dtpFechaIngreso,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 155,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addComponent(jLabel7)).addGap(30, 30, 30)
                                                                .addGroup(layout.createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                        .addGroup(layout.createSequentialGroup()
                                                                                .addComponent(jLabel8)
                                                                                .addPreferredGap(
                                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                        Short.MAX_VALUE)
                                                                                .addComponent(
                                                                                        jScrollPane2,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                        359,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                                                        .addGroup(
                                                                                javax.swing.GroupLayout.Alignment.TRAILING,
                                                                                layout.createSequentialGroup()
                                                                                        .addGap(0, 0,
                                                                                                Short.MAX_VALUE)
                                                                                        .addComponent(
                                                                                                btnBuscarProducto,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                125,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                        .addPreferredGap(
                                                                                                javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                                                        .addComponent(
                                                                                                btnAgregarProducto)
                                                                                        .addGap(18, 18, 18)
                                                                                        .addComponent(
                                                                                                btnLimpiarProducto,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                117,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                                                        .addGroup(layout
                                                                                .createSequentialGroup()
                                                                                .addGroup(layout
                                                                                        .createParallelGroup(
                                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                        .addComponent(jLabel14)
                                                                                        .addComponent(chHora,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                155,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                        .addComponent(jLabel15))
                                                                                .addGap(0, 0, Short.MAX_VALUE))))
                                                .addGroup(layout.createSequentialGroup().addComponent(jLabel2)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                356, Short.MAX_VALUE)
                                                        .addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(cboxAdmin,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 201,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addComponent(jLabel3))
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(cboxInstalador,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 201,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addComponent(jLabel4).addComponent(jLabel13))
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addGroup(
                                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                                        layout.createSequentialGroup()
                                                                                .addComponent(jLabel1)
                                                                                .addGap(52, 52, 52))
                                                                .addComponent(
                                                                        txtFolio,
                                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 142,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout
                                                        .createSequentialGroup().addComponent(btnIngresarReserva)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                        .addComponent(btnLimpiarReserva,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 116,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                        .addComponent(btnAnularReserva)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE)
                                                        .addComponent(lblEstado).addGap(115, 115, 115)
                                                        .addComponent(btnExportarApdf).addGap(18, 18, 18)
                                                        .addComponent(btnExportarExcel,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 156,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                                                .addGap(19, 19, 19)))));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                layout.createSequentialGroup().addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel1).addComponent(jLabel3).addComponent(jLabel4)
                                .addComponent(jLabel2).addComponent(jLabel14))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(chHora, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(txtFolio, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(cboxAdmin, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(cboxInstalador, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(dtpFechaIngreso, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(14, 14, 14)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel12).addComponent(jLabel15))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createSequentialGroup().addGroup(layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup()
                                                .addComponent(dtpFechaTermino,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(6, 6, 6))
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout
                                                .createSequentialGroup()
                                                .addComponent(chHora2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(12, 12, 12)))
                                        .addGap(10, 10, 10)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel8).addComponent(jLabel7))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(txtRut, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(btnLimpiarPersona,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 38,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(13, 13, 13)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(layout.createSequentialGroup()
                                                        .addGroup(layout.createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(jLabel9).addComponent(jLabel10))
                                                        .addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.BASELINE)
                                                                .addComponent(txtTelefono,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addComponent(txtCelular,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                                .addComponent(btnBuscarPersona,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 38,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7,
                                                Short.MAX_VALUE)
                                        .addComponent(jLabel11)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7,
                                                Short.MAX_VALUE)
                                        .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup().addComponent(jLabel13).addGap(18, 18, 18)
                                        .addComponent(jScrollPane2)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel5).addComponent(jLabel6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(txtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(btnAgregarProducto).addComponent(btnBuscarProducto)
                                .addComponent(btnLimpiarProducto).addComponent(txtDescripcion,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 134,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(btnIngresarReserva)
                                                        .addComponent(btnAnularReserva))
                                                .addGroup(layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(btnExportarApdf)
                                                        .addComponent(btnExportarExcel,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 42,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addComponent(btnLimpiarReserva,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 41,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addContainerGap(43, Short.MAX_VALUE))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                        layout.createSequentialGroup()
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(lblEstado).addGap(45, 45, 45)))));

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

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

    private void btnAgregarProductoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarProductoActionPerformed
        // TODO add your handling code here:
        try {
            if (txtCodigo.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(this, "Debe seleccionar item a agregar");
            } else {
                // AgregarItem();
                DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
                int numRow = jTable1.getRowCount();
                if (numRow == 0) {
                    numRow = 1;
                } else {
                    numRow = jTable1.getRowCount() + 1;
                }

                Connection miConexion = (Connection) Conexion.GetConnection();
                Statement statement = (Statement) miConexion.createStatement();
                String producto = txtCodigo.getText();
                ResultSet rs = statement.executeQuery("SELECT COUNT(*) AS num FROM tb_articulo WHERE codigo ='"
                        + producto + "' AND disponible = 1 OR disponible = 2");
                int rows = 0;
                if (rs.next()) {
                    rows = rs.getInt("num");
                }

                if (rows == 0) {
                    modelo.addRow(new Object[] { numRow, txtCodigo.getText(), txtDescripcion.getText() });
                    LimpiarProducto();
                } else {
                    JOptionPane.showMessageDialog(this, "ARTICULO SELECCIONADO NO DISPONIBLE");
                }

            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "Error " + ex.getMessage());
        }

    }//GEN-LAST:event_btnAgregarProductoActionPerformed

    private void txtCodigoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtCodigoActionPerformed
        // TODO add your handling code here:
        if (txtCodigo.getText().trim().isEmpty()) {
            JOptionPane.showMessageDialog(this, "Debe seleccionar item a agregar");
        } else {

            try {
                ResultSet rs = null;
                Connection miConexion = (Connection) Conexion.GetConnection();
                Statement statement = (Statement) miConexion.createStatement();
                String codigo = txtCodigo.getText();
                rs = statement.executeQuery("SELECT * from tb_articulo where codigo = '" + codigo + "'");

                while (rs.next()) {

                    txtCodigo.setText(rs.getString("codigo"));
                    txtDescripcion.setText(rs.getString("descripcion"));

                }

                miConexion.close();
            } catch (Exception ex) {
                //JOptionPane.showMessageDialog(this, "Error "+ex.getMessage());
            }
        }

    }//GEN-LAST:event_txtCodigoActionPerformed

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

        if (txtRut.getText().trim().isEmpty()) {
            JOptionPane.showMessageDialog(this, "Debe seleccionar item a agregar");
        } else {

            try {
                ResultSet rs = null;
                Connection miConexion = (Connection) Conexion.GetConnection();
                Statement statement = (Statement) miConexion.createStatement();
                String rut = txtRut.getText();
                rs = statement.executeQuery("SELECT * from tb_cliente where rut = '" + rut + "'");

                while (rs.next()) {

                    txtRut.setText(rs.getString("rut"));
                    txtNombre.setText(rs.getString("nombre"));
                    txtTelefono.setText(rs.getString("telefono"));
                    txtCelular.setText(rs.getString("celular"));
                    txtEmail.setText(rs.getString("email"));

                }

                miConexion.close();
            } catch (Exception ex) {
                //JOptionPane.showMessageDialog(this, "Error "+ex.getMessage());
            }
        }

    }//GEN-LAST:event_txtRutActionPerformed

    private void btnLimpiarPersonaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpiarPersonaActionPerformed
        // TODO add your handling code here:
        txtRut.setText("");
        txtNombre.setText("");
        txtTelefono.setText("");
        txtCelular.setText("");
        txtEmail.setText("");
    }//GEN-LAST:event_btnLimpiarPersonaActionPerformed

    private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened
        // TODO add your handling code here:
        String[] hora = { "08:00", "08:30", "09:00", "09:30", "10:00", "10:30", "11:00", "11:30", "12:00", "12:30",
                "13:00", "13:30", "14:00", "14:30", "15:00", "15:30", "16:00", "16:30", "17:00", "17:30", "18:00",
                "18:30", "19:00", "19:30", "20:00", "20:30", "21:00", "21:30", "22:00", "22:30", "23:00", "23:30",
                "24:00" };

        for (int i = 0; i < hora.length; i++) {
            chHora.add(hora[i]);
            chHora2.add(hora[i]);
        }
        cargarlista();
        ObtenerFolio();
    }//GEN-LAST:event_formInternalFrameOpened

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

        Connection miConexion = (Connection) Conexion.GetConnection();
        try {
            int fila = jTable1.getRowCount();
            if (txtRut.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(this, "Debe ingresar campo rut");
            } else if (fila == 0) {
                JOptionPane.showMessageDialog(this, "Debe asociar items a grilla");
            } else {

                Statement statement = (Statement) miConexion.createStatement();

                ObtenerFolio();
                //String fecha = dtpFecha.getText();
                String fechaI = String.format("%1$td/%1$tm/%1$ty", dtpFechaIngreso.getDate());
                //String fechaT = dtpFechaTermino.getText();
                String fechaT = String.format("%1$td/%1$tm/%1$ty", dtpFechaTermino.getDate());
                String hora = chHora.getSelectedItem();
                String horaT = chHora2.getSelectedItem();
                String rut = txtRut.getText();
                String observacion = txtObservacion.getText();
                int folio = Integer.parseInt(txtFolio.getText());
                String admin = cboxAdmin.getSelectedItem().toString();
                String insta = cboxInstalador.getSelectedItem().toString();

                statement.execute(
                        "insert into tb_reserva (num, fecha, fecha_entrega, hora, hora_entrega, rut, observacion, cod_admin, cod_instalador, estado) values('"
                                + folio + "','" + fechaI + "','" + fechaT + "','" + hora + "','" + horaT + "','"
                                + rut + "', '" + observacion + "', '" + admin + "', '" + insta + "', 1)");

                for (int i = 0; i < jTable1.getRowCount(); i++) {
                    int num = (int) jTable1.getValueAt(i, 0);
                    String cod = (String) jTable1.getValueAt(i, 1);
                    String des = (String) jTable1.getValueAt(i, 2);
                    statement.execute("insert into tb_reserva_detalle values('" + folio + "','" + num + "','" + cod
                            + "','" + des + "')");
                    statement.execute("update tb_articulo set disponible = 1 where codigo = '" + cod + "' ");
                }

                JOptionPane.showMessageDialog(this, "Datos ingresados correctamente");
                Limpiar();
                statement.close();
                miConexion.close();

            }

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "Error " + ex.getMessage());
        }

    }//GEN-LAST:event_btnIngresarReservaActionPerformed

    private void btnLimpiarReservaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpiarReservaActionPerformed
        // TODO add your handling code here:
        Limpiar();
        ObtenerFolio();
    }//GEN-LAST:event_btnLimpiarReservaActionPerformed

    private void btnBuscarPersonaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarPersonaActionPerformed
        // TODO add your handling code here:
        frmClienteBusca frm = new frmClienteBusca();
        frmPanelAdministrativo.desktopPane.add(frm);
        frm.toFront();
        frm.setVisible(true);
    }//GEN-LAST:event_btnBuscarPersonaActionPerformed

    private void btnBuscarProductoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarProductoActionPerformed
        // TODO add your handling code here:
        frmArticuloBusca frm = new frmArticuloBusca();
        frmPanelAdministrativo.desktopPane.add(frm);
        frm.toFront();
        frm.setVisible(true);
    }//GEN-LAST:event_btnBuscarProductoActionPerformed

    private void txtFolioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtFolioActionPerformed
        // TODO add your handling code here:
        Connection miConexion = (Connection) Conexion.GetConnection();
        try {
            if (txtFolio.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(this, "Debe ingresar campo numero de folio");
            } else {

                Statement statement = (Statement) miConexion.createStatement();
                String folio = txtFolio.getText();

                ResultSet rs = statement
                        .executeQuery("SELECT COUNT(*) AS num FROM tb_reserva WHERE num ='" + folio + "' ");
                int rows = 0;
                if (rs.next()) {
                    rows = rs.getInt("num");
                }

                if (rows > 0) {
                    rs = statement.executeQuery("SELECT * FROM tb_reserva WHERE num ='" + folio + "' ");

                    while (rs.next()) {

                        txtObservacion.setText(rs.getString("observacion"));
                        txtRut.setText(rs.getString("rut"));

                        ObtenerRegistroCliente(rs.getString("rut"));

                        //dtpFecha_old.setText(rs.getString("fecha"));
                        //dtpFechaTermino_old.setText(rs.getString("fecha_entrega"));
                        dtpFechaIngreso.setDate(rs.getDate("fecha"));
                        dtpFechaTermino.setDate(rs.getDate("fecha_entrega"));
                        chHora.select(rs.getString("hora"));
                        chHora2.select(rs.getString("hora_entrega"));

                        int estado = rs.getInt("estado");
                        switch (estado) {
                        case 1:
                            lblEstado.setText("EMITIDO");
                            break;
                        case 2:
                            lblEstado.setText("ANULADO");
                            break;
                        case 3:
                            lblEstado.setText("EJECUTADO");
                            break;
                        }
                        DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
                        rs = statement
                                .executeQuery("SELECT * FROM tb_reserva_detalle WHERE folio ='" + folio + "' ");
                        for (int i = 0; i < jTable1.getRowCount(); i++) {
                            modelo.removeRow(i);
                            i -= 1;
                        }
                        while (rs.next()) {

                            modelo.addRow(new Object[] { rs.getString("codigo"), rs.getString("descripcion") });

                        }

                    }
                    rs.close();

                    statement.close();
                    miConexion.close();
                } else {
                    JOptionPane.showMessageDialog(this, "Numero de folio ingresado no se encuentra en sistema");
                }

            }

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "Error " + ex.getMessage());
        }
    }//GEN-LAST:event_txtFolioActionPerformed

    private void ObtenerRegistroCliente(String rut) {

        try {
            ResultSet rs, rs2 = null;
            Connection miConexion = (Connection) Conexion.GetConnection();
            Statement statement = (Statement) miConexion.createStatement();
            rs = statement.executeQuery("SELECT * from tb_cliente where rut = '" + rut + "'");

            while (rs.next()) {
                txtRut.setText(rs.getString("rut"));
                txtNombre.setText(rs.getString("nombre"));
                txtTelefono.setText(rs.getString("telefono"));
                txtCelular.setText(rs.getString("celular"));
                txtEmail.setText(rs.getString("email"));
            }

            miConexion.close();
        } catch (Exception ex) {
            //JOptionPane.showMessageDialog(this, "Error "+ex.getMessage());
        }

    }

    private void btnExportarExcelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExportarExcelActionPerformed
        // TODO add your handling code here:
        // TODO add your handling code here:
        if (this.jTable1.getRowCount() == 0) {
            JOptionPane.showMessageDialog(null, "No hay datos en la tabla para exportar.", "BCO",
                    JOptionPane.INFORMATION_MESSAGE);

            return;
        }
        JFileChooser chooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter("Archivos de excel", "xls");
        chooser.setFileFilter(filter);
        chooser.setDialogTitle("Guardar archivo");
        chooser.setMultiSelectionEnabled(false);
        chooser.setAcceptAllFileFilterUsed(false);
        if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
            List<JTable> tb = new ArrayList<>();
            List<String> nom = new ArrayList<>();
            tb.add(jTable1);
            nom.add("Detalle de Gastos");
            String file = chooser.getSelectedFile().toString().concat(".xls");
            try {
                Exporter e = new Exporter(new File(file), tb, nom);
                if (e.export()) {
                    JOptionPane.showMessageDialog(null, "Los datos fueron exportados a excel.", "BCO",
                            JOptionPane.INFORMATION_MESSAGE);

                }
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null, "Hubo un error" + ex.getMessage(), "Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_btnExportarExcelActionPerformed

    private void btnAnularReservaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAnularReservaActionPerformed
        // TODO add your handling code here:
        Connection miConexion = (Connection) Conexion.GetConnection();
        try {
            int dialogButton = JOptionPane.YES_NO_OPTION;
            int dialogResult = JOptionPane.showConfirmDialog(this, " DESEA ANULAR DOCUMENTO ?", "RESERVAS",
                    dialogButton);
            if (dialogResult == 0) {
                if (txtFolio.getText().trim().isEmpty()) {
                    JOptionPane.showMessageDialog(this, "Debe ingresar campo numero de folio");
                } else {
                    Statement statement = (Statement) miConexion.createStatement();
                    String folio = txtFolio.getText();
                    ResultSet rs = statement
                            .executeQuery("SELECT COUNT(*) AS num FROM tb_reserva WHERE num ='" + folio + "' ");
                    int rows = 0;
                    if (rs.next()) {
                        rows = rs.getInt("num");
                    }
                    if (rows > 0) {
                        int cantidad = statement
                                .executeUpdate("UPDATE tb_reserva SET estado = 2 WHERE num ='" + folio + "' ");
                        if (cantidad > 0) {
                            JOptionPane.showMessageDialog(this, "Registro ANULADO exitosamente");
                            Limpiar();
                        } else {
                            JOptionPane.showMessageDialog(this, "Problema ANULANDO registro de sistema");
                        }
                    } else {
                        JOptionPane.showMessageDialog(this, "Numero de folio ingresado no se encuentra en sistema");
                    }

                }
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "Error " + ex.getMessage());
        }
    }//GEN-LAST:event_btnAnularReservaActionPerformed

    private void btnExportarApdfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExportarApdfActionPerformed
        // TODO add your handling code here:
        try {
            Connection miConexion = (Connection) Conexion.GetConnection();
            Statement statement = (Statement) miConexion.createStatement();
            String folio = txtFolio.getText();
            ResultSet rs = statement
                    .executeQuery("SELECT COUNT(*) AS num FROM tb_reserva WHERE num ='" + folio + "' ");
            int rows = 0;
            if (rs.next()) {
                rows = rs.getInt("num");
            }

            if (rows > 0) {
                JFileChooser chooser = new JFileChooser();
                FileNameExtensionFilter filter = new FileNameExtensionFilter("Documento Pdf", "pdf");
                chooser.setFileFilter(filter);
                chooser.setDialogTitle("Guardar archivo");
                chooser.setMultiSelectionEnabled(false);
                chooser.setAcceptAllFileFilterUsed(false);
                if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {

                    String file = chooser.getSelectedFile().toString().concat(".pdf");
                    FileOutputStream archivo = new FileOutputStream(file);
                    Document documento = new Document();
                    PdfWriter.getInstance(documento, archivo);
                    documento.open();

                    documento.add(new Paragraph("DOCUMENTO RESERVA", new Font(Font.FontFamily.HELVETICA, 20)));
                    documento.add(new Paragraph(""));
                    documento.add(new Paragraph(""));
                    documento.add(new Paragraph("Nmero de folio : " + folio));
                    documento.add(new Paragraph(""));
                    rs = statement.executeQuery("SELECT * FROM tb_reserva WHERE num ='" + folio + "' ");
                    while (rs.next()) {
                        documento.add(new Paragraph("Pedido Para Dia : " + rs.getString("fecha") + " A Las : "
                                + rs.getString("hora") + "  Horas"));
                        documento.add(
                                new Paragraph("Devolucion De Pedido Para El Dia : " + rs.getString("fecha_entrega")
                                        + " A Las : " + rs.getString("hora_entrega") + "  Horas"));
                        documento.add(new Paragraph("Solicit : " + rs.getString("rut")));
                        documento.add(new Paragraph("Fue Atendido Por : " + rs.getString("cod_admin")));
                        documento.add(new Paragraph("Sera Instalado Por : " + rs.getString("cod_instalador")));

                        int estado = rs.getInt("estado");
                        switch (estado) {
                        case 1:
                            documento.add(new Paragraph("ESTADO : EMITIDO"));
                            break;
                        case 2:
                            documento.add(new Paragraph("ESTADO : ANULADO"));
                            break;
                        case 3:
                            documento.add(new Paragraph("ESTADO : EJECUTADO"));
                            break;
                        }

                        documento.add(new Paragraph("OBSERVACION : " + rs.getString("observacion"),
                                new Font(Font.FontFamily.HELVETICA, 14)));
                    }

                    PdfPTable table = new PdfPTable(3);

                    rs = statement.executeQuery("SELECT * FROM tb_reserva_detalle WHERE folio ='" + folio + "' ");

                    table.addCell("LINEA");
                    table.addCell("CODIGO");
                    table.addCell("DESCRIPCION");
                    while (rs.next()) {
                        table.addCell(rs.getString("num"));
                        table.addCell(rs.getString("codigo"));
                        table.addCell(rs.getString("descripcion"));

                    }

                    documento.add(new Paragraph(" "));
                    documento.add(new Paragraph(" "));
                    documento
                            .add(new Paragraph(" Equipos Solicitados : ", new Font(Font.FontFamily.HELVETICA, 14)));
                    documento.add(new Paragraph(" "));
                    documento.add(table);

                    documento.close();
                } // fin saveshowdialog                    
            } else {
                JOptionPane.showMessageDialog(this, "Numero de folio ingresado no se encuentra en sistema");
            }

        } // fin trycatch
        catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "Error " + ex.getMessage());
        }

    }//GEN-LAST:event_btnExportarApdfActionPerformed

    private void Limpiar() {
        //dtpFecha_old.setText("");
        //dtpFechaTermino_old.setText("");
        dtpFechaIngreso.setDate(null);
        dtpFechaTermino.setDate(null);
        chHora.select(0);
        chHora2.select(0);

        txtRut.setText("");
        txtNombre.setText("");
        txtTelefono.setText("");
        txtCelular.setText("");
        txtEmail.setText("");
        txtObservacion.setText("");
        txtCodigo.setText("");
        txtDescripcion.setText("");
        lblEstado.setText("NUEVO");

        DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();

        for (int i = 0; i < jTable1.getRowCount(); i++) {
            modelo.removeRow(i);
            i -= 1;
        }

    }

    private void ObtenerFolio() {
        Connection miConexion = (Connection) Conexion.GetConnection();
        try {

            Statement statement = (Statement) miConexion.createStatement();
            ResultSet rs = statement.executeQuery("SELECT COUNT(*) AS num FROM tb_reserva ");
            int rows = 0;
            if (rs.next()) {
                rows = rs.getInt("num");
            }

            if (rows > 0) {
                rs = statement.executeQuery("SELECT MAX(num) + 1 as num from tb_reserva");
                while (rs.next()) {
                    rows = rs.getInt("num");
                }

            } else {
                rows = 1;
            }

            txtFolio.setText(Integer.toString(rows));
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "Error " + ex.getMessage());
        }
    }

    private void cargarlista() {

        try {
            ResultSet rs = null;
            Connection miConexion = (Connection) Conexion.GetConnection();
            Statement statement = (Statement) miConexion.createStatement();
            rs = statement.executeQuery("SELECT * FROM tb_administrador WHERE tipo_usuario = 2");

            while (rs.next()) {
                String tmpStrObtenido = rs.getString("nombre");
                cboxAdmin.addItem(tmpStrObtenido);

            }

            rs = statement.executeQuery("SELECT * FROM tb_administrador WHERE tipo_usuario =3");

            while (rs.next()) {
                String tmpStrObtenido = rs.getString("nombre");
                cboxInstalador.addItem(tmpStrObtenido);
            }
            miConexion.close();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "Error " + ex.getMessage());
        }

    }

    void fillData(JTable table, File file) {

        try {

            //Desktopane.getDesktop().open(path); 
            WritableWorkbook workbook1 = Workbook.createWorkbook(file);
            WritableSheet sheet1 = workbook1.createSheet("First Sheet", 0);
            TableModel model = table.getModel();

            for (int i = 0; i < model.getColumnCount(); i++) {
                Label column = new Label(i, 0, model.getColumnName(i));
                sheet1.addCell(column);
            }

            int j = 0;
            for (int i = 0; i < model.getRowCount(); i++) {
                for (j = 0; j < model.getColumnCount(); j++) {
                    Label row = new Label(j, i + 1, model.getValueAt(i, j).toString());
                    sheet1.addCell(row);
                }
            }

            workbook1.write();
            workbook1.close();

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Error creating Excel file.");
            ex.printStackTrace();
        }
    }

    private void LimpiarProducto() {

        txtCodigo.setText("");
        txtDescripcion.setText("");

    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAgregarProducto;
    private javax.swing.JButton btnAnularReserva;
    private javax.swing.JButton btnBuscarPersona;
    private javax.swing.JButton btnBuscarProducto;
    private javax.swing.JButton btnExportarApdf;
    private javax.swing.JButton btnExportarExcel;
    private javax.swing.JButton btnIngresarReserva;
    private javax.swing.JButton btnLimpiarPersona;
    private javax.swing.JButton btnLimpiarProducto;
    private javax.swing.JButton btnLimpiarReserva;
    private javax.swing.JComboBox<String> cboxAdmin;
    private javax.swing.JComboBox<String> cboxInstalador;
    private java.awt.Choice chHora;
    private java.awt.Choice chHora2;
    private datechooser.beans.DateChooserDialog dateChooserDialog1;
    private com.toedter.calendar.JDateChooser dtpFechaIngreso;
    private com.toedter.calendar.JDateChooser dtpFechaTermino;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable1;
    private javax.swing.JLabel lblEstado;
    public static javax.swing.JTextField txtCelular;
    public static javax.swing.JTextField txtCodigo;
    public static javax.swing.JTextField txtDescripcion;
    public static javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtFolio;
    public static javax.swing.JTextField txtNombre;
    private javax.swing.JTextArea txtObservacion;
    public static javax.swing.JTextField txtRut;
    public static javax.swing.JTextField txtTelefono;
    // End of variables declaration//GEN-END:variables
}