FUNCTION Main()
LOCA lCreate
LOCAL oIniFile, cLanIp, cLanPort, cInternetIp, cInternetPort, cServerType, cServerName, cDictionary
LOCAL cIpFija, cPortFijo, cRootDrive, cUserServer, cServerPath, cPassServer, cErrorAds, cImageFondo
REQUEST ADS , ADSKeyno, ADSKeycount, AdsGetRelKeyPos, AdsSetRelKeyPos
RddRegister( "ADS", 1 ) // ADS for Harbour
RddSetDefault( "ADS" ) // ADS for Harbour
AdsLocking( lLocking )
AdsRightsCheck( lRightsCheck )
AdsTestRecLocks( .T. )
ADSCACHEOPENTABLES( nCacheOpenTables )
AdsSetFileType( VAL( cServerType ) ) /// 1 NTX / 2 CDX / 3 ADT
AdsSetDateFormat( cDateFormat )
oIniFile := TIniFile():New( cPathExe + "Ads.ini" )
cLanIp := oIniFile:ReadString( "SETTINGS", "LAN_IP", "" )
cLanPort := oIniFile:ReadString( "SETTINGS", "LAN_PORT", "" )
cInternetIp := oIniFile:ReadString( "SETTINGS", "INTERNET_IP", "" )
cInternetPort:= oIniFile:ReadString( "SETTINGS", "INTERNET_PORT", "" )
cServerType := oIniFile:ReadString( "SETTINGS", "ADS_SERVER_TYPE", "" )
cServerName := oIniFile:ReadString( "SETTINGS", "ADS_SERVER_NAME", "" )
cServerPath := oIniFile:ReadString( "SETTINGS", "ADS_SERVER_PATH", "" )
cImageFondo := oIniFile:ReadString( "SETTINGS", "ADS_SERVER_JPEG", "" )
lCreate := AdsDdCreate( cNameDictionary,, "Diccionario de datos ADS")
IF ! lCreate
Alert( "DICCIONARIO DE DATOS NO CREADO")
RETURN
ENDIF
IF cServerType == "1"
cDictionary:= cServerPath + cServerName
cIpFija := ""
cPortFijo := ""
cRootDrive := ""
ELSEIF cServerType =="2" .OR. cServerType =="3"
cDictionary:= cServerPath + cServerName
cIpFija := cLanIp
cPortFijo := ":" + cLanPort
cRootDrive := "\\"
ELSEIF cServerType == "4" .OR. cServerType =="7"
cDictionary:= cServerPath + cServerName
cIpFija := cInternetIp
cPortFijo := ":" + cInternetPort
cRootDrive := "\\"
ENDIF
AdsSetServerType( Val(cServerType) )
oWait:= TMsgWait():New("CONECTANDOSE AL SERVIDOR REMOTO... UN MOMENTO POR FAVOR" )
IF AdsConnect60( cRootDrive + cIpFija + cPortFijo + cDictionary, Val(cServerType), "AdsSys", "Edss18462",,@hCONN )
oWait:Close()
ELSE
oWait:Close()
nError:= AdsGetLastError(@cErrorAds)
Alert( cErrorAds,;
"ERROR DE ADS...")
DBCloseAll()
QUIT
ENDIF
// SI QUIERES USAR SQL CON LAS TABLAS QUE TENGAS EN EL DICCIONARIO.. TE RECOMIENDO QUE USES LAS TABLAS NATIVAS DE ADS. ADT EN VEZ DE DBF
oWait:= TMsgWait():New("ABRIENDO ARCHIVOS DE DATOS, ESPERE UN MOMENTO POR FAVOR..." )
lSqlQuery:= .F.
cSqlQuery:= "SELECT * FROM CATGASTO ORDER BY ID_GASTO"
IF Select( "CATGAS" ) > 0
catgas->( DBCloseArea() )
ENDIF
DbSelectArea( 0 )
IF ADSCreateSQLStatement( 'CATGAS', 3, hCONN )
lSqlQuery:= ADSExecuteSQLDirect( cSqlQuery )
IF !lSqlQuery
oWait:Close()
nError:= AdsGetLastError(@cErrorAds)
ALERT( cErrorAds,'ERROR SCRIPT DE ADVANTAGE...' )
RETURN NIL
ENDIF
ELSE
oWait:Close()
nError:= AdsGetLastError(@cErrorAds)
ALERT( cErrorAds,'ERROR SCRIPT DE ADVANTAGE...' )
RETURN NIL
ENDIF
aGastos:= {}
DBSelectArea( "CATGAS"); DBGoTop()
DO WHILE !Eof()
AAdd( aGastos, { catgas->ID_GASTO, Left(catgas->NOMBRE,25), catgas->TIPO, IF( catgas->TIPO="E", "EGRESO", "INGRESO") } )
DBSkip()
ENDDO