Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 76295 Details for
Bug 200348
Teste Mylyn
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
dd
PnCadEntrada.java (text/plain), 14.19 KB, created by
Eduardo Hitek
on 2007-08-17 08:53:03 EDT
(
hide
)
Description:
dd
Filename:
MIME Type:
Creator:
Eduardo Hitek
Created:
2007-08-17 08:53:03 EDT
Size:
14.19 KB
patch
obsolete
>/* > * PnExemploEntrada.java > * > * Created on 1 de Setembro de 2005, 13:43 > */ > >package com.maxmil.olimpo.almoxarifado; >import com.maxmil.olimpo.config.Configuracao; >import com.maxmil.util.LoadLib; >import com.maxmil.olimpo.core.MMTipo; >import com.maxmil.olimpo.core.Pessoa; >import com.maxmil.olimpo.core.Produto; >import com.maxmil.olimpo.core.SaidaProduto; >import com.maxmil.olimpo.comums.DiPesqItens; >import com.maxmil.olimpo.template.ComboConTemplate; >import com.maxmil.olimpo.template.ConComboBoxActionListener; >import com.maxmil.olimpo.template.EditDialogTemplate; >import com.maxmil.olimpo.template.InsercaoPanelTemplate; >import com.maxmil.swing.ConTable; >import com.maxmil.swing.table.ConTableModel; >import com.maxmil.swing.table.FormTableModel; >import com.maxmil.olimpo.exceptions.DeleteObjectException; >import com.maxmil.ui.NavegacaoInterface; >import com.maxmil.ui.PesquisaInterface; >import com.maxmil.olimpo.exceptions.SaveObjectException; >import java.math.BigDecimal; >import java.util.Iterator; >import java.util.Vector; >import javax.swing.JOptionPane; >import javax.swing.table.DefaultTableCellRenderer; > >/** ><<<<<<< PnCadEntrada.java > * @author samuel >======= > * Cadastro de Entrada > * @author samuel >>>>>>>> 1.43.8.1 > */ >public class PnCadEntrada extends InsercaoPanelTemplate implements NavegacaoInterface, PesquisaInterface { > > /** > * > */ > private static final long serialVersionUID = -1920339623016960020L; > /** Cria uma nota instancia de PnCadEntrada */ > public PnCadEntrada() { > super(); > remove( tableScrollPane ); > initComponents(); > add(tableScrollPane, java.awt.BorderLayout.CENTER); > } > > /** Inicia os componentes gráficos */ > // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents > private void initComponents() { > itensPanel = new javax.swing.JPanel(); > itensScrollPane = new javax.swing.JScrollPane(); > itensTable = new ConTable(); > bottomPanel = new javax.swing.JPanel(); > gerenciaButton = new javax.swing.JButton(); > valorLabel = new javax.swing.JLabel(); > valorNotaLabel = new javax.swing.JLabel(); > > setLayout(new java.awt.BorderLayout()); > > itensPanel.setLayout(new java.awt.BorderLayout()); > > itensPanel.setPreferredSize(new java.awt.Dimension(10, 180)); > itensTable.setModel(new ConTableModel( > new Object [][] { }, > new String [] { "Nome", "Quantidade", "Valor" } > )); > itensTable.getColumnModel().getColumn(1).setMaxWidth(85); > itensTable.getColumnModel().getColumn(1).setMinWidth(85); > itensTable.getColumnModel().getColumn(2).setMaxWidth(85); > itensTable.getColumnModel().getColumn(2).setMinWidth(85); > itensScrollPane.setViewportView(itensTable); > > itensPanel.add(itensScrollPane, java.awt.BorderLayout.CENTER); > > bottomPanel.setLayout(new java.awt.BorderLayout()); > > gerenciaButton.setMnemonic('G'); > gerenciaButton.setText("Gerencia Itens"); > gerenciaButton.setPreferredSize(new java.awt.Dimension(152, 25)); > gerenciaButton.addActionListener(new java.awt.event.ActionListener() { > public void actionPerformed(java.awt.event.ActionEvent evt) { > gerenciaButtonActionPerformed(evt); > } > }); > > bottomPanel.add(gerenciaButton, java.awt.BorderLayout.WEST); > > valorLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); > valorLabel.setText("Valor: "); > bottomPanel.add(valorLabel, java.awt.BorderLayout.CENTER); > > bottomPanel.add(valorNotaLabel, java.awt.BorderLayout.EAST); > > itensPanel.add(bottomPanel, java.awt.BorderLayout.SOUTH); > > add(itensPanel, java.awt.BorderLayout.SOUTH); > > } > // </editor-fold>//GEN-END:initComponents > /** > * Evento do botão Gerencia Itens que chama o método gerenciaItens() > */ > private void gerenciaButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gerenciaButtonActionPerformed > gerenciaItens(); > }//GEN-LAST:event_gerenciaButtonActionPerformed > > > // Variables declaration - do not modify//GEN-BEGIN:variables > private javax.swing.JPanel bottomPanel; > private javax.swing.JButton gerenciaButton; > private javax.swing.JPanel itensPanel; > private javax.swing.JScrollPane itensScrollPane; > private javax.swing.JTable itensTable; > private javax.swing.JLabel valorLabel; > private javax.swing.JLabel valorNotaLabel; > // End of variables declaration//GEN-END:variables > > > > private NotaFiscal nota; > /** > * Monta o objeto de acordo com as informações dos campos da tela > * @return Objeto já preenchido corretamente > */ > public com.maxmil.olimpo.core.MMTipo getForm() { > if ( nota == null ) > nota = new NotaFiscal(); > try { > FormTableModel ft = (FormTableModel)formTable.getModel(); > nota.setData( (java.sql.Date)ft.getValue("Data") ); > nota.setPessoa( (Pessoa)ft.getValue("Fornecedor") ); > nota.setNotaFiscal( ft.getValue("Nota Fiscal").toString() ); > nota.setValorDesconto( Double.parseDouble( ft.getValue("Desconto").toString() ) ); > nota.setItems( getItems() ); > nota.setValorTotal( nota.calculaValorTotal() ); > } catch ( Exception e ) { > Configuracao.logger.warn( this.getClass().toString()+" Erro no getForm: " + e.getMessage() ); > e.printStackTrace(); > } > return nota; > } > /** > * Preenche os campos da tela com as informações contidas no objeto > * @param objeto > */ > @SuppressWarnings({ "unchecked", "static-access" }) > public void initFormTable( com.maxmil.olimpo.core.MMTipo objeto ) { > if ( ( objeto instanceof NotaFiscal ) == false ) { > objeto = new NotaFiscal(); > if ( gerenciaButton != null ) > gerenciaButton.setEnabled( true ); > > } else { > if ( gerenciaButton != null ) > gerenciaButton.setEnabled( false ); > } > try { > NotaFiscal s = (NotaFiscal)objeto; > FormTableModel ft = (FormTableModel)formTable.getModel(); > ft.removeAllRows(); > ft.addDateField( "Data", s.getData(), true, "Informe a data de entrada" ); > ft.addComboBox( "Fornecedor", Configuracao.daoF.getAlmoxarifadoDAO().getFornecedores(), s.getPessoa(), "Selecione o fornecedor" ); > ft.addFormattedTextField( "Nota Fiscal", s.getNotaFiscal(), "Informe o número da nota fiscal" ); > ft.addSpecificTextField( "Desconto", ""+s.getValorDesconto(), ft.TYPE_CURRENCY, "Informe o valor do desconto" ); > ft.addRowActionListener( "Fornecedor", new ConComboBoxActionListener( "Fornecedor", "com.maxmil.olimpo.core.PnConCredores", formTable )); > > formTable.setModel( ft ); > nota = s; > carregaItens( nota.getItems() ); > } catch ( Exception ex ) { > Configuracao.logger.warn( this.getClass().toString()+" Erro no initFormTable: " + ex.getMessage() ); > ex.printStackTrace(); > } > } > /** > * Verifica se o objeto é novo ou se é um objeto já cadastrado, inicia os campos gráficos > * de maneira diferente para um objeto novo e para um objeto já cadastrado. > * Se é um objeto novo, inicia os campos da tela com valores em branco. > * Se é um objeto já cadastrado, recupera os dados do objeto cadastrado no banco. > * @param id > */ > public void setObjectId( int id ) { > initIfExists( Configuracao.daoF.getAlmoxarifadoDAO().getNotaFiscal( id ) ); > } > /** > * Retorna o tÃtulo da janela > * @return TÃtulo da janela > */ > public String getTitulo() { > return "Cadastro de Entrada"; > } > /** > * Salva o determinado objeto no banco de dados, seja ele um novo objeto, > * ou um objeto ja cadastrado que foi modificado > * @return Id do objeto ultimo objeto cadastrado > * @throws SaveObjectException > */ > public int salvar() throws SaveObjectException { > int retValue = 0; > try { > > ((FormTableModel)formTable.getModel()).validateFields(); > if ( ! ((FormTableModel)formTable.getModel()).validateFields() ) > throw new Exception( "H\u00e1 campos requeridos nao preenchidos." ); > getForm(); // Atualiza a variavel setor. > retValue = Configuracao.daoF.getAlmoxarifadoDAO().insertNotaFiscal( nota ); > if (retValue > 0) { > //int novo = javax.swing.JOptionPane.showOptionDialog(null, "Deseja gerar sa\u00edda referente a esta nota?", "Gerar Sa\u00edda",javax.swing.JOptionPane.DEFAULT_OPTION, javax.swing.JOptionPane.WARNING_MESSAGE,null, options, options[0]); > int novo = JOptionPane.showConfirmDialog(this, "Deseja gerar sa\u00edda referente a esta nota?", "Gerar Sa\u00edda", JOptionPane.YES_NO_OPTION ); > if (novo == 0) { > EditDialogTemplate et = new EditDialogTemplate( Configuracao.xFrame, true ); > et.setDynPanel( "com.maxmil.olimpo.almoxarifado.PnCadSaida" ); > SaidaProduto sp = new SaidaProduto(); > sp.setData( nota.getData() ); > sp.setRequisicao( nota.getNotaFiscal() ); > sp.setItems( nota.getItems() ); > et.setObject( sp ); > et.setVisible( true ); > } > //FrPopupGeraSaida janela = new FrPopupGeraSaida(nota.getData().toString(), nota.getNotaFiscal(), retValue) ; > } > } catch ( Exception g ) { > throw new SaveObjectException( "NotaFiscal: "+g.getMessage(), nota ); > } > return retValue; > } > /** > * Cancela o salvamento do novo objeto ou a alteração de um objeto > */ > public void cancelar() { > } > /** > * Abre a Dialog de Pesquisa de Itens > */ > private void gerenciaItens() { > DiPesqItens novo = new DiPesqItens( Configuracao.xFrame, true, getItems(), 0, true, true ); > if ( novo.isOk() ) > carregaItens( novo.getItems() ); > } > /** > * Preenche a tabela com os itens contidos no Vector de itens da entrada > * @param items > * @throws Exception > */ > private void carregaItens( Vector items ) { > try { > if ( items == null ) { > items = nota.getItems(); > nota.setItems( items ); > } > } catch ( NullPointerException np ) { items = new Vector(); } > Iterator it = items.iterator(); > double valorTotal = 0.0; > try { > ConTableModel tm = (ConTableModel)itensTable.getModel(); > > tm.removeAllRows(); > Object [] arr; > while ( it.hasNext() ) { > Object tmp = it.next(); > if ( tmp instanceof Produto ) { > arr = new Object[3]; > arr[0] = tmp; > arr[2] = LoadLib.formataValorpReais( new Double( ( (Produto)arr[0] ).getValorUnit() ), 3 ); > arr[1] = ((Produto)arr[0]).getSaldo(); > tm.addRow( arr ); > valorTotal += ( ( Produto )arr[0] ).getValorUnit() * ( (Produto)arr[0]).getSaldo(); > } > tmp = null; > } > double desconto = 0; > try { > desconto = Double.parseDouble( ((FormTableModel)formTable.getModel()).getValue("Desconto").toString() ); > } catch ( Exception fd ) { } > BigDecimal vTotal = new BigDecimal( valorTotal - desconto ); > vTotal = vTotal.setScale( 3, BigDecimal.ROUND_HALF_UP ); > valorNotaLabel.setText( "R$ "+ LoadLib.formataValorpReais( vTotal.doubleValue(), 3 ) ); > itensTable.setModel( tm ); > > DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); > renderer.setHorizontalAlignment(DefaultTableCellRenderer.RIGHT); > itensTable.getColumnModel().getColumn(1).setCellRenderer(renderer); > itensTable.getColumnModel().getColumn(2).setCellRenderer(renderer); > > } catch ( Exception g ) { } > } > /** > * Adiciona os itens selecionados no Vector Items > * @return Vector de Itens > */ > private Vector<Produto> getItems() { > Vector<Produto> items = new Vector<Produto>(); > double valorTotal = 0.0; > int cont = itensTable.getRowCount(); > Object tmp = null; > for ( int i = 0; i < cont; i++ ) { > tmp = itensTable.getValueAt( i, 0 ); > if ( tmp instanceof Produto ) { > items.add( (com.maxmil.olimpo.core.Produto)tmp ); > valorTotal += ((com.maxmil.olimpo.core.Produto)tmp).getValorUnit() * ((com.maxmil.olimpo.core.Produto)tmp).getSaldo(); > } > tmp = null; > } > nota.setItems( items ); > return items; > } > /** > * Retorna o objeto do tipo genérico MMTipo > * @return Objeto genérico > */ > public com.maxmil.olimpo.core.MMTipo getPureObject() { > return nota; > } > /** > * Chama a tela de pesquisa referente ao determinado cadastro > */ > public void pesquisar() { > try { > ComboConTemplate ct = new ComboConTemplate( Configuracao.xFrame, true ); > ct.setDynPanel( "com.maxmil.olimpo.almoxarifado.PnConEntradas" ); > ct.setVisible( true ); > MMTipo r = ct.getSelectedObject(); > if ( r != null && ct.isOk() ) > setObjectId( r.getId() ); > } catch ( Exception gfd ) { } > } > /** > * Exclui o objeto do banco de dados > * @throws DeleteObjectException > */ > public void excluir() throws com.maxmil.olimpo.exceptions.DeleteObjectException { > MMTipo p = getForm(); > try { > Configuracao.daoF.getAlmoxarifadoDAO().deleteNotaFiscal( (NotaFiscal)p ); > } catch ( Exception e ) { > throw new com.maxmil.olimpo.exceptions.DeleteObjectException( e.getMessage() ); > } > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 200348
: 76295 |
76297