2
Copyright 2010, 2012, 2014 Jose Robson Mariano Alves
4
This file is part of bgfinancas.
6
This program is free software: you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
11
This package is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
21
package Movimentacoes;
23
import Biblioteca.Botoes;
24
import Biblioteca.Calendario;
25
import Biblioteca.Datas;
26
import Biblioteca.Janela;
27
import Biblioteca.Janelinha;
28
import Biblioteca.Visual;
29
import Principal.TelaPrincipal;
30
import java.sql.SQLException;
31
import javax.swing.table.DefaultTableModel;
33
public class TransferenciasPesquisar extends Janela {
35
private final String Acao;
36
private final Transferencias Transferencias;
37
private final TelaPrincipal Principal;
39
public TransferenciasPesquisar(TelaPrincipal principal, Transferencias transferencias, String acao) {
41
Visual.Janela(this.getJanela());
42
BarraDeFerramentas.add(Botoes.Sair(this));
43
Transferencias = transferencias;
45
Principal = principal;
46
resultado_pesquisa.setFont(FonteFinancas);
47
resultado_pesquisa.getTableHeader().setFont(FonteFinancas);
52
if(data.getSelectedItem()==null)
54
Banco.executeQuery("SELECT transferencias.*, TO_CHAR(transferencias.data,'DD/MM/YYYY') AS data_exibir, transferencias_itens.nome AS item_nome, transferencias_categorias.nome AS categoria_nome FROM transferencias, transferencias_itens, transferencias_categorias WHERE transferencias_itens.nome LIKE '%"+item.getText()+"%' AND transferencias.id_item=transferencias_itens.id_item AND transferencias_itens.id_categoria=transferencias_categorias.id_categoria ORDER BY transferencias.data DESC, transferencias.hora DESC");
56
Banco.executeQuery("SELECT transferencias.*, TO_CHAR(transferencias.data,'DD/MM/YYYY') AS data_exibir, transferencias_itens.nome AS item_nome, transferencias_categorias.nome AS categoria_nome FROM transferencias, transferencias_itens, transferencias_categorias WHERE transferencias_itens.nome LIKE '%"+item.getText()+"%' AND transferencias.data LIKE '%"+Datas.ConverterData(data.getSelectedItem().toString())+"%' AND transferencias.id_item=transferencias_itens.id_item AND transferencias_itens.id_categoria=transferencias_categorias.id_categoria ORDER BY transferencias.data DESC, transferencias.hora DESC");
61
DefaultTableModel modelo = (DefaultTableModel)resultado_pesquisa.getModel();
63
while(Banco.getResultSet().next())
65
modelo.addRow(new Object[]{Banco.getResultSet().getString("id_transferencia"),Banco.getResultSet().getString("item_nome"),Banco.getResultSet().getString("categoria_nome"),Lingua.getMensagem("moeda")+" "+Banco.getResultSet().getString("valor"),Banco.getResultSet().getString("data_exibir")+" "+Banco.getResultSet().getString("hora")});
67
}catch(SQLException e)
69
Janelinha.Aviso(Lingua.getMensagem("atencao"),Lingua.getMensagem("excecao")+" "+e.getMessage());
74
public void Botoes(String acao)
76
if(acao.equals(Lingua.getMensagem("sair"))){
77
TransferenciasPesquisar.this.dispose();
82
/** This method is called from within the constructor to
83
* initialize the form.
84
* WARNING: Do NOT modify this code. The content of this method is
85
* always regenerated by the Form Editor.
87
@SuppressWarnings("unchecked")
88
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
89
private void initComponents() {
91
jScrollPane1 = new javax.swing.JScrollPane();
92
jTable1 = new javax.swing.JTable();
93
BarraDeFerramentas = new javax.swing.JToolBar();
94
pesquisar_venda = new javax.swing.JPanel();
95
scroll_pesquisa = new javax.swing.JScrollPane();
96
resultado_pesquisa = new javax.swing.JTable();
97
CLIENTE_NOME = new javax.swing.JLabel();
98
item = new javax.swing.JTextField();
99
ESTADO = new javax.swing.JLabel();
100
BFiltrar = new javax.swing.JButton();
101
data = new Calendario(false);
103
jTable1.setModel(new javax.swing.table.DefaultTableModel(
105
{null, null, null, null},
106
{null, null, null, null},
107
{null, null, null, null},
108
{null, null, null, null}
111
"Title 1", "Title 2", "Title 3", "Title 4"
114
jScrollPane1.setViewportView(jTable1);
116
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
117
setTitle(Lingua.getMensagem("pesquisar"));
118
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
119
getContentPane().setLayout(null);
121
BarraDeFerramentas.setFloatable(false);
122
BarraDeFerramentas.setRollover(true);
123
getContentPane().add(BarraDeFerramentas);
124
BarraDeFerramentas.setBounds(0, 0, 710, 41);
126
pesquisar_venda.setBorder(javax.swing.BorderFactory.createTitledBorder(null, Lingua.getMensagem("transferencia"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, FonteFinancas, new java.awt.Color(0, 102, 204)));
127
pesquisar_venda.setForeground(new java.awt.Color(51, 94, 168));
129
resultado_pesquisa.setModel(new javax.swing.table.DefaultTableModel(
137
boolean[] canEdit = new boolean [] {
138
false, false, false, false, false
141
public boolean isCellEditable(int rowIndex, int columnIndex) {
142
return canEdit [columnIndex];
145
resultado_pesquisa.getTableHeader().setReorderingAllowed(false);
146
resultado_pesquisa.addMouseListener(new java.awt.event.MouseAdapter() {
147
public void mouseClicked(java.awt.event.MouseEvent evt) {
148
resultado_pesquisaMouseClicked(evt);
151
scroll_pesquisa.setViewportView(resultado_pesquisa);
152
if (resultado_pesquisa.getColumnModel().getColumnCount() > 0) {
153
resultado_pesquisa.getColumnModel().getColumn(0).setMaxWidth(40);
154
resultado_pesquisa.getColumnModel().getColumn(1).setHeaderValue(Lingua.getMensagem("nome"));
155
resultado_pesquisa.getColumnModel().getColumn(2).setHeaderValue(Lingua.getMensagem("categoria"));
156
resultado_pesquisa.getColumnModel().getColumn(3).setHeaderValue(Lingua.getMensagem("valor"));
157
resultado_pesquisa.getColumnModel().getColumn(4).setHeaderValue(Lingua.getMensagem("data"));
160
CLIENTE_NOME.setFont(FonteFinancas);
161
CLIENTE_NOME.setText(Lingua.getMensagem("item")+":");
163
item.setFont(FonteFinancas);
164
item.addActionListener(new java.awt.event.ActionListener() {
165
public void actionPerformed(java.awt.event.ActionEvent evt) {
166
itemActionPerformed(evt);
170
ESTADO.setFont(FonteFinancas);
171
ESTADO.setText(Lingua.getMensagem("data")+":");
173
BFiltrar.setFont(FonteFinancas);
174
BFiltrar.setText(Lingua.getMensagem("pesquisar"));
175
BFiltrar.setPreferredSize(null);
176
BFiltrar.addActionListener(new java.awt.event.ActionListener() {
177
public void actionPerformed(java.awt.event.ActionEvent evt) {
178
BFiltrarActionPerformed(evt);
182
data.setFont(FonteFinancas);
184
javax.swing.GroupLayout pesquisar_vendaLayout = new javax.swing.GroupLayout(pesquisar_venda);
185
pesquisar_venda.setLayout(pesquisar_vendaLayout);
186
pesquisar_vendaLayout.setHorizontalGroup(
187
pesquisar_vendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
188
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pesquisar_vendaLayout.createSequentialGroup()
190
.addGroup(pesquisar_vendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
191
.addComponent(scroll_pesquisa)
192
.addGroup(pesquisar_vendaLayout.createSequentialGroup()
193
.addComponent(CLIENTE_NOME)
194
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
196
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
197
.addComponent(ESTADO)
198
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
199
.addComponent(data, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
200
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
201
.addComponent(BFiltrar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
204
pesquisar_vendaLayout.setVerticalGroup(
205
pesquisar_vendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
206
.addGroup(pesquisar_vendaLayout.createSequentialGroup()
208
.addGroup(pesquisar_vendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
209
.addComponent(CLIENTE_NOME)
210
.addComponent(BFiltrar, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
211
.addComponent(item, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
212
.addComponent(ESTADO)
213
.addComponent(data, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
215
.addComponent(scroll_pesquisa, javax.swing.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE)
219
getContentPane().add(pesquisar_venda);
220
pesquisar_venda.setBounds(10, 60, 560, 389);
222
setSize(new java.awt.Dimension(590, 489));
223
setLocationRelativeTo(null);
224
}// </editor-fold>//GEN-END:initComponents
226
private void itemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemActionPerformed
228
}//GEN-LAST:event_itemActionPerformed
230
private void BFiltrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BFiltrarActionPerformed
232
}//GEN-LAST:event_BFiltrarActionPerformed
234
private void resultado_pesquisaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_resultado_pesquisaMouseClicked
235
String codSelecionado0;
236
String codSelecionado1;
237
String codSelecionado3;
238
codSelecionado0 = (String)resultado_pesquisa.getValueAt(resultado_pesquisa.getSelectedRow(), 0);
239
codSelecionado1 = (String)resultado_pesquisa.getValueAt(resultado_pesquisa.getSelectedRow(), 1);
240
codSelecionado3 = (String)resultado_pesquisa.getValueAt(resultado_pesquisa.getSelectedRow(), 3);
241
if(Janelinha.Pergunta(codSelecionado1, Lingua.getMensagem("tem_certeza"))){
242
Transferencias.PreencherFormulario(Acao, codSelecionado0);
243
TransferenciasPesquisar.this.dispose();
245
}//GEN-LAST:event_resultado_pesquisaMouseClicked
248
// Variables declaration - do not modify//GEN-BEGIN:variables
249
private javax.swing.JButton BFiltrar;
250
private javax.swing.JToolBar BarraDeFerramentas;
251
private javax.swing.JLabel CLIENTE_NOME;
252
private javax.swing.JLabel ESTADO;
253
private javax.swing.JComboBox data;
254
private javax.swing.JTextField item;
255
private javax.swing.JScrollPane jScrollPane1;
256
private javax.swing.JTable jTable1;
257
private javax.swing.JPanel pesquisar_venda;
258
private javax.swing.JTable resultado_pesquisa;
259
private javax.swing.JScrollPane scroll_pesquisa;
260
// End of variables declaration//GEN-END:variables