public function grabar() { $sql = ""; $count = 0; if (!$this->_existe) { $this->cve_tipo = UtilDB::getSiguienteNumero("tipos_actividades", "cve_tipo"); $sql = "INSERT INTO tipos_actividades VALUES ({$this->cve_tipo}," . $this->cve_unidad_negocio->getCve_unidad_negocio() . ",'{$this->nombre}',{$this->activo})"; $count = UtilDB::ejecutaSQL($sql); if ($count > 0) { $this->_existe = true; } } else { $sql = "UPDATE tipos_actividades SET "; $sql .= "cve_unidad_negocio = " . $this->cve_unidad_negocio->getCve_unidad_negocio() . ","; $sql .= "nombre = '{$this->nombre}',"; $sql .= "activo=" . ($this->activo ? "1" : "0"); $sql .= " WHERE cve_tipo = {$this->cve_tipo}"; $count = UtilDB::ejecutaSQL($sql); } return $count; }