method seek Dolphin

Post Reply
User avatar
sysctrl2
Posts: 833
Joined: Mon Feb 05, 2007 7:15 pm
Contact:

method seek Dolphin

Post 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.
Cesar Cortes Cruz
SysCtrl Software
Mexico

' Sin +- FWH es mejor "
User avatar
Daniel Garcia-Gil
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita
Contact:

Re: method seek Dolphin

Post by Daniel Garcia-Gil »

Cesar

Gracias por compartirlo
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
nnicanor
Posts: 296
Joined: Fri Apr 23, 2010 4:30 am
Location: Colombia

Re: method seek Dolphin

Post 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
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
User avatar
Daniel Garcia-Gil
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita
Contact:

Re: method seek Dolphin

Post by Daniel Garcia-Gil »

Nicanor

a mi me fucniona bien, si pudieras enviarmen un ejemplo a mi correo que pueda probar te lo agradezco
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
Post Reply