br.com.atmatech.sac.view.ViewAtendimento.java Source code

Java tutorial

Introduction

Here is the source code for br.com.atmatech.sac.view.ViewAtendimento.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 br.com.atmatech.sac.view;

import br.com.atmatech.sac.beans.AtendimentoBeans;
import br.com.atmatech.sac.beans.PessoaBeans;
import br.com.atmatech.sac.beans.UsuarioBeans;
import br.com.atmatech.sac.beans.UsuarioLogadoBeans;
import br.com.atmatech.sac.beans.VeiculoBeans;
import br.com.atmatech.sac.controller.Email;
import br.com.atmatech.sac.controller.NivelAcesso;
import br.com.atmatech.sac.dao.AtendimentoDao;
import br.com.atmatech.sac.dao.PessoaDao;
import br.com.atmatech.sac.dao.UsuarioDao;
import br.com.atmatech.sac.dao.VeiculoDao;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.net.MalformedURLException;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import javax.swing.table.DefaultTableModel;
import org.apache.commons.mail.EmailException;

/**
 *
 * @author MARCOS
 */
public class ViewAtendimento extends javax.swing.JPanel {

    /**
     * Creates new form ViewModulo
     */
    ViewPrincipal viewprincipal;
    static ViewListaAtendimento viewlatendimento;
    List<PessoaBeans> lpb;
    List<UsuarioBeans> lub;
    List<VeiculoBeans> vb;
    Timestamp dtabertura;
    Timestamp dtinicial;
    Timestamp dtfinal;
    AtendimentoBeans ab;

    public ViewAtendimento(ViewPrincipal viewprincipal, ViewListaAtendimento viewlatendimento, AtendimentoBeans ab,
            Boolean alttecnico, Boolean showjdclienteagrup) {
        initComponents();
        inicializaAtalhos();
        jTidveiculo.setVisible(false);
        this.viewprincipal = viewprincipal;

        ViewAtendimento.viewlatendimento = viewlatendimento;
        if (!alttecnico) {
            if (jTidtecnico.getText().equals("")) {
                jTidtecnico.setText(new UsuarioLogadoBeans().getIdusuario().toString());
                jBtecnico.setEnabled(false);
                jTtecnico.setText(new UsuarioLogadoBeans().getNome());
            }
        }
        if (jTidtecnico.getText().equals("")) {

        }
        if (showjdclienteagrup) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    jBexcluir.setEnabled(false);
                    // showJDclienteagrup();
                    showJDcliente();
                }
            }).start();
        } else {
            //this.ab = ab;
            this.ab = new AtendimentoDao().getAtendimento(ab.getIDATENDIMENTO());
            atendimentoSelecionado(this.ab);
        }
        permissaoUsuario();
        jTidcliente.setVisible(false);
        jTidtecnico.setVisible(false);
        jTidtecnicoanterior.setVisible(false);
        jTemail.setVisible(false);
        jTsolicitante.requestFocusInWindow();
        jTidtecnicoabertura.setVisible(false);
    }

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

        jDcliente = new javax.swing.JDialog();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTtdcliente = new javax.swing.JTable();
        jDtecnico = new javax.swing.JDialog();
        jScrollPane5 = new javax.swing.JScrollPane();
        jTtdtecnico = new javax.swing.JTable();
        jDcombocliente = new javax.swing.JDialog();
        ACBcliente = new com.jidesoft.swing.AutoCompletionComboBox();
        jLabel17 = new javax.swing.JLabel();
        jDveiculo = new javax.swing.JDialog();
        jPanel3 = new javax.swing.JPanel();
        jCveiculo = new javax.swing.JComboBox();
        jTplaca = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jTkminicial = new javax.swing.JTextField();
        jTkmfinal = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jTidveiculo = new javax.swing.JTextField();
        jBok = new javax.swing.JButton();
        jDajuda = new javax.swing.JDialog();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTbajuda = new javax.swing.JTable();
        jTajuda = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jBalterar = new javax.swing.JButton();
        jBexcluir = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jTidcliente = new javax.swing.JTextField();
        jTidtecnico = new javax.swing.JTextField();
        jTidtecnicoanterior = new javax.swing.JTextField();
        jTemail = new javax.swing.JTextField();
        jTidtecnicoabertura = new javax.swing.JTextField();
        jBajuda = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTresponsavel = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jTfantasia = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jTmodulo = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jTtelefone = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jFabertura = new javax.swing.JFormattedTextField();
        jLabel9 = new javax.swing.JLabel();
        jDinicial = new com.toedter.calendar.JDateChooser();
        jFinicial = new javax.swing.JFormattedTextField();
        jDfinal = new com.toedter.calendar.JDateChooser();
        jFfinal = new javax.swing.JFormattedTextField();
        jLabel10 = new javax.swing.JLabel();
        jDabertura = new com.toedter.calendar.JDateChooser();
        jLabel11 = new javax.swing.JLabel();
        jTsolicitante = new javax.swing.JTextField();
        jCtipo = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        jTtecnico = new javax.swing.JTextField();
        jBtecnico = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jTidatendimento = new javax.swing.JTextField();
        jTrazao = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jCStatus = new javax.swing.JComboBox();
        jLabel16 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        jTsolicitacao = new javax.swing.JTextArea();
        jScrollPane8 = new javax.swing.JScrollPane();
        jTrealizado = new javax.swing.JTextArea();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTpendente = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTanotacao = new javax.swing.JTextArea();
        jCnfe = new javax.swing.JCheckBox();
        jCecf = new javax.swing.JCheckBox();
        jCnfce = new javax.swing.JCheckBox();
        jScrollPane6 = new javax.swing.JScrollPane();
        jTobsatend = new javax.swing.JTextArea();
        jTtecnicoedit = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();

        jDcliente.setTitle("Clientes");
        jDcliente.setMinimumSize(new java.awt.Dimension(538, 249));
        jDcliente.setModal(true);
        jDcliente.setResizable(false);
        jDcliente.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                jDclienteWindowOpened(evt);
            }
        });
        jDcliente.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jDclienteKeyPressed(evt);
            }
        });

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

        }, new String[] { "FANTASIA", "RAZAO", "CNPJ", "CIDADE", "ENDERECO" }) {
            boolean[] canEdit = new boolean[] { false, false, false, false, false };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        jTtdcliente.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jTtdcliente.getTableHeader().setReorderingAllowed(false);
        jTtdcliente.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTtdclienteMouseClicked(evt);
            }

            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jTtdclienteMouseEntered(evt);
            }
        });
        jTtdcliente.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTtdclienteKeyPressed(evt);
            }
        });
        jScrollPane4.setViewportView(jTtdcliente);
        if (jTtdcliente.getColumnModel().getColumnCount() > 0) {
            jTtdcliente.getColumnModel().getColumn(0).setResizable(false);
            jTtdcliente.getColumnModel().getColumn(0).setPreferredWidth(200);
            jTtdcliente.getColumnModel().getColumn(1).setMinWidth(200);
            jTtdcliente.getColumnModel().getColumn(1).setPreferredWidth(200);
            jTtdcliente.getColumnModel().getColumn(2).setMinWidth(120);
            jTtdcliente.getColumnModel().getColumn(2).setPreferredWidth(120);
            jTtdcliente.getColumnModel().getColumn(3).setMinWidth(200);
            jTtdcliente.getColumnModel().getColumn(3).setPreferredWidth(200);
            jTtdcliente.getColumnModel().getColumn(4).setMinWidth(300);
            jTtdcliente.getColumnModel().getColumn(4).setPreferredWidth(300);
        }

        javax.swing.GroupLayout jDclienteLayout = new javax.swing.GroupLayout(jDcliente.getContentPane());
        jDcliente.getContentPane().setLayout(jDclienteLayout);
        jDclienteLayout
                .setHorizontalGroup(
                        jDclienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDclienteLayout
                                        .createSequentialGroup().addContainerGap().addComponent(jScrollPane4,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, 518, Short.MAX_VALUE)
                                        .addContainerGap()));
        jDclienteLayout
                .setVerticalGroup(jDclienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jDclienteLayout.createSequentialGroup().addContainerGap()
                                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 201,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        jDtecnico.setTitle("Tecnico");
        jDtecnico.setMinimumSize(new java.awt.Dimension(538, 249));
        jDtecnico.setModal(true);
        jDtecnico.setResizable(false);

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

        }, new String[] { "TECNICO" }) {
            boolean[] canEdit = new boolean[] { false };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        jTtdtecnico.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_LAST_COLUMN);
        jTtdtecnico.getTableHeader().setReorderingAllowed(false);
        jTtdtecnico.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTtdtecnicoMouseClicked(evt);
            }
        });
        jTtdtecnico.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTtdtecnicoKeyPressed(evt);
            }
        });
        jScrollPane5.setViewportView(jTtdtecnico);
        if (jTtdtecnico.getColumnModel().getColumnCount() > 0) {
            jTtdtecnico.getColumnModel().getColumn(0).setResizable(false);
            jTtdtecnico.getColumnModel().getColumn(0).setPreferredWidth(200);
        }

        javax.swing.GroupLayout jDtecnicoLayout = new javax.swing.GroupLayout(jDtecnico.getContentPane());
        jDtecnico.getContentPane().setLayout(jDtecnicoLayout);
        jDtecnicoLayout
                .setHorizontalGroup(
                        jDtecnicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDtecnicoLayout
                                        .createSequentialGroup().addContainerGap().addComponent(jScrollPane5,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, 518, Short.MAX_VALUE)
                                        .addContainerGap()));
        jDtecnicoLayout
                .setVerticalGroup(jDtecnicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jDtecnicoLayout.createSequentialGroup().addContainerGap()
                                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 201,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        jDcombocliente.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        jDcombocliente.setTitle("Consulta Clientes");
        jDcombocliente.setMinimumSize(new java.awt.Dimension(700, 90));
        jDcombocliente.setModal(true);
        jDcombocliente.setResizable(false);

        ACBcliente.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                ACBclienteItemStateChanged(evt);
            }
        });
        ACBcliente.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                ACBclienteKeyPressed(evt);
            }

            public void keyReleased(java.awt.event.KeyEvent evt) {
                ACBclienteKeyReleased(evt);
            }
        });

        jLabel17.setText("CLIENTES");

        javax.swing.GroupLayout jDcomboclienteLayout = new javax.swing.GroupLayout(jDcombocliente.getContentPane());
        jDcombocliente.getContentPane().setLayout(jDcomboclienteLayout);
        jDcomboclienteLayout.setHorizontalGroup(
                jDcomboclienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jDcomboclienteLayout.createSequentialGroup().addContainerGap()
                                .addGroup(jDcomboclienteLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(ACBcliente, javax.swing.GroupLayout.DEFAULT_SIZE, 573,
                                                Short.MAX_VALUE)
                                        .addGroup(jDcomboclienteLayout.createSequentialGroup()
                                                .addComponent(jLabel17).addGap(0, 0, Short.MAX_VALUE)))
                                .addContainerGap()));
        jDcomboclienteLayout.setVerticalGroup(jDcomboclienteLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jDcomboclienteLayout.createSequentialGroup().addGap(7, 7, 7).addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ACBcliente, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(28, Short.MAX_VALUE)));

        jDveiculo.setTitle("Veiculo");
        jDveiculo.setMinimumSize(new java.awt.Dimension(218, 220));
        jDveiculo.setModal(true);
        jDveiculo.setResizable(false);

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Veiculo"));
        jPanel3.setName(""); // NOI18N

        jCveiculo.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jCveiculoItemStateChanged(evt);
            }
        });

        jTplaca.setEditable(false);

        jLabel18.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel18.setText("KM INICIAL");

        jTkminicial.setEditable(false);

        jLabel19.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel19.setText("KM FINAL");

        jTidveiculo.setEditable(false);

        jBok.setIcon(new javax.swing.ImageIcon(
                getClass().getResource("/br/com/atmatech/sac/icon/Knob Valid Green.png"))); // NOI18N
        jBok.setText("OK");
        jBok.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBokActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(jPanel3Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jCveiculo, 0, 170, Short.MAX_VALUE).addComponent(jTplaca))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTidveiculo, javax.swing.GroupLayout.PREFERRED_SIZE, 15,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jTkminicial, javax.swing.GroupLayout.PREFERRED_SIZE, 72,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel18))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(
                                        jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel19).addComponent(jTkmfinal,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 74,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addGroup(jPanel3Layout.createSequentialGroup().addGap(47, 47, 47).addComponent(jBok,
                        javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)));
        jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jCveiculo, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTidveiculo, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTplaca, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel18).addComponent(jLabel19))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jTkminicial, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTkmfinal, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jBok,
                                javax.swing.GroupLayout.PREFERRED_SIZE, 33,
                                javax.swing.GroupLayout.PREFERRED_SIZE)));

        javax.swing.GroupLayout jDveiculoLayout = new javax.swing.GroupLayout(jDveiculo.getContentPane());
        jDveiculo.getContentPane().setLayout(jDveiculoLayout);
        jDveiculoLayout.setHorizontalGroup(
                jDveiculoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jPanel3,
                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE));
        jDveiculoLayout.setVerticalGroup(
                jDveiculoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jPanel3,
                        javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE));

        jDajuda.setTitle("AJUDA");
        jDajuda.setMinimumSize(new java.awt.Dimension(693, 449));
        jDajuda.setModal(true);

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

        }, new String[] { "SOLICITAO", "SOLUO" }) {
            boolean[] canEdit = new boolean[] { false, false };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        jTbajuda.getTableHeader().setResizingAllowed(false);
        jTbajuda.getTableHeader().setReorderingAllowed(false);
        jScrollPane3.setViewportView(jTbajuda);
        if (jTbajuda.getColumnModel().getColumnCount() > 0) {
            jTbajuda.getColumnModel().getColumn(0).setResizable(false);
            jTbajuda.getColumnModel().getColumn(1).setResizable(false);
        }

        jTajuda.setDocument(new br.com.atmatech.sac.controller.LimitaCaracterUpper(600, true));
        jTajuda.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTajudaKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jDajudaLayout = new javax.swing.GroupLayout(jDajuda.getContentPane());
        jDajuda.getContentPane().setLayout(jDajudaLayout);
        jDajudaLayout
                .setHorizontalGroup(jDajudaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 693, Short.MAX_VALUE)
                        .addComponent(jTajuda));
        jDajudaLayout.setVerticalGroup(jDajudaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDajudaLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jTajuda, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)));

        setName("ViewAtendimento"); // NOI18N
        setPreferredSize(new java.awt.Dimension(1021, 613));

        jPanel1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jBalterar.setIcon(
                new javax.swing.ImageIcon(getClass().getResource("/br/com/atmatech/sac/icon/Knob Valid Blue.png"))); // NOI18N
        jBalterar.setText("F2-Salvar");
        jBalterar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBalterarActionPerformed(evt);
            }
        });

        jBexcluir.setIcon(
                new javax.swing.ImageIcon(getClass().getResource("/br/com/atmatech/sac/icon/Knob Remove Red.png"))); // NOI18N
        jBexcluir.setText("F4-Excluir");
        jBexcluir.setMaximumSize(new java.awt.Dimension(118, 41));
        jBexcluir.setMinimumSize(new java.awt.Dimension(118, 41));
        jBexcluir.setPreferredSize(new java.awt.Dimension(118, 41));
        jBexcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBexcluirActionPerformed(evt);
            }
        });

        jButton5.setIcon(
                new javax.swing.ImageIcon(getClass().getResource("/br/com/atmatech/sac/icon/Knob Loop Off.png"))); // NOI18N
        jButton5.setText("Cancelar");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

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

        jBajuda.setIcon(
                new javax.swing.ImageIcon(getClass().getResource("/br/com/atmatech/sac/icon/Knob Help.png"))); // NOI18N
        jBajuda.setText("AJUDA");
        jBajuda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBajudaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(jPanel1Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(jBalterar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jBexcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 118,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jBajuda)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jTidcliente, javax.swing.GroupLayout.PREFERRED_SIZE, 72,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jTidtecnico, javax.swing.GroupLayout.PREFERRED_SIZE, 74,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTidtecnicoanterior, javax.swing.GroupLayout.PREFERRED_SIZE, 77,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTemail, javax.swing.GroupLayout.PREFERRED_SIZE, 78,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTidtecnicoabertura, javax.swing.GroupLayout.PREFERRED_SIZE, 77,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap()));

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
                new java.awt.Component[] { jBajuda, jBalterar, jButton5 });

        jPanel1Layout
                .setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                jPanel1Layout.createSequentialGroup().addContainerGap()
                                        .addGroup(jPanel1Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jBalterar)
                                                .addComponent(jBexcluir, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jButton5)
                                                .addComponent(jTidcliente, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jTidtecnico, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jTidtecnicoanterior,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jTemail, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jTidtecnicoabertura,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jBajuda))
                                        .addContainerGap()));

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL,
                new java.awt.Component[] { jBalterar, jBexcluir, jButton5 });

        jPanel2.setPreferredSize(new java.awt.Dimension(779, 294));

        jLabel2.setForeground(new java.awt.Color(255, 0, 0));
        jLabel2.setText("Razo:");

        jLabel3.setText("Responsvel:");

        jTresponsavel.setEditable(false);

        jLabel4.setText("Tipo:");

        jLabel5.setText("Fantasia:");

        jTfantasia.setEditable(false);

        jLabel6.setText("Sistema:");

        jTmodulo.setEditable(false);

        jLabel7.setText("Telefone:");

        jTtelefone.setEditable(false);

        jLabel8.setText("Abertura:");

        jFabertura.setEditable(false);
        jFabertura.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(
                new javax.swing.text.DateFormatter(java.text.DateFormat.getTimeInstance())));
        jFabertura.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N

        jLabel9.setText("Inicial:");

        jDinicial.setForeground(new java.awt.Color(255, 0, 51));
        jDinicial.setEnabled(false);
        jDinicial.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N

        jFinicial.setEditable(false);
        jFinicial.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(
                new javax.swing.text.DateFormatter(java.text.DateFormat.getTimeInstance())));
        jFinicial.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N

        jDfinal.setForeground(new java.awt.Color(255, 0, 51));
        jDfinal.setEnabled(false);
        jDfinal.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N

        jFfinal.setEditable(false);
        jFfinal.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(
                new javax.swing.text.DateFormatter(java.text.DateFormat.getTimeInstance())));
        jFfinal.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N

        jLabel10.setText("Final:");

        jDabertura.setForeground(new java.awt.Color(255, 0, 51));
        jDabertura.setEnabled(false);
        jDabertura.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N

        jLabel11.setForeground(new java.awt.Color(255, 0, 0));
        jLabel11.setText("Solicitante:");

        jTsolicitante.setDocument(new br.com.atmatech.sac.controller.LimitaCaracterUpper(20, true));
        jTsolicitante.setNextFocusableComponent(jTsolicitacao);

        jCtipo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "INTERNO", "EXTERNO", "PLANTAO" }));
        jCtipo.setAutoscrolls(true);
        jCtipo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jCtipoMouseClicked(evt);
            }
        });
        jCtipo.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jCtipoItemStateChanged(evt);
            }
        });
        jCtipo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jCtipoFocusLost(evt);
            }
        });

        jLabel12.setForeground(new java.awt.Color(255, 0, 0));
        jLabel12.setText("Tecnico:");

        jTtecnico.setEditable(false);

        jBtecnico.setText("...");
        jBtecnico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtecnicoActionPerformed(evt);
            }
        });

        jLabel1.setForeground(new java.awt.Color(255, 51, 51));
        jLabel1.setText("Solicitao:");

        jLabel13.setText("Realizado:");

        jLabel14.setText("Pendencia:");

        jLabel15.setText("OS:");

        jTidatendimento.setEditable(false);

        jTrazao.setEditable(false);

        jButton3.setText("...");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jCStatus.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "ABERTO", "INICIADO", "PENDENTE", "FECHADO" }));
        jCStatus.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jCStatusMouseClicked(evt);
            }

            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jCStatusMouseEntered(evt);
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
                jCStatusMouseExited(evt);
            }
        });
        jCStatus.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jCStatusItemStateChanged(evt);
            }
        });
        jCStatus.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jCStatusFocusLost(evt);
            }
        });

        jLabel16.setText("Status:");

        jLabel20.setText("Anotaes:");

        jTsolicitacao.setColumns(20);
        jTsolicitacao.setDocument(new br.com.atmatech.sac.controller.LimitaCaracterUpper(600, true));
        jTsolicitacao.setLineWrap(true);
        jTsolicitacao.setRows(5);
        jTsolicitacao.setTabSize(0);
        jTsolicitacao.setNextFocusableComponent(jTrealizado);
        jTsolicitacao.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTsolicitacaoKeyPressed(evt);
            }
        });
        jScrollPane7.setViewportView(jTsolicitacao);

        jTrealizado.setColumns(20);
        jTrealizado.setDocument(new br.com.atmatech.sac.controller.LimitaCaracterUpper(600, true));
        jTrealizado.setLineWrap(true);
        jTrealizado.setRows(5);
        jTrealizado.setTabSize(0);
        jTrealizado.setNextFocusableComponent(jTpendente);
        jTrealizado.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTrealizadoKeyPressed(evt);
            }
        });
        jScrollPane8.setViewportView(jTrealizado);

        jTpendente.setColumns(20);
        jTpendente.setDocument(new br.com.atmatech.sac.controller.LimitaCaracterUpper(600, true));
        jTpendente.setLineWrap(true);
        jTpendente.setRows(3);
        jTpendente.setTabSize(0);
        jTpendente.setNextFocusableComponent(jTrealizado);
        jTpendente.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTpendenteKeyPressed(evt);
            }
        });
        jScrollPane1.setViewportView(jTpendente);

        jTanotacao.setColumns(20);
        jTanotacao.setDocument(new br.com.atmatech.sac.controller.LimitaCaracterUpper(600, true));
        jTanotacao.setLineWrap(true);
        jTanotacao.setRows(5);
        jScrollPane2.setViewportView(jTanotacao);

        jCnfe.setText("NFE");
        jCnfe.setEnabled(false);

        jCecf.setText("ECF");
        jCecf.setEnabled(false);

        jCnfce.setText("NFCE");
        jCnfce.setEnabled(false);

        jScrollPane6.setViewportBorder(javax.swing.BorderFactory.createTitledBorder(null, "Observao Chamado:",
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                javax.swing.border.TitledBorder.DEFAULT_POSITION, null, new java.awt.Color(255, 0, 0)));

        jTobsatend.setEditable(false);
        jTobsatend.setColumns(20);
        jTobsatend.setLineWrap(true);
        jTobsatend.setRows(4);
        jTobsatend.setTabSize(4);
        jTobsatend.setBorder(null);
        jScrollPane6.setViewportView(jTobsatend);

        jTtecnicoedit.setEditable(false);

        jLabel21.setText("Edio:");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(jPanel2Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addGroup(jPanel2Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jLabel3)
                                        .addComponent(jTresponsavel, javax.swing.GroupLayout.DEFAULT_SIZE, 141,
                                                Short.MAX_VALUE)
                                        .addComponent(jCtipo, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE))
                                        .addGap(3, 3, 3)
                                        .addGroup(jPanel2Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jTtelefone)
                                                .addGroup(jPanel2Layout.createSequentialGroup()
                                                        .addGroup(jPanel2Layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(jLabel8).addComponent(jLabel7))
                                                        .addGap(0, 0, Short.MAX_VALUE))
                                                .addGroup(jPanel2Layout.createSequentialGroup()
                                                        .addComponent(jDabertura,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 92,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addGap(1, 1, 1).addComponent(jFabertura))))
                                .addComponent(jLabel2).addComponent(jLabel4).addComponent(jTrazao,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 305,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(3, 3, 3)
                                .addGroup(jPanel2Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jTsolicitante, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        154, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel11)).addGap(3, 3, 3)
                                                .addGroup(jPanel2Layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addComponent(jLabel16).addComponent(jCStatus,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 154,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGroup(jPanel2Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                        false)
                                                .addComponent(jLabel5)
                                                .addComponent(jTfantasia, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        312, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGroup(jPanel2Layout.createSequentialGroup()
                                                        .addComponent(jDinicial,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addGap(1, 1, 1)
                                                        .addComponent(jFinicial,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 64,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addGroup(jPanel2Layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addGroup(
                                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                                        jPanel2Layout.createSequentialGroup()
                                                                                .addPreferredGap(
                                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                        Short.MAX_VALUE)
                                                                                .addComponent(jFfinal,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                        59,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                                                .addGroup(jPanel2Layout.createSequentialGroup()
                                                                        .addGap(3, 3, 3)
                                                                        .addGroup(jPanel2Layout.createParallelGroup(
                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                .addComponent(jLabel10)
                                                                                .addComponent(jDfinal,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                        94,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                                                        .addGap(0, 0, Short.MAX_VALUE))))
                                                .addComponent(jLabel9)))
                                .addGap(3, 3, 3)
                                .addGroup(jPanel2Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel12).addComponent(jTtecnico,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 141,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addGap(2, 2, 2).addComponent(jBtecnico,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 23,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(jTmodulo, javax.swing.GroupLayout.PREFERRED_SIZE, 139,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel6)
                                        .addGroup(jPanel2Layout.createSequentialGroup()
                                                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(jPanel2Layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addGroup(jPanel2Layout.createSequentialGroup()
                                                                .addComponent(jCnfe)
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                                .addComponent(jCnfce))
                                                        .addComponent(jCecf))))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel2Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jTtecnicoedit, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        99, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel21))
                                                .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addGroup(jPanel2Layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addComponent(jTidatendimento,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 77,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(jLabel15)))
                                        .addGroup(jPanel2Layout.createSequentialGroup()
                                                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(0, 0, Short.MAX_VALUE))))
                        .addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 795,
                                        Short.MAX_VALUE)
                                .addComponent(jScrollPane8).addComponent(jScrollPane1))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel2Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jLabel20)
                                                .addGap(0, 0, Short.MAX_VALUE))
                                        .addComponent(jScrollPane2))))
                        .addContainerGap()));
        jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                                        .addGroup(jPanel2Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel2).addComponent(jLabel5).addComponent(jLabel15)
                                                .addComponent(jLabel21)))
                                .addComponent(jCecf))
                        .addGap(1, 1, 1)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jTfantasia, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTidatendimento, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTrazao, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButton3).addComponent(jCnfe).addComponent(jCnfce)
                                .addComponent(jTtecnicoedit, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel3).addComponent(jLabel7).addComponent(jLabel11)
                                        .addComponent(jLabel16).addComponent(jLabel6)).addGap(1, 1, 1)
                                        .addGroup(jPanel2Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jTresponsavel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jTtelefone, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jTsolicitante, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jCStatus, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jTmodulo, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel2Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addGroup(jPanel2Layout.createSequentialGroup()
                                                        .addGroup(jPanel2Layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.BASELINE)
                                                                .addComponent(jLabel4).addComponent(jLabel9)
                                                                .addComponent(jLabel8))
                                                        .addGap(4, 4, 4)
                                                        .addGroup(jPanel2Layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING,
                                                                        false)
                                                                .addComponent(jCtipo,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addComponent(jDabertura,
                                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE)
                                                                .addComponent(jFabertura,
                                                                        javax.swing.GroupLayout.Alignment.TRAILING)
                                                                .addComponent(jDinicial,
                                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addComponent(jFinicial,
                                                                        javax.swing.GroupLayout.Alignment.TRAILING)
                                                                .addComponent(jDfinal,
                                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                                .addComponent(jFfinal).addComponent(jBtecnico)
                                                .addGroup(jPanel2Layout.createSequentialGroup()
                                                        .addGroup(jPanel2Layout.createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                                                .addComponent(jLabel12).addComponent(jLabel10))
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent(jTtecnico,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addComponent(jScrollPane6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel1).addComponent(jLabel20))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(
                                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(jPanel2Layout.createSequentialGroup()
                                                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLabel13)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLabel14)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jScrollPane1))
                                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 320,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        jPanel2Layout.linkSize(javax.swing.SwingConstants.VERTICAL,
                new java.awt.Component[] { jDabertura, jDfinal, jDinicial, jFabertura, jFfinal, jFinicial });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 1001, Short.MAX_VALUE))
                        .addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 514, Short.MAX_VALUE)
                        .addContainerGap()));
    }// </editor-fold>//GEN-END:initComponents

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
        //ViewListaAtendimento view = new ViewListaAtendimento(viewprincipal);
        showViewListaAtendimento();
    }//GEN-LAST:event_jButton5ActionPerformed

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

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

    private void jTtdclienteKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTtdclienteKeyPressed
        // TODO add your handling code here:        
        if ((evt.getKeyCode() == KeyEvent.VK_F)) {
            if (evt.isControlDown()) {
                atalhoBuscaCliente();
            }
        }
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            clienteSelecionado();
        }
    }//GEN-LAST:event_jTtdclienteKeyPressed

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

    private void jTtdclienteMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTtdclienteMouseClicked
        // TODO add your handling code here:
        if (evt.getClickCount() == 2) {
            clienteSelecionado();
        }
    }//GEN-LAST:event_jTtdclienteMouseClicked

    private void jTtdtecnicoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTtdtecnicoMouseClicked
        // TODO add your handling code here:
        if (evt.getClickCount() == 2) {
            clickTecnico();
            jDtecnico.setVisible(false);
            jTsolicitante.requestFocusInWindow();
        }

    }//GEN-LAST:event_jTtdtecnicoMouseClicked

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

    private void jCStatusFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jCStatusFocusLost
        // TODO add your handling code here:

    }//GEN-LAST:event_jCStatusFocusLost

    private void jCStatusMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jCStatusMouseExited
        // TODO add your handling code here:

    }//GEN-LAST:event_jCStatusMouseExited

    private void jCStatusMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jCStatusMouseEntered
        // TODO add your handling code here:

    }//GEN-LAST:event_jCStatusMouseEntered

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

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

    private void jBexcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBexcluirActionPerformed
        // TODO add your handling code here:
        if (Integer.valueOf(jTidatendimento.getText()) > 0) {
            if (JOptionPane.showConfirmDialog(this, "Deseja Excluir o Atendimento", "Atendimento",
                    JOptionPane.OK_CANCEL_OPTION) == 0) {
                deleteAtendimento();
            }
        }
    }//GEN-LAST:event_jBexcluirActionPerformed

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

    private void ACBclienteKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_ACBclienteKeyReleased
        // TODO add your handling code here:

    }//GEN-LAST:event_ACBclienteKeyReleased

    private void ACBclienteItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_ACBclienteItemStateChanged
        // TODO add your handling code here:

    }//GEN-LAST:event_ACBclienteItemStateChanged

    private void jTtdtecnicoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTtdtecnicoKeyPressed
        // TODO add your handling code here:
        if ((evt.getKeyCode() == evt.VK_ENTER) && (jTtdtecnico.getSelectedRow() >= 0)) {
            clickTecnico();
            jDtecnico.setVisible(false);
            jTsolicitante.requestFocusInWindow();
        }
    }//GEN-LAST:event_jTtdtecnicoKeyPressed

    private void jDclienteKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jDclienteKeyPressed
        // TODO add your handling code here:
        if ((evt.getKeyCode() == KeyEvent.VK_F)) {
            if (evt.isControlDown()) {
                atalhoBuscaCliente();
            }
        }

    }//GEN-LAST:event_jDclienteKeyPressed

    private void jDclienteWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_jDclienteWindowOpened
        // TODO add your handling code here:
        atalhoBuscaCliente();
    }//GEN-LAST:event_jDclienteWindowOpened

    private void jCtipoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCtipoItemStateChanged
        // TODO add your handling code here:

    }//GEN-LAST:event_jCtipoItemStateChanged

    private void jCtipoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jCtipoMouseClicked
        // TODO add your handling code here:

    }//GEN-LAST:event_jCtipoMouseClicked

    private void jCtipoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jCtipoFocusLost
        // TODO add your handling code here:
        if ((jCtipo.getSelectedItem().toString().equals("EXTERNO"))) {
            veiculo();
        }
    }//GEN-LAST:event_jCtipoFocusLost

    private void jCveiculoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCveiculoItemStateChanged
        // TODO add your handling code here:
        if (jDveiculo.isVisible()) {

            if (jCveiculo.getSelectedIndex() != 0) {
                jTidveiculo.setText(vb.get(jCveiculo.getSelectedIndex() - 1).getIdveiculo().toString());
                jTplaca.setText(vb.get(jCveiculo.getSelectedIndex() - 1).getPlaca());
                jTkminicial.setText(Double.toString((vb.get(jCveiculo.getSelectedIndex() - 1).getKm())));

            } else {
                jTplaca.setText("");
                jTkminicial.setText("");
                jTkmfinal.setText("");
                jTidveiculo.setText("");
            }
        }

    }//GEN-LAST:event_jCveiculoItemStateChanged

    private void jBokActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBokActionPerformed
        // TODO add your handling code here:
        jDveiculo.setVisible(false);
    }//GEN-LAST:event_jBokActionPerformed

    private void jTsolicitacaoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTsolicitacaoKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_TAB) {
            jTsolicitacao.transferFocus();
        }
    }//GEN-LAST:event_jTsolicitacaoKeyPressed

    private void jTrealizadoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTrealizadoKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_TAB) {
            jTrealizado.transferFocus();
        }
    }//GEN-LAST:event_jTrealizadoKeyPressed

    private void jTpendenteKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTpendenteKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_TAB) {
            jTsolicitacao.transferFocus();
        }
    }//GEN-LAST:event_jTpendenteKeyPressed

    private void jBajudaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBajudaActionPerformed
        // TODO add your handling code here:
        jTajuda.setText("");
        DefaultTableModel tabel = (DefaultTableModel) jTbajuda.getModel();
        tabel.setNumRows(0);
        jDajuda.setLocationRelativeTo(this);
        jDajuda.setVisible(true);
    }//GEN-LAST:event_jBajudaActionPerformed

    private void jTajudaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTajudaKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            consultaAjuda();
        }
    }//GEN-LAST:event_jTajudaKeyPressed

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private com.jidesoft.swing.AutoCompletionComboBox ACBcliente;
    private javax.swing.JButton jBajuda;
    private javax.swing.JButton jBalterar;
    private javax.swing.JButton jBexcluir;
    private javax.swing.JButton jBok;
    private javax.swing.JButton jBtecnico;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton5;
    private javax.swing.JComboBox jCStatus;
    private javax.swing.JCheckBox jCecf;
    private javax.swing.JCheckBox jCnfce;
    private javax.swing.JCheckBox jCnfe;
    private javax.swing.JComboBox jCtipo;
    private javax.swing.JComboBox jCveiculo;
    private com.toedter.calendar.JDateChooser jDabertura;
    private javax.swing.JDialog jDajuda;
    private javax.swing.JDialog jDcliente;
    private javax.swing.JDialog jDcombocliente;
    private com.toedter.calendar.JDateChooser jDfinal;
    private com.toedter.calendar.JDateChooser jDinicial;
    private javax.swing.JDialog jDtecnico;
    private javax.swing.JDialog jDveiculo;
    private javax.swing.JFormattedTextField jFabertura;
    private javax.swing.JFormattedTextField jFfinal;
    private javax.swing.JFormattedTextField jFinicial;
    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 jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    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.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JTextField jTajuda;
    private javax.swing.JTextArea jTanotacao;
    private javax.swing.JTable jTbajuda;
    private javax.swing.JTextField jTemail;
    private javax.swing.JTextField jTfantasia;
    private javax.swing.JTextField jTidatendimento;
    private javax.swing.JTextField jTidcliente;
    private javax.swing.JTextField jTidtecnico;
    private javax.swing.JTextField jTidtecnicoabertura;
    private javax.swing.JTextField jTidtecnicoanterior;
    private javax.swing.JTextField jTidveiculo;
    private javax.swing.JTextField jTkmfinal;
    private javax.swing.JTextField jTkminicial;
    private javax.swing.JTextField jTmodulo;
    private javax.swing.JTextArea jTobsatend;
    private javax.swing.JTextArea jTpendente;
    private javax.swing.JTextField jTplaca;
    private javax.swing.JTextField jTrazao;
    private javax.swing.JTextArea jTrealizado;
    private javax.swing.JTextField jTresponsavel;
    private javax.swing.JTextArea jTsolicitacao;
    private javax.swing.JTextField jTsolicitante;
    private javax.swing.JTable jTtdcliente;
    private javax.swing.JTable jTtdtecnico;
    private javax.swing.JTextField jTtecnico;
    private javax.swing.JTextField jTtecnicoedit;
    private javax.swing.JTextField jTtelefone;
    // End of variables declaration//GEN-END:variables

    public void showJDcliente() {
        //buscaCliente("fantasia", "", "fantasia");
        jDcliente.setLocationRelativeTo(viewprincipal);
        jDcliente.setVisible(true);
    }

    private void showJDtecnico() {
        lub = new UsuarioDao().getUsuario("tecnico", "true", "idusuario");
        DefaultTableModel tabelatecnico = (DefaultTableModel) jTtdtecnico.getModel();
        tabelatecnico.setNumRows(0);
        for (UsuarioBeans ub : lub) {
            tabelatecnico.addRow(new Object[] { ub.getNome() });
        }
        jDtecnico.setLocationRelativeTo(this);
        jDtecnico.setVisible(true);
    }

    private void buscaCliente(String parametro, String ordenacao) {
        lpb = new PessoaDao().getPessoaAtivo(parametro, ordenacao);
        DefaultTableModel tabelacliente = (DefaultTableModel) jTtdcliente.getModel();
        tabelacliente.setNumRows(0);
        for (PessoaBeans pb : lpb) {
            tabelacliente.addRow(new Object[] { pb.getFantasia(), pb.getRazao(), pb.getCnpj(), pb.getDistrito(),
                    pb.getEndereco() });
        }
    }

    private void clickCliente() {
        for (int i = 0; i < lpb.size(); i++) {
            if (i == jTtdcliente.getSelectedRow()) {
                jTidcliente.setText(lpb.get(i).getIdpessoa().toString());
                jTrazao.setText(lpb.get(i).getRazao());
                jTfantasia.setText(lpb.get(i).getFantasia());
                jTresponsavel.setText(lpb.get(i).getResponsavel());
                jTtelefone.setText(lpb.get(i).getTelefone1());
                jTmodulo.setText(lpb.get(i).getModulo());
                jTemail.setText(lpb.get(i).getEmail());
                jCecf.setSelected(lpb.get(i).isEcf());
                jCnfe.setSelected(lpb.get(i).isNfe());
                jCnfce.setSelected(lpb.get(i).isNfce());
                jTobsatend.setText(lpb.get(i).getObsatend());
                if (lpb.get(i).getObsatend() != null) {
                    if (lpb.get(i).getObsatend().length() > 0) {
                        JOptionPane.showMessageDialog(this, lpb.get(i).getObsatend(), "Observao Chamado",
                                JOptionPane.INFORMATION_MESSAGE);
                    }
                }
                return;
            }
        }
    }

    private void clickTecnico() {
        for (int i = 0; i < lub.size(); i++) {
            if (jTtdtecnico.getSelectedRow() == i) {
                jTidtecnico.setText(lub.get(i).getIdusuario().toString());
                jTtecnico.setText(lub.get(i).getNome());
            }
        }
    }

    private void salvarAtendimento() {
        try {
            AtendimentoBeans ab = new AtendimentoBeans();
            ab.setIDPESSOA(Integer.valueOf(jTidcliente.getText()));

            ab.setIDTECNICO(Integer.valueOf(jTidtecnico.getText()));

            ab.setIDABERTURA(new UsuarioLogadoBeans().getIdusuario());
            ab.setDTABERTURA(dtabertura);
            ab.setDTINICIAL(dtinicial);
            ab.setDTFINAL(dtfinal);
            ab.setSTATUS(jCStatus.getSelectedItem().toString());
            ab.setATIVO(true);
            ab.setSOLICITANTE(jTsolicitante.getText());
            ab.setTIPO(jCtipo.getSelectedItem().toString());
            ab.setSOLICITACAO(jTsolicitacao.getText());
            ab.setREALIZADO(jTrealizado.getText());
            ab.setPENDENTE(jTpendente.getText());
            ab.setAnotacao(jTanotacao.getText());
            if ((!jTidveiculo.getText().equals("0")) && (!jTidveiculo.getText().equals(""))) {
                ab.setIdveiculo(Integer.valueOf(jTidveiculo.getText()));
                ab.setKminicial(Double.valueOf(jTkminicial.getText().replaceAll(",", ".")));
                ab.setKmfinal(Double.valueOf(jTkmfinal.getText().replaceAll(",", ".")));
            } else {
                ab.setIdveiculo(null);
                ab.setKminicial(0.000);
                ab.setKmfinal(0.00);
            }
            Integer idatendimento = new AtendimentoDao().setAtendimento(ab);
            UsuarioLogadoBeans ubl = new UsuarioLogadoBeans();
            SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
            if (jCStatus.getSelectedItem().toString().equals("FECHADO")) {
                if (jTemail.getText().length() == 0) {
                    JOptionPane.showMessageDialog(this, "Cliente no Possui Email\n", "Atendimento",
                            JOptionPane.ERROR_MESSAGE);
                } else if ((ubl.getEmail().length() == 0) || (ubl.getSmtp().length() == 0)
                        || (ubl.getSenha().length() == 0) || (ubl.getPorta() == 0)
                        || (ubl.getSsl().toString().length() == 0) || (ubl.getTls().toString().length() == 0)) {
                    JOptionPane.showMessageDialog(this, "Tecnico no Possui Email\n", "Atendimento",
                            JOptionPane.ERROR_MESSAGE);
                } else {
                    new Email().emailAtendimento(ubl.getSmtp(), ubl.getEmail(), ubl.getSenhaemail(), ubl.getPorta(),
                            ubl.getSsl(), ubl.getTls(), "" + jTemail.getText(), ubl.getEmail(),
                            "" + jTsolicitante.getText(), idatendimento.toString(), jTrazao.getText(),
                            sdf.format(dtfinal), "" + jTsolicitacao.getText(), jTrealizado.getText(),
                            jTtecnico.getText(), ubl.getAssinatura());
                }
            }
            //JOptionPane.showMessageDialog(this, "Registro Salvo Com Sucesso", "Atendimento", JOptionPane.PLAIN_MESSAGE);
            showViewListaAtendimento();
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(this, "Erro ao Salvar\n" + ex, "Atendimento", JOptionPane.ERROR_MESSAGE);
        } catch (EmailException ex) {
            JOptionPane.showMessageDialog(this, "Erro ao Enviar Email\n" + ex, "Atendimento",
                    JOptionPane.ERROR_MESSAGE);
            showViewListaAtendimento();
        } catch (MalformedURLException ex) {
            JOptionPane.showMessageDialog(this, "Erro ao Enviar Email\n" + ex, "Atendimento",
                    JOptionPane.ERROR_MESSAGE);
            showViewListaAtendimento();
        } catch (NullPointerException ex) {
            JOptionPane.showMessageDialog(this, "Erro ao Enviar Email\n" + ex, "Atendimento",
                    JOptionPane.ERROR_MESSAGE);
            showViewListaAtendimento();
        }
    }

    private void alterarAtendimento() {
        try {
            AtendimentoBeans ab = new AtendimentoBeans();
            ab.setIDATENDIMENTO(Integer.valueOf(jTidatendimento.getText()));
            ab.setIDPESSOA(Integer.valueOf(jTidcliente.getText()));
            ab.setIDTECNICO(Integer.valueOf(jTidtecnico.getText()));
            ab.setIDABERTURA(Integer.valueOf(jTidtecnicoabertura.getText()));
            ab.setDTABERTURA(dtabertura);
            ab.setDTINICIAL(dtinicial);
            ab.setDTFINAL(dtfinal);
            ab.setSTATUS(jCStatus.getSelectedItem().toString());
            ab.setATIVO(true);
            ab.setSOLICITANTE(jTsolicitante.getText());
            ab.setTIPO(jCtipo.getSelectedItem().toString());
            ab.setSOLICITACAO(jTsolicitacao.getText());
            ab.setREALIZADO(jTrealizado.getText());
            ab.setPENDENTE(jTpendente.getText());
            ab.setAnotacao(jTanotacao.getText());
            ab.setIdtecnicoedit(new UsuarioLogadoBeans().getIdusuario());
            ab.setIDTECNICOANTERIOR(Integer.valueOf(jTidtecnicoanterior.getText()));
            if ((!jTidveiculo.getText().equals("0")) && (!jTidveiculo.getText().equals(""))) {
                ab.setIdveiculo(Integer.valueOf(jTidveiculo.getText()));
                ab.setKminicial(Double.valueOf(jTkminicial.getText().replaceAll(",", ".")));
                ab.setKmfinal(Double.valueOf(jTkmfinal.getText().replaceAll(",", ".")));
            } else {
                ab.setIdveiculo(null);
                ab.setKminicial(0.000);
                ab.setKmfinal(0.00);
            }
            new AtendimentoDao().updateAtendimento(ab);
            UsuarioLogadoBeans ubl = new UsuarioLogadoBeans();
            SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
            if (jCStatus.getSelectedItem().toString().equals("FECHADO")) {
                if (jTemail.getText().length() == 0) {
                    JOptionPane.showMessageDialog(this, "Cliente no Possui Email\n", "Atendimento",
                            JOptionPane.ERROR_MESSAGE);
                } else if ((ubl.getEmail().length() == 0) || (ubl.getSmtp().length() == 0)
                        || (ubl.getSenha().length() == 0) || (ubl.getPorta() == 0)
                        || (ubl.getSsl().toString().length() == 0) || (ubl.getTls().toString().length() == 0)) {
                    JOptionPane.showMessageDialog(this, "Tecnico no Possui Email\n", "Atendimento",
                            JOptionPane.ERROR_MESSAGE);
                } else {
                    new Email().emailAtendimento(ubl.getSmtp(), ubl.getEmail(), ubl.getSenhaemail(), ubl.getPorta(),
                            ubl.getSsl(), ubl.getTls(), "" + jTemail.getText(), ubl.getEmail(),
                            "" + jTsolicitante.getText(), jTidatendimento.getText(), jTrazao.getText(),
                            sdf.format(dtfinal), "" + jTsolicitacao.getText(), jTrealizado.getText(),
                            jTtecnico.getText(), ubl.getAssinatura());
                }
            }
            //JOptionPane.showMessageDialog(this, "Registro Alterado Com Sucesso", "Atendimento", JOptionPane.PLAIN_MESSAGE);
            showViewListaAtendimento();
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(this, "Erro ao Alterar\n" + ex, "Atendimento", JOptionPane.ERROR_MESSAGE);
        } catch (EmailException ex) {
            JOptionPane.showMessageDialog(this, "Erro ao Enviar Email\n" + ex, "Atendimento",
                    JOptionPane.ERROR_MESSAGE);
            showViewListaAtendimento();
        } catch (MalformedURLException ex) {
            JOptionPane.showMessageDialog(this, "Erro ao Enviar Email\n" + ex, "Atendimento",
                    JOptionPane.ERROR_MESSAGE);
            showViewListaAtendimento();
        } catch (NullPointerException ex) {
            JOptionPane.showMessageDialog(this, "Erro ao Enviar Email\n" + ex, "Atendimento",
                    JOptionPane.ERROR_MESSAGE);
            showViewListaAtendimento();
        }
    }

    private void showViewListaAtendimento() {
        //  ViewListaAtendimento view = new ViewListaAtendimento(viewprincipal, viewlatendimento,false);
        if (new UsuarioLogadoBeans().getBconsulta()) {
            ViewAtendimento.this.setVisible(false);
            viewprincipal.jTaabas.getSelectedIndex();
            viewprincipal.jTaabas.setComponentAt(viewprincipal.jTaabas.getSelectedIndex(), viewlatendimento);
        } else {
            ViewListaAtendimento view = new ViewListaAtendimento(viewprincipal, true, true);
            ViewAtendimento.this.setVisible(false);
            viewprincipal.jTaabas.getSelectedIndex();
            viewprincipal.jTaabas.setComponentAt(viewprincipal.jTaabas.getSelectedIndex(), view);
        }

    }

    public void setDataInicialFinal() {
        if ((!jCStatus.getSelectedItem().toString().equals("ABERTO")) && (jFinicial.getText().equals(""))) {
            dtinicial = new Timestamp(new Date().getTime());

            jDinicial.setDate(dtinicial);
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
            jFinicial.setText(sdf.format(dtinicial));
        }
        if (jCStatus.getSelectedItem().toString().equals("FECHADO")) {
            dtfinal = new Timestamp(new Date().getTime());
            jDfinal.setDate(dtfinal);
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
            jFfinal.setText(sdf.format(dtfinal));
        }
        if ((jCStatus.getSelectedItem().toString().equals("ABERTO"))) {
            dtinicial = null;
            jDinicial.setDate(null);
            jFinicial.setText("");
            dtfinal = null;
            jDfinal.setDate(null);
            jFfinal.setText("");
        }
        if (!(jCStatus.getSelectedItem().toString().equals("ABERTO"))
                && (!jCStatus.getSelectedItem().toString().equals("FECHADO"))) {
            dtfinal = null;
            jDfinal.setDate(null);
            jFfinal.setText("");
        }
    }

    private void atendimentoSelecionado(AtendimentoBeans ab) {
        jTidatendimento.setText(ab.getIDATENDIMENTO().toString());
        jTidcliente.setText(ab.getIDPESSOA().toString());
        jTidtecnico.setText(ab.getIDTECNICO().toString());
        jTidtecnicoabertura.setText(ab.getIDABERTURA().toString());
        jTrazao.setText(ab.getRazao());
        jTfantasia.setText(ab.getFantasia());
        jTresponsavel.setText(ab.getResponsavel());
        jTmodulo.setText(ab.getModulo());
        jTtelefone.setText(ab.getTelefone1());
        jTsolicitante.setText(ab.getSOLICITANTE());
        jCStatus.setSelectedItem(ab.getSTATUS());
        jTobsatend.setText(ab.getObsatend());
        verificaStatus(ab.getSTATUS());
        jCtipo.setSelectedItem(ab.getTIPO());
        jDabertura.setDate(ab.getDTABERTURA());
        jFabertura.setText(new SimpleDateFormat("HH:mm:ss").format(ab.getDTABERTURA()));
        dtabertura = ab.getDTABERTURA();
        jTemail.setText(ab.getEmail());
        jCecf.setSelected(ab.isEcf());
        jCnfe.setSelected(ab.isNfe());
        jCnfce.setSelected(ab.isNfce());
        jTtecnicoedit.setText(ab.getNometecnicoedit());
        if (ab.getDTINICIAL() != null) {
            jDinicial.setDate(ab.getDTINICIAL());
            jFinicial.setText(new SimpleDateFormat("HH:mm:ss").format(ab.getDTINICIAL()));
            dtinicial = ab.getDTINICIAL();
        } else {
            jDinicial.setDate(null);
            jFinicial.setValue(null);
        }
        if (ab.getDTFINAL() != null) {
            jDfinal.setDate(ab.getDTFINAL());
            jFfinal.setText(new SimpleDateFormat("HH:mm:ss").format(ab.getDTFINAL()));
            dtfinal = ab.getDTFINAL();
        } else {
            jDfinal.setDate(null);
            jFfinal.setValue(null);
        }
        jTtecnico.setText(ab.getTecniconome());
        jTsolicitacao.setText(ab.getSOLICITACAO());
        jTrealizado.setText(ab.getREALIZADO());
        jTpendente.setText(ab.getPENDENTE());
        jTanotacao.setText(ab.getAnotacao());
        jTidtecnicoanterior.setText(String.valueOf(ab.getIDTECNICOANTERIOR()));
        if (ab.getIdveiculo() > 0) {
            jTidveiculo.setText(ab.getIdveiculo().toString());
            jTplaca.setText(ab.getPlaca());
            jTkminicial.setText(Double.toString(ab.getKminicial()));
            jTkmfinal.setText(Double.toString(ab.getKmfinal()));

        }

    }

    private void deleteAtendimento() {
        try {
            new AtendimentoDao().deleteAtendimento(Integer.valueOf(jTidatendimento.getText()));
            showViewListaAtendimento();
            JOptionPane.showMessageDialog(this, "Registro Excluido Com Sucesso", "Atendimento",
                    JOptionPane.INFORMATION_MESSAGE);

        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(this, "Erro ao Excluir Registro\n" + ex, "Atendimento",
                    JOptionPane.ERROR_MESSAGE);
        }
    }

    private void permissaoUsuario() {
        int ver = 0;
        if (!new NivelAcesso().getAcesso("ViewAtendimento", "salvar", false)) {
            jBalterar.setVisible(false);
            ver++;
        }
        if (!new NivelAcesso().getAcesso("ViewAtendimento", "excluir", false)) {
            jBexcluir.setVisible(false);
            ver++;
        }

    }

    private void inicializaAtalhos() {
        KeyStroke keyStrokeJBalterar = KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0);
        String actionNameJBalterar = "TECLA_F2";
        InputMap inputMapJBalterar = jBalterar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);

        inputMapJBalterar.put(keyStrokeJBalterar, actionNameJBalterar);
        ActionMap actionMapJBMARCA = jBalterar.getActionMap();
        actionMapJBMARCA.put(actionNameJBalterar, acaojBnovo);

        //Atalho excluir
        KeyStroke keyStrokeJBexcluir = KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0);
        String actionNameJBexcluir = "F4";
        InputMap inputMapJBexcluir = jBexcluir.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);

        inputMapJBexcluir.put(keyStrokeJBexcluir, actionNameJBexcluir);
        ActionMap actionMapJBexcluir = jBexcluir.getActionMap();
        actionMapJBexcluir.put(actionNameJBexcluir, acaoJBexcluir);

        //aTALHO AJUDA
        KeyStroke keyStrokeJBajuda = KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0);
        String actionNameJBajuda = "TECLA_F9";
        InputMap inputMapJBajuda = jBajuda.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);

        inputMapJBajuda.put(keyStrokeJBajuda, actionNameJBajuda);
        ActionMap actionMapJBajuda = jBajuda.getActionMap();
        actionMapJBajuda.put(actionNameJBajuda, acaoJBajuda);

        //Atalho enter
        InputMap inputMapJBenter = this.jDcombocliente.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
        inputMapJBenter.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "forward");
        this.jDcombocliente.getRootPane().setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, inputMapJBenter);
        this.jDcombocliente.getRootPane().getActionMap().put("forward", new AbstractAction() {
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                selecionaCliente();
            }

        });
    }

    //FUNCAO DA ACAO DO BOTAO JBnovo
    Action acaojBnovo = new AbstractAction() { //funcao da acao do botao
        @Override
        public void actionPerformed(ActionEvent e) {
            //simula o click no boto  
            jBalterar.doClick();
        }
    };

    //FUNCAO de atalho excluir
    Action acaoJBexcluir = new AbstractAction() { //funcao da acao do botao
        @Override
        public void actionPerformed(ActionEvent e) {
            //simula o click no boto  

            jBexcluir.doClick();
        }
    };
    //FUNCAO de atalho ajuda
    Action acaoJBajuda = new AbstractAction() { //funcao da acao do botao
        @Override
        public void actionPerformed(ActionEvent e) {
            //simula o click no boto  

            jBajuda.doClick();
        }
    };

    public void showJDclienteagrup() {
        buscaClienteAgroup();
        jDcombocliente.setLocationRelativeTo(this);
        jDcombocliente.setVisible(true);
    }

    private void buscaClienteAgroup() {
        List<PessoaBeans> plpb = new PessoaDao().getPessoaAgrupada();
        ACBcliente.removeAllItems();
        for (PessoaBeans pb : plpb) {
            ACBcliente.addItem(pb.getRazao());
        }
    }

    private String selecionaClienteAgroup() {
        int count = 0;
        int x = 0;
        String razao = String.valueOf(ACBcliente.getSelectedItem());
        for (int i = 0; i < razao.length(); i++) {
            if (razao.charAt(i) == '|') {
                count++;
                if (count == 2) {
                    x = i;
                }
            }
        }
        return razao.substring(x + 2, razao.length());
    }

    private void selecionaCliente() {
        selecionadoCliente(Integer.valueOf(selecionaClienteAgroup()));
        jDcliente.setVisible(false);
        dtabertura = new Timestamp(new Date().getTime());
        jDabertura.setDate(dtabertura);
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
        jFabertura.setText(sdf.format(dtabertura));
        jDcombocliente.setVisible(false);
        showJDtecnico();
        jTsolicitante.requestFocusInWindow();

    }

    private void selecionadoCliente(int idcliente) {
        PessoaBeans pb = new PessoaDao().getPessoaAtivo(idcliente);
        jTidcliente.setText(pb.getIdpessoa().toString());
        jTrazao.setText(pb.getRazao());
        jTfantasia.setText(pb.getFantasia());
        jTresponsavel.setText(pb.getResponsavel());
        jTtelefone.setText(pb.getTelefone1());
        jTmodulo.setText(pb.getModulo());
        jTemail.setText(pb.getEmail());
    }

    private void verificaStatus(String status) {
        if (status.equals("FECHADO")) {
            jTsolicitante.setEnabled(false);
            jCStatus.setEnabled(false);
            jButton3.setEnabled(false);
            jBtecnico.setEnabled(false);
            jCtipo.setEnabled(false);
            jBalterar.setEnabled(false);
            jBexcluir.setEnabled(false);
            jTsolicitacao.setEnabled(false);
            jTrealizado.setEnabled(false);
            jTpendente.setEnabled(false);
            jTanotacao.setEditable(false);
        }
    }

    private void atalhoBuscaCliente() {
        //if ((evt.getKeyCode() == KeyEvent.VK_F)) {
        //  if (evt.isControlDown()) {
        String text = JOptionPane.showInputDialog(jDcliente, "Pesquisa: ", "PESQUISA", JOptionPane.WARNING_MESSAGE);
        if (text != null) {
            //DefaultTableModel tabela = (DefaultTableModel) jTtmodulo.getModel();
            //final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tabela);
            // jTtmodulo.setRowSorter(sorter);
            text = text.toUpperCase();
            //                    if (jTtdcliente.getColumnName(coluna).equals("FANTASIA")) {
            //                        buscaCliente("FANTASIA", text, "FANTASIA");
            //                    }
            //                    if (jTtdcliente.getColumnName(coluna).equals("RAZAO")) {
            //                        buscaCliente("RAZAO", text, "RAZAO");
            //                    }
            //                    if (jTtdcliente.getColumnName(coluna).equals("CNPJ")) {
            //                        buscaCliente("CNPJ", text, "CNPJ");
            //                    }
            //                    if (jTtdcliente.getColumnName(coluna).equals("CIDADE")) {
            //                        buscaCliente("DISTRITO", text, "DISTRITO");
            //                    }
            //                    if (jTtdcliente.getColumnName(coluna).equals("ENDERECO")) {
            //                        buscaCliente("ENDERECO", text, "ENDERECO");
            //                    }
            buscaCliente(text, "RAZAO");
        }

        //  }
        // }
    }

    private void clienteSelecionado() {
        clickCliente();
        jDcliente.setVisible(false);
        dtabertura = new Timestamp(new Date().getTime());
        jDabertura.setDate(dtabertura);
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
        jFabertura.setText(sdf.format(dtabertura));
        if (jTidtecnico.getText().equals("")) {
            showJDtecnico();
        }
    }

    private boolean validaCampos() {
        if ((!"".equals(jTidcliente.getText())) && (!"".equals(jTidtecnico.getText()))
                && (!jTsolicitante.getText().equals("")) && (!jTsolicitacao.getText().equals(""))) {
            return true;
        } else {
            return false;
        }
    }

    private void salvaChamado() {
        if (jTidtecnico.getText().equals("")) {
            jTidtecnico.setText("1");
        }
        //verifica se e o primeiro chamado
        if (jTidatendimento.getText().equals("")) {
            //verifica se todos os campos obrigatorios estao corretos
            if (validaCampos()) {
                //verifica se o tecnico que abril e o mesmo do selecionado e pergunta se quer abrir
                if ((Integer.valueOf(jTidtecnico.getText()) == new UsuarioLogadoBeans().getIdusuario())
                        && (jCStatus.getSelectedItem().toString().equals("ABERTO"))
                        && (jTrealizado.getText().equals("")) && (jTpendente.getText().equals(""))) {
                    if (JOptionPane.showConfirmDialog(this, "Deseja Inicializar o Atendimento?", "Atendimento",
                            JOptionPane.YES_NO_OPTION) == 0) {
                        setDataInicialFinal();
                        jCStatus.setSelectedIndex(1);
                        salvarAtendimento();
                    } else {
                        salvarAtendimento();
                    }
                    //verifica se o campo realizado esta preenchido e o status esta diferente de fechado e pergunta se quer fechar
                } else if ((!jTrealizado.getText().equals(""))
                        && (!jCStatus.getSelectedItem().toString().equals("FECHADO"))
                        && (jTpendente.getText().equals(""))) {
                    if (JOptionPane.showConfirmDialog(this, "Deseja Finalizar o Atendimento?", "Atendimento",
                            JOptionPane.YES_NO_OPTION) == 0) {
                        if (!jTidtecnico.getText().equals("1")) {
                            setDataInicialFinal();
                            jCStatus.setSelectedIndex(3);
                            salvarAtendimento();
                        } else {
                            JOptionPane.showMessageDialog(this, "Selecione um Tecnico", "Atendimento",
                                    JOptionPane.INFORMATION_MESSAGE);
                        }
                    } else {
                        salvarAtendimento();
                    }
                    //verifica se o campo pendente esta preenchido
                } else if ((!jCStatus.getSelectedItem().toString().equals("PENDENTE"))
                        && (!jTpendente.getText().equals(""))) {
                    if (JOptionPane.showConfirmDialog(this, "Deseja Colocar Chamado como Pendente?", "Atendimento",
                            JOptionPane.YES_NO_OPTION) == 0) {
                        if ((jTrealizado.getText().equals(""))) {
                            JOptionPane.showMessageDialog(this, "Digite oque Foi Realizado", "Atendimento",
                                    JOptionPane.INFORMATION_MESSAGE);
                        } else if (!jTidtecnico.getText().equals("1")) {
                            setDataInicialFinal();
                            jCStatus.setSelectedIndex(2);
                            salvarAtendimento();
                        } else {
                            JOptionPane.showMessageDialog(this, "Selecione um Tecnico", "Atendimento",
                                    JOptionPane.INFORMATION_MESSAGE);
                        }
                    } else {
                        salvarAtendimento();
                    }
                    //se nao entrou em nenhuma das condicoes salva o atendimento
                } else if ((jTidtecnico.getText().equals("1"))
                        && (jCStatus.getSelectedItem().toString().equals("FECHADO"))) {
                    JOptionPane.showMessageDialog(this, "Selecione um Tecnico", "Atendimento",
                            JOptionPane.INFORMATION_MESSAGE);
                } else if ((jTidtecnico.getText().equals("1"))
                        && (jCStatus.getSelectedItem().toString().equals("INICIADO"))) {
                    jTidtecnico.setText(new UsuarioLogadoBeans().getIdusuario().toString());
                    salvarAtendimento();
                } else if ((jCStatus.getSelectedItem().toString().equals("PENDENTE"))) {
                    if (jTpendente.getText().equals("")) {
                        JOptionPane.showMessageDialog(this, "Digite a Pendncia", "Atendimento",
                                JOptionPane.INFORMATION_MESSAGE);
                    } else if (jTrealizado.getText().equals("")) {
                        JOptionPane.showMessageDialog(this, "Digite a Realizao", "Atendimento",
                                JOptionPane.INFORMATION_MESSAGE);
                    } else {
                        salvarAtendimento();
                    }
                } else {
                    salvarAtendimento();
                }

            } else {
                JOptionPane.showMessageDialog(this, "H Campos Obrigatorios", "Atendimento",
                        JOptionPane.INFORMATION_MESSAGE);
            }
            //verifica se um chamado existente
        } else if (validaCampos()) {
            //verifica se o tecnico que abril e o mesmo do selecionado e pergunta se quer abrir
            if ((Integer.valueOf(jTidtecnico.getText()) == new UsuarioLogadoBeans().getIdusuario())
                    && (jCStatus.getSelectedItem().toString().equals("ABERTO"))
                    && (jTrealizado.getText().equals("")) && (jTpendente.getText().equals(""))) {
                if (JOptionPane.showConfirmDialog(this, "Deseja Inicializar o Atendimento?", "Atendimento",
                        JOptionPane.YES_NO_OPTION) == 0) {
                    setDataInicialFinal();
                    jCStatus.setSelectedIndex(1);
                    alterarAtendimento();
                } else {
                    alterarAtendimento();
                }
                //verifica se o campo realizado esta preenchido e o status esta diferente de fechado e pergunta se quer fechar
            } else if (!jTrealizado.getText().equals("")
                    && (!jCStatus.getSelectedItem().toString().equals("FECHADO"))
                    && (jTpendente.getText().equals(""))) {
                if (JOptionPane.showConfirmDialog(this, "Deseja Finalizar o Atendimento?", "Atendimento",
                        JOptionPane.YES_NO_OPTION) == 0) {
                    if (!jTidtecnico.getText().equals("1")) {
                        setDataInicialFinal();
                        jCStatus.setSelectedIndex(3);
                        alterarAtendimento();
                    } else {
                        JOptionPane.showMessageDialog(this, "Selecione um Tecnico", "Atendimento",
                                JOptionPane.INFORMATION_MESSAGE);
                    }
                } else {
                    alterarAtendimento();
                }

            } //verifica se o campo pendente esta preenchido
            else if ((!jCStatus.getSelectedItem().toString().equals("PENDENTE"))
                    && (!jTpendente.getText().equals(""))) {
                if (JOptionPane.showConfirmDialog(this, "Deseja Colocar Chamado como Pendente?", "Atendimento",
                        JOptionPane.YES_NO_OPTION) == 0) {
                    if ((jTrealizado.getText().equals(""))) {
                        JOptionPane.showMessageDialog(this, "Digite oque Foi Realizado", "Atendimento",
                                JOptionPane.INFORMATION_MESSAGE);
                    } else if (!jTidtecnico.getText().equals("1")) {
                        setDataInicialFinal();
                        jCStatus.setSelectedIndex(2);
                        alterarAtendimento();
                    } else {
                        JOptionPane.showMessageDialog(this, "Selecione um Tecnico", "Atendimento",
                                JOptionPane.INFORMATION_MESSAGE);
                    }
                } else {
                    alterarAtendimento();
                }
                //se nao entrou em nenhuma condicao salva 
            } else if ((jTidtecnico.getText().equals("1"))
                    && (jCStatus.getSelectedItem().toString().equals("FECHADO"))) {
                JOptionPane.showMessageDialog(this, "Selecione um Tecnico", "Atendimento",
                        JOptionPane.INFORMATION_MESSAGE);

            } else if ((jTidtecnico.getText().equals("1"))
                    && (jCStatus.getSelectedItem().toString().equals("INICIADO"))) {
                jTidtecnico.setText(new UsuarioLogadoBeans().getIdusuario().toString());
                alterarAtendimento();
            } else if ((jCStatus.getSelectedItem().toString().equals("PENDENTE"))) {
                if (jTpendente.getText().equals("")) {
                    JOptionPane.showMessageDialog(this, "Digite a Pendncia", "Atendimento",
                            JOptionPane.INFORMATION_MESSAGE);
                } else if (jTrealizado.getText().equals("")) {
                    JOptionPane.showMessageDialog(this, "Digite a Realizao", "Atendimento",
                            JOptionPane.INFORMATION_MESSAGE);
                } else {
                    alterarAtendimento();
                }
            } else {
                alterarAtendimento();
            }

        } else {
            JOptionPane.showMessageDialog(this, "H Campos Obrigatorios", "Atendimento",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    }

    private void veiculo() {
        getVeiculo();
        jDveiculo.setLocationRelativeTo(this);
        jDveiculo.setVisible(true);
    }

    private void getVeiculo() {

        vb = new VeiculoDao().getVeiculoAtivo();
        jCveiculo.removeAllItems();
        jCveiculo.addItem("");
        for (VeiculoBeans vb1 : vb) {
            jCveiculo.addItem(vb1.getModelo());
        }

    }

    private void consultaAjuda() {
        List<AtendimentoBeans> lab = new ArrayList<>();
        String sql = "";
        int count2 = 0;

        if (!jTajuda.getText().equals("")) {
            String[] sqlt = jTajuda.getText().split(" ");
            for (int i = 0; i < sqlt.length; i++) {
                if (!sqlt[i].equals("")) {
                    //if (sql.equals("")) {
                    sql = sql + " and solicitacao like('%" + sqlt[i] + "%') ";
                    //}
                }

            }
            if (!sql.equals("")) {
                sql = sql + "or(";
            }
            for (int i = 0; i < sqlt.length; i++) {
                if (!sqlt[i].equals("")) {
                    if (count2 == 0) {
                        sql = sql + " realizado like('%" + sqlt[i] + "%') ";
                    } else {
                        sql = sql + " and realizado like('%" + sqlt[i] + "%') ";
                    }
                    count2++;
                }

            }
            if (!sql.equals("")) {
                sql = sql + ")";
            }

        }
        lab = new AtendimentoDao().getAjuda(sql);
        if (lab != null) {
            DefaultTableModel tabel = (DefaultTableModel) jTbajuda.getModel();
            tabel.setNumRows(0);
            jTbajuda.setRowHeight(100);
            for (AtendimentoBeans lab1 : lab) {
                try {
                    tabel.addRow(new Object[] { adcQuebraPagina(lab1.getSOLICITACAO()),
                            adcQuebraPagina(lab1.getREALIZADO()) });
                } catch (Exception ex) {
                    JOptionPane.showMessageDialog(this, "Erro \n" + ex);
                }
            }
        }
    }

    private String adcQuebraPagina(String txt) {
        //ajusta solicitacao
        StringBuilder str = new StringBuilder();
        StringBuilder strt = new StringBuilder();
        int count = 0;
        Boolean fin = false;
        if (txt != null) {
            if (txt.length() > 40) {
                str.delete(0, str.length());
                str.append("<html>");
                for (int i = 0, x = 0; i < txt.length(); i++, x++) {
                    if (x == 40) {
                        str.append(txt.substring(count, i));
                        str.append("<br>");

                        count = i;
                        fin = true;
                        x = 0;
                        strt.delete(0, strt.length());
                    } else {
                        fin = false;
                        strt.delete(0, strt.length());
                        strt.append(txt.substring(count, txt.length()));

                    }
                }
                if (fin) {
                    str.append("</html>");
                } else {
                    str.append(strt);
                    str.append("<br>");
                    str.append("</html>");
                }

            } else {
                str.delete(0, str.length());
                str.append(txt);
            }
        }
        return str.toString();
    }
}