/*
* Demonstrates oRs:EditBaseRecord( [cFieldList], [lAppend], [bEditDlg], [oBrw] )
* Where RowSet contains only some of the fields. this method can be used
* to edit full record of the table with all fields/selected fields
*
*/
#include "fivewin.ch"
#include "dbcombo.ch"
static aStates
//----------------------------------------------------------------------------//
function Main()
local oCn, oRs
local oDlg, oBrw
FWNumFormat( "A", .t. )
oCn := FW_DemoDB()
aStates := oCn:Execute( "SELECT CODE,NAME FROM states" )
oRs := oCn:RowSet( "SELECT ID,FIRST,CITY,SALARY FROM customer" )
DEFINE DIALOG oDlg SIZE 500,600 PIXEL TRUEPIXEL ;
TITLE "EditBaseRecord()"
@ 70,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE oRs AUTOCOLS ;
COLSIZES -4, -20, -20 ;
CELL LINES NOBORDER FOOTERS
WITH OBJECT oBrw
:Salary:nFooterType := AGGR_SUM
:MakeTotals()
:CreateFromCode()
END
@ 20, 20 BTNBMP PROMPT "ADD" SIZE 100,30 PIXEL FLAT OF oDlg ;
ACTION oRs:EditBaseRecord( nil, .t., { |oRec| MyEditDlg( oRec ) }, oBrw )
@ 20,130 BTNBMP PROMPT "EDIT" SIZE 100,30 PIXEL FLAT OF oDlg ;
ACTION oRs:EditBaseRecord( nil, .f., { |oRec| MyEditDlg( oRec ) }, oBrw )
ACTIVATE DIALOG oDlg CENTERED
return nil
static function MyEditDlg( oRec )
local lNew := ( oRec:RecNo == 0 )
local oDlg, oFont, oFld
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-15
DEFINE DIALOG oDlg SIZE 400,570 PIXEL FONT oFont ;
TITLE If( lNew, "ADD NEW ", "EDIT" ) + " RECORD"
//@ 2, 3 FOLDERex oFld OF oDlg SIZE 395, 390 PIXEL;
@ 2, 3 FOLDERex oFld OF oDlg SIZE 380/2, 440/2 PIXEL;
PROMPTS "Page1", "Page2","Page3","Page4" ;
ROUND 10
// This for look size of folder and dialogs and not put buttons in a dialog of folder
AEVal( oFld:aDialogs, { | o | o:SetColor( CLR_BLUE, CLR_YELLOW ) } )
@ 015,010 SAY "ID :" SIZE 40,10 PIXEL OF oFld:aDialogs[1] RIGHT
@ 030,010 SAY "First" SIZE 40,10 PIXEL OF oFld:aDialogs[1] RIGHT
@ 045,010 SAY "Last" SIZE 40,10 PIXEL OF oFld:aDialogs[1] RIGHT
@ 060,010 SAY "Street" SIZE 40,10 PIXEL OF oFld:aDialogs[1] RIGHT
@ 075,010 SAY "City" SIZE 40,10 PIXEL OF oFld:aDialogs[1] RIGHT
@ 090,010 SAY "State" SIZE 40,10 PIXEL OF oFld:aDialogs[1] RIGHT
@ 105,010 SAY "Zip" SIZE 40,10 PIXEL OF oFld:aDialogs[1] RIGHT
@ 120,010 SAY "HireDate" SIZE 40,10 PIXEL OF oFld:aDialogs[1] RIGHT
@ 135,010 SAY "Married" SIZE 40,10 PIXEL OF oFld:aDialogs[1] RIGHT
@ 150,010 SAY "Age" SIZE 40,10 PIXEL OF oFld:aDialogs[1] RIGHT
@ 165,010 SAY "Salary" SIZE 40,10 PIXEL OF oFld:aDialogs[1] RIGHT
@ 180,010 SAY "Notes" SIZE 40,10 PIXEL OF oFld:aDialogs[1] RIGHT
@ 015,055 GET oRec:ID SIZE 050,12 PIXEL OF oFld:aDialogs[1] READONLY RIGHT
@ 030,055 GET oRec:First SIZE 120,12 PIXEL OF oFld:aDialogs[1] VALID !Empty( oRec:First )
@ 045,055 GET oRec:Last SIZE 120,12 PIXEL OF oFld:aDialogs[1] VALID ( oDlg:AEValWhen(), !Empty( oRec:Last ) )
@ 060,055 GET oRec:Street SIZE 120,12 PIXEL OF oFld:aDialogs[1] VALID !Empty( oRec:Street )
@ 075,055 GET oRec:City SIZE 120,12 PIXEL OF oFld:aDialogs[1] VALID !Empty( oRec:City )
@ 090,055 DBCOMBO oRec:State SIZE 120,300 PIXEL OF oFld:aDialogs[1] ;
ALIAS aStates ITEMFIELD "1" LISTFIELD "2"
@ 105,055 GET oRec:Zip SIZE 120,12 PIXEL OF oFld:aDialogs[1] VALID !Empty( oRec:Zip )
@ 120,055 GET oRec:HireDate SIZE 120,12 PIXEL OF oFld:aDialogs[1] VALID !Empty( oRec:HireDate )
@ 135,055 CHECKBOX oRec:Married PROMPT "" SIZE 22,12 PIXEL OF oFld:aDialogs[1]
@ 150,055 GET oRec:Age SIZE 120,12 PIXEL OF oFld:aDialogs[1] PICTURE "99" RIGHT VALID ( oRec:Age >= 20 )
@ 165,055 GET oRec:Salary SIZE 120,12 PIXEL OF oFld:aDialogs[1] PICTURE "999,999.99" RIGHT VALID ( oRec:Salary > 0 )
@ 180,055 GET oRec:Notes SIZE 120,12 PIXEL OF oFld:aDialogs[1]
@ 250,010 BTNBMP PROMPT "Save" SIZE 75,15 PIXEL FLAT OF oDlg ;
ACTION ( If( oRec:Modified(), oRec:Save(), nil ), oDlg:End() ) WHEN oRec:Modified()
@ 250,120 BTNBMP PROMPT "Cancel" SIZE 75,15 PIXEL FLAT OF oDlg ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
//ON PAINT oDlg:Box( 15, 10, 395, 390 )
return nil