Trying out PGDBE with DCBROWSE, but got an error when dragging down the vertical bar
Code: Select all
#include "dctree.ch"
#INCLUDE "dccursor.CH"
#include "dcdialog.ch"
#include "dcbitmap.ch"
#include "dcicon.ch"
#include "appevent.ch"
#include "xbp.ch"
#include "inkey.ch"
#include "dcmsg.ch"
#include "DCGRAPH.CH"
#INCLUDE "GRA.CH"
#include "Dmlb.ch" && 20090827
#include "DbfDbe.ch" && 20090827
#include "pgdbe.ch"
PROCEDURE Main
LOCAL oSession
LOCAL cConnStr
LOCAL GetList := {}, aPres, oBrowse, oToolBar, aColors, bColor, GetOptions
DbeLoad("pgdbe")
DbeSetDefault("pgdbe")
cConnStr := "DBE=pgdbe;server=localhost;"
cConnStr += "db=testpgdbe;uid=postgres;pwd=postgres"
oSession := DacSession():New(cConnStr)
IF(!oSession:IsConnected())
MsgBox("Connection failed ("+Var2Char(oSession:GetLastMessage())+")")
QUIT
ENDIF
//MsgBox("Connected to PostgreSQL server")
IF(!TABLE("ytdtrnp"))
MsgBox("No ytdtrnp table")
ENDIF
USE YTDTRNP INDEX YTDTRNP5 ALIAS COLLECT NEW
aColors := { {GRA_CLR_WHITE,GRA_CLR_DARKRED}, ;
{GRA_CLR_WHITE,GRA_CLR_DARKBLUE}, ;
{GRA_CLR_BLACK,GRA_CLR_DARKGREEN} }
bColor := {|x|x:=COLLECT->for_sale, ;
x := Min(x,2), ;
x := Max(x,0), ;
aColors[x+1]}
aPres := ;
{ { XBP_PP_COL_HA_FGCLR, GRA_CLR_WHITE }, /* Header FG Color */ ;
{ XBP_PP_COL_HA_BGCLR, GRA_CLR_DARKGRAY }, /* Header BG Color */ ;
{ XBP_PP_COL_FA_FGCLR, GRA_CLR_YELLOW }, /* Footer FG Color */ ;
{ XBP_PP_COL_FA_BGCLR, GRA_CLR_DARKGRAY }, /* Footer BG Color */ ;
{ XBP_PP_COL_DA_ROWSEPARATOR, XBPCOL_SEP_DOTTED }, /* Row Sep */ ;
{ XBP_PP_COL_DA_COLSEPARATOR, XBPCOL_SEP_DOTTED }, /* Col Sep */ ;
{ XBP_PP_COL_DA_ROWHEIGHT, 20 }, /* Row Height */ ;
{ XBP_PP_COL_DA_CELLHEIGHT, 20 } } /* Cell Height */
/* ----- Create ToolBar ----- */
@ 1,1 DCTOOLBAR oToolBar ;
SIZE 77, 1.5
DCADDBUTTON CAPTION 'Top' ;
SIZE 9 ;
ACTION {||dbGoTop(), DC_GetRefresh(GetList)} ;
WHEN {||!DC_TestBof()} ;
PARENT oToolBar ;
TOOLTIP 'Go to top of file'
DCADDBUTTON CAPTION 'Previous' ;
SIZE 9 ;
ACTION {||dbSkip(-1), DC_GetRefresh(GetList)} ;
WHEN {||!DC_TestBof()} ;
PARENT oToolBar ;
TOOLTIP 'Skip to previous record in file'
DCADDBUTTON CAPTION 'Next' ;
SIZE 9 ;
ACTION {||dbSkip(1), DC_GetRefresh(GetList)} ;
WHEN {||!DC_TestEof()} ;
PARENT oToolBar ;
TOOLTIP 'Skip to next record in file'
DCADDBUTTON CAPTION 'Bottom' ;
SIZE 9 ;
ACTION {||dbGoBottom(), DC_GetRefresh(GetList)} ;
WHEN {||!DC_TestEof()} ;
PARENT oToolBar ;
TOOLTIP 'Go to Bottom of file'
DCADDBUTTON CAPTION 'APPEND' ;
SIZE 9 ;
ACTION {||APPENDHERE(), DC_GetRefresh(GetList)} ;
PARENT oToolBar ;
TOOLTIP 'APPENDING'
DCADDBUTTON CAPTION 'DELETING' ;
SIZE 9 ;
ACTION {||IIF(RLOCK(),DBDELETE(),), DC_GetRefresh(GetList)} ;
PARENT oToolBar ;
TOOLTIP 'DELETING'
DCADDBUTTON CAPTION 'SEEK' ;
SIZE 9 ;
ACTION {||SEEKHERE(), DC_GetRefresh(GetList)} ;
PARENT oToolBar ;
TOOLTIP 'SEEK'
/* ----- Create browse ----- */
@ 3,1 DCBROWSE oBrowse ALIAS 'COLLECT' ;
SIZE 77,11.8 ;
EDIT xbeBRW_ItemSelected MODE DCGUI_BROWSE_EDITDOWN ;
PRESENTATION aPres
DCBROWSECOL FIELD COLLECT->ORDNO ;
HEADER "Description" PARENT oBrowse FOOTER '1'
DCBROWSECOL FIELD COLLECT->PROD ;
HEADER "Type" PARENT oBrowse FOOTER '2'
DCBROWSECOL FIELD COLLECT->DESC ;
HEADER "SubType" PARENT oBrowse FOOTER '3'
DCBROWSECOL FIELD COLLECT->DESC2 ;
HEADER "Location" PARENT oBrowse FOOTER '4'
DCBROWSECOL FIELD COLLECT->RELQTY ;
HEADER "Orig Date" PARENT oBrowse FOOTER '6'
DCBROWSECOL FIELD COLLECT->ORDQTY ;
HEADER "Acqu Date" PARENT oBrowse FOOTER '7'
DCBROWSECOL FIELD COLLECT->BLQTY ;
HEADER "Acqu Price" PARENT oBrowse FOOTER '8'
DCBROWSECOL FIELD COLLECT->QTY ;
HEADER "Appr Value" PARENT oBrowse FOOTER '9'
DCBROWSECOL FIELD COLLECT->CURR ;
HEADER "Condition" PARENT oBrowse FOOTER '10'
DCBROWSECOL FIELD COLLECT->DODATE ;
HEADER "Orig Owner?" PARENT oBrowse FOOTER '11'
DCBROWSECOL FIELD COLLECT->TRDATE ;
HEADER "Comments" PARENT oBrowse ;
WHEN {||.f.} FOOTER '12'
DCGETOPTIONS TABSTOP
DCREAD GUI ;
OPTIONS GetOptions ;
MODAL ;
TITLE 'Database Browse Demo' ;
FIT ;
BUTTONS DCGUI_BUTTON_EXIT ;
CLEAREVENTS
CLOSE ALL
ReTURN
FUNCTION APPENDHERE()
APPEND BLANK
REPLACE ORDNO WITH '9999', PROD WITH 'ANDY', DESC WITH 'ANDY DESC', DESC2 WITH 'ANDY DESC2'
RETURN NIL
FUNCTION SEEKHERE()
SEEK 'P114475'
RETURN NIL
Regards,
Andy