Page 1 of 1

method seek Dolphin

Posted: Thu Jan 27, 2011 6:51 pm
by sysctrl2
La siguiente funcion yo la utilizo con tablas DBF, con un pequeño ajuste
funciona con tdolphin para buscar sobre una tabla de mysql,
la busqueda se realiza con el method seek, partiendo desde un GET, y el query se encuentra en un xbrowse.
acontinuacion un pedazo de codigo:
Saludos.

Code: Select all

::oClientes := ::oMain:oCon:Query( "SELECT * FROM clientes ORDER BY nombre" )   

@ 100, 10 GET oGet VAR ::cBuscar of oDlg SIZE 150, 24  PICTURE "@!k" PIXEL ;
   ON CHANGE( oSelf:oGrid:Refresh(), oSelf:Buscar( nKey, oGet ) )

* busqueda incremental partiendo desde un objeto GET.
METHOD Buscar( nKey, oGet ) CLASS Clientes
   local cFras
   if nKey <> 13
      if ( nKey >= 032 .OR. nKey <= 126 )
         cFras:= upper( AllTrim( oGet:cTitle ) )
         nSeek := ::oClientes:Seek( cFras, 2, , , .T.) // lSoft := .T.         
         if nSeek > 0
            ::oClientes:refresh()   
         else
            ::oClientes:Gotop()
            ::oClientes:refresh()               
         endif         
      endif
   endif
   ::oGrid:refresh()
return .t.

Re: method seek Dolphin

Posted: Thu Jan 27, 2011 7:25 pm
by Daniel Garcia-Gil
Cesar

Gracias por compartirlo

Re: method seek Dolphin

Posted: Fri Jan 28, 2011 4:40 am
by nnicanor
Muy interensante,

agrego unas modificaciones para que sea mas generico el codigo

Code: Select all

     REDEFINE GET aGet[1] VAR cBusca ID 111              ;
             PICTURE "@!"                                ;
             OF oDlg UPDATE                              ;
             ON CHANGE( oQry:Refresh(), Buscar_Inc( nKey, @aGet[1], oQry, oBrw ) )


//------------------------------------------------------------------------//

Function Buscar_Inc( nKey, oGet, oQry, oBrw ) 
   local cFras
   if nKey <> 13
      if ( nKey >= 032 .OR. nKey <= 126 )
         cFras:= upper( AllTrim( oGet:cTitle ) )
         nSeek := oQry:Seek( cFras, 2, , , .T.) // lSoft := .T.        
         if nSeek > 0
            oQry:refresh()  
         else
            oQry:Gotop()
            oQry:refresh()
         endif        
      endif
   endif
   oBrw:refresh()
return .t.
//-----------------------------------------------------------------------//

Daniel cuando el query tiene mas de una tabla la busqueda incremental el seek no funciona aunque este ordenada por la columna correcta

Eje:

cSql:="SELECT c.codciud as codigop,c.nomciud as puerto,p.codpuer as codigom,p.nompuer as muelle "+;
" FROM puertos p INNER JOIN ciudad c ON p.codciud=c.codciud "+;
"ORDER BY p.nompuer "

Si hago un locate funciona :

oQry:locate( { cBusca },{"muelle"},,.t. )

Slds,

Nicanor Martinez

Re: method seek Dolphin

Posted: Fri Jan 28, 2011 12:50 pm
by Daniel Garcia-Gil
Nicanor

a mi me fucniona bien, si pudieras enviarmen un ejemplo a mi correo que pueda probar te lo agradezco