PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 25 → WX - Relatorio CSV com Query
WX - Relatorio CSV com Query
Débuté par adrianoboller, 15 avr. 2015 14:24 - 2 réponses
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 15 avril 2015 - 14:24
//WX - Relatorio CSV com Query
LOCKM is real = 0
LOCVALOR is real = 0
QRY_Select_FechamentoDetalhado.AnoFechamento = COMBO_Ano..DisplayedValue
QRY_Select_FechamentoDetalhado.CentroDeCusto = EDT_CentroCusto
QRY_Select_FechamentoDetalhado.ClienteConvenio = gnConvenioAdministrador
QRY_Select_FechamentoDetalhado.NumeroFechamento = COMBO_NumFechamento..DisplayedValue
ok is boolean = HExecuteQuery(QRY_Select_FechamentoDetalhado,hQueryDefault,gnConvenioAdministrador,COMBO_NumFechamento..DisplayedValue,COMBO_Ano..DisplayedValue,EDT_CentroCusto)
IF ok = True
EDT_CSV = "RADIOTAXI FAIXA VERMELHA" +Charact(13)+Charact(10)

FOR EACH QRY_Select_FechamentoDetalhado
EDT_CSV += "Fechamento Detalhado: "+ GloCabecalho+Charact(13)+Charact(10)
EDT_CSV += "Corrida;Horario;RT;Funcionario;Embarque;Desembarque;Finalidade;Km;Valor;Vouchers"+Charact(13)+Charact(10)
EDT_CSV += QRY_Select_FechamentoDetalhado.Corrida +";"+ QRY_Select_FechamentoDetalhado.Horario +";"+ QRY_Select_FechamentoDetalhado.RT +";"+ QRY_Select_FechamentoDetalhado.Funcionario +";"+ QRY_Select_FechamentoDetalhado.Embarque +";"+ QRY_Select_FechamentoDetalhado.Desembarque +";"+ QRY_Select_FechamentoDetalhado.Finalidade +";"+ QRY_Select_FechamentoDetalhado.Km +";"+ QRY_Select_FechamentoDetalhado.Valor +";"+ QRY_Select_FechamentoDetalhado.Vouchers+Charact(13)+Charact(10)
LOCKM +=QRY_Select_FechamentoDetalhado.Km
LOCVALOR +=QRY_Select_FechamentoDetalhado.Valor
END

EDT_CSV += ";;;;;;;"+ LOCKM +";"+ LOCVALOR +";"+Charact(13)+Charact(10)

END
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 15 avril 2015 - 14:25
SELECT
NG0002_FechamentoDetalhado.ClienteConvenio AS ClienteConvenio,
NG0002_FechamentoDetalhado.Corrida AS Corrida,
NG0002_FechamentoDetalhado.Horario AS Horario,
NG0002_FechamentoDetalhado.RT AS RT,
NG0002_FechamentoDetalhado.Funcionario AS Funcionario,
NG0002_FechamentoDetalhado.Embarque AS Embarque,
NG0002_FechamentoDetalhado.Desembarque AS Desembarque,
NG0002_FechamentoDetalhado.Finalidade AS Finalidade,
NG0002_FechamentoDetalhado.Km AS Km,
NG0002_FechamentoDetalhado.Vouchers AS Vouchers,
NG0002_FechamentoDetalhado.Valor AS Valor,
NG0002_FechamentoDetalhado.CentroDeCusto AS CentroDeCusto,
NG0002_FechamentoDetalhado.DesCentroDeCusto AS DesCentroDeCusto,
NG0002_FechamentoDetalhado.AnoFechamento AS AnoFechamento,
NG0002_FechamentoDetalhado.NumeroFechamento AS NumeroFechamento
FROM
NG0002_FechamentoDetalhado
WHERE
NG0002_FechamentoDetalhado.ClienteConvenio = {pCodClientConvenio}
ANDNG0002_FechamentoDetalhado.NumeroFechamento = {pNumFechamento}
ANDNG0002_FechamentoDetalhado.AnoFechamento = {pAnoFechamento}
ANDNG0002_FechamentoDetalhado.CentroDeCusto = {pCodCentroCusto}
ORDER BY
Horario ASC,
Corrida ASC
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 15 avril 2015 - 15:50
// Local variables

CalculaCabecalho()

LOCKM is real = 0
LOCVALOR is real = 0
QRY_Select_FechamentoDetalhado.AnoFechamento = COMBO_Ano..DisplayedValue
QRY_Select_FechamentoDetalhado.CentroDeCusto = EDT_CentroCusto
QRY_Select_FechamentoDetalhado.ClienteConvenio = gnConvenioAdministrador
QRY_Select_FechamentoDetalhado.NumeroFechamento = COMBO_NumFechamento..DisplayedValue
ok is boolean = HExecuteQuery(QRY_Select_FechamentoDetalhado,hQueryDefault,gnConvenioAdministrador,COMBO_NumFechamento..DisplayedValue,COMBO_Ano..DisplayedValue,EDT_CentroCusto)
IF ok = True THEN

EDT_CSV = "RADIOTAXI FAIXA VERMELHA" +Charact(13)+Charact(10) +";;;;;;;;;"
EDT_CSV += "Fechamento Detalhado: "+ GloCabecalho+Charact(13)+Charact(10) +";;;;;;;;;"
EDT_CSV += "Corrida; Horario; RT; Funcionario; Embarque; Desembarque; Finalidade; Km; Valor; Vouchers"+Charact(13)+Charact(10)

FOR EACH QRY_Select_FechamentoDetalhado
EDT_CSV += QRY_Select_FechamentoDetalhado.Corrida +";"+ QRY_Select_FechamentoDetalhado.Horario +";"+ QRY_Select_FechamentoDetalhado.RT +";"+ QRY_Select_FechamentoDetalhado.Funcionario +";"+ QRY_Select_FechamentoDetalhado.Embarque +";"+ QRY_Select_FechamentoDetalhado.Desembarque +";"+ QRY_Select_FechamentoDetalhado.Finalidade +";"+ QRY_Select_FechamentoDetalhado.Km +";"+ QRY_Select_FechamentoDetalhado.Valor +";"+ QRY_Select_FechamentoDetalhado.Vouchers+Charact(13)+Charact(10)
LOCKM +=QRY_Select_FechamentoDetalhado.Km
LOCVALOR +=QRY_Select_FechamentoDetalhado.Valor
END

EDT_CSV += ";;;;;;;"+ LOCKM +";"+ LOCVALOR +";"+Charact(13)+Charact(10)

END

EDT_CSV = NoAccent(EDT_CSV)

//Exportar Download do arquivo
Numero_Ano is string = COMBO_NumFechamento..DisplayedValue +"_"+ COMBO_Ano..DisplayedValue
sFileName is string = WS_ReturnGenerationDir()+"\FechamentoVoucher"+ Numero_Ano +".csv"
fSaveText(sFileName, EDT_CSV)
FileDisplay(sFileName,"application/unknown", "FechamentoVoucher"+ Numero_Ano +".csv")
fDelete(sFileName)

ToastDisplay("Exportado registros com sucesso!",toastLong,vaMiddle,haCenter)




OU




// Local variables
EDT_CSV = ""
EDT_CSV = TableToText(TABLE_QRY_Select_FechamentoDetalhado,taColumnsTitles,";",Charact(13)+Charact(10))
EDT_CSV = NoAccent(EDT_CSV)
//Exportar Download do arquivo
Numero_Ano is string = COMBO_NumFechamento..DisplayedValue +"_"+ COMBO_Ano..DisplayedValue
sFileName is string = WS_ReturnGenerationDir()+"\FechamentoVoucher"+ Numero_Ano +".csv"
fSaveText(sFileName, EDT_CSV)
FileDisplay(sFileName,"application/unknown", "FechamentoVoucher"+ Numero_Ano +".csv")
fDelete(sFileName)
ToastDisplay("Exportado registros com sucesso!",toastLong,vaMiddle,haCenter)