alterei o exemplo hboleto.prg
/*
* $Id: SAFRA.prg,v 1.1 2006/09/27 11:57:19 marioargon Exp $
*/
/*
* Copyright 2006 Mario Simoes Filho mario@argoninformatica.com.br for original
* Copyright 2006 Marcelo Sturm for modifications in the original project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#include "FiveWin.ch"
#xtranslate Default( , ) => IIF( == NIL, , )
Function hboleto(oLbx)
Local oFont, oDlg, oBan_Cona, nBan_Cona:=0, oNom_Agen, oCon_Cona, cCon_Cona:=Space(15),;
cInst1:=Space(80), cInst2:=Space(80), cInst3:=Space(80), nPercMora:=0, cAce_Cona:=Cona->Ace_Cona, oAce_Cona,;
oCar_Cona, cCar_Cona:=Cona->Car_Cona, nMultPosVnc:=0, nProtDias:=0, cTpd_Cona:=Cona->Tpd_Cona, oTpd_Cona
DEFINE FONT oFont NAME "Arial" SIZE 0, -12
DEFINE DIALOG oDlg FROM 4, 4 TO 20, 50 TITLE "Informar Banco / Conta Corrente"
@ 003, 005 SAY "Agente Cobrador (Banco):" PIXEL OF oDlg FONT oFont SIZE 80, 08
@ 021, 005 SAY "C.Corrente (CC):" PIXEL OF oDlg FONT oFont SIZE 60, 08
@ 041, 005 SAY "Aceite:" PIXEL OF oDlg FONT oFont SIZE 60, 08
@ 041, 028 SAY "Carteira:" PIXEL OF oDlg FONT oFont SIZE 60, 08
@ 041, 054 SAY "Esp.Doc:" PIXEL OF oDlg FONT oFont SIZE 60, 08
@ 041, 085 SAY "Protesto:" PIXEL OF oDlg FONT oFont SIZE 60, 08
@ 049, 101 SAY "Dias" PIXEL OF oDlg FONT oFont SIZE 60, 08
@ 041, 119 SAY "Multa $:" PIXEL OF oDlg FONT oFont SIZE 60, 08
@ 041, 153 SAY "Mora %:" PIXEL OF oDlg FONT oFont SIZE 60, 08
@ 062, 005 SAY "Instruções Cobrança:" PIXEL OF oDlg FONT oFont SIZE 60, 08
@ 010, 005 GET oBan_Cona VAR nBan_Cona PIXEL OF oDlg VALID LkPeAg(StrZero(nBan_Cona,3), oNom_Agen, oBan_Cona) COLOR CLR_GET1,CLR_GET2 SIZE 25,10 BITMAP "" PICTURE "999" ACTION PesqAgen( oBan_Cona, oNom_Agen )
@ 010, 032 SAY oNom_Agen VAR Iif(nBan_Cona=0, "", Agen->Nom_Agen) PIXEL OF oDlg UPDATE BORDER FONT oFont COLOR CLR_GET1,CLR_GET2 SIZE 145, 10
@ 029, 005 GET oCon_Cona VAR cCon_Cona PIXEL OF oDlg VALID LookupCon(StrZero(nBan_Cona,3), cCon_Cona, oCon_Cona, oNom_Cona ) COLOR CLR_GET1,CLR_GET2 SIZE 45, 10 BITMAP "" PICTURE "@!" ACTION PesqCona(oCon_Cona, oNom_Cona, StrZero(nBan_Cona,3))
@ 029, 052 SAY oNom_Cona VAR Iif(Empty(cCon_Cona), "", Cona->Nom_Cona) PIXEL OF oDlg UPDATE BORDER FONT oFont COLOR CLR_GET1,CLR_GET2 SIZE 125, 10
@ 048, 006 GET oAce_Cona VAR cAce_Cona PICT "@!" PIXEL OF oDlg COLOR CLR_GET1,CLR_GET2 SIZE 10,10 FONT oFont
@ 048, 030 GET oCar_Cona VAR cCar_Cona PICT "@!" PIXEL OF oDlg COLOR CLR_GET1,CLR_GET2 SIZE 15,10 FONT oFont
@ 048, 055 GET oTpd_Cona VAR cTpd_Cona PICT "@!" PIXEL OF oDlg COLOR CLR_GET1,CLR_GET2 SIZE 15,10 FONT oFont
@ 048, 084 GET nProtDias PICT "999" PIXEL OF oDlg COLOR CLR_GET1,CLR_GET2 RIGHT SIZE 17,10 FONT oFont
@ 048, 118 GET nMultPosVnc PICT "9,999.99" PIXEL OF oDlg COLOR CLR_GET1,CLR_GET2 RIGHT SIZE 30,10 FONT oFont
@ 048, 152 GET nPercMora PICT "999.99%" PIXEL OF oDlg COLOR CLR_GET1,CLR_GET2 SIZE 25,10 FONT oFont
@ 070, 005 GET cInst1 PICT "@!" PIXEL OF oDlg COLOR CLR_GET1,CLR_GET2 SIZE 172,10 FONT oFont
@ 082, 005 GET cInst2 PICT "@!" PIXEL OF oDlg COLOR CLR_GET1,CLR_GET2 SIZE 172,10 FONT oFont
@ 094, 005 GET cInst3 PICT "@!" PIXEL OF oDlg COLOR CLR_GET1,CLR_GET2 SIZE 172,10 FONT oFont
oAce_Cona:bGotFocus := {|| RecAceBol(oAce_Cona, cAce_Cona) }
oCar_Cona:bGotFocus := {|| RecCarBol(oCar_Cona, cCar_Cona) }
oTpd_Cona:bGotFocus := {|| RecTpdBol(oTpd_Cona, cTpd_Cona) }
@ 108, 005 BUTTON "&Gerar" PIXEL OF oDlg SIZE 40, 10 ACTION (oDlg:End(), FunctionMainBoleto(oApp:cDir_001+"boleto.ini", StrZero(nBan_Cona,3), cCon_Cona, cInst1, cInst2, cInst3, nPercMora, nMultPosVnc, nProtDias, oLbx, cAce_Cona, cCar_Cona))
oDlg:lHelpIcon := .f.
ACTIVATE DIALOG oDlg CENTERED
Return Nil
*--------------------------------------------------------------------------------------------------------------------------------------------------
Static Function RecAceBol(oAce_Cona, cAce_Cona)
oAce_Cona:varput(Cona->Ace_Cona)
oAce_Cona:Refresh()
Return Nil
*--------------------------------------------------------------------------------------------------------------------------------------------------
Static Function RecTpdBol(oTpd_Cona, cTpd_Cona)
oTpd_Cona:varput(Cona->Tpd_Cona)
oTpd_Cona:Refresh()
Return Nil
*--------------------------------------------------------------------------------------------------------------------------------------------------
Static Function RecCarBol(oCar_Cona, cCar_Cona)
oCar_Cona:varput(Cona->Car_Cona)
oCar_Cona:Refresh()
Return Nil
*--------------------------------------------------------------------------------------------------------------------------------------------------
Static Function FunctionMainBoleto( cFileName, cBan_Cona, cCon_Cona, cInst1, cInst2, cInst3, nPercMora, nMultPosVnc, nProtDias, oLbx, cAce_Cona, cCar_Cona )
LOCAL oIni, oRetIni, oBol
LOCAL cDir, cDirRemessa, lPrint, lPreview, lPromptPrint, cBol, nI := 0
CriaIni(cFileName, cBan_Cona, cCon_Cona, cInst1, cInst2, cInst3, nPercMora, nMultPosVnc, nProtDias, cAce_Cona, cCar_Cona)
oIni = TIniFile():New(Default(cFilename, 'bol.ini'))
oBol := oBoleto(oIni:ReadString("CAB", "Banco"))
oBol:lBoleto := oIni:ReadBool("CAB", "lBoleto", .T.)
oBol:lRemessa := oIni:ReadBool("CAB", "lRemessa", .F.)
oBol:lAnsi := oIni:ReadBool("CAB", "lAnsi", .F.)
lPrint := oIni:ReadBool("CAB", "lPrint", .F.)
lPreview := oIni:ReadBool("CAB", "lPreview", .F.)
lPromptPrint := oIni:ReadBool("CAB", "lPromptPrint", .F.)
oBol:nBolsPag := oIni:ReadNumber("CAB", "nBolsPag", 2)
oBol:cImageLnk := oIni:ReadString("CAB", "cImageLnk")
oBol:Cedente := oIni:ReadString("CAB", "Cedente")
oBol:CedenteCNPJ := oIni:ReadString("CAB", "CedenteCNPJ")
oBol:cNumCC := oIni:ReadString("CAB", "cNumCC")
oBol:cNumAgencia := oIni:ReadString("CAB", "cNumAgencia")
oBol:cCarteira := oIni:ReadString("CAB", "cCarteira")
oBol:EspecieTit := oIni:ReadString("CAB", "EspecieTit")
oBol:cTipoCob := oIni:ReadString("CAB", "cTipoCob")
oBol:nMora := oIni:ReadNumber("CAB", "nMora", 0)
oBol:nMulta := oIni:ReadNumber("CAB", "nMulta", 0)
oBol:nDiasProt := oIni:ReadNumber("CAB", "nDiasProt", 0)
cDir := oIni:ReadString("CAB", "cDir")
cDirRemessa := oIni:ReadString("CAB", "cDirRemessa")
oBol:Open("boleto") //, cDir, cDirRemessa, cDir) // Cria html - Sempre colocar após a definição completa do Cedente, pois
// isso influencia na criação do Arquivo Remessa.
DO WHILE .T.
cBol := "BOL" + LTRIM(STR(++nI))
IF EMPTY(oIni:ReadNumber(cBol, "nValor", 0))
EXIT
ENDIF
oBol:Sacado := oIni:ReadString(cBol, "Sacado")
oBol:Endereco := oIni:ReadString(cBol, "Endereco")
oBol:Bairro := oIni:ReadString(cBol, "Bairro")
oBol:Cidade := oIni:ReadString(cBol, "Cidade")
oBol:Estado := oIni:ReadString(cBol, "Estado")
oBol:CEP := oIni:ReadString(cBol, "CEP")
oBol:CNPJ := oIni:ReadString(cBol, "CNPJ")
oBol:Instrucoes := oIni:ReadString(cBol, "Instrucoes", "")
oBol:cNumDoc := oIni:ReadString(cBol, "cNumDoc", "") // seu numero do documento
oBol:cNossoNumero := oIni:ReadString(cBol, "cNossoNumero", "") // numero do banco
oBol:nValor := oIni:ReadNumber(cBol, "nValor", 0) // valor do boleto
oBol:DtEmis := oIni:ReadDate(cBol, "DtEmis", DATE())
oBol:DtVenc := oIni:ReadDate(cBol, "DtVenc", DATE())
oBol:Execute() // monta html
Rebb->(DbSkip())
ENDDO
oBol:Close()
IF lPrint
oBol:Print(lPreview, lPromptPrint) // Imprime o boleto */
ENDIF
IF oBol:lRemessa .AND. !EMPTY(oBol:oRem:NomeRem)
oRetIni = TIniFile():New(Default(cFilename, 'bol.ini') + '.ret')
oRetIni:WriteString("RET", "NomeRem", oBol:oRem:NomeRem)
oRetIni:WriteString("RET", "Destino", oBol:oRem:Destino)
oRetIni:WriteString("RET", "cNumSequencial", oBol:oRem:cNumSequencial)
oRetIni:WriteNumber("RET", "nTitLote", oBol:oRem:nTitLote)
oRetIni:UpdateFile()
ENDIF
Rebb->(DbGoTop())
oLbx:SetFocus()
oLbx:Refresh()
RETURN NIL
/* -------------------------------------------------------------------------- */
STATIC FUNCTION CriaIni( cFileName, cBan_Cona, cCon_Cona, cInst1, cInst2, cInst3, nPercMora, nMultPosVnc, nProtDias, cAce_Cona, cCar_Cona )
Local cInstru, nVlrMora, nNumBols:=0
LOCAL oIni
Ferase(cFileName)
oIni = TIniFile():New(Default(cFilename, 'bol.ini'))
oIni:WriteString("CAB", "Banco", cBan_Cona)
oIni:WriteString("CAB", "cImageLnk", "")
oIni:WriteBool("CAB", "lBoleto", .T.)
oIni:WriteBool("CAB", "lRemessa", .T.)
oIni:WriteBool("CAB", "lAnsi", .T.)
oIni:WriteBool("CAB", "lPrint", .T.)
oIni:WriteBool("CAB", "lPreview", .T.)
oIni:WriteBool("CAB", "lPromptPrint", .T.)
oIni:WriteNumber("CAB", "nBolsPag", 2)
oIni:WriteString("CAB", "Cedente", Alltrim(Cona->Nom_Cona))
oIni:WriteString("CAB", "CedenteCNPJ", Alltrim(Empr->Cgc_Empr))
oIni:WriteString("CAB", "cNumCC", Alltrim(cCon_Cona)) // "100778-3")
oIni:WriteString("CAB", "cNumAgencia", Alltrim(Cona->Age_Cona)) // "1748-5")
oIni:WriteString("CAB", "cCarteira", Alltrim(cCar_Cona))
oIni:WriteString("CAB", "EspecieTit", Alltrim(Cona->Tpd_Cona))
oIni:WriteString("CAB", "cTipoCob", "5")
oIni:WriteNumber("CAB", "nMora", nPercMora)
oIni:WriteNumber("CAB", "nMulta", nMultPosVnc)
oIni:WriteNumber("CAB", "nDiasProt", nProtDias)
oIni:WriteString("CAB", "cDir", "")
oIni:WriteString("CAB", "cDirRemessa", "")
dbSelectArea( "Rebb" )
Rebb->(DbGoTop())
Do While !Rebb->(Eof())
dbSelectArea( "Rece" )
Rece->(DbSeek(Rebb->Cod_Rebb))
dbSelectArea( "Rebb" )
nNumBols++
cInstru:=Alltrim(cInst1)+" "+Alltrim(cInst2)+" "+Alltrim(cInst3)
oIni:WriteString("BOL"+Alltrim(Str(nNumBols)), "Sacado", Clie->Nom_Clie+" - "+Clie->Cod_Clie)
oIni:WriteString("BOL"+Alltrim(Str(nNumBols)), "Endereco", alltrim(Clie->Enc_Clie)+", "+alltrim(Clie->Nmc_Clie)+" "+alltrim(Clie->Cmc_Clie))
oIni:WriteString("BOL"+Alltrim(Str(nNumBols)), "Bairro", alltrim(Clie->Bac_Clie))
oIni:WriteString("BOL"+Alltrim(Str(nNumBols)), "Cidade", alltrim(Clie->Cic_Clie))
oIni:WriteString("BOL"+Alltrim(Str(nNumBols)), "Estado", alltrim(Clie->Esc_Clie))
oIni:WriteString("BOL"+Alltrim(Str(nNumBols)), "CEP", alltrim(Clie->Cec_Clie))
oIni:WriteString("BOL"+Alltrim(Str(nNumBols)), "CNPJ", Iif(Clie->pfj_clie, alltrim(Clie->Cgc_Clie), alltrim(Clie->Cpf_Clie)) )
oIni:WriteString("BOL"+Alltrim(Str(nNumBols)), "Instrucoes", cInstru )
oIni:WriteString("BOL"+Alltrim(Str(nNumBols)), "cNumDoc", Alltrim(Rece->Cod_Rece)) // seu numero do documento
oIni:WriteString("BOL"+Alltrim(Str(nNumBols)), "cNossoNumero", NOVOCOD("NossoNumero"+Cona->Cod_Cona+".dat", 10, "rece")) // numero do banco
oIni:WriteNumber("BOL"+Alltrim(Str(nNumBols)), "nValor", Rece->Tpg_Rece) // valor do boleto
oIni:WriteDate("BOL"+Alltrim(Str(nNumBols)), "DtVenc", Rece->Ven_Rece) // vencimento
Rebb->(DbSkip())
Enddo
RETURN oIni:UpdateFile()
id=code>id=code>ainda estou testando
tem outros exemplos sem usar arquivo .ini
at+