SQL BROWSER with FIVEWIN + xBrowser
Posted: Fri Dec 20, 2019 1:27 pm
Friends, I'm trying to create an internal SQL BROWSER with fivewin. The idea is that when you type QUERY and click RUN, the system loads the browse with the result. But I can't update the browser, could anyone help?
this function does not work:
static procedure PopulaBrowseQuery(cNotes, aResult)
local oData
oData := m->oserver:query( Alltrim(cNotes) )
aResult :=oData:FillArray()
s_oBrowse:setarray(aResult)
s_oBrowse:Refresh()
return
follow the source below:
prg:
#include "fivewin.ch"
#include "xbrowse.ch"
#include "ttitle.ch"
static s_oWndSqlBrowser := Nil, s_oFonteTitle, s_oFonteBold, s_oTitle, s_oBrowse, hLays := {=>}
/******************************************************************************************************/
procedure SQLBrowser()
/*
*/
Local cNotes := 'select * from produtos', oGet, aResult := {}, hButtons := {=>}, oBotao1, oBotao2
if !VerificaWindowsSQLBrowser()
return
endif
DEFINE FONT s_oFonteBold NAME "Times New Roman" SIZE 0,-15
DEFINE FONT s_oFonteTitle NAME "Segoe UI Light" SIZE 0, 32
define window s_oWndSqlBrowser mdichild of M->oWnd title "SQL Browser" color CLR_WHITE,CLR_WHITE
hLays["MAIN"] := TLayout():new( s_oWndSqlBrowser )
hLays["TITLE"] := hLays["MAIN"]:addVLayout(38)
hLays["GET"] := hLays["MAIN"]:addVLayout(120)
hLays["BROWSE"] := hLays["MAIN"]:addVLayout()
//TITLE
@ 0, 0 TITLE s_oTitle size 8, 10 of hLays["TITLE"] SHADOW NOSHADOW
@ 3, 10 TITLETEXT OF s_oTitle TEXT "SQL Browser" FONT s_oFonteTitle
s_oTitle:bGotfocus := {|| xSetFocus(oGet) }
hLays["TITLE"]:oClient := s_oTitle
//get comandos
hLays["GET"]:addHLayout()
hLays["GET"]:addHLayout(80)
@ 0,0 GET oGet VAR cNotes TEXT PIXEL OF hLays["GET"]:aHLayout[1] MEMO font s_oFonteBold multiline
hLays["GET"]:aHLayout[1]:oClient := oGet
oGet:lClrFocus := .t.
oGet:bGotfocus := {|| oGet:setpos(0) }
//botoes
oBotao1 := hLays["GET"]:aHLayout[2]:addVLayout()
oBotao2 := hLays["GET"]:aHLayout[2]:addVLayout()
@ 0,0 btnbmp hButtons["UM"] prompt "F3 Executar" of oBotao1 MULTILINE Action(PopulaBrowseQuery(cNotes, @aResult), xSetFocus(s_oBrowse))
oBotao1:oClient := hButtons["UM"]
@ 0,0 btnbmp hButtons["DOIS"] prompt "&Sair" of oBotao2 MULTILINE Action(s_oWndSqlBrowser:End())
oBotao2:oClient := hButtons["DOIS"]
//browse
@ 0,0 xbrowse s_oBrowse of hLays["BROWSE"] array aResult color CLR_BLACK,RGB(224,236,255)
s_oBrowse:bClrSelFocus := {|| {CLR_WHITE,CLR_HBLUE}}
s_oBrowse:bClrStd := {|| IIf((s_oBrowse:nArrayAt % 2 )==0,{CLR_BLACK, RGB(224,236,255)},{CLR_BLACK,RGB(189, 211,253)})}
s_oBrowse:bClrSel := {|| {CLR_WHITE,RGB(30,144,255)}}
s_oBrowse:nRowHeight := 26
s_oBrowse:nHeaderHeight := 30
s_oBrowse:nMarqueeStyle := 8
s_oBrowse:CreateFromCode()
hLays["BROWSE"]:oClient := s_oBrowse
// s_oWndSqlBrowser:SetIcon( TIcon():New(,,'MGAICON'))
s_oWndSqlBrowser:bPostEnd := {|| MsgRun("Aguarde...",,{|| Valid_SQLBrowser() } ) }
activate window s_oWndSqlBrowser maximized on init(xSetFocus(oGet));
valid( s_oWndSqlBrowser := Nil, .t. )
return
/************************************************************************************/
static procedure PopulaBrowseQuery(cNotes, aResult)
/*
*/
local oData
oData := m->oserver:query( Alltrim(cNotes) )
aResult :=oData:FillArray()
s_oBrowse:setarray(aResult)
s_oBrowse:Refresh()
return
/************************************************************************************/
static procedure Valid_SQLBrowser()
/*
*/
s_oFonteBold:end()
s_oFonteTitle:end()
s_oTitle:end()
HB_GCAll(.t.)
return
/************************************************************************************/
static function VerificaWindowsSQLBrowser()
/*
*/
if s_oWndSqlBrowser != Nil
if !IsZoomed(s_oWndSqlBrowser:hWnd)
s_oWndSqlBrowser:Maximize()
endif
return(.f.)
endif
return(.t.)