From 7a34c1c7d2cf3435e3e47d741cafd20aa9a4fe49 Mon Sep 17 00:00:00 2001 From: Frederico Palma Date: Thu, 1 Apr 2004 11:11:13 +0000 Subject: [PATCH] no message git-svn-id: https://svn.coded.pt/svn/SIPRP@17 bb69d46d-e84e-40c8-a05a-06db0d633741 --- trunk/siprp/FichaDataProvider.java | 14 +++++++---- trunk/siprp/ficha/FichaWindow.java | 38 +++++++++++++----------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/trunk/siprp/FichaDataProvider.java b/trunk/siprp/FichaDataProvider.java index 6744235d..c9852061 100644 --- a/trunk/siprp/FichaDataProvider.java +++ b/trunk/siprp/FichaDataProvider.java @@ -235,22 +235,28 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter { } public Virtual2DArray searchEmpresas( String pattern ) throws Exception { - Select select = new Select( "SELECT e.id, e.designacao_social FROM empresas e;" ); + Select select = new Select( "SELECT e.id, e.designacao_social FROM empresas e ORDER BY lower( e.designacao_social );" ); return executer.executeQuery( select ); } public Virtual2DArray searchEstabelecimentos( String pattern ) throws Exception { - Select select = new Select( "SELECT e.id, e.nome FROM estabelecimentos e;" ); + Select select = new Select( "SELECT e.id, e.nome FROM estabelecimentos e WHERE empresa_id = " + SEARCH_EMPRESAS_ID + + " ORDER BY lower( e.nome )"); return executer.executeQuery( select ); } public Virtual2DArray searchTrabalhadores( String pattern ) throws Exception { - Select select = new Select( "SELECT t.id, t.nome FROM trabalhadores t;" ); + Select select = + new Select( "SELECT t.id, t.nome FROM trabalhadores t, estabelecimentos es " + + " WHERE t.estabelecimento_id = es.id " + + " AND es.empresa_id = " + SEARCH_EMPRESAS_ID + " ORDE BY lower(t.nome);" ); return executer.executeQuery( select ); } public Virtual2DArray searchExames( String pattern ) throws Exception { - Select select = new Select( "SELECT e.id, e.data FROM exames e;" ); + Select select = new Select( "SELECT e.id, e.data FROM exames e " + + " WHERE e.trabalhador_id = " + SEARCH_TRABALHADORES_ID + + " ORDER BY e.data DESC;" ); return executer.executeQuery( select ); } diff --git a/trunk/siprp/ficha/FichaWindow.java b/trunk/siprp/ficha/FichaWindow.java index 705fead3..d8677830 100644 --- a/trunk/siprp/ficha/FichaWindow.java +++ b/trunk/siprp/ficha/FichaWindow.java @@ -112,31 +112,25 @@ public class FichaWindow extends TabbedWindow public boolean newItem( int index ) { - switch( index ) - { - case 0: - fdpProvider.setSearch( FichaDataProvider.SEARCH_EMPRESAS ); - SearchDialog search = new SearchDialog( fdpProvider, null, true, null, false ); - Integer empresaID = ( Integer )search.getSelected(); + fdpProvider.setSearch( FichaDataProvider.SEARCH_EMPRESAS ); + SearchDialog search = new SearchDialog( fdpProvider, null, true, null, false ); + Integer empresaID = ( Integer )search.getSelected(); - if( empresaID == null ) - { - return false; - } + if( empresaID == null ) + { + return false; + } - fdpProvider.setSearch( FichaDataProvider.SEARCH_ESTABELECIMENTOS ); - fdpProvider.setSearchID( FichaDataProvider.SEARCH_EMPRESAS, empresaID.intValue() ); - search = new SearchDialog( fdpProvider, null, true, null, false ); - Integer estabelecimentoID = ( Integer )search.getSelected(); + fdpProvider.setSearch( FichaDataProvider.SEARCH_ESTABELECIMENTOS ); + fdpProvider.setSearchID( FichaDataProvider.SEARCH_EMPRESAS, empresaID.intValue() ); + search = new SearchDialog( fdpProvider, null, true, null, false ); + Integer estabelecimentoID = ( Integer )search.getSelected(); - if( estabelecimentoID == null ) - { - return false; - } - - break; - } - return true; + if( estabelecimentoID == null ) + { + return false; + } + return true; } public boolean delete( int index )