From ba75384ad5523e26ba350f5cb61835c7178373b5 Mon Sep 17 00:00:00 2001 From: Frederico Palma Date: Wed, 16 May 2007 11:17:08 +0000 Subject: [PATCH] no message git-svn-id: https://svn.coded.pt/svn/SIPRP@396 bb69d46d-e84e-40c8-a05a-06db0d633741 --- .../processo/ProcessoDataProvider.java | 48 +++++++++++++++++ .../processo/detalhes/ConsultaPanel.java | 54 +++++++++++++++++-- .../detalhes/DetalhesProcessoPanel.java | 15 +++++- 3 files changed, 112 insertions(+), 5 deletions(-) diff --git a/trunk/siprp/medicina/processo/ProcessoDataProvider.java b/trunk/siprp/medicina/processo/ProcessoDataProvider.java index 1a7d0bf9..21f22e39 100644 --- a/trunk/siprp/medicina/processo/ProcessoDataProvider.java +++ b/trunk/siprp/medicina/processo/ProcessoDataProvider.java @@ -225,6 +225,30 @@ public class ProcessoDataProvider } } + public Integer getLastConsultaDataIDForConsulta( Integer consultaID ) + throws Exception + { + Select select = + new Select2( new String[]{ "trabalhadores_consultas_datas" }, + new Integer[]{}, + new Expression[]{}, + new String[]{ "MAX( id )" }, + new Field( "trabalhadores_consultas_id" ).isEqual( consultaID ), + null, + null, + null, + null ); + Virtual2DArray array = EXECUTER.executeQuery( select ); + if( array.columnLength() == 0 || array.get( 0, 0 ) == null ) + { + return null; + } + else + { + return ( Integer ) array.get( 0, 0 ); + } + } + public IDObject getObservacoesECDsData( Integer ecdsDataID ) throws Exception { @@ -248,4 +272,28 @@ public class ProcessoDataProvider return new MappableObject( ( Integer ) array.get( 0, 0 ), ( String ) array.get( 0, 1 ) ); } } + + public Integer getLastECDsDataIDForECDs( Integer ecdsID ) + throws Exception + { + Select select = + new Select2( new String[]{ "trabalhadores_ecds_datas" }, + new Integer[]{}, + new Expression[]{}, + new String[]{ "MAX( id )" }, + new Field( "trabalhadores_ecds_id" ).isEqual( ecdsID ), + null, + null, + null, + null ); + Virtual2DArray array = EXECUTER.executeQuery( select ); + if( array.columnLength() == 0 || array.get( 0, 0 ) == null ) + { + return null; + } + else + { + return ( Integer ) array.get( 0, 0 ); + } + } } diff --git a/trunk/siprp/medicina/processo/detalhes/ConsultaPanel.java b/trunk/siprp/medicina/processo/detalhes/ConsultaPanel.java index 29a119d0..d1b4c519 100644 --- a/trunk/siprp/medicina/processo/detalhes/ConsultaPanel.java +++ b/trunk/siprp/medicina/processo/detalhes/ConsultaPanel.java @@ -9,17 +9,22 @@ package siprp.medicina.processo.detalhes; +import com.evolute.utils.Singleton; +import com.evolute.utils.jdo.JDOProvider; +import com.evolute.utils.ui.DialogException; import com.evolute.utils.ui.calendar.JCalendarPanel; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.Date; import java.util.Vector; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import siprp.medicina.MedicinaConstants; import siprp.medicina.processo.ProcessoListener; +import siprp.medicina.processo.data.TrabalhadoresConsultasData; /** * @@ -33,15 +38,19 @@ public class ConsultaPanel extends JPanel protected JButton estadoButton; protected JButton emailButton; protected JButton observacoesButton; - protected ObservacoesDialog observacoesDialog; - private final Vector PROCESSO_LISTENERS = new Vector(); + protected final Vector PROCESSO_LISTENERS = new Vector(); + protected JDOProvider JDO; + + protected TrabalhadoresConsultasData consulta; + protected Integer trabalhadorID; /** Creates a new instance of ConsultaPanel */ public ConsultaPanel( JFrame owner ) { this.owner = owner; + JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); setupComponents(); } @@ -92,7 +101,6 @@ public class ConsultaPanel extends JPanel { observacoesDialog = new ObservacoesDialog( owner ); } - } public void addProcessoListener( ProcessoListener listener ) @@ -104,4 +112,44 @@ public class ConsultaPanel extends JPanel { PROCESSO_LISTENERS.remove( listener ); } + + public void clear() + { + dataConsultaPanel.setDate( null ); + estadoButton.setText( " " ); + } + + public void fill( Object value ) + { + clear(); + if( value != null ) + { + try + { + consulta = ( TrabalhadoresConsultasData ) JDO.load( TrabalhadoresConsultasData.class, ( Integer ) value ); + Date data = ( Date ) consulta.get( TrabalhadoresConsultasData.DATA ); + Integer estado = ( Integer ) consulta.get( TrabalhadoresConsultasData.ESTADO ); + dataConsultaPanel.setDate( data ); + if( estado != null ) + { + estadoButton.setText( ESTADOS_CONSULTA_STR[ estado.intValue() ] ); + } + else + { + estadoButton.setText( " " ); + } + + } + catch( Exception ex ) + { + DialogException.showExceptionMessage( ex, "Erro a carregar dados da consulta", true ); + } + } + + } + + public void setTrabalhadorID( Integer trabalhadorID ) + { + this.trabalhadorID = trabalhadorID; + } } diff --git a/trunk/siprp/medicina/processo/detalhes/DetalhesProcessoPanel.java b/trunk/siprp/medicina/processo/detalhes/DetalhesProcessoPanel.java index 56d41a81..8f659642 100644 --- a/trunk/siprp/medicina/processo/detalhes/DetalhesProcessoPanel.java +++ b/trunk/siprp/medicina/processo/detalhes/DetalhesProcessoPanel.java @@ -25,7 +25,7 @@ public class DetalhesProcessoPanel extends JPanel private static final String CARD_BLANK = ""; private static final String CARD_CONSULTA = "CONSULTA"; - private static final String CARD_ECD = "ECD"; + private static final String CARD_ECDS = "ECDS"; protected JFrame owner; @@ -54,7 +54,7 @@ public class DetalhesProcessoPanel extends JPanel setLayout( cardLayout ); add( blankPanel, CARD_BLANK ); add( consultaPanel, CARD_CONSULTA ); - add( ecdsPanel, CARD_ECD ); + add( ecdsPanel, CARD_ECDS ); } public void addProcessoListener( ProcessoListener listener ) @@ -75,4 +75,15 @@ public class DetalhesProcessoPanel extends JPanel { cardLayout.first( this ); } + + public void setConsulta( Integer consultaID ) + { + cardLayout.show( this, CARD_CONSULTA ); + consultaPanel.fill( consultaID ); + } + + public void setECDs( Integer ecdsID ) + { + cardLayout.show( this, CARD_ECDS ); + } }