FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour method seek Dolphin
Posts: 1144
Joined: Mon Feb 05, 2007 07:15 PM
method seek Dolphin
Posted: Thu Jan 27, 2011 06:51 PM
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 (fw): Select all Collapse
::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.
Cesar Cortes Cruz

SysCtrl Software

Mexico



' Sin +- FWH es mejor "
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: method seek Dolphin
Posted: Thu Jan 27, 2011 07:25 PM

Cesar

Gracias por compartirlo

Posts: 302
Joined: Fri Apr 23, 2010 04:30 AM
Re: method seek Dolphin
Posted: Fri Jan 28, 2011 04:40 AM
Muy interensante,

agrego unas modificaciones para que sea mas generico el codigo
Code (fw): Select all Collapse
     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
Nicanor Martinez M.
Auditoria y Sistemas Ltda.
MicroExpress Ltda.
FW + FWH + XHARBOUR + HARBOUR + PELLES C + XDEVSTUDIO + XEDIT + BCC + VC_X86 + VCC_X64 + MINGW + R&R Reports + FastReport + Tdolphin + ADO + MYSQL + MARIADB + ORACLE
nnicanor@yahoo.com
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: method seek Dolphin
Posted: Fri Jan 28, 2011 12:50 PM

Nicanor

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

Continue the discussion