button_mouseClick( objectID );

if( objectID.indexOf( 'button' ) != -1  )
{
  idx = getButton_index( objectID );

  switch( idx )
  {
    case 0:
      button1_mouseClick( objectID );
      break;
    case 1:
      button2_mouseClick( objectID );
      break;
  }// End switch( idx )

}// End if( objectID.indexOf( 'dbGrid' ) != -1 )


function button1_mouseClick( objectID )
{
  var pet_old = getDBgrid_col_value_by_name( "dbgrid1", "pet" );
  var pet_new = getDBgrid_col_sum_by_name( "dbgrid2", "volume" ) * 10;
  var total   = getDBgrid_col_sum_by_name( "dbgrid2", "percentual" );
//alert('PET: '+pet_new);
//alert('total: '+total);
  setEdit_value( "edit1", total );
  setEdit_value( "edit2", pet_old );
  setEdit_value( "edit3", pet_new.toFixed(4) );

  if( total == '100.0000' )
  {
    setButton_enabled( "button2", true );
  }else
  {
    alert( "Valores Incorreto..." );
  }// End

//  alert('button');
}// End

function button2_mouseClick( objectID )
{
  var codigo = getDBgrid_col_value_by_name( "dbgrid1", "codigo" );
  var valor = getEdit_value( "edit3" );
  
  var query = "UPDATE formula SET pet = '" + valor + "' WHERE codigo = '"+codigo+"' LIMIT 1;";
  
  dataAccess.execSql( query );
  
  dataAccess.getFields( "dbgrid1" );
  key = 'dbgrid1:';
  dataAccess.getResult( key  );

//alert('2');
}// End

