IF lAppend // Si hay que a¤adir
oData := TDataRow():New( oRs, nil, .t. )
ELSE
oRs:AbsolutePosition := nRegistro // Goto
oData := TDataRow():New( oRs )
ENDIF
IF lAppend
DEFINE DIALOG oDlg RESOURCE "USUARIOS" TITLE "Añadir un nuevo USUARIO"
ELSE
DEFINE DIALOG oDlg RESOURCE "USUARIOS" TITLE "Modificar un USUARIO"
ENDIF
REDEFINE GET oData:USUARIO ID 101 OF oDlg
REDEFINE GET oData:CLAVE ID 102 OF oDlg
REDEFINE BUTTON ID 701 OF oDlg ACTION( lSave := .T., oDlg:End() )
REDEFINE BUTTON ID 702 OF oDlg ACTION( lSave := .F., oDlg:End() )
ACTIVATE DIALOG oDlg CENTERED
IF lSave
oData:Save()
ENDIF
// ---------------------------------------------------------------------
/*
* tstdrow.prg
* test TDataRow usage
*
*/
#include "fivewin.ch"
#include "xbrowse.ch"
#include "adodef.ch"
REQUEST DBFCDX
//----------------------------------------------------------------------------//
function Main()
local uDataSource
SET DATE ITALIAN
SET CENTURY ON
SET DELETED ON
FWNumFormat( "A", .t. )
uDataSource := OpenData()
BrowseData( uDataSource )
CloseData( uDataSource )
return nil
//----------------------------------------------------------------------------//
// TESTING XBROWSE WITH TDATAROW
// Both XBrowse and TDataRow Code is the same for all Data Sources
//----------------------------------------------------------------------------//
static function BrowseData( uData )
local oDlg, oBrw, oFont, oRec
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE GetSysMetrics(0) * 0.9,400 PIXEL FONT oFont ;
TITLE "TDataRow test : " + FWVERSION
@ 30,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
DATASOURCE uData AUTOCOLS AUTOSORT ;
FOOTERS CELL LINES NOBORDER
WITH OBJECT oBrw
:nEditTypes := EDIT_GET
:Married:SetCheck()
//
:CreateFromCode()
END
@ 10, 10 BUTTON "Edit" SIZE 40,12 PIXEL OF oDlg ;
ACTION ( oRec := TDataRow():New( uData ), oRec:Edit(), oBrw:Refresh(), oBrw:SetFocus() )
@ 10, 60 BUTTON "Append" SIZE 40,12 PIXEL OF oDlg ;
ACTION ( oRec := TDataRow():New( uData, nil, .t. ), oRec:Edit(), oBrw:Refresh(), oBrw:SetFocus() )
@ 10,110 BUTTON "Delete" SIZE 40,12 PIXEL OF oDlg ACTION ( oBrw:Delete(), oBrw:SetFocus() )
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
//----------------------------------------------------------------------------//
static function OpenData()
local nChoice, uDataSource
nChoice := Alert( "Choose DataSource", { "DBF", "TDATABASE", "ADO", "Quit" }, "DATASOURCE" )
if nChoice <= 2
USE C:\FWH\SAMPLES\CUSTOMER NEW ALIAS CUST SHARED VIA "DBFCDX"
if nChoice == 1
uDataSource := Alias()
else
DATABASE uDataSource
endif
elseif nChoice == 3
uDataSource := FW_OpenRecordSet( "c:\fwh\samples\xbrtest.mdb", "CUSTOMER" )
else
QUIT
endif
return uDataSource
//----------------------------------------------------------------------------//
static function CloseData( uDataSource )
if ValType( uDataSource ) == 'C'
( uDataSource )->( DbCloseArea() )
elseif ValType( uDataSource ) == 'O'
uDataSource:Close()
if uDataSource:ClassName() == "TOLEAUTO"
uDataSource:ActiveConnection:Close()
endif
endif
return nil
//----------------------------------------------------------------------------//
Antonio Linares wrote:Rao,
I think that the Class TDataRow name is little confusing, as James commented about it (not sure if he was who did it)
Maybe TRecord would be easier to understand it ? I admit that I am not used to this great Class from Rao yet
lucasdebeltran wrote:Hello,
Works this class with ADO?.
I have to convert an old program that uses TDatabase.
Thank you very much.
The presence of the method Execute for SQL confused me.
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 88 guests