#include "FiveWin.ch"
#include "richedit.ch"
#include "ord.ch"
#include "xbrowse.ch"
#include "Mail.ch"
REQUEST DBFCDX
#define WID 600
#define HGT 350
#define MY_GREEN nRGB( 145, 214, 124)
FUNCTION Main
local cTable, oBrw, oList, aData
local oDlg, oBar, oFont
local cErrorLogFileName:= "MyLog.log"
Public cServer := "your data"
Public cDataBase := "your data"
Public cUser := "your data"
Public cPassWord := "your data"
PUBLIC oCn, oRs, setup_user:="", setup_naam:="", setup_version:="", setup_level:="", sys_admin:=.F., cPath:="", cLocal:="", cOnline:=""
PUBLIC oCn_kab, oRs_kab
PUBLIC system_version:="20052018", sys_ploegsplit:=0
PUBLIC aPloegen:= {} ,aBtn:= {} ,aBtn2:= {}, aToegang:= {}, aPloegTypes:= {}
Public aUserEdit:= {}
SetPostErrorAction( { |cErrorLogFileName, oError| MyErrorAction( cErrorLogFileName, oError ) } )
RDDSetDefault( "DBFCDX" )
set( 4, "mm/dd/yyyy" )
set( 5, 1930 )
SET DATE BRITISH
XbrNumFormat( 'E', .t. )
//set deleted on
SetHandleCount( 100 )
setkey( VK_F12,{|| xbrowser(oBrw[4]) } )
FWCONNECT oCn HOST cServer USER cUser PASSWORD cPassword DATABASE cDatabase
if oCn == nil
? "Failed to connect to Maveco"
return nil
endif
getploegen() // this gets some data
oRs := oCn:RowSet( "SELECT * FROM parameters" )
system_version = oRs:versie
if lGetPassword(.t.)
oCn:close()
oCn_kab:close()
SET 3DLOOK ON
DEFINE BRUSH oBrush STYLE TILED // FiveWin new predefined Brushes
DEFINE WINDOW oWnd TITLE "LEDEN - ADMINISTRATIE" MENU BuildMenu() BRUSH oBrush
/// Rest code
function getploegen()
oRs := oCn:RowSet( "select * from ploegen where `actief` = ?", { .T. } )
oRs:MoveFirst()
aPloegen := ArrTranspose( oRs:GetRows() )[ 2 ]
aPloegTypes := ArrTranspose( oRs:GetRows() )[ 14 ]
ASize( aBtn, len(aPloegen))
ASize( aBtn2, len(aPloegen))
oRs:close()
return NIL
/*
Some samples :
oRs_Match := oCn_kab:RowSet( "SELECT * FROM tbl_matchen where `poule` = ? " , { "3B" } )
oRsInvent := oCn:RowSet( "SELECT * FROM inventaris" )
oRsMatch := oCn:RowSet( "select * from matchen where `bond` = ?", { oRs:bond } )
oCn:Insert( "changes", "veld, doorwie, naam, voornaam,oldploeg,newploeg,datum", { "Ploeg", setup_naam,oBrw:naam:value, oBrw:voornaam:value, oBrw:p2018:value, cPloeg, date() } )
oCn:Insert( "errors", "datum,uur,user,error,errorlog", { date(),time(), setup_naam, oError:dEscription,cErrText } )
*/
static function BrwDelselect(oBrw)
if msgyesno("Wenst U deze regels te wissen ?")
if !Empty( oBrw:aDeleted )
a := {}
AEval( oBrw:aDeleted, { |x| If( Empty( x[ 1 ] ), nil, AAdd( a, x[ 1 ] ) ) } )
// Array of IDs (primary key) to delete
if !Empty( a )
cSql := "DELETE FROM leden WHERE ID IN " + oCn:ValToSQL( a )
oCn:Execute( cSql )
if oCn:nError != 0
BREAK
endif
endif
endif
endif
return nil
///// This will get some Data from online database and change it.
FWCONNECT oCn HOST cServer USER cUser PASSWORD cPassword DATABASE cDatabase
if oCn == nil
? "Failed to connect"
return nil
endif
oRs := oCn:RowSet( "SELECT * FROM leden" )
oRs:sort:= 'BOND'
oRs:MoveFirst()
do while ! oRs:Eof() // reset bondflag voor controle
oRs:bondlid = .f.
oRs:save()
oRs:MoveNext()
enddo
oRs:MoveFirst()
// check local database with online database.
// controleer bond teveel aan spelers
bond->(dbgotop())
nTel = 0
nPass = 0
do while ! bond->(eof())
cData = alltrim(bond->bondnum)
oRs := oCn:RowSet( "select * FROM leden where bond = ? ", { cData } )
if oRs:BOND = cData
oRs:BONDLID = .T.
oRs:aansluit = bond->aansluit_B
if !empty(bond->ontslag)
oRs:bonderror = "Ontslag: "+dtoc(bond->ontdat)
else
oRs:bonderror = ""
endif
nTel++
else
oRs:Append()
oRs:BOND = alltrim(bond->bondnum)
oRs:NAAM = alltrim(bond->naam_B)
oRs:VOORNAAM = alltrim(bond->VOORN_B)
oRs:ADRES = alltrim(bond->adres_B)
oRs:ADRES = alltrim(bond->adres_B)
oRs:POST = alltrim(bond->post_B)
oRs:GEMEENTE = alltrim(bond->plaats_B)
oRs:BONDERROR = alltrim(bond->ontslag)
oRs:BONDLID = .T.
oRs:geboorte = bond->geboorte_B
oRs:aansluit = bond->aansluit_B
oRs:ploeg2018 = "NIEUW LID"
endif
oRs:Save()
bond->(dbskip())
enddo
msginfo("Bondcontrole verwerkt")
oCn:close()
// select bond
// bond->(dbgotop())
// showbond()
close all
return nil