no message

git-svn-id: https://svn.coded.pt/svn/SIPRP@24 bb69d46d-e84e-40c8-a05a-06db0d633741
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Frederico Palma 22 years ago
parent 143752dfdc
commit 4bfc89aa1c

@ -222,6 +222,8 @@ public class EmpresaPanel extends JPanel
public Object save() public Object save()
{ {
StringBuffer msg = new StringBuffer();
boolean hasMsg = false;
try try
{ {
if( estabelecimento == null ) if( estabelecimento == null )
@ -261,13 +263,40 @@ public class EmpresaPanel extends JPanel
estabelecimento.setProperty( name, hash.get( name ) ); estabelecimento.setProperty( name, hash.get( name ) );
} }
estabelecimento.setProperty( provider.R_ESTABELECIMENTO_EMPRESA, empresa ); estabelecimento.setProperty( provider.R_ESTABELECIMENTO_EMPRESA, empresa );
return estabelecimento;
if( ((String)empresa.getProperty( provider.DESIGNACAO_SOCIAL )).trim().length() == 0 )
{
msg.append( "A empresa tem de ter uma design\u00e7\u00e3o social\n" );
hasMsg = true;
}
if( empresa.getProperty( provider.SERVICO_SAUDE_TIPO ) == null )
{
msg.append( "A empresa tem de ter um tipo de seri\00e7o de sa\u00fade\n" );
hasMsg = true;
}
if( empresa.getProperty( provider.SERVICO_HIGIENE_TIPO ) == null )
{
msg.append( "A empresa tem de ter um tipo de seri\00e7o de higiene\n" );
hasMsg = true;
}
if( ((String)estabelecimento.getProperty( provider.NOME )).trim().length() == 0 )
{
msg.append( "O estabelecimento tem de ter nome\n" );
hasMsg = true;
}
} }
catch( Exception ex ) catch( Exception ex )
{ {
ex.printStackTrace(); ex.printStackTrace();
return null;
} }
return null; if( hasMsg )
{
throw new ValuesException( msg.toString() );
}
return estabelecimento;
} }
public void clear() public void clear()

@ -106,22 +106,47 @@ public class FichaWindow extends TabbedWindow
new Runnable(){ new Runnable(){
public void run() public void run()
{ {
MetaObject estabelecimento = (MetaObject)empresaPanel.save();
try
{
estabelecimento.save();
MetaObject trabalhador = (MetaObject)trabalhadorPanel.save();
trabalhador.setProperty( fdpProvider.R_TRABALHADOR_ESTABELECIMENTO, estabelecimento );
trabalhador.setProperty( fdpProvider.OBSERVACOES, observacoesPanel.save() );
trabalhador.save();
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a guardar", true );
}
} }
}); });
StringBuffer msg = new StringBuffer();
MetaObject estabelecimento;
try
{
estabelecimento = (MetaObject)empresaPanel.save();
}
catch( ValuesException vex )
{
msg.append( vex.getMessage() );
estabelecimento = null;
}
MetaObject trabalhador;
try
{
trabalhador = (MetaObject)trabalhadorPanel.save();
}
catch( ValuesException vex )
{
msg.append( vex.getMessage() );
trabalhador = null;
}
if( estabelecimento == null || trabalhador == null )
{
JOptionPane.showMessageDialog( this, msg.toString(), "Erro...", JOptionPane.ERROR_MESSAGE );
return false;
}
trabalhador.setProperty( fdpProvider.R_TRABALHADOR_ESTABELECIMENTO, estabelecimento );
trabalhador.setProperty( fdpProvider.OBSERVACOES, observacoesPanel.save() );
try
{
trabalhador.save();
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a guardar", true );
return false;
}
return true; return true;
} }

@ -0,0 +1,22 @@
/*
* ValuesException.java
*
* Created on 5 de Abril de 2004, 20:22
*/
package siprp.ficha;
/**
*
* @author fpalma
*/
public class ValuesException extends RuntimeException
{
/** Creates a new instance of ValuesException */
public ValuesException( String msg )
{
super( msg );
}
}
Loading…
Cancel
Save