Exemplo n.º 1
0
 /**
  * method onInlineEdit()
  * edicao de registro inline
  * @param $param Array containing:
  *              key: object ID value
  *              field nome: object attribute to be updated
  *              value: new attribute content 
  */
 function onInlineEdit($param)
 {
     try {
         // get the parameter $key
         $field = $param['field'];
         $key = $param['key'];
         $value = $param['value'];
         // open a transaction with database 'saciq'
         TTransaction::open('saciq');
         // instantiates object Funcionalidade
         $object = new Funcionalidade($key);
         // deletes the object from the database
         $object->{$field} = $value;
         $object->store();
         // close the transaction
         TTransaction::close();
         // reload the listing
         $this->onReload($param);
         // shows the success message
         new TMessage('info', 'Registro atualizado');
     } catch (Exception $e) {
         if ($e->getCode() == 23000) {
             new TMessage('error', '<b>Registro duplicado</b><br>Verifique os campos inseridos e tente novamente');
         } else {
             if ($e->getCode() == 0) {
                 new TMessage('error', '<b>Error</b> <br>' . $e->getMessage());
             } else {
                 new TMessage('error', '<b>Error Desconhecido</b> <br>Código: ' . $e->getCode());
             }
         }
         // desfazer todas as operacoes pendentes
         TTransaction::rollback();
     }
 }