ruben Dario wrote:Saudos
Giovany
Entonces lo Ideal seria trabajar com ADT (Lo nativo de ADS) que usar DBF , CDX ... , o hay alguna limitacion
ruben Dario wrote:Giovany.
Saludos
Hice una prueba, pero funciona usando la clase TDatabase(), tu has tenido o has provado esta clase.
USE F_CFOP.ADT NEW ALIAS "DATOS" SHARED
oDatx := TDatabase():New()
Saludos
//Classe gerada por TAds 09/06/2014 - 15:54:21
#Include "Fivewin.ch"
#Include "TAds.ch"
CLASS DB_DEVEDOR from TAds
Data cTableName Init "DEVEDOR"
Data nCache
Data aTableInfo Init {}
Data aColumnsInfo Init {}
Data aIndexInfo Init {}
Data lConnected Init .F.
METHOD OpenRdd(f_nConexao,; // Numero da Conexão - Default tAds_GetConnectionDefault()
f_nCache); // Numero de registros em Cache - Default nCacheAds()
Constructor
METHOD End()
Method DB_DEVEDOR_SeekDocumento(f_cCpfCnpj,f_nOpcDoc,f_lFormat)
Method DB_DEVEDOR_FilterDocumento(f_cCpfCnpj,f_nOpcDoc,f_lFormat)
Method DB_DEVEDOR_SeekCodigo(f_nCodigo)
Method DB_DEVEDOR_DocumentoValido(f_nCodigo)
Method DB_DEVEDOR_Descricao(f_nCodigo)
Method DB_DEVEDOR_FindNomeDoc(f_nTpPessoa, f_cNomeDevedor, f_cCnpj, f_cCpf)
ENDCLASS
//-----------------------------------------------------------------------------
METHOD OpenRdd(f_nConexao,f_nCache) Class DB_DEVEDOR
Default f_nCache := nCacheAds()
::nCache := f_nCache
::nTpCallRdd := 2
::NewRdd(::cTableName,f_nConexao,::nCache)
If ::nOpenStatus == 0
::lConnected := .T.
EndIf
RETURN Self
//-----------------------------------------------------------------------------
METHOD End() Class DB_DEVEDOR
If ::lConnected
::Super:End()
EndIf
Self := Nil
RETURN Nil
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
Method DB_DEVEDOR_SeekDocumento(f_cCpfCnpj,f_nOpcDoc,f_lFormat) Class DB_DEVEDOR
Local cRetDoc := "", cCampoPesquisa := "CPF", lFound := .F.
Default f_lFormat := .F.
If f_lFormat
f_cCpfCnpj := DOC_CPF_CNPJ_FORMAT(f_cCpfCnpj,f_nOpcDoc)
EndIf
f_cCpfCnpj := StrTran(f_cCpfCnpj," ","")
If f_nOpcDoc == 1 // CPF
cCampoPesquisa := "CPF"
ElseIf f_nOpcDoc == 2 // CNPJ
cCampoPesquisa := "CGC"
EndIf
lFound := ::Seek(f_cCpfCnpj,cCampoPesquisa)
Return lFound
//-----------------------------------------------------------------------------
Method DB_DEVEDOR_FilterDocumento(f_cCpfCnpj,f_cNomeDevedor,f_nOpcDoc,f_lFormat) Class DB_DEVEDOR
Local cRetDoc := "", cCampoPesquisa := "CPF", lFound := .F.
Local cAof := "", aVarsFormat := {}, nDevedoresQtaFind := 0, nDevedorRecFound := 0
Default f_lFormat := .F.
If f_lFormat
f_cCpfCnpj := DOC_CPF_CNPJ_FORMAT(f_cCpfCnpj,f_nOpcDoc)
EndIf
f_cCpfCnpj := StrTran(f_cCpfCnpj," ","")
If f_nOpcDoc == 1 // CPF
cCampoPesquisa := "CPF"
ElseIf f_nOpcDoc == 2 // CNPJ
cCampoPesquisa := "CGC"
EndIf
aadd(aVarsFormat,{"_cCpfCnpj_",f_cCpfCnpj})
cAof := cCampoPesquisa + "==_cCpfCnpj_"
::Filter(cAof,aVarsFormat)
nDevedoresQtaFind := ::KeyCount()
if nDevedoresQtaFind == 0
lFound := .F.
ElseIf nDevedoresQtaFind == 1
///If ::VarGetAlltrim("NOME") == AllTrim(f_cNomeDevedor)
If TXT_DIF_COMPARE(::VarGetAlltrim("NOME"),AllTrim(f_cNomeDevedor)) > 60
lFound := .T.
nDevedorRecFound := ::Recno()
Else
lFound := .F.
EndIf
//? nDevedoresQtaFind, ::VarGetAlltrim("NOME"), AllTrim(f_cNomeDevedor), lFound, TXT_DIF_COMPARE(::VarGetAlltrim("NOME"),AllTrim(f_cNomeDevedor))
ElseIf nDevedoresQtaFind > 1
Do While !::Eof()
///If ::VarGetAlltrim("NOME") == AllTrim(f_cNomeDevedor)
If TXT_DIF_COMPARE(::VarGetAlltrim("NOME"),AllTrim(f_cNomeDevedor)) > 60
lFound := .T.
nDevedorRecFound := ::Recno()
Exit
Else
lFound := .F.
EndIf
//? "WHILE", nDevedoresQtaFind, ::VarGetAlltrim("NOME"), AllTrim(f_cNomeDevedor), lFound, TXT_DIF_COMPARE(::VarGetAlltrim("NOME"),AllTrim(f_cNomeDevedor))
::Skip()
EndDo
EndIf
::ClearFilter()
If nDevedorRecFound > 0
::GoTo(nDevedorRecFound)
EndIf
///? "ESCOLHIDO", nDevedoresQtaFind, ::VarGetAlltrim("NOME"), AllTrim(f_cNomeDevedor), lFound, TXT_DIF_COMPARE(::VarGetAlltrim("NOME"),AllTrim(f_cNomeDevedor))
Return lFound
//-----------------------------------------------------------------------------
Method DB_DEVEDOR_SeekCodigo(f_nCodigo) Class DB_DEVEDOR
Local lFound := .F.
If f_nCodigo == -1
f_nCodigo := ::VarGet("NCODIGO")
EndIf
If ::VarGet("NCODIGO") != f_nCodigo
lFound := ::Seek(f_nCodigo,"NCODIGO")
Else
lFound := .T.
EndIf
Return lFound
//-----------------------------------------------------------------------------
Method DB_DEVEDOR_DocumentoValido(f_nCodigo,f_lDataLoad) Class DB_DEVEDOR
Local cDocumento := "", cVirgula := "", cTmpCpfCnpj := "", cTmpRgIe := ""
Default f_lDataLoad := .F.
::DB_DEVEDOR_SeekCodigo(f_nCodigo)
IF ::VarGet("NPESSOA") == 1
cDocumento := ::VarGet("CPF")
ELSE
cDocumento := ::VarGet("CGC")
ENDIF
If f_lDataLoad
::DataLoad()
EndIf
Return cDocumento
//-----------------------------------------------------------------------------
Method DB_DEVEDOR_Descricao(f_nCodigo) Class DB_DEVEDOR
Local lFound := .F., cRetDescricao := ""
If f_nCodigo == -1
f_nCodigo := ::VarGet("NCODIGO")
EndIf
If ::VarGet("NCODIGO") != f_nCodigo
lFound := ::Seek(f_nCodigo,"NCODIGO")
Else
lFound := .T.
EndIf
If !lFound
cRetDescricao := "ERRO, DEVEDOR NÃO ENCONTRADO"
Else
cRetDescricao := ::VarGetRtrim("NOME")
EndIf
Return cRetDescricao
//-----------------------------------------------------------------------------
Method DB_DEVEDOR_FindNomeDoc(f_nCodigoDistribuidor, f_nTpPessoa, f_cNomeDevedor, f_cCnpj, f_cCpf) Class DB_DEVEDOR
Local nCodigoFound := 0
If f_nCodigoDistribuidor > 0
if ::Seek(f_nCodigoDistribuidor,"nCodDistribuidor")
nCodigoFound := ::VarGet("NCODIGO")
Return nCodigoFound
EndIf
Endif
If f_nTpPessoa == 1 .and. Len(Strtran(f_cCpf," ","")) == 14 // Cpf
If ::Seek(f_cCpf,"CPF",.F.,.T.)
nCodigoFound := ::VarGet("NCODIGO")
Endif
ElseIf f_nTpPessoa == 2 .and. Len(Strtran(f_cCnpj," ","")) == 18 // Cnpj
If ::Seek(f_cCnpj,"CGC",.F.,.T.)
nCodigoFound := ::VarGet("NCODIGO")
Endif
Endif
If nCodigoFound == 0
//If ::Seek(f_cNomeDevedor,"NOME",.F.,.T.)
// nCodigoFound := ::VarGet("NCODIGO")
//EndIf
EndIf
If nCodigoFound > 0 .and. ::VarGet("nCodDistribuidor") == 0
::rLock()
::VarPut("nCodDistribuidor",f_nCodigoDistribuidor)
If AllTrim(f_cNomeDevedor) != ::VarGetAlltrim("NOME")
::VarPut("NOME",f_cNomeDevedor)
EndIf
::UnLock()
EndIf
Return nCodigoFound
ruben Dario wrote:Giovany.
Saludos
Gracias por tu informacion, ya estoy entendiento la clase TAds, (Se abren la tablas y se navegan e insertan y modimican registro Excelente)
Te hago esta preguntas
Cuando usas este codigo
::oDs_CepSql := tAds():DsNew(1,1) // 1-Definir query com retorno de Cursors (Handle) / Usar conexão de numero 1
::oDs_CepSql:cQrySql := "Select {static} DISTINCT CIDADE, ESTADO from TB_CEP Order By CIDADE "
En el Select cual es la funcionalidad de USAR Select {static} DISTINCT .... Exactamento {static} , que pasa si se le Quita el {static}
MAnejar la clase Es Excelente.
Otra Duda, cuando se Maneja ADO (OBDC) Cuando se ingresan registros, los indices se actulizan, me parece que vi un documento que no.
Gracias
::oDs_CepSql := tAds():DsNew(1,1)
::oDs_CepSql:cQrySql := "Select * from TB_CEP "
::oDs_CepSql := tAds():DsNew(1,1)
::oDs_CepSql:cQrySql := "Select {STATIC} * from TB_CEP "
::oDs_CepSql := tAds():DsNew(1,1)
::oDs_CepSql:cQrySql := "Select * from TB_CEP Order By CIDADE"
::oDs_RecibosEventos := tAds():DsNew(1)
::oDs_RecibosEventos:cQrySql := "Select "+;
"Tb01.*, "+;
"Tb02.CODIGO AS EVENTOS_CODIGO, "+;
"Tb02.DESCRICAO AS EVENTOS_DESCRICAO, "+;
"Tb02.L_NaoFiscal AS EVENTOS_L_NaoFiscal, "+;
"Tb03.SEQUENCIA AS CAIXA_SETO_SEQUENCIA, "+;
"Tb03.SETOR AS CAIXA_SETO_SETOR "+;
"From RECIB_AV AS Tb01 "+;
"Full Join EVENTOS AS Tb02 ON Tb02.CODIGO = Tb01.N_EVENTO "+;
"Full Join CAIXA_SETO AS Tb03 ON Tb03.SEQUENCIA = Tb01.N_SETOR_CX "+;
"Where Tb01.DATA >= _DataInicio_ and Tb01.Data <= _DataFinal_ "+;
"and Tb02.L_NaoFiscal = False "+;
"Order By Tb01.DATA, Tb01.N_SETOR_CX ;"
::oDs_RecibosEventos:DsAddVar("_DataInicio_",Date())
::oDs_RecibosEventos:DsAddVar("_DataFinal_",Date())
::oDs_RecibosEventos:lBufferOnSkip := .T.
::oDs_RecibosEventos:DsExecute(120) // o valor de 120 define o controle de buffer / page de carregamento da tabela estatica (120 registros)
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: Google [Bot] and 47 guests