Java tutorial
/* * 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 Visao.Outros; import Controle.ControleCliente; import Controle.ControleFornecedor; import Controle.ControleFornecimento; import Controle.ControleFuncionario; import Controle.ControleObjeto; import Controle.ControleSaida; import Controle.ControleVenda; import Modelo.BEAN.Cliente; import Modelo.BEAN.Fornecedor; import Modelo.BEAN.Fornecimento; import Modelo.BEAN.Funcionario; import Modelo.BEAN.Objeto; import Modelo.BEAN.Saida; import java.util.Date; import Modelo.BEAN.Venda; import Modelo.SQL.VendaSql; import java.awt.Color; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.List; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import org.apache.commons.lang.time.DateUtils; /** * * @author Isabella */ public class FRMRelatorio extends javax.swing.JFrame { private static List<Venda> dadosVenda; private static List<Fornecimento> dadosFornecimento; private static List<Saida> dadosSaida; /** * Creates new form FRMRelatorio */ public FRMRelatorio() { initComponents(); try { dadosVenda = ControleVenda.listarTodos(); this.preencheTabelaVenda(); dadosFornecimento = ControleFornecimento.listarTodos(); this.preencheTabelaFornecimento(); dadosSaida = ControleSaida.listarTodos(); this.preencheTabelaSaida(); } catch (RuntimeException e) { JOptionPane.showMessageDialog(null, "Deu ruim: " + e); } } /** * 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() { jPanel2 = new javax.swing.JPanel(); jTabbedPane1 = new javax.swing.JTabbedPane(); jToolBar1 = new javax.swing.JToolBar(); jPanel3 = new javax.swing.JPanel(); jPanel9 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); tableVenda = new javax.swing.JTable(); jPanel10 = new javax.swing.JPanel(); dcDataInicioVenda = new com.toedter.calendar.JDateChooser(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); dcDataFimVenda = new com.toedter.calendar.JDateChooser(); btnPesquisarPeriodoVenda = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel(); cbOpcVenda = new javax.swing.JComboBox<>(); tfDadoVenda = new javax.swing.JTextField(); btnPesquisaVenda = new javax.swing.JButton(); jPanel13 = new javax.swing.JPanel(); jLabel7 = new javax.swing.JLabel(); lblTotalVenda = new javax.swing.JLabel(); jToolBar2 = new javax.swing.JToolBar(); jPanel1 = new javax.swing.JPanel(); jLabel4 = new javax.swing.JLabel(); cbOpcFornecimento = new javax.swing.JComboBox<>(); tfDadoFornecimento = new javax.swing.JTextField(); btnPesquisaFornecimento = new javax.swing.JButton(); jPanel11 = new javax.swing.JPanel(); dcDataInicioFornecimento = new com.toedter.calendar.JDateChooser(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); dcDataFimFornecimento = new com.toedter.calendar.JDateChooser(); btnPesquisarPeriodoFornecimento = new javax.swing.JButton(); jPanel12 = new javax.swing.JPanel(); jScrollPane2 = new javax.swing.JScrollPane(); tableFornecimento = new javax.swing.JTable(); jPanel14 = new javax.swing.JPanel(); jLabel8 = new javax.swing.JLabel(); lblTotalFornecimento = new javax.swing.JLabel(); jToolBar3 = new javax.swing.JToolBar(); jPanel4 = new javax.swing.JPanel(); jLabel9 = new javax.swing.JLabel(); cbOpcSaida = new javax.swing.JComboBox<>(); tfDadoSaida = new javax.swing.JTextField(); btnPesquisaSaida = new javax.swing.JButton(); jPanel15 = new javax.swing.JPanel(); jScrollPane3 = new javax.swing.JScrollPane(); tableSaida = new javax.swing.JTable(); jPanel16 = new javax.swing.JPanel(); dcDataInicioSaida = new com.toedter.calendar.JDateChooser(); jLabel10 = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); dcDataFimSaida = new com.toedter.calendar.JDateChooser(); btnPesquisarPeriodoSaida = new javax.swing.JButton(); jPanel17 = new javax.swing.JPanel(); jLabel12 = new javax.swing.JLabel(); lblTotalSaida = new javax.swing.JLabel(); btnVoltar = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Relatrios"); jPanel2.setBackground(new java.awt.Color(153, 255, 153)); jTabbedPane1.setBackground(new java.awt.Color(153, 255, 153)); jTabbedPane1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); jToolBar1.setRollover(true); jPanel3.setBackground(new java.awt.Color(204, 255, 204)); jPanel9.setBackground(new java.awt.Color(204, 255, 204)); jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder( new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED), "Relatrio de vendas")); tableVenda .setModel(new javax.swing.table.DefaultTableModel(new Object[][] { {}, {}, {}, {} }, new String[] { })); tableVenda.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { tableVendaMouseClicked(evt); } }); jScrollPane1.setViewportView(tableVenda); javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9); jPanel9.setLayout(jPanel9Layout); jPanel9Layout.setHorizontalGroup(jPanel9Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel9Layout.createSequentialGroup().addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 548, Short.MAX_VALUE) .addContainerGap())); jPanel9Layout.setVerticalGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 392, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(35, 35, 35))); jPanel10.setBackground(new java.awt.Color(204, 255, 204)); jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder( new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED), "Pesquisa por perodo")); jLabel1.setText("Data de incio:"); jLabel2.setText("Data de fim:"); btnPesquisarPeriodoVenda.setText("Pesquisar"); btnPesquisarPeriodoVenda.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPesquisarPeriodoVendaActionPerformed(evt); } }); javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10); jPanel10.setLayout(jPanel10Layout); jPanel10Layout.setHorizontalGroup(jPanel10Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel10Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(dcDataFimVenda, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel10Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) .addComponent(btnPesquisarPeriodoVenda)) .addComponent(dcDataInicioVenda, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel10Layout.createSequentialGroup() .addGroup(jPanel10Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1).addComponent(jLabel2)) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap())); jPanel10Layout.setVerticalGroup(jPanel10Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel10Layout.createSequentialGroup().addGap(6, 6, 6).addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(dcDataInicioVenda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(dcDataFimVenda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btnPesquisarPeriodoVenda).addContainerGap(20, Short.MAX_VALUE))); jLabel3.setText("Pesquisar vendas por:"); cbOpcVenda.setModel(new javax.swing.DefaultComboBoxModel<>( new String[] { "Listar todas", "Listar por Cdigo", "Listar pagas", "Listar no pagas" })); cbOpcVenda.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cbOpcVendaActionPerformed(evt); } }); tfDadoVenda.setForeground(new java.awt.Color(153, 153, 153)); tfDadoVenda.setText("Insira o dado para pesquisa..."); tfDadoVenda.addFocusListener(new java.awt.event.FocusAdapter() { public void focusGained(java.awt.event.FocusEvent evt) { tfDadoVendaFocusGained(evt); } public void focusLost(java.awt.event.FocusEvent evt) { tfDadoVendaFocusLost(evt); } }); tfDadoVenda.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { tfDadoVendaActionPerformed(evt); } }); btnPesquisaVenda .setIcon(new javax.swing.ImageIcon(getClass().getResource("/Visao.icon/magnifying-glass.png"))); // NOI18N btnPesquisaVenda.setText("Localizar"); btnPesquisaVenda.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPesquisaVendaActionPerformed(evt); } }); jPanel13.setBackground(new java.awt.Color(204, 255, 204)); jPanel13.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); jLabel7.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel7.setText("Total"); lblTotalVenda.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N lblTotalVenda.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13); jPanel13.setLayout(jPanel13Layout); jPanel13Layout.setHorizontalGroup(jPanel13Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel13Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblTotalVenda, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); jPanel13Layout .setVerticalGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel13Layout.createSequentialGroup().addContainerGap().addComponent(jLabel7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lblTotalVenda, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(23, Short.MAX_VALUE))); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel3Layout.createSequentialGroup().addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(cbOpcVenda, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(tfDadoVenda)) .addComponent(jPanel9, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGap(26, 26, 26) .addComponent(btnPesquisaVenda, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(37, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout .createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel10, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel13, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())))); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel3) .addComponent(cbOpcVenda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(tfDadoVenda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnPesquisaVenda)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGap(8, 8, 8) .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, 446, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jToolBar1.add(jPanel3); jTabbedPane1.addTab("Vendas", jToolBar1); jToolBar2.setRollover(true); jPanel1.setBackground(new java.awt.Color(204, 255, 204)); jLabel4.setText("Pesquisar fornecimento por:"); cbOpcFornecimento.setModel( new javax.swing.DefaultComboBoxModel<>(new String[] { "Listar todos", "Listar por Cdigo" })); cbOpcFornecimento.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cbOpcFornecimentoActionPerformed(evt); } }); tfDadoFornecimento.setForeground(new java.awt.Color(153, 153, 153)); tfDadoFornecimento.setText("Insira o dado para pesquisa..."); tfDadoFornecimento.addFocusListener(new java.awt.event.FocusAdapter() { public void focusGained(java.awt.event.FocusEvent evt) { tfDadoFornecimentoFocusGained(evt); } public void focusLost(java.awt.event.FocusEvent evt) { tfDadoFornecimentoFocusLost(evt); } }); tfDadoFornecimento.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { tfDadoFornecimentoActionPerformed(evt); } }); btnPesquisaFornecimento .setIcon(new javax.swing.ImageIcon(getClass().getResource("/Visao.icon/magnifying-glass.png"))); // NOI18N btnPesquisaFornecimento.setText("Localizar"); btnPesquisaFornecimento.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPesquisaFornecimentoActionPerformed(evt); } }); jPanel11.setBackground(new java.awt.Color(204, 255, 204)); jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder( new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED), "Pesquisa por perodo")); jLabel5.setText("Data de incio:"); jLabel6.setText("Data de fim:"); btnPesquisarPeriodoFornecimento.setText("Pesquisar"); btnPesquisarPeriodoFornecimento.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPesquisarPeriodoFornecimentoActionPerformed(evt); } }); javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11); jPanel11.setLayout(jPanel11Layout); jPanel11Layout.setHorizontalGroup(jPanel11Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel11Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(dcDataFimFornecimento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) .addComponent(btnPesquisarPeriodoFornecimento)) .addComponent(dcDataInicioFornecimento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel11Layout.createSequentialGroup() .addGroup(jPanel11Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel5).addComponent(jLabel6)) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap())); jPanel11Layout.setVerticalGroup(jPanel11Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel11Layout.createSequentialGroup().addGap(6, 6, 6).addComponent(jLabel5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(dcDataInicioFornecimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabel6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(dcDataFimFornecimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btnPesquisarPeriodoFornecimento).addContainerGap(20, Short.MAX_VALUE))); jPanel12.setBackground(new java.awt.Color(204, 255, 204)); jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder( new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED), "Relatrio de fornecimentos")); tableFornecimento .setModel(new javax.swing.table.DefaultTableModel(new Object[][] { {}, {}, {}, {} }, new String[] { })); jScrollPane2.setViewportView(tableFornecimento); javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12); jPanel12.setLayout(jPanel12Layout); jPanel12Layout.setHorizontalGroup(jPanel12Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel12Layout.createSequentialGroup().addContainerGap() .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 548, Short.MAX_VALUE) .addContainerGap())); jPanel12Layout.setVerticalGroup(jPanel12Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(25, 25, 25))); jPanel14.setBackground(new java.awt.Color(204, 255, 204)); jPanel14.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); jLabel8.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel8.setText("Total"); lblTotalFornecimento.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N lblTotalFornecimento.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14); jPanel14.setLayout(jPanel14Layout); jPanel14Layout.setHorizontalGroup(jPanel14Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel14Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblTotalFornecimento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); jPanel14Layout .setVerticalGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel14Layout.createSequentialGroup().addContainerGap().addComponent(jLabel8) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lblTotalFornecimento, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(23, Short.MAX_VALUE))); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(cbOpcFornecimento, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(tfDadoFornecimento)) .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(26, 26, 26) .addComponent(btnPesquisaFornecimento, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(37, Short.MAX_VALUE)) .addGroup(jPanel1Layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel14, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel4) .addComponent(cbOpcFornecimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(tfDadoFornecimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnPesquisaFornecimento)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(8, 8, 8) .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, 446, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jToolBar2.add(jPanel1); jTabbedPane1.addTab("Fornecimentos", jToolBar2); jToolBar3.setRollover(true); jPanel4.setBackground(new java.awt.Color(204, 255, 204)); jLabel9.setText("Pesquisar saida por:"); cbOpcSaida.setModel( new javax.swing.DefaultComboBoxModel<>(new String[] { "Listar todos", "Listar por Cdigo" })); cbOpcSaida.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cbOpcSaidaActionPerformed(evt); } }); tfDadoSaida.setForeground(new java.awt.Color(153, 153, 153)); tfDadoSaida.setText("Insira o dado para pesquisa..."); tfDadoSaida.addFocusListener(new java.awt.event.FocusAdapter() { public void focusGained(java.awt.event.FocusEvent evt) { tfDadoSaidaFocusGained(evt); } public void focusLost(java.awt.event.FocusEvent evt) { tfDadoSaidaFocusLost(evt); } }); tfDadoSaida.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { tfDadoSaidaActionPerformed(evt); } }); btnPesquisaSaida .setIcon(new javax.swing.ImageIcon(getClass().getResource("/Visao.icon/magnifying-glass.png"))); // NOI18N btnPesquisaSaida.setText("Localizar"); btnPesquisaSaida.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPesquisaSaidaActionPerformed(evt); } }); jPanel15.setBackground(new java.awt.Color(204, 255, 204)); jPanel15.setBorder(javax.swing.BorderFactory.createTitledBorder( new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED), "Relatrio de saidas")); tableSaida .setModel(new javax.swing.table.DefaultTableModel(new Object[][] { {}, {}, {}, {} }, new String[] { })); jScrollPane3.setViewportView(tableSaida); javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15); jPanel15.setLayout(jPanel15Layout); jPanel15Layout.setHorizontalGroup(jPanel15Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel15Layout.createSequentialGroup().addContainerGap() .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 548, Short.MAX_VALUE) .addContainerGap())); jPanel15Layout.setVerticalGroup(jPanel15Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel15Layout.createSequentialGroup().addContainerGap() .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE) .addContainerGap())); jPanel16.setBackground(new java.awt.Color(204, 255, 204)); jPanel16.setBorder(javax.swing.BorderFactory.createTitledBorder( new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED), "Pesquisa por perodo")); jLabel10.setText("Data de incio:"); jLabel11.setText("Data de fim:"); btnPesquisarPeriodoSaida.setText("Pesquisar"); btnPesquisarPeriodoSaida.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPesquisarPeriodoSaidaActionPerformed(evt); } }); javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16); jPanel16.setLayout(jPanel16Layout); jPanel16Layout.setHorizontalGroup(jPanel16Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel16Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(dcDataFimSaida, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel16Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) .addComponent(btnPesquisarPeriodoSaida)) .addComponent(dcDataInicioSaida, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel16Layout.createSequentialGroup() .addGroup(jPanel16Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel10).addComponent(jLabel11)) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap())); jPanel16Layout.setVerticalGroup(jPanel16Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel16Layout.createSequentialGroup().addGap(6, 6, 6).addComponent(jLabel10) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(dcDataInicioSaida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel11).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(dcDataFimSaida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btnPesquisarPeriodoSaida).addContainerGap(20, Short.MAX_VALUE))); jPanel17.setBackground(new java.awt.Color(204, 255, 204)); jPanel17.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); jLabel12.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel12.setText("Total"); lblTotalSaida.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N lblTotalSaida.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17); jPanel17.setLayout(jPanel17Layout); jPanel17Layout.setHorizontalGroup(jPanel17Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel17Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblTotalSaida, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); jPanel17Layout .setVerticalGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel17Layout.createSequentialGroup().addContainerGap().addComponent(jLabel12) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lblTotalSaida, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(23, Short.MAX_VALUE))); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel4Layout.createSequentialGroup().addComponent(jLabel9) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(cbOpcSaida, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(tfDadoSaida)) .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addGap(26, 26, 26) .addComponent(btnPesquisaSaida, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(37, Short.MAX_VALUE)) .addGroup(jPanel4Layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel16, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())))); jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap().addGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel9) .addComponent(cbOpcSaida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(tfDadoSaida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnPesquisaSaida)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addGap(8, 8, 8) .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jToolBar3.add(jPanel4); jTabbedPane1.addTab("Saidas", jToolBar3); btnVoltar.setText("Voltar"); btnVoltar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnVoltarActionPerformed(evt); } }); 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) .addComponent(jTabbedPane1).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) .addComponent(btnVoltar))) .addContainerGap())); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 524, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE) .addComponent(btnVoltar).addContainerGap())); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)); pack(); }// </editor-fold>//GEN-END:initComponents private void tfDadoVendaFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tfDadoVendaFocusGained if (tfDadoVenda.getText().equals("Insira o dado para pesquisa...")) { tfDadoVenda.setText(""); tfDadoVenda.setForeground(Color.BLACK); } }//GEN-LAST:event_tfDadoVendaFocusGained private void tfDadoVendaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tfDadoVendaFocusLost if (tfDadoVenda.getText().equals("")) { tfDadoVenda.setForeground(Color.GRAY); tfDadoVenda.setText("Insira o dado para pesquisa..."); } }//GEN-LAST:event_tfDadoVendaFocusLost private void tfDadoVendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfDadoVendaActionPerformed this.localizarVenda(); }//GEN-LAST:event_tfDadoVendaActionPerformed private void btnPesquisaVendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisaVendaActionPerformed this.localizarVenda(); }//GEN-LAST:event_btnPesquisaVendaActionPerformed private void cbOpcVendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbOpcVendaActionPerformed if (cbOpcVenda.getSelectedIndex() == 0) { try { dadosVenda = ControleVenda.listarTodos(); this.preencheTabelaVenda(); } catch (RuntimeException e) { JOptionPane.showMessageDialog(null, "Deu ruim: " + e); } } else if (cbOpcVenda.getSelectedIndex() == 2) { try { dadosVenda = ControleVenda.listarPorSituacao(Venda.Situacao.PAGO); this.preencheTabelaVenda(); } catch (RuntimeException e) { JOptionPane.showMessageDialog(null, "Deu ruim: " + e); } } else if (cbOpcVenda.getSelectedIndex() == 3) { try { dadosVenda = ControleVenda.listarPorSituacao(Venda.Situacao.NAOPAGO); this.preencheTabelaVenda(); } catch (RuntimeException e) { JOptionPane.showMessageDialog(null, "Deu ruim: " + e); } } }//GEN-LAST:event_cbOpcVendaActionPerformed private void btnPesquisarPeriodoVendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisarPeriodoVendaActionPerformed try { if ((dcDataInicioVenda.getDate() != null) && (dcDataFimVenda.getDate() != null)) { Date dataInicio = DateUtils.truncate(dcDataInicioVenda.getDate(), Calendar.DATE); Calendar calendar = Calendar.getInstance(); calendar.setTime(dcDataFimVenda.getDate()); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 59); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.HOUR_OF_DAY, 23); Date dataFim = calendar.getTime(); dadosVenda = ControleVenda.listarPorDataInicioFim(dataInicio, dataFim); this.preencheTabelaVenda(); } else if (dcDataInicioVenda.getDate() != null) { Date dataInicio = DateUtils.truncate(dcDataInicioVenda.getDate(), Calendar.DATE); dadosVenda = ControleVenda.listarPorDataInicio(dataInicio); this.preencheTabelaVenda(); } else if (dcDataFimVenda.getDate() != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(dcDataFimVenda.getDate()); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 59); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.HOUR_OF_DAY, 23); Date dataFim = calendar.getTime(); dadosVenda = ControleVenda.listarPorDataFim(dataFim); this.preencheTabelaVenda(); } else { JOptionPane.showMessageDialog(null, "Ao menos uma data deve ser inserida ou escolhida."); } } catch (RuntimeException e) { System.out.println("Deu ruim: " + e); } }//GEN-LAST:event_btnPesquisarPeriodoVendaActionPerformed private void cbOpcFornecimentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbOpcFornecimentoActionPerformed if (cbOpcFornecimento.getSelectedIndex() == 0) { try { dadosFornecimento = ControleFornecimento.listarTodos(); this.preencheTabelaFornecimento(); } catch (RuntimeException e) { JOptionPane.showMessageDialog(null, "Deu ruim: " + e); } } }//GEN-LAST:event_cbOpcFornecimentoActionPerformed private void tfDadoFornecimentoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tfDadoFornecimentoFocusGained if (tfDadoFornecimento.getText().equals("Insira o dado para pesquisa...")) { tfDadoFornecimento.setText(""); tfDadoFornecimento.setForeground(Color.BLACK); } }//GEN-LAST:event_tfDadoFornecimentoFocusGained private void tfDadoFornecimentoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tfDadoFornecimentoFocusLost if (tfDadoFornecimento.getText().equals("")) { tfDadoFornecimento.setForeground(Color.GRAY); tfDadoFornecimento.setText("Insira o dado para pesquisa..."); } }//GEN-LAST:event_tfDadoFornecimentoFocusLost private void tfDadoFornecimentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfDadoFornecimentoActionPerformed this.localizarFornecimento(); }//GEN-LAST:event_tfDadoFornecimentoActionPerformed private void btnPesquisaFornecimentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisaFornecimentoActionPerformed this.localizarFornecimento(); }//GEN-LAST:event_btnPesquisaFornecimentoActionPerformed private void btnPesquisarPeriodoFornecimentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisarPeriodoFornecimentoActionPerformed try { if ((dcDataInicioFornecimento.getDate() != null) && (dcDataFimFornecimento.getDate() != null)) { Date dataInicio = DateUtils.truncate(dcDataInicioFornecimento.getDate(), Calendar.DATE); Calendar calendar = Calendar.getInstance(); calendar.setTime(dcDataFimFornecimento.getDate()); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 59); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.HOUR_OF_DAY, 23); Date dataFim = calendar.getTime(); dadosFornecimento = ControleFornecimento.listarPorDataInicioFim(dataInicio, dataFim); this.preencheTabelaFornecimento(); } else if (dcDataInicioFornecimento.getDate() != null) { Date dataInicio = DateUtils.truncate(dcDataInicioFornecimento.getDate(), Calendar.DATE); dadosFornecimento = ControleFornecimento.listarPorDataInicio(dataInicio); this.preencheTabelaFornecimento(); } else if (dcDataFimFornecimento.getDate() != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(dcDataFimFornecimento.getDate()); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 59); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.HOUR_OF_DAY, 23); Date dataFim = calendar.getTime(); dadosFornecimento = ControleFornecimento.listarPorDataFim(dataFim); this.preencheTabelaFornecimento(); } else { JOptionPane.showMessageDialog(null, "Ao menos uma data deve ser inserida ou escolhida."); } } catch (RuntimeException e) { System.out.println("Deu ruim: " + e); } }//GEN-LAST:event_btnPesquisarPeriodoFornecimentoActionPerformed private void cbOpcSaidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbOpcSaidaActionPerformed if (cbOpcSaida.getSelectedIndex() == 0) { try { dadosSaida = ControleSaida.listarTodos(); this.preencheTabelaSaida(); } catch (RuntimeException e) { JOptionPane.showMessageDialog(null, "Deu ruim: " + e); } } }//GEN-LAST:event_cbOpcSaidaActionPerformed private void tfDadoSaidaFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tfDadoSaidaFocusGained if (tfDadoSaida.getText().equals("Insira o dado para pesquisa...")) { tfDadoSaida.setText(""); tfDadoSaida.setForeground(Color.BLACK); } }//GEN-LAST:event_tfDadoSaidaFocusGained private void tfDadoSaidaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tfDadoSaidaFocusLost if (tfDadoSaida.getText().equals("")) { tfDadoSaida.setForeground(Color.GRAY); tfDadoSaida.setText("Insira o dado para pesquisa..."); } }//GEN-LAST:event_tfDadoSaidaFocusLost private void tfDadoSaidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfDadoSaidaActionPerformed this.localizarSaida(); }//GEN-LAST:event_tfDadoSaidaActionPerformed private void btnPesquisaSaidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisaSaidaActionPerformed this.localizarSaida(); }//GEN-LAST:event_btnPesquisaSaidaActionPerformed private void btnPesquisarPeriodoSaidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisarPeriodoSaidaActionPerformed try { if ((dcDataInicioSaida.getDate() != null) && (dcDataFimSaida.getDate() != null)) { Date dataInicio = DateUtils.truncate(dcDataInicioSaida.getDate(), Calendar.DATE); Calendar calendar = Calendar.getInstance(); calendar.setTime(dcDataFimSaida.getDate()); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 59); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.HOUR_OF_DAY, 23); Date dataFim = calendar.getTime(); dadosSaida = ControleSaida.listarPorDataInicioFim(dataInicio, dataFim); this.preencheTabelaSaida(); } else if (dcDataInicioSaida.getDate() != null) { Date dataInicio = DateUtils.truncate(dcDataInicioSaida.getDate(), Calendar.DATE); dadosSaida = ControleSaida.listarPorDataInicio(dataInicio); this.preencheTabelaSaida(); } else if (dcDataFimSaida.getDate() != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(dcDataFimSaida.getDate()); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 59); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.HOUR_OF_DAY, 23); Date dataFim = calendar.getTime(); dadosSaida = ControleSaida.listarPorDataFim(dataFim); this.preencheTabelaSaida(); } else { JOptionPane.showMessageDialog(null, "Ao menos uma data deve ser inserida ou escolhida."); } } catch (RuntimeException e) { throw new RuntimeException(e); } }//GEN-LAST:event_btnPesquisarPeriodoSaidaActionPerformed private void btnVoltarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVoltarActionPerformed FRMPrincipal p = new FRMPrincipal(); p.setVisible(true); this.dispose(); }//GEN-LAST:event_btnVoltarActionPerformed private void tableVendaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableVendaMouseClicked Venda v = dadosVenda.get(tableVenda.getSelectedRow()); if (v.getSituacao().equals(Venda.Situacao.NAOPAGO)) { int opc = JOptionPane.showConfirmDialog(null, "Gostaria de confirmar o pagamento da venda de cdigo " + v.getCodigo() + "?"); if (opc == 0) { try { ControleVenda.confirmaPagamento(v); dadosVenda = ControleVenda.listarTodos(); this.preencheTabelaVenda(); } catch (RuntimeException e) { JOptionPane.showMessageDialog(null, "Deu ruim: " + e); } } } }//GEN-LAST:event_tableVendaMouseClicked /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(FRMRelatorio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(FRMRelatorio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(FRMRelatorio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(FRMRelatorio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new FRMRelatorio().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnPesquisaFornecimento; private javax.swing.JButton btnPesquisaSaida; private javax.swing.JButton btnPesquisaVenda; private javax.swing.JButton btnPesquisarPeriodoFornecimento; private javax.swing.JButton btnPesquisarPeriodoSaida; private javax.swing.JButton btnPesquisarPeriodoVenda; private javax.swing.JButton btnVoltar; private javax.swing.JComboBox<String> cbOpcFornecimento; private javax.swing.JComboBox<String> cbOpcSaida; private javax.swing.JComboBox<String> cbOpcVenda; private com.toedter.calendar.JDateChooser dcDataFimFornecimento; private com.toedter.calendar.JDateChooser dcDataFimSaida; private com.toedter.calendar.JDateChooser dcDataFimVenda; private com.toedter.calendar.JDateChooser dcDataInicioFornecimento; private com.toedter.calendar.JDateChooser dcDataInicioSaida; private com.toedter.calendar.JDateChooser dcDataInicioVenda; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel10; private javax.swing.JPanel jPanel11; private javax.swing.JPanel jPanel12; private javax.swing.JPanel jPanel13; private javax.swing.JPanel jPanel14; private javax.swing.JPanel jPanel15; private javax.swing.JPanel jPanel16; private javax.swing.JPanel jPanel17; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel9; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JTabbedPane jTabbedPane1; private javax.swing.JToolBar jToolBar1; private javax.swing.JToolBar jToolBar2; private javax.swing.JToolBar jToolBar3; private javax.swing.JLabel lblTotalFornecimento; private javax.swing.JLabel lblTotalSaida; private javax.swing.JLabel lblTotalVenda; private javax.swing.JTable tableFornecimento; private javax.swing.JTable tableSaida; private javax.swing.JTable tableVenda; private javax.swing.JTextField tfDadoFornecimento; private javax.swing.JTextField tfDadoSaida; private javax.swing.JTextField tfDadoVenda; // End of variables declaration//GEN-END:variables private void localizarVenda() { if (cbOpcVenda.getSelectedIndex() == 1) { if ((tfDadoVenda.getText().equals("")) || (tfDadoVenda.getText().equals("Insira o dado para pesquisa..."))) { JOptionPane.showMessageDialog(null, "Insira algum dado para pesquisa."); } else { try { dadosVenda = ControleVenda.listarTudoTodosOuPorCodigo(Integer.parseInt(tfDadoVenda.getText())); this.preencheTabelaVenda(); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(null, "Para pesquisa por cdigos, insira apenas nmeros"); } catch (RuntimeException e) { JOptionPane.showMessageDialog(null, "Deu ruim: " + e); } } } } private void preencheTabelaVenda() { DefaultTableModel dtm = this.criaTabelaVenda(); dtm.addColumn("Cdigo"); dtm.addColumn("Data e hora"); dtm.addColumn("Valor total"); dtm.addColumn("Situao"); dtm.addColumn("Cliente"); dtm.addColumn("Funcionrio"); for (Venda dado : dadosVenda) { SimpleDateFormat sdf = new SimpleDateFormat("HH:mm - dd/MM/yyyy"); String dataHora = sdf.format(dado.getDataHora()); String situacao = ""; if (dado.getSituacao().equals(Venda.Situacao.PAGO)) { situacao = "Pago"; } else { situacao = "No pago"; } dtm.addRow(new Object[] { dado.getCodigo(), dataHora, dado.getValorTotal(), situacao, dado.getCliente().getNome(), dado.getFuncionario().getNome() }); } tableVenda.setModel(dtm); this.calculaTotalVenda(); } private DefaultTableModel criaTabelaVenda() { DefaultTableModel dTable = new DefaultTableModel() { Class[] types = new Class[] { java.lang.Integer.class, java.lang.String.class, java.lang.Float.class, java.lang.String.class, java.lang.String.class, java.lang.String.class }; boolean[] canEdit = new boolean[] { false, false, false, false, false, false }; @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; }; }; return dTable; } private void calculaTotalVenda() { float valorTotal = 0; for (Venda venda : dadosVenda) { valorTotal += venda.getValorTotal(); } lblTotalVenda.setText(valorTotal + ""); } private void localizarFornecimento() { if (cbOpcFornecimento.getSelectedIndex() == 1) { if ((tfDadoFornecimento.getText().equals("")) || (tfDadoFornecimento.getText().equals("Insira o dado para pesquisa..."))) { JOptionPane.showMessageDialog(null, "Insira algum dado para pesquisa."); } else { try { dadosFornecimento = ControleFornecimento .listarTudoTodosOuPorCodigo(Integer.parseInt(tfDadoFornecimento.getText())); this.preencheTabelaFornecimento(); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(null, "Para pesquisa por cdigos, insira apenas nmeros"); } catch (RuntimeException e) { JOptionPane.showMessageDialog(null, "Deu ruim: " + e); } } } } private void preencheTabelaFornecimento() { DefaultTableModel dtm = this.criaTabelaFornecimento(); dtm.addColumn("Cdigo"); dtm.addColumn("Data"); dtm.addColumn("Valor total"); dtm.addColumn("Nota fiscal"); dtm.addColumn("Fornecedor"); for (Fornecimento dado : dadosFornecimento) { SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); String dataHora = sdf.format(dado.getData()); dtm.addRow(new Object[] { dado.getCodigo(), dataHora, dado.getValorTotal(), dado.getnNotaFiscal(), dado.getFornecedor().getNome() }); } tableFornecimento.setModel(dtm); this.calculaTotalFornecimento(); } private DefaultTableModel criaTabelaFornecimento() { DefaultTableModel dTable = new DefaultTableModel() { Class[] types = new Class[] { java.lang.Integer.class, java.lang.String.class, java.lang.Float.class, java.lang.String.class, java.lang.String.class }; boolean[] canEdit = new boolean[] { false, false, false, false, false }; @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; }; }; return dTable; } private void calculaTotalFornecimento() { float valorTotal = 0; for (Fornecimento fornecimento : dadosFornecimento) { valorTotal += fornecimento.getValorTotal(); } lblTotalFornecimento.setText(valorTotal + ""); } private void localizarSaida() { if (cbOpcSaida.getSelectedIndex() == 1) { if ((tfDadoSaida.getText().equals("")) || (tfDadoSaida.getText().equals("Insira o dado para pesquisa..."))) { JOptionPane.showMessageDialog(null, "Insira algum dado para pesquisa."); } else { try { dadosSaida = ControleSaida.listarTudoTodosOuPorCodigo(Integer.parseInt(tfDadoSaida.getText())); this.preencheTabelaSaida(); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(null, "Para pesquisa por cdigos, insira apenas nmeros"); } catch (RuntimeException e) { JOptionPane.showMessageDialog(null, "Deu ruim: " + e); } } } } private void preencheTabelaSaida() { DefaultTableModel dtm = this.criaTabelaSaida(); dtm.addColumn("Cdigo"); dtm.addColumn("Data"); dtm.addColumn("Valor total"); dtm.addColumn("Tipo de saida"); for (Saida dado : dadosSaida) { SimpleDateFormat sdf = new SimpleDateFormat("HH:mm - dd/MM/yyyy"); String dataHora = sdf.format(dado.getDataHora()); String tipo = ""; if (dado.getTipoSaida().equals(Saida.TipoSaida.SAIDAMANUAL)) { tipo = "Manual"; } else { tipo = "Pela venda"; } dtm.addRow(new Object[] { dado.getCodigo(), dataHora, dado.getValorTotal(), tipo }); } tableSaida.setModel(dtm); this.calculaTotalSaida(); } private DefaultTableModel criaTabelaSaida() { DefaultTableModel dTable = new DefaultTableModel() { Class[] types = new Class[] { java.lang.Integer.class, java.lang.String.class, java.lang.Float.class, java.lang.String.class }; boolean[] canEdit = new boolean[] { false, false, false, false }; @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; }; }; return dTable; } private void calculaTotalSaida() { float valorTotal = 0; for (Saida saida : dadosSaida) { valorTotal += saida.getValorTotal(); } lblTotalSaida.setText(valorTotal + ""); } }