Mr Rao ha logrado hacer mas compatible la clase Eagle1 para obtener muchas de las funcionalidades del XBrowse y TDatarow. Tambien agradezco a Manu por haber permitido este gran avance a los que somos usuarios de la Eagle1
- Code: Select all Expand view RUN
//#include "Eagle1.ch"
#include "FiveWin.ch"
#include "dtpicker.ch"
#include "calendar.ch"
//----------------------------------------------------------------------------//
function Main()
local oDlg, oFont, oBrw
local oConnect // Connection object
local oQry // DataSet or RecordSet object
local cHost := "127.0.0.1"
local cUser := "root"
local cPassword := ""
local cDbName := "fwhdemo"
local cTable := "customers"
local cPort, oRec
FWNumFormat( "A", .t. )
SetGetColorFocus()
// Create the "connection" object
oConnect := TMSConnect():New()
// We connect to the server
if !oConnect:Connect( cHost, cUser, cPassword, cDbName )
MsgInfo( "There is no connection with the server", "Operation Canceled" )
oConnect:Free()
return( nil )
endif
oQry := TMsTable():New( oConnect, cTable )
oQry:SetTinyAsLogical( .t. )
// We open the table, we bring the result to our client
if !oQry:Open()
MsgInfo( "Cannot open table: " + cTable, "Operation Cancelled" )
return( nil )
endif
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-15
DEFINE DIALOG oDlg SIZE 750,500 PIXEL TRUEPIXEL FONT oFont ;
TITLE oQry:ClassName()
@ 50, 20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE oQry COLUMNS "FIRST", "CITY", "SALARY", "AGE", "MARRIED" ;
CELL LINES NOBORDER FOOTERS FASTEDIT AUTOSORT
WITH OBJECT oBrw
:nEditTypes := EDIT_GET
//
:bEdit := { |oRec| CtrDatos( oRec ) }
//
:Salary:nFooterType := AGGR_SUM
:Age:nFooterType := AGGR_AVG
:MakeTotals()
//
:CreateFromCode()
END
@ 10, 10 BUTTON "&Add" SIZE 80, 30 PIXEL OF oDlg;
ACTION oBrw:EditSource( .t. )
@ 10, 100 BUTTON "&Mod" SIZE 80, 30 PIXEL OF oDlg;
ACTION oBrw:EditSource()
@ 10, 190 BUTTON "&Del" SIZE 80, 30 PIXEL OF oDlg;
ACTION oBrw:Delete( .t. )
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
oQry:Close()
oConnect:Close()
return nil
static procedure CtrDatos( oRec )
local lNew := ( oRec:RecNo == 0 )
local oDlg
DEFINE DIALOG oDlg FROM 2, 2 TO 30, 77;
TITLE "Mantenimiento de la tabla Test - " + If( lNew, "ADD", "EDIT" );
STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, 4 )
@ 01, 02 SAY "First" OF oDlg
@ 02, 1.5 GET oRec:First PICTURE "@K" UPDATE OF oDlg
@ 01, 26.6 SAY "Last" OF oDlg
@ 02, 20 GET oRec:Last PICTURE "@K" UPDATE OF oDlg
@ 2.8, 02 SAY "Street" OF oDlg
@ 4, 1.5 GET oRec:Street PICTURE "@K" UPDATE OF oDlg
@ 2.8, 26.6 SAY "City" OF oDlg
@ 4, 20 GET oRec:City PICTURE "@K" UPDATE OF oDlg
@ 4.6, 02 SAY "State" OF oDlg
@ 6, 1.5 GET oRec:State PICTURE "@K XX" UPDATE OF oDlg
@ 4.6, 5.5 SAY "Zip" OF oDlg
@ 6, 4 GET oRec:Zip PICTURE "@K 99999-9999" UPDATE OF oDlg
@ 4.6, 13.9 SAY "Hiredate" OF oDlg
@ 78, 83 DTPICKER oRec:Hiredate UPDATE PIXEL SIZE 50, 11 OF oDlg
@ 6, 10 GET oRec:Hiredate PICTURE "@K" UPDATE OF oDlg
@ 5.7, 22 CHECKBOX oRec:Married PROMPT "Married" UPDATE OF oDlg
@ 4.6, 33 SAY "Age" OF oDlg
@ 6, 24.5 GET oRec:Age PICTURE "@K 999" UPDATE OF oDlg
@ 4.6, 37.5 SAY "Salary" OF oDlg
@ 6, 28 GET oRec:Salary PICTURE "@KE 9,999,999.999" UPDATE OF oDlg
//..................... El campo MEMO...............................................
@ 6.4, 02 SAY "Notes" OF oDlg
@ 8.1, 1.5 GET oRec:Notes MEMO UPDATE OF oDlg SIZE 270, 65
//..................................................................................
@ 10.5, 02 BUTTON "&Save";
OF oDlg;
SIZE 40, 12;
WHEN oRec:Modified() ;
ACTION ( oRec:Save(), oDlg:Update() )
@ 10.5, 10 BUTTON "&Cancel";
OF oDlg;
SIZE 40, 12;
ACTION ( oRec:Undo(), oDlg:Update() )
@ 10.5, 18 BUTTON "&Exit";
OF oDlg;
SIZE 40, 12;
ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
return
//----------------------------------------------------------------------------//