Recd
I will get back to you
oBrw:oTreeItem:SetText( cNewValue )
#include "fivewin.ch"
#include "dbcombo.ch"
static oMarcas, oModelos
function Main()
local oCn, oRs, cSql
local oDlg, oBrw, oFont
FWNumFormat( "A", .t. )
SetGetColorFocus()
MsgRun( "Connecting", "FW Clould Server", { || ;
oCn := maria_Connect( "209.250.245.152,fwh,fwhuser,FiveTech@2022", .t. ) } )
if oCn == nil; return nil; endif
oCn:lShowErrors := .t.
TEXT INTO cSql
SELECT A.*, B.MAR_DES, C.MOD_DES
FROM partes A
LEFT JOIN marcas B ON A.PAR_MAR = B.MAR_NUM
LEFT JOIN modelos C ON A.PAR_MAR = C.MOD_MAR AND A.PAR_MOD = C.MOD_COD
ORDER BY PAR_MAR,PAR_MOD,PAR_COD
ENDTEXT
oMarcas := oCn:RowSet( "marcas" )
oModelos := oCn:RowSet( "modelos" )
MsgRun( "Opening table", "partes", { || ;
oRs := oCn:RowSet( cSql ) } )
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 700,400 PIXEL TRUEPIXEL FONT oFont RESIZABLE
@ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE oRs ;
COLUMNS "MAR_DES","MOD_DES","PAR_DES","PAR_COD";
HEADERS "Marca","Modelo","Nombre o descripción","Código";
CELL LINES NOBORDER
WITH OBJECT oBrw
:nStretchCol := 1
:SetTree( 3 )
:oTree:OpenAll()
:lDisplayZeros := .f.
:bClrStd := { || { CLR_BLACK, If( oBrw:oTreeItem:oTree == nil, CLR_WHITE, CLR_YELLOW ) } }
:bEdit := { |oRec| Editar( oRec ) }
:blDblClick := { || oBrw:EditSource() }
:bKeyDown := { |nKey| IIF(nKey == VK_RETURN, oBrw:EditSource(), ) }
:bChange := { || oDlg:AEvalWhen() }
:CreateFromCode()
END
@ 10, 20 BUTTON "ADD" SIZE 100,40 PIXEL OF oDlg ACTION MsgInfo( "Not implemented" ) ;
WHEN Empty( oBrw:oTreeItem:oTree )
@ 10,140 BUTTON "EDIT" SIZE 100,40 PIXEL OF oDlg ACTION oBrw:EditSource() ;
WHEN oBrw:oTreeItem:Cargo > 0
@ 10,260 BUTTON "Delete" SIZE 100,40 PIXEL OF oDlg ACTION MsgInfo( "Not implemented" ) ;
WHEN Empty( oBrw:oTreeItem:oTree )
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
oRs:Close()
oCn:Close()
return nil
function Editar( oRec ) // oRec is FW_Record Object
local lAppend := ( oRec:RecNo == 0 )
local oBrw := oRec:oBrw
local oTreeItem := oBrw:oTreeItem
local oDlg, oCbx1, oCbx2
if lAppend
? "append not implemented"
return nil
endif
oRec:bOnSave := { || oTreeItem:cPrompt := oRec:par_des }
DEFINE DIALOG oDlg SIZE 400,180 PIXEL TRUEPIXEL
@ 22, 20 SAY "MAR_DES" SIZE 60,24 PIXEL OF oDlg
@ 20, 90 DBCOMBO oCbx1 VAR oRec:par_mar SIZE 200,24 PIXEL OF oDlg ;
ALIAS oMarcas ITEMFIELD "MAR_NUM" LISTFIELD "MAR_DES" ;
WHEN lAppend
@ 52, 20 SAY "MOD_DES" SIZE 60,24 PIXEL OF oDlg
@ 50, 90 DBCOMBO oCbx2 VAR oRec:par_mod SIZE 200,24 PIXEL OF oDlg ;
ALIAS oModelos ITEMFIELD "MOD_COD" LISTFIELD "MOD_DES" ;
WHEN lAppend
@ 80, 20 SAY "PAR_DES" GET oRec:par_des SIZE 340,24 PIXEL OF oDlg
@ 120, 20 BUTTON "SAVE" SIZE 80,30 PIXEL OF oDlg ACTION ( oRec:Save() )
@ 120,140 BUTTON "CLOSE" SIZE 80,30 PIXEL OF oDlg ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
return nil
#include "fivewin.ch"
#include "dbcombo.ch"
REQUEST DBFCDX
static oMarcas, oModelos
function Main()
local oCn, oRs, cSql
local oDlg, oBrw, oFont, oTree
FWNumFormat( "A", .t. )
SetGetColorFocus()
MsgRun( "Connecting", "FW Clould Server", { || ;
oCn := maria_Connect( "209.250.245.152,fwh,fwhuser,FiveTech@2022", .t. ) } )
if oCn == nil; return nil; endif
oCn:lShowErrors := .t.
TEXT INTO cSql
SELECT A.*, B.MAR_DES, C.MOD_DES
FROM partes A
LEFT JOIN marcas B ON A.PAR_MAR = B.MAR_NUM
LEFT JOIN modelos C ON A.PAR_MAR = C.MOD_MAR AND A.PAR_MOD = C.MOD_COD
ORDER BY PAR_MAR,PAR_MOD,PAR_COD
ENDTEXT
oMarcas := oCn:RowSet( "marcas" )
oModelos := oCn:RowSet( "modelos" )
MsgRun( "Opening table", "partes", { || ;
oRs := oCn:RowSet( cSql ) } )
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 700,600 PIXEL TRUEPIXEL FONT oFont RESIZABLE
@ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE oRs ;
COLUMNS "MAR_DES","MOD_DES","PAR_DES","PAR_COD";
HEADERS "Marca","Modelo","Nombre o descripción","Código";
CELL LINES NOBORDER
WITH OBJECT oBrw
:nStretchCol := 1
:SetTree( 3 )
:oTree:OpenAll()
:lDisplayZeros := .f.
:bClrStd := { || { CLR_BLACK, If( oBrw:oTreeItem:oTree == nil, CLR_WHITE, CLR_YELLOW ) } }
:bEdit := { |oRec| Editar( oRec ) }
:blDblClick := { || oBrw:EditSource() }
:bKeyDown := { |nKey| IIF(nKey == VK_RETURN, oBrw:EditSource(), ) }
:bChange := { || oDlg:AEvalWhen() }
:CreateFromCode()
END
@ 10, 20 BUTTON "ADD" SIZE 100,40 PIXEL OF oDlg ACTION oBrw:EditSource( .t. )
@ 10,140 BUTTON "EDIT" SIZE 100,40 PIXEL OF oDlg ACTION oBrw:EditSource() ;
WHEN oBrw:oTreeItem:Cargo > 0
@ 10,260 BUTTON "Delete" SIZE 100,40 PIXEL OF oDlg ACTION ( ;
oBrw:Delete(), oBrw:oTreeItem:Delete(), oBrw:Refresh(), oBrw:Change() ) ;
WHEN oBrw:oTreeItem:Cargo > 0
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
oRs:Close()
oCn:Close()
return nil
function Editar( oRec ) // oRec is FW_Record Object
local lAppend := ( oRec:RecNo == 0 )
local oBrw := oRec:oBrw
local oTreeItem := oBrw:oTreeItem
local oDlg, oCbx1, oCbx2
if lAppend
oRec:bOnSave := { |oRec| OnAppend( oRec ), oDlg:End() }
else
oRec:bOnSave := { || oTreeItem:cPrompt := oRec:par_des }
endif
oRec:bValid := { |o| !( EMPTY( o:par_mar ) .or. EMPTY( o:par_mod ) .or. EMPTY( o:par_cod ) ) }
DEFINE DIALOG oDlg SIZE 400,220 PIXEL TRUEPIXEL
@ 22, 20 SAY "MAR_DES" SIZE 60,24 PIXEL OF oDlg
@ 20, 90 DBCOMBO oCbx1 VAR oRec:par_mar SIZE 200,24 PIXEL OF oDlg ;
ALIAS oMarcas ITEMFIELD "MAR_NUM" LISTFIELD "MAR_DES" ;
WHEN lAppend
oCbx1:bChange := <||
oModelos:Filter := "MOD_MAR=" + cValToChar( oRec:par_mar )
oModelos:MoveFirst()
oCbx2:Refill()
oCbx2:Refresh()
return .t.
>
@ 52, 20 SAY "MOD_DES" SIZE 60,24 PIXEL OF oDlg
@ 50, 90 DBCOMBO oCbx2 VAR oRec:par_mod SIZE 200,24 PIXEL OF oDlg ;
ALIAS oModelos ITEMFIELD "MOD_COD" LISTFIELD "MOD_DES" ;
WHEN lAppend
@ 80, 20 SAY "PAR_COD" GET oRec:par_cod SIZE 200,24 PIXEL OF oDlg
@ 110, 20 SAY "PAR_DES" GET oRec:par_des SIZE 340,24 PIXEL OF oDlg
@ 160, 20 BUTTON "SAVE" SIZE 80,30 PIXEL OF oDlg ACTION oRec:Save( .t. ) ;
WHEN oRec:Modified()
@ 160,140 BUTTON "CLOSE" SIZE 80,30 PIXEL OF oDlg ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
return nil
static function OnAppend( oRec )
local nNewRec := oRec:RecNo
local oBrw := oRec:oBrw
local oRs := oBrw:uDataSource
local oTree, nLen, oItem
local aBlocks := { { || oRs:Fields( "MAR_DES" ):Value }, ;
{ || oRs:Fields( "MOD_DES" ):Value }, ;
{ || oRs:Fields( "PAR_DES" ):Value } }
oRs:ReQuery()
oRs:Sort := "PAR_MAR,PAR_MOD,PAR_COD"
oRs:MoveFirst()
nLen := oRs:RecordCount()
oTree := SummaryDataAsTree( ;
{ || oRs:Move( 1 ) }, { |nRow| nRow > nLen }, aBlocks, { || oRs:BookMark } )
oTree:OpenAll()
oBrw:oTree := oTree
oBrw:GoTop()
oBrw:Refresh()
return nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: albeiroval and 66 guests