diff --git a/trunk/siprp/FichaDataProvider.java b/trunk/siprp/FichaDataProvider.java index 726bc533..38c0b365 100644 --- a/trunk/siprp/FichaDataProvider.java +++ b/trunk/siprp/FichaDataProvider.java @@ -122,7 +122,7 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter { OUTRO_TIPO, RESULTADO, OUTRA_FUNCAO_1, OUTRA_FUNCAO_2, OUTRA_FUNCAO_3, OUTRA_FUNCAO_4, PROXIMO_EXAME, - OUTRAS_RECOMENDACOES, TRABALHADOR_ID, MEDICO_ID, PDF }, + OUTRAS_RECOMENDACOES, TRABALHADOR_ID, MEDICO_ID, PDF, INACTIVO }, ID ); public static DBReference R_ESTABELECIMENTO_EMPRESA = new DBReference( ESTABELECIMENTOS.getFieldByName( EMPRESA_ID ) ); @@ -357,7 +357,8 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter { { Select select = new Select( new String[]{ T_EXAMES }, new String[]{ "MAX("+ID+")", DATA }, - new Field( TRABALHADOR_ID ).isEqual( trabalhadorID ), + new Field( TRABALHADOR_ID ).isEqual( trabalhadorID ).and( + new Field( INACTIVO ).isEqual( "n" ) ), new String[]{ DATA + " DESC" }, new String[]{ DATA } ); Virtual2DArray array = executer.executeQuery( select ); IDObject exames[] = new IDObject[ array.columnLength() ]; @@ -519,4 +520,5 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter { } return objects; } + } diff --git a/trunk/siprp/ficha/FichaWindow.java b/trunk/siprp/ficha/FichaWindow.java index a33e2728..73fc158c 100644 --- a/trunk/siprp/ficha/FichaWindow.java +++ b/trunk/siprp/ficha/FichaWindow.java @@ -140,6 +140,22 @@ public class FichaWindow extends TabbedWindow "Imprimir Fichas Anteriores", null, 0, false ); + registerAction( new ActionHandler(){ + public void execute() + { + deleteOld(); + } + + public boolean activate( boolean newAction, boolean editAction, + boolean cancelAction, boolean saveAction, + boolean deleteAction, boolean selectAction ) + { + return saveAction || editAction; + } + }, "Apagar Fichas Anteriores", + "Apagar Fichas Anteriores", null, + 0, false ); + registerAction( new ActionHandler(){ public void execute() { @@ -347,6 +363,53 @@ public class FichaWindow extends TabbedWindow return true; } + public void deleteOld() + { + if( trabalhadorID == null ) + { + return; + } + Vector linhas; + try + { + IDObject fichas[] = fdpProvider.getAllFichasForTrabalhador( trabalhadorID ); + linhas = new Vector( Arrays.asList( fichas ) ); + } + catch( Exception ex ) + { + DialogException.showExceptionMessage( ex, "Erro a criar lista de Fichas anteriores", true ); + return; + } + ListActionDialog dialog = + new ListActionDialog( this, "Apagar Fichas Anteriores", new String[]{ "Data" }, linhas, + new ListAction(){ + public String getListActionName() + { + return "Apagar"; + } + + public boolean executeListAction( int line, Object value ) + { + if( value == null ) + { + return true; + } + try + { + delete( ( ( IDObject )value ).getID() ); + } + catch( Exception ex ) + { + DialogException.showExceptionMessage( ex, "Erro a Apagar Ficha", true ); + return false; + } + return true; + } + } ); + dialog.setSize( 250, 200 ); + dialog.show(); + } + public void reload( int index ) { Integer upperData[] = new Integer[]{ empresaID, estabelecimentoID, trabalhadorID }; @@ -524,12 +587,16 @@ public class FichaWindow extends TabbedWindow case 6: ht.put( "tipo_trabalho", "" ); break; + case 10: + aux = (String)exame.getProperty( fdpProvider.OUTRO_TIPO ); + ht.put( "tipo_outro", aux != null ? aux : "" ); + break; } break; - case 4: - aux = (String)exame.getProperty( fdpProvider.OUTRO_TIPO ); - ht.put( "tipo_outro", aux != null ? aux : "" ); - break; +// case 4: +// aux = (String)exame.getProperty( fdpProvider.OUTRO_TIPO ); +// ht.put( "tipo_outro", aux != null ? aux : "" ); +// break; } tipo = (Integer)exame.getProperty( fdpProvider.RESULTADO ); switch( tipo.intValue() ) @@ -646,4 +713,21 @@ public class FichaWindow extends TabbedWindow { return "Imprimir"; } + + private void delete( Integer exameID ) + throws Exception + { + MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) ); + if( exame == null ) + { + throw new Exception( "N\u00e3o existe exame" ); + } + if( JOptionPane.showConfirmDialog( this, + "Tem a certeza que quer apagar o exame de " + exame.getProperty( fdpProvider.DATA ) + "?", + "...", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null ) == 0 ) + { + exame.setProperty( fdpProvider.INACTIVO, "y" ); + exame.save(); + } + } }