FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Consulta sobre TDolphin
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Consulta sobre TDolphin
Posted: Wed May 16, 2012 04:23 PM
Estimados:
Estoy usando la clase Tdolphin, y cuando utilizo la funci贸n GetBlankRow() o GetRow() en un dialogo y estoy editando con gets, si muevo el dialogo los gets se actualizan con los datos guardados en la base de dato y pierden el dato que estaba editando.
A alguien le pas贸?
Gracias por vuestra ayuda.
Pongo el c贸digo para mayor informaci贸n
Code (fw): Select all Collapse
#include "Fivewin.ch"
#include "xbrowse.ch"
#include "tdolphin.ch"
*************************************************
** ABM DE Encuesta
*************************************************

PROCEDURE Encuesta( oServer)
LOCAL oDlg, oBrw, oGet, oWnd, cBuscar := SPACE(50), base, oBar, oQry
oQry 聽= oServer:Query( "SELECT * FROM ENCUESTAS ORDER BY numero")

聽 聽// Defino el dialogo tomado del recurso ABMCAJA
聽 聽DEFINE WINDOW oWnd MDICHILD TITLE "A/B/M de Encuestas" ;
聽 聽 聽 聽 聽OF MEMVAR->oWPpal NOZOOM ICON MEMVAR->oIco
聽 聽 聽 聽 聽DEFINE BUTTONBAR oBar 聽3D SIZE 30,30 OF oWnd 2010
聽 聽 聽 聽 聽DEFINE BUTTON RESOURCE "ALTA" OF oBar ;
聽 聽 聽 聽 聽 聽 TOOLTIP "Agregar Registro" 聽;
聽 聽 聽 聽 聽 聽 ACTION Formu( oBrw , oQry, oWnd , .t., oServer)
聽 聽 聽 聽 聽// Este boton cierra la aplicacion
聽 聽 聽 聽 聽DEFINE BUTTON RESOURCE "BAJA" OF oBar;
聽 聽 聽 聽 聽 聽 TOOLTIP "Eliminar Registro" ;
聽 聽 聽 聽 聽 聽 ACTION Baja( oBrw, oQry, oServer ) WHEN(oQry:RecCount()>0)
聽 聽 聽 聽 聽DEFINE BUTTON RESOURCE "MODI" OF oBar ;
聽 聽 聽 聽 聽 聽 TOOLTIP "Modificar Registro" ;
聽 聽 聽 聽 聽 聽 ACTION Formu( oBrw, oQry, oWnd, .f.,oServer) WHEN(oQry:RecCount()>0)
聽 聽 聽 聽 聽DEFINE BUTTON RESOURCE "EXCE" OF oBar ;
聽 聽 聽 聽 聽 聽 TOOLTIP "Exportar a Excel" ;
聽 聽 聽 聽 聽 聽 ACTION oBrw:ToExcel() WHEN(oQry:RecCount()>0)
聽 聽 聽 聽 聽DEFINE BUTTON RESOURCE "IMPR" OF oBar ;
聽 聽 聽 聽 聽 聽 TOOLTIP "Reporte" ;
聽 聽 聽 聽 聽 聽 ACTION oBrw:Report() WHEN(oQry:RecCount()>0)
聽 聽 聽 聽 聽// Este boton cierra la aplicacion
聽 聽 聽 聽 聽DEFINE BUTTON RESOURCE "SALE" OF oBar;
聽 聽 聽 聽 聽 聽 TOOLTIP "Cerrar Ventana" ;
聽 聽 聽 聽 聽 聽 ACTION oWnd:End()
聽 聽oWnd:bGotFocus := { || oDlg:SetFocus}
聽 聽oWnd:bResized := { || Incrusta( oWnd, oDlg, .t.) }
聽 聽 聽DEFINE DIALOG oDlg RESOURCE "ABMS" OF oWnd
聽 聽 聽REDEFINE XBROWSE oBrw;
聽 聽 聽 聽 聽 聽 聽 FIELDS oQry:numero , oQry:calle, oQry:npuerta,;
聽 聽 聽 聽 聽 聽 聽 oQry:piso, oQry:depto, oQry:motivo, oQry:fecha;
聽 聽 聽 聽 聽 聽 聽 HEADERS "Nro Enc.", "Calle", "Puerta", "Piso",;
聽 聽 聽 聽 聽 聽 聽 "Depto", "Cod.Motivo", "Fecha";
聽 聽 聽 聽 聽 聽 聽 SIZES 90, 80, 80, 70,70,70, 100 ID 111 OF oDlg
聽 聽 聽*oBrw:aCols[1]:bDlbClick := {|| 聽Modi(oBrw, oQry, oWnd ) }
聽 聽 聽REDEFINE GET oGet VAR cBuscar PICTURE "9999999999" ID 112 OF oDlg ;
聽 聽 聽 聽 聽 聽 聽 ON CHANGE bus1(oQry, oGet, oBrw, "numero")
聽 聽 聽oQry:bOnChangePage := {|| oBrw:Refresh() }
聽 聽 聽SetDolphin( oBrw, oQry, .f. )
聽 聽 聽oBrw:bClrStd := { || If( oBrw:KeyNo() % 2 == 0, ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ CLR_BLACK, RGB(193,221,255) }, ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ CLR_BLACK, RGB(221,245,255) } ) }
聽 聽 聽oBrw:nFreeze := 6
聽 聽 聽*oBrw:GOTOP()
聽 聽 聽// Activo el dialogo y al iniciar muevo a 0,0
聽 聽 聽ACTIVATE DIALOG oDlg NOWAIT ON INIT oDlg:Move(0,0)
聽 聽ACTIVATE WINDOW oWnd ON INIT Incrusta( oWnd, oDlg, .T.) VALID(cerrar(oQry))
RETURN

*************************************
** Agregar un registro nuevo
STATIC FUNCTION Formu ( oBrw, base, oWnd, lAlta, oServer )
LOCAL oGet := ARRAY(11), oBrw1, oBot := ARRAY(5), oDlg1, mrta := .f.,;
聽 聽 聽 aMotivo:= {"1. Entrevista realizada",;
聽 聽 聽 聽 聽 聽 聽 聽 聽"2. Todas las personas est谩n temporalmente ausentes",;
聽 聽 聽 聽 聽 聽 聽 聽 聽"3. La vivienda est谩 en alquiler o venta",;
聽 聽 聽 聽 聽 聽 聽 聽 聽"4. La vivienda est谩 en construcci贸n",;
聽 聽 聽 聽 聽 聽 聽 聽 聽"5. La vivienda se usa como comercio/oficina/consult.",;
聽 聽 聽 聽 聽 聽 聽 聽 聽"6. La vivienda se usa para vacaciones o fin de semana",;
聽 聽 聽 聽 聽 聽 聽 聽 聽"7. La vivienda est谩 cerrada por motivos desconocidos",;
聽 聽 聽 聽 聽 聽 聽 聽 聽"8. La vivienda est谩 abandonada",;
聽 聽 聽 聽 聽 聽 聽 聽 聽"9. Direcci贸n inexistente",;
聽 聽 聽 聽 聽 聽 聽 聽 聽"10. Rechaza la entrevista"},;
聽 聽 聽 aSexo:= {"Masculino", "Femenino"}, base1, oQry, nEncu := 0
IF lAlta
聽 聽base:gobottom()
聽 聽nEncu := base:numero + 1
聽 聽base:GetBlankRow(.t.) 聽
聽 聽base:numero := nEncu
聽 聽*base1:GetBlankRow(.f.)
聽 聽oQry := BuildQuery( {"*"}, {"personas"} , "personas.numero = " + ClipValue2SQL( base:numero ) 聽)
聽 聽*oQry := BuildQuery( {"*"}, {"personas"} , "personas.numero = " + ClipValue2SQL( base:numero ) 聽 )
聽 聽base1 聽:= oServer:Query( oQry) 聽 
ELSE
聽 聽base:GetRow()
聽 聽nEncu := base:numero
聽 聽oQry := BuildQuery( {"*"}, {"personas"} , "personas.numero = " + ClipValue2SQL( nEncu ) 聽)
聽 聽base1 聽:= oServer:Query( oQry)
聽 聽*base1:GetRow()
ENDIF
DEFINE DIALOG oDlg1 TITLE IF(lAlta,"Alta","Modificacion")+" de Encuestas" RESOURCE "ENCU" ;
聽 聽 聽 聽OF oWnd
聽 聽oDlg1:lHelpIcon := .f.
聽 聽REDEFINE GET oGet[1] VAR base:numero ID 111 PICTURE "99999999" OF oDlg1 ;
聽 聽 聽 WHEN (lAlta .and. oBrw1:nLen() = 0) VALID(base:numero >0)
聽 聽REDEFINE GET oGet[2] VAR base:calle ID 112 PICTURE "@!" OF oDlg1 
聽 聽REDEFINE GET oGet[3] VAR base:npuerta ID 113 PICTURE "99999" OF oDlg1
聽 聽REDEFINE GET oGet[4] VAR base:piso ID 114 PICTURE "999" OF oDlg1
聽 聽REDEFINE GET oGet[5] VAR base:depto ID 115 PICTURE "@!" OF oDlg1
聽 聽REDEFINE COMBOBOX oGet[6] VAR base:motivo ID 116 ITEMS aMotivo OF oDlg1
聽 聽REDEFINE GET oGet[7] VAR base:fecha 聽ID 117 PICTURE "@D" OF oDlg1
聽 聽REDEFINE BUTTON oBot[1] ID 118 OF oDlg1 ACTION (base:Save(),AgregaPer(oBrw1, base1, .t., base:numero, oDlg1))
聽 聽REDEFINE BUTTON oBot[2] ID 119 OF oDlg1 ACTION AgregaPer(oBrw1, base1, .f., base:numero, oDlg1) WHEN oBrw1:nLen()>0
聽 聽REDEFINE BUTTON oBot[3] ID 120 OF oDlg1 ACTION BorraPer(oBrw1, base1) WHEN oBrw1:nLen()>0 
聽 聽REDEFINE XBROWSE oBrw1 FIELDS base1:numfami, base1:apenom, base1:sexo, base1:edad;
聽 聽HEADERS "Persona N潞", "Nombre", "Sexo", "Edad" SIZES 60, 300, 80, 60 ID 123 OF oDlg1
聽 聽 聽base1:bOnChangePage := {|| oBrw1:Refresh() }
聽 聽 聽SetDolphin( oBrw1, base1, .f. )
聽 聽 聽oBrw1:bClrStd := { || If( oBrw1:KeyNo() % 2 == 0, ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ CLR_BLACK, RGB(193,221,255) }, ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ CLR_BLACK, RGB(221,245,255) } ) } 聽 
聽 聽REDEFINE BUTTON oBot[4] ID 125 OF oDlg1 ACTION (mrta:=.t., oDlg1:End())
聽 聽REDEFINE BUTTON oBot[5] ID 126 OF oDlg1 ACTION (mrta:=.f., oDlg1:End()) CANCEL
聽 聽ACTIVATE DIALOG oDlg1 CENTER //ON INIT oGet[1]:SetFocus() 聽
IF !mrta .or. base:numero = 0
聽 聽base:lAppend := .f.
聽 聽base:Refresh()
聽 聽base1:End()
聽 聽RETURN nil
ENDIF
IF lAlta .and. base:Seek(base:numero,"NUMERO") > 0
聽 聽MsgStop("Registro duplicado","Error")
聽 聽base:lAppend := .f.
聽 聽base:Refresh()
聽 聽RETURN nil
ENDIF
base:Save()
base:Refresh()
base1:End()
oBrw:Refresh()
RETURN nil
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Consulta sobre TDolphin
Posted: Fri May 25, 2012 03:41 PM
Hola

revisa el ejemplo testfw1.prg dentro de la carpeta de samples de dolphin, ese ejemplo funciona bien

por otra parte

si quieres usar GetBlankRow( .T. ), enviado TRUE como parametro este devuelve un objeto TDolphinRow que hereda todas las propiedades del registro actual seleccionado y en vez de usar el objeto YDolphinQry inicial puedes usar el objeto TDolphinRow

ejemplo

Code (fw): Select all Collapse
oRow = oQry:GetBlankRow( .T. )

@ 1,1 GET oGet VAR oRow:nombre

oRow:Save()


para reversar cambios puedes hacer

Code (fw): Select all Collapse
oRow:undo()

Continue the discussion