Aggiunta la funzione setfiler.

Aggiornato l'uso della funzione filter e setregion


git-svn-id: svn://10.65.10.50/trunk@72 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1994-08-26 14:06:07 +00:00
parent fe146577cf
commit 10cb8b20f6
17 changed files with 4639 additions and 4555 deletions

View File

@ -1,267 +1,267 @@
// ba3200 Stampa tabelle // ba3200 Stampa tabelle
// //
// legge un file con estensione .rpt che descrive la stampa. // legge un file con estensione .rpt che descrive la stampa.
// Vedi file leggimi.txt per il formato del file // Vedi file leggimi.txt per il formato del file
// //
#include <mask.h> #include <mask.h>
#include <printapp.h> #include <printapp.h>
#include <relation.h> #include <relation.h>
#include <tabutil.h> #include <tabutil.h>
#include <utility.h> #include <utility.h>
#include "ba3.h" #include "ba3.h"
#include "ba3200.h" #include "ba3200.h"
#define FOOTER_LEN 4 // se non ridefinito nel .rpt #define FOOTER_LEN 4 // se non ridefinito nel .rpt
class BA3200_application : public TPrintapp class BA3200_application : public TPrintapp
{ {
// TTable* _tab; // TTable* _tab;
TString _tabname; TString _tabname;
TFilename _rptname; TFilename _rptname;
TRelation* _rel; TRelation* _rel;
TCursor *_cur; TCursor *_cur;
TMask* _msk; TMask* _msk;
TString _maskname; TString _maskname;
// TScanner *_rpt; // TScanner *_rpt;
int _logicnum; int _logicnum;
public: public:
virtual void user_create() ; virtual void user_create() ;
virtual void user_destroy() ; virtual void user_destroy() ;
virtual bool set_print(int) ; virtual bool set_print(int) ;
virtual void set_page(int, int); virtual void set_page(int, int);
void leggi_rpt(); void leggi_rpt();
void set_headers(); void set_headers();
void set_rows(); void set_rows();
void set_footers(); void set_footers();
void set_translations(); void set_translations();
BA3200_application(const char * tabname) : _tabname(tabname) {} BA3200_application(const char * tabname) : _tabname(tabname) {}
virtual ~BA3200_application() {} virtual ~BA3200_application() {}
}; };
bool BA3200_application::set_print(int) bool BA3200_application::set_print(int)
{ {
TRectype from(_rel->lfile()->curr()); TRectype from(_rel->lfile()->curr());
TRectype to (_rel->lfile()->curr()); TRectype to (_rel->lfile()->curr());
from.zero(); from.zero();
to.zero(); to.zero();
const KEY tasto = _msk->run(); const KEY tasto = _msk->run();
if (tasto == K_ENTER) if (tasto == K_ENTER)
{ {
const int campi_maschera = _msk->fields(); // - 2; Tolgo bottoni... const int campi_maschera = _msk->fields(); // - 2; Tolgo bottoni...
for (int i = 0; i < campi_maschera; i++) for (int i = 0; i < campi_maschera; i++)
{ {
const TMask_field& campo_maschera = _msk->fld(i); const TMask_field& campo_maschera = _msk->fld(i);
const char* val = campo_maschera.get(); const char* val = campo_maschera.get();
const TFieldref* campo_ref = campo_maschera.field(); const TFieldref* campo_ref = campo_maschera.field();
if (*val && campo_ref != NULL && campo_ref->ok()) if (*val && campo_ref != NULL && campo_ref->ok())
{ {
if (campo_maschera.in_group(1)) campo_ref->write(val, from); else if (campo_maschera.in_group(1)) campo_ref->write(val, from); else
if (campo_maschera.in_group(2)) campo_ref->write(val, to); if (campo_maschera.in_group(2)) campo_ref->write(val, to);
} }
} }
_cur->filter ("", from.empty() ? NULL : &from, to.empty() ? NULL : &to); _cur->setregion (from, to);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
void BA3200_application::set_page (int , int ) void BA3200_application::set_page (int , int )
{ {
leggi_rpt(); leggi_rpt();
} }
void BA3200_application::set_headers() void BA3200_application::set_headers()
{ {
TString NomeTabella, sep, formato_intesta, testo_intesta; TString NomeTabella, sep, formato_intesta, testo_intesta;
int LungRiga, riga_intesta=0, last_riga=1; int LungRiga, riga_intesta=0, last_riga=1;
TToken_string line; TToken_string line;
reset_header (); reset_header ();
TScanner rpt(_rptname); TScanner rpt(_rptname);
rpt.paragraph("Headers"); rpt.paragraph("Headers");
// Leggo la lunghezza della riga (usata per centrare l'intestazione) // Leggo la lunghezza della riga (usata per centrare l'intestazione)
line = rpt.line(); line = rpt.line();
LungRiga = line.get_int(); LungRiga = line.get_int();
// Leggo il nome della tabella // Leggo il nome della tabella
line = rpt.line(); line = rpt.line();
NomeTabella = line.get(); NomeTabella = line.get();
// Centro il nome della tabella e aggiungo il numero di pagina // Centro il nome della tabella e aggiungo il numero di pagina
NomeTabella.center_just (LungRiga); NomeTabella.center_just (LungRiga);
NomeTabella.overwrite ("Pag. @#", NomeTabella.len()-8); NomeTabella.overwrite ("Pag. @#", NomeTabella.len()-8);
set_header (last_riga, "%s", (const char *)NomeTabella); set_header (last_riga, "%s", (const char *)NomeTabella);
last_riga++; last_riga++;
// Aggiungo una riga vuota per separare prima intestazione // Aggiungo una riga vuota per separare prima intestazione
sep.fill ('-', LungRiga); sep.fill ('-', LungRiga);
set_header (last_riga, "%s", (const char *)sep); set_header (last_riga, "%s", (const char *)sep);
line = rpt.line(); line = rpt.line();
while ( (line != "") && (line[0] != '[') ) while ( (line != "") && (line[0] != '[') )
{ {
riga_intesta = atoi (line.get()); riga_intesta = atoi (line.get());
formato_intesta = line.get(); formato_intesta = line.get();
testo_intesta = (const char *) line.get(); testo_intesta = (const char *) line.get();
if (riga_intesta) if (riga_intesta)
set_header (last_riga+riga_intesta, (const char *)formato_intesta, set_header (last_riga+riga_intesta, (const char *)formato_intesta,
(const char *)testo_intesta); (const char *)testo_intesta);
line = rpt.line(); line = rpt.line();
} }
if (riga_intesta) last_riga += riga_intesta; if (riga_intesta) last_riga += riga_intesta;
last_riga++; last_riga++;
set_header (last_riga, (const char *)sep); set_header (last_riga, (const char *)sep);
last_riga++; last_riga++;
sep.fill(' '); sep.fill(' ');
set_header (last_riga, (const char *)sep); set_header (last_riga, (const char *)sep);
} }
void BA3200_application::set_rows() void BA3200_application::set_rows()
{ {
TToken_string line; TToken_string line;
TFieldref campo; TFieldref campo;
int from, to, riga_record; int from, to, riga_record;
TString formato_campo, picture; TString formato_campo, picture;
const char * name; const char * name;
TScanner rpt(_rptname); TScanner rpt(_rptname);
rpt.paragraph("Rows"); rpt.paragraph("Rows");
line = rpt.line(); line = rpt.line();
while ( (line != "") && (line[0] != '[') ) while ( (line != "") && (line[0] != '[') )
{ {
riga_record = line.get_int(); riga_record = line.get_int();
campo = line.get(); campo = line.get();
from = campo.from(); from = campo.from();
to = campo.to(); to = campo.to();
name = campo.name(); name = campo.name();
formato_campo = line.get(); formato_campo = line.get();
formato_campo.trim(); formato_campo.trim();
if (formato_campo.lower() == "@pn") if (formato_campo.lower() == "@pn")
picture = line.get(); picture = line.get();
else else
picture = ""; picture = "";
if (to == -1) if (to == -1)
if (picture != "") if (picture != "")
set_row (riga_record, formato_campo, FLD(_logicnum,name,picture) ); set_row (riga_record, formato_campo, FLD(_logicnum,name,picture) );
else else
set_row (riga_record, formato_campo, FLD(_logicnum,name) ); set_row (riga_record, formato_campo, FLD(_logicnum,name) );
else else
set_row (riga_record, formato_campo, FLD(_logicnum,name,from,to) ); set_row (riga_record, formato_campo, FLD(_logicnum,name,from,to) );
line = (const char *) rpt.line(); line = (const char *) rpt.line();
} }
} }
void BA3200_application::set_footers() void BA3200_application::set_footers()
{ {
TToken_string line; TToken_string line;
int footer_len, riga; int footer_len, riga;
TString formato, testo; TString formato, testo;
reset_footer(); reset_footer();
TScanner rpt(_rptname); TScanner rpt(_rptname);
rpt.paragraph("Footers"); rpt.paragraph("Footers");
line = rpt.line(); line = rpt.line();
footer_len = line.get_int(); footer_len = line.get_int();
if (footer_len) printer().footerlen (footer_len); if (footer_len) printer().footerlen (footer_len);
line = rpt.line(); line = rpt.line();
while ( (line != "") && (line[0] != '[') ) while ( (line != "") && (line[0] != '[') )
{ {
riga = line.get_int(); riga = line.get_int();
formato = line.get(); formato = line.get();
testo = line.get(); testo = line.get();
set_footer (riga, (const char *)formato, (const char*)testo); set_footer (riga, (const char *)formato, (const char*)testo);
line = rpt.line(); line = rpt.line();
} }
} }
void BA3200_application::set_translations() void BA3200_application::set_translations()
{ {
TString campo, from, to; TString campo, from, to;
TToken_string line; TToken_string line;
int logicnum; int logicnum;
TScanner rpt(_rptname); TScanner rpt(_rptname);
rpt.paragraph("Translations"); rpt.paragraph("Translations");
line = rpt.line(); line = rpt.line();
while ( (line != "") && (line[0] != '[') ) while ( (line != "") && (line[0] != '[') )
{ {
logicnum = line.get_int(); logicnum = line.get_int();
campo = line.get(); campo = line.get();
from = line.get(); from = line.get();
to = line.get(); to = line.get();
set_translation (logicnum, (char*)(const char *)campo, (char*)(const char *)from, (char*)(const char *)to); set_translation (logicnum, (char*)(const char *)campo, (char*)(const char *)from, (char*)(const char *)to);
line = rpt.line(); line = rpt.line();
} }
} }
void BA3200_application::leggi_rpt() void BA3200_application::leggi_rpt()
{ {
set_rows(); set_rows();
} }
void BA3200_application::user_create() void BA3200_application::user_create()
{ {
_rptname << "batb" << _tabname << ".rpt" ; _rptname << "batb" << _tabname << ".rpt" ;
if (!fexist(_rptname)) if (!fexist(_rptname))
fatal_box("Impossibile aprire il file '%s'", (const char*)_rptname); fatal_box("Impossibile aprire il file '%s'", (const char*)_rptname);
// _tab = new TTable (_tabname); // _tab = new TTable (_tabname);
_rel = new TRelation (_tabname); _rel = new TRelation (_tabname);
_cur = new TCursor (_rel); _cur = new TCursor (_rel);
_maskname << "bast" << _tabname; _maskname << "bast" << _tabname;
_msk = new TMask (_maskname) ; _msk = new TMask (_maskname) ;
add_cursor (_cur); add_cursor (_cur);
add_file (_tabname); add_file (_tabname);
_logicnum = _cur->file()->num(); _logicnum = _cur->file()->num();
reset_print (); reset_print ();
printer().footerlen (FOOTER_LEN); printer().footerlen (FOOTER_LEN);
for (int i=1; i <= FOOTER_LEN; i++) set_footer(i, "%s", " "); for (int i=1; i <= FOOTER_LEN; i++) set_footer(i, "%s", " ");
set_headers(); set_headers();
set_footers(); set_footers();
set_translations(); set_translations();
} }
void BA3200_application::user_destroy() void BA3200_application::user_destroy()
{ {
delete _msk; delete _msk;
delete _cur; delete _cur;
delete _rel; delete _rel;
// delete _tab; // delete _tab;
} }
int ba3200(int argc, char* argv[]) int ba3200(int argc, char* argv[])
{ {
BA3200_application a(argv[2]) ; BA3200_application a(argv[2]) ;
a.run(argc, argv, "Tabella"); a.run(argc, argv, "Tabella");
return 0; return 0;
} }

View File

@ -43,7 +43,7 @@ BEGIN
INPUT TIPOA "G" INPUT TIPOA "G"
INPUT CODANAGR FLD_CODANAGR INPUT CODANAGR FLD_CODANAGR
DISPLAY "Codice" CODANAGR DISPLAY "Codice" CODANAGR
DISPLAY "Denominazione@50" RAGSOC DISPLAY "Ragione sociale@50" RAGSOC
DISPLAY "Codice Fiscale@16" COFI DISPLAY "Codice Fiscale@16" COFI
OUTPUT FLD_CODANAGR CODANAGR OUTPUT FLD_CODANAGR CODANAGR
OUTPUT FLD_AG1_RAGSOC RAGSOC OUTPUT FLD_AG1_RAGSOC RAGSOC
@ -64,7 +64,7 @@ BEGIN
INPUT TIPOA "G" INPUT TIPOA "G"
CHECKTYPE REQUIRED CHECKTYPE REQUIRED
INPUT RAGSOC FLD_AG1_RAGSOC INPUT RAGSOC FLD_AG1_RAGSOC
DISPLAY "Denominazione@50" RAGSOC DISPLAY "Ragione sociale@50" RAGSOC
DISPLAY "Codice" CODANAGR DISPLAY "Codice" CODANAGR
DISPLAY "Codice Fiscale " COFI DISPLAY "Codice Fiscale " COFI
COPY OUTPUT FLD_CODANAGR COPY OUTPUT FLD_CODANAGR
@ -115,7 +115,7 @@ BEGIN
INPUT TIPOA "G" INPUT TIPOA "G"
INPUT COFI FLD_AG1_COFI INPUT COFI FLD_AG1_COFI
DISPLAY "Codice Fiscale@16" COFI DISPLAY "Codice Fiscale@16" COFI
DISPLAY "Denominazione@50" RAGSOC DISPLAY "Ragione sociale@50" RAGSOC
DISPLAY "Codice" CODANAGR DISPLAY "Codice" CODANAGR
COPY OUTPUT FLD_CODANAGR COPY OUTPUT FLD_CODANAGR
CHECKTYPE REQUIRED CHECKTYPE REQUIRED
@ -1071,7 +1071,7 @@ END
STRING F_IMP_PROVCOM 5 STRING F_IMP_PROVCOM 5
BEGIN BEGIN
PROMPT 64 6 "Prov." PROMPT 62 6 "Prov."
FLAGS "D" FLAGS "D"
END END
@ -1092,10 +1092,15 @@ BEGIN
WARNING "Ufficio imposte assente" WARNING "Ufficio imposte assente"
END END
STRINF F_DENUFFIIDD 50 STRINF F_DENUFFIIDD 50 48
BEGIN BEGIN
PROMPT 23 7 " " PROMPT 23 7 " "
FLAGS "D" USE %UID KEY 2
INPUT S0 F_DENUFFIIDD
DISPLAY "Denominazione@50" S0
DISPLAY "Ufficio" CODTAB
DISPLAY "C.C.@8" S4
COPY OUTPUT F_UFFIIDD
END END
STRING F_CC_ESATTORIA 8 STRING F_CC_ESATTORIA 8
@ -1115,7 +1120,7 @@ BEGIN
FLAGS "UDG" FLAGS "UDG"
END END
STRING F_DENUFFREG 50 STRING F_DENUFFREG 50 48
BEGIN BEGIN
PROMPT 24 9 "" PROMPT 24 9 ""
FLAGS "D" FLAGS "D"
@ -1132,7 +1137,7 @@ BEGIN
CHECKTYPE NORMAL CHECKTYPE NORMAL
END END
STRING F_DENUFFCONC 50 STRING F_DENUFFCONC 50 48
BEGIN BEGIN
PROMPT 24 10 "" PROMPT 24 10 ""
FLAGS "D" FLAGS "D"
@ -1149,7 +1154,7 @@ BEGIN
CHECKTYPE NORMAL CHECKTYPE NORMAL
END END
STRING F_DENUFFSERV 50 STRING F_DENUFFSERV 50 48
BEGIN BEGIN
PROMPT 24 11 "" PROMPT 24 11 ""
FLAGS "D" FLAGS "D"

View File

@ -309,7 +309,7 @@ STRING FLD_GD1_COMAA_COMUNI_DESCR 50
BEGIN BEGIN
PROMPT 8 12 ": Nome " PROMPT 8 12 ": Nome "
USE LF_COMUNI KEY 2 SELECT STATO="" USE LF_COMUNI KEY 2 SELECT STATO=""
INPUT COM FLD_GD1_COMAA_COMUNI_DESCR INPUT DENCOM FLD_GD1_COMAA_COMUNI_DESCR
#include <comdden.h> #include <comdden.h>
OUTPUT FLD_GD1_COMAA COM OUTPUT FLD_GD1_COMAA COM
OUTPUT FLD_GD1_COMAA_COMUNI_DESCR DENCOM OUTPUT FLD_GD1_COMAA_COMUNI_DESCR DENCOM

File diff suppressed because it is too large Load Diff

View File

@ -183,7 +183,7 @@ bool BA6200_application::set_print(int)
a.put(COM_STATO,statofine); a.put(COM_STATO,statofine);
a.put(COM_COM ,codicefine); a.put(COM_COM ,codicefine);
current_cursor()->setregion(&da, &a); current_cursor()->setregion(da, a);
} }
else else
if (scelta == 2) if (scelta == 2)
@ -207,7 +207,7 @@ bool BA6200_application::set_print(int)
a.put (COM_DENCOM, denomfine); a.put (COM_DENCOM, denomfine);
current_cursor()->setregion(&da, &a); current_cursor()->setregion(da, a);
} }
//set_print_zero(); //set_print_zero();
@ -257,7 +257,7 @@ void BA6200_application::user_create()
_comuni = new TLocalisamfile (LF_COMUNI); _comuni = new TLocalisamfile (LF_COMUNI);
_descr_comune = new TParagraph_string ("",25); _descr_comune = new TParagraph_string ("",25);
_msk = new TMask("ba6200a"); _msk = new TMask("ba6200a");
} }

View File

@ -288,14 +288,13 @@ HIDDEN bool sottoc_handler(TMask_field& f, KEY key)
{ {
if (key == K_TAB) if (key == K_TAB)
{ {
TString gruppo(f.mask().get(FLD_CM1_GRUPPO)); int gruppo = f.mask().get_int(FLD_CM1_GRUPPO);
if (gruppo.empty()) return TRUE; if (gruppo == 0) return TRUE;
TString conto(f.mask().get(FLD_CM1_CONTO)); int conto = f.mask().get_int(FLD_CM1_CONTO);
TString sottoconto(f.mask().get(FLD_CM1_SOTTOCONTO)); long sottoconto = f.mask().get_long(FLD_CM1_SOTTOCONTO);
if (sottoconto.not_empty() && conto.empty()) return f.error_box("Manca il CONTO"); if (sottoconto != 0 && conto == 0) return f.error_box("Manca il CONTO");
dispatch_e_char(f.parent(), K_AUTO_ENTER); f.mask().stop_run(K_AUTO_ENTER);
} }
return TRUE; return TRUE;
} }

View File

@ -50,7 +50,7 @@ HIDDEN bool key_handler (TMask_field& f, KEY k)
if (m.get(F_ANNO).not_empty() && m.get(F_CODATT).not_empty() && if (m.get(F_ANNO).not_empty() && m.get(F_CODATT).not_empty() &&
m.get(F_CODCF).not_empty()) m.get(F_CODCF).not_empty())
m.send_key(K_AUTO_ENTER, 0); m.stop_run(K_AUTO_ENTER);
} }
return TRUE; return TRUE;
} }

View File

@ -2813,9 +2813,9 @@ bool CG1500_application::set_print(int)
_cur->setkey(3); _cur->setkey(3);
if (_situazione.not_empty()) if (_situazione.not_empty())
_cur->filter(format("TIPOCF = \"%s\"",(const char*)_situazione)); _cur->setfilter(format("TIPOCF = \"%s\"",(const char*)_situazione));
else else
_cur->filter(""); _cur->setfilter("");
_prog = new TProgind(_cur->items(),"Elaborazione in corso... prego attendere",FALSE); _prog = new TProgind(_cur->items(),"Elaborazione in corso... prego attendere",FALSE);

File diff suppressed because it is too large Load Diff

View File

@ -996,7 +996,7 @@ bool CG3200_application::set_print(int)
a.put(PCN_CONTO,contofine); a.put(PCN_CONTO,contofine);
a.put(PCN_SOTTOCONTO,sottocontofine); a.put(PCN_SOTTOCONTO,sottocontofine);
current_cursor()->setregion(&da, &a); current_cursor()->setregion(da, a);
} }
else else
{ {
@ -1026,7 +1026,7 @@ bool CG3200_application::set_print(int)
a.put(CLI_CONTO,contofine); a.put(CLI_CONTO,contofine);
a.put(CLI_CODCF,sottocontofine); a.put(CLI_CODCF,sottocontofine);
current_cursor()->setregion(&da, &a); current_cursor()->setregion(da, a);
} }
if (_stampatotiva) if (_stampatotiva)
@ -1280,6 +1280,81 @@ void CG3200_application::calcola_progressivi_al()
void CG3200_application::calcola_progressivi() void CG3200_application::calcola_progressivi()
{ {
<<<<<<< cg3200.cpp
TLocalisamfile pconti(LF_PCON);
TLocalisamfile saldi (LF_SALDI);
real pdaresca,paveresca,pdarescap,paverescap;
real progdare_attuale,progavere_attuale,progdare_prec,progavere_prec;
real saldo,progredare_eseprec,progreavere_eseprec,pdarep,paverep;
int indbil;
char salini;
TRectype record(saldi.curr());
saldo = 0.00;
pdarep = 0.00;
paverep = 0.00;
pdaresca = 0.00;
paveresca = 0.00;
pdarescap = 0.00;
paverescap = 0.00;
// Ricerca sull'archivio saldi dei record con gruppo,conto,sottoconto
// uguali a quelli di rmov per il calcolo dei progressivi precedenti
record.zero();
record.put(SLD_GRUPPO, _gruppo);
record.put(SLD_CONTO, _conto);
record.put(SLD_SOTTOCONTO, _sottoc);
if (_ricerca == 'P')
indbil = atoi (current_cursor()->file(LF_PCON)->get(PCN_INDBIL));
else
{
if ((_ricerca == 'C') || (_ricerca == 'F'))
{
pconti.setkey(1);
pconti.zero();
pconti.put(PCN_GRUPPO, _gruppo);
pconti.put(PCN_CONTO , _conto);
pconti.read();
if (pconti.good())
indbil = atoi (pconti.get(PCN_INDBIL));
else
indbil = 0;
}
}
saldi.setkey(2);
saldi.zero();
saldi.put(SLD_GRUPPO, _gruppo);
saldi.put(SLD_CONTO, _conto);
saldi.put(SLD_SOTTOCONTO, _sottoc);
for ( saldi.read();
((saldi.curr()==record) && !saldi.eof());
saldi.next())
{
long annoes_saldi = saldi.curr().get_long(SLD_ANNOES);
//Calcola i progressivi dell'esercizio attuale
if (annoes_saldi == _annomsk)
{
pdaresca = saldi.curr().get_real(SLD_PDARESCA);
paveresca = saldi.curr().get_real(SLD_PAVERESCA);
saldo = saldi.curr().get_real(SLD_SALDO);
salini = saldi.curr().get(SLD_FLAGSALINI)[0];
}
//Calcola i progressivi dell'esercizio precedente
if (annoes_saldi == _annoesmsk)
{
pdarescap = saldi.curr().get_real(SLD_PDARESCA);
pdarep = saldi.curr().get_real(SLD_PDARE);
paverescap = saldi.curr().get_real(SLD_PAVERESCA);
paverep = saldi.curr().get_real(SLD_PAVERE);
=======
TLocalisamfile pconti(LF_PCON); TLocalisamfile pconti(LF_PCON);
TLocalisamfile saldi (LF_SALDI); TLocalisamfile saldi (LF_SALDI);
real pdaresca,paveresca,pdarescap,paverescap; real pdaresca,paveresca,pdarescap,paverescap;
@ -1353,6 +1428,7 @@ void CG3200_application::calcola_progressivi()
pdarep = saldi.curr().get_real(SLD_PDARE); pdarep = saldi.curr().get_real(SLD_PDARE);
paverescap = saldi.curr().get_real(SLD_PAVERESCA); paverescap = saldi.curr().get_real(SLD_PAVERESCA);
paverep = saldi.curr().get_real(SLD_PAVERE); paverep = saldi.curr().get_real(SLD_PAVERE);
>>>>>>> 1.2
// Se il saldo dell'esercizio attuale e' diverso da 0 allora significa che // Se il saldo dell'esercizio attuale e' diverso da 0 allora significa che
// quello corrisponde al saldo finale dell'esercizio precedente. Per ottenere // quello corrisponde al saldo finale dell'esercizio precedente. Per ottenere

File diff suppressed because it is too large Load Diff

View File

@ -1,327 +1,327 @@
// ------------------------------------------------------------ // ------------------------------------------------------------
// Calcolo liquidazioni // Calcolo liquidazioni
// Part 1: interfaccia // Part 1: interfaccia
// fv 21-1-94 // fv 21-1-94
// ------------------------------------------------------------ // ------------------------------------------------------------
#include "cg4300.h" #include "cg4300.h"
#include "cg4300a.h" #include "cg4300a.h"
void CG4300_App::user_create() void CG4300_App::user_create()
{ {
TProgind pnd(3,"Preparazione archivi\nPrego attendere", TProgind pnd(3,"Preparazione archivi\nPrego attendere",
FALSE, TRUE, 30); FALSE, TRUE, 30);
_nditte = new TRelation(LF_NDITTE); _nditte = new TRelation(LF_NDITTE);
_nditte->add(LF_ATTIV,"CODDITTA=CODDITTA"); _nditte->add(LF_ATTIV,"CODDITTA=CODDITTA");
_nditte_r = &(_nditte->curr()); _nditte_r = &(_nditte->curr());
_att_r = &(_nditte->curr(LF_ATTIV)); _att_r = &(_nditte->curr(LF_ATTIV));
_ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Ditte", _ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Ditte",
"@1|Cod.@5|Ragione Sociale@50|Vers."); "@1|Cod.@5|Ragione Sociale@50|Vers.");
_n_ditte = 0l; _n_ditte = 0l;
pnd.addstatus(1); pnd.addstatus(1);
for (_nditte->first(); !_nditte->eof(); _nditte->next()) for (_nditte->first(); !_nditte->eof(); _nditte->next())
{ {
TString cod = _nditte_r->get("CODDITTA"); TString cod = _nditte_r->get("CODDITTA");
TString vers = _nditte_r->get("FREQVIVA"); TString vers = _nditte_r->get("FREQVIVA");
_n_ditte++; _n_ditte++;
TToken_string* d = new TToken_string(" "); TToken_string* d = new TToken_string(" ");
// add record // add record
d->add(cod); d->add(cod);
d->add(_nditte_r->get("RAGSOC")); d->add(_nditte_r->get("RAGSOC"));
d->add(vers); d->add(vers);
_nomiditte.add(d); _nomiditte.add(d);
} }
pnd.addstatus(1); pnd.addstatus(1);
_rel = new TRelation(LF_MOV); _rel = new TRelation(LF_MOV);
_rel->add(LF_RMOVIVA,"NUMREG=NUMREG"); _rel->add(LF_RMOVIVA,"NUMREG=NUMREG");
_cur = new TCursor(_rel); _cur = new TCursor(_rel);
(*_cur) = 0; (*_cur) = 0;
_pim = new TTable("PIM"); _pim = new TTable("PIM");
_ppa = new TTable("PPA"); _ppa = new TTable("PPA");
_plm = new TTable("PLM"); _plm = new TTable("PLM");
_ptm = new TTable("PTM"); _ptm = new TTable("PTM");
_lim = new TTable("LIM"); _lim = new TTable("LIM");
_pla = new TTable("PLA"); _pla = new TTable("PLA");
_reg = new TTable("REG"); _reg = new TTable("REG");
_iva = new TTable("%IVA"); _iva = new TTable("%IVA");
_del = new TTable("%DEL"); _del = new TTable("%DEL");
_lia = new TTable("LIA"); _lia = new TTable("LIA");
_mov = _cur->file(LF_MOV); _mov = _cur->file(LF_MOV);
_rmoviva = _cur->file(LF_RMOVIVA); _rmoviva = _cur->file(LF_RMOVIVA);
_pim_r = &(_pim->curr()); _pim_r = &(_pim->curr());
_plm_r = &(_plm->curr()); _plm_r = &(_plm->curr());
_ptm_r = &(_ptm->curr()); _ptm_r = &(_ptm->curr());
_lim_r = &(_lim->curr()); _lim_r = &(_lim->curr());
_iva_r = &(_iva->curr()); _iva_r = &(_iva->curr());
_del_r = &(_del->curr()); _del_r = &(_del->curr());
_pla_r = &(_pla->curr()); _pla_r = &(_pla->curr());
_ppa_r = &(_ppa->curr()); _ppa_r = &(_ppa->curr());
_reg_r = &(_reg->curr()); _reg_r = &(_reg->curr());
_rmoviva_r = &(_cur->curr(LF_RMOVIVA)); _rmoviva_r = &(_cur->curr(LF_RMOVIVA));
_mov_r = &(_mov->curr()); _mov_r = &(_mov->curr());
// ACHTUNG: tutti i _codatt (codici attivita') sono // ACHTUNG: tutti i _codatt (codici attivita') sono
// in realta' composti dal codice attivita' piu' il // in realta' composti dal codice attivita' piu' il
// tipo attivita' (1 o 2) // tipo attivita' (1 o 2)
_pim_anno = new TRecfield(*_pim_r,"CODTAB",0,3); _pim_anno = new TRecfield(*_pim_r,"CODTAB",0,3);
_pim_codatt = new TRecfield(*_pim_r,"CODTAB",4,9); _pim_codatt = new TRecfield(*_pim_r,"CODTAB",4,9);
_pim_codreg = new TRecfield(*_pim_r,"CODTAB",10,12); _pim_codreg = new TRecfield(*_pim_r,"CODTAB",10,12);
_pim_mese = new TRecfield(*_pim_r,"CODTAB",13,14); _pim_mese = new TRecfield(*_pim_r,"CODTAB",13,14);
_pim_tipocr = new TRecfield(*_pim_r,"CODTAB",15,15); _pim_tipocr = new TRecfield(*_pim_r,"CODTAB",15,15);
_pim_codiva = new TRecfield(*_pim_r,"CODTAB",16,17); _pim_codiva = new TRecfield(*_pim_r,"CODTAB",16,17);
_ppa_year = new TRecfield(*_ppa_r,"CODTAB",0,3); _ppa_year = new TRecfield(*_ppa_r,"CODTAB",0,3);
_ppa_codatt = new TRecfield(*_ppa_r,"CODTAB",4,9); _ppa_codatt = new TRecfield(*_ppa_r,"CODTAB",4,9);
_ppa_month = new TRecfield(*_ppa_r,"CODTAB",10,11); _ppa_month = new TRecfield(*_ppa_r,"CODTAB",10,11);
_ppa_kind = new TRecfield(*_ppa_r,"CODTAB",12,12); _ppa_kind = new TRecfield(*_ppa_r,"CODTAB",12,12);
_plm_anno = new TRecfield(*_plm_r,"CODTAB",0,3); _plm_anno = new TRecfield(*_plm_r,"CODTAB",0,3);
_plm_codatt = new TRecfield(*_plm_r,"CODTAB",4,9); _plm_codatt = new TRecfield(*_plm_r,"CODTAB",4,9);
_plm_mese = new TRecfield(*_plm_r,"CODTAB",10,11); _plm_mese = new TRecfield(*_plm_r,"CODTAB",10,11);
_ptm_anno = new TRecfield(*_ptm_r,"CODTAB",0,3); _ptm_anno = new TRecfield(*_ptm_r,"CODTAB",0,3);
_ptm_codatt = new TRecfield(*_ptm_r,"CODTAB",4,9); _ptm_codatt = new TRecfield(*_ptm_r,"CODTAB",4,9);
_ptm_mese = new TRecfield(*_ptm_r,"CODTAB",10,11); _ptm_mese = new TRecfield(*_ptm_r,"CODTAB",10,11);
_lim_anno = new TRecfield(*_lim_r,"CODTAB",0,3); _lim_anno = new TRecfield(*_lim_r,"CODTAB",0,3);
_lim_mese = new TRecfield(*_lim_r,"CODTAB",4,6); _lim_mese = new TRecfield(*_lim_r,"CODTAB",4,6);
_pla_anno = new TRecfield(*_pla_r,"CODTAB",0,3); _pla_anno = new TRecfield(*_pla_r,"CODTAB",0,3);
_pla_codatt = new TRecfield(*_pla_r,"CODTAB",4,9); _pla_codatt = new TRecfield(*_pla_r,"CODTAB",4,9);
_del_ditta = new TRecfield(*_del_r,"CODTAB",0,4); _del_ditta = new TRecfield(*_del_r,"CODTAB",0,4);
_del_anno = new TRecfield(*_del_r,"CODTAB",5,8); _del_anno = new TRecfield(*_del_r,"CODTAB",5,8);
_del_mese = new TRecfield(*_del_r,"CODTAB",9,10); _del_mese = new TRecfield(*_del_r,"CODTAB",9,10);
_del_tipo = new TRecfield(*_del_r,"CODTAB",11,11); _del_tipo = new TRecfield(*_del_r,"CODTAB",11,11);
pnd.addstatus(1); pnd.addstatus(1);
set_real_picture(REAL_PICTURE); set_real_picture(REAL_PICTURE);
} }
void CG4300_App::user_destroy() void CG4300_App::user_destroy()
{ {
delete _ditte; delete _ditte;
delete _pim_anno; delete _pim_anno;
delete _pim_codreg; delete _pim_codreg;
delete _pim_mese; delete _pim_mese;
delete _pim_tipocr; delete _pim_tipocr;
delete _pim_codiva; delete _pim_codiva;
delete _ppa_year; delete _ppa_year;
delete _ppa_codatt; delete _ppa_codatt;
delete _ppa_month; delete _ppa_month;
delete _ppa_kind; delete _ppa_kind;
delete _plm_anno; delete _plm_anno;
delete _plm_codatt; delete _plm_codatt;
delete _plm_mese; delete _plm_mese;
delete _ptm_anno; delete _ptm_anno;
delete _ptm_codatt; delete _ptm_codatt;
delete _ptm_mese; delete _ptm_mese;
delete _lim_anno; delete _lim_anno;
delete _lim_mese; delete _lim_mese;
delete _pla_anno; delete _pla_anno;
delete _pla_codatt; delete _pla_codatt;
delete _pim_codatt; delete _pim_codatt;
delete _del_ditta; delete _del_ditta;
delete _del_anno; delete _del_anno;
delete _del_mese; delete _del_mese;
delete _del_tipo; delete _del_tipo;
delete _pim; delete _pim;
delete _ppa; delete _ppa;
delete _plm; delete _plm;
delete _ptm; delete _ptm;
delete _lim; delete _lim;
delete _pla; delete _pla;
delete _del; delete _del;
delete _nditte; delete _nditte;
delete _rel; delete _rel;
delete _cur; delete _cur;
} }
bool CG4300_App::set_print(int n) bool CG4300_App::set_print(int n)
{ {
TString yy = _year; TString yy = _year;
_descr_arr.destroy(); _descr_arr.destroy();
switch(n) switch(n)
{ {
case 1: // liquidazione case 1: // liquidazione
_isprint = TRUE; _isprint = TRUE;
if (set_liquidazione()) if (set_liquidazione())
{ {
if (_selected.ones() > 0l) if (_selected.ones() > 0l)
{ {
if (_year != yy) if (_year != yy)
{ {
TString cond(format("ANNOES=%s",(const char*)_year)); TString cond(format("ANNOES=%s",(const char*)_year));
_cur->filter(cond); _cur->setfilter(cond);
} }
recalc_all(); recalc_all();
return _isprint; return _isprint;
} }
else warning_box("Nessuna ditta selezionata!"); else warning_box("Nessuna ditta selezionata!");
} }
break; break;
case 2: // estrazione deleghe case 2: // estrazione deleghe
_isprint = FALSE; _isprint = FALSE;
if (set_deleghe()) if (set_deleghe())
{ {
if (_year != yy) if (_year != yy)
{ {
TString cond(format("ANNOES=%s",(const char*)_year)); TString cond(format("ANNOES=%s",(const char*)_year));
_cur->filter(cond); _cur->setfilter(cond);
} }
extract_deleghe(); extract_deleghe();
return FALSE; return FALSE;
} }
break; break;
case 3: // calcolo acconto case 3: // calcolo acconto
_isprint = TRUE; _isprint = TRUE;
if (set_acconto()) if (set_acconto())
{ {
if (_year != yy) if (_year != yy)
{ {
TString cond(format("ANNOES=%s",(const char*)_year)); TString cond(format("ANNOES=%s",(const char*)_year));
_cur->filter(cond); _cur->setfilter(cond);
} }
recalc_acconti(); recalc_acconti();
return _isprint; return _isprint;
} }
break; break;
} }
return FALSE; return FALSE;
} }
bool CG4300_App::set_liquidazione() bool CG4300_App::set_liquidazione()
{ {
TMask m("cg4300a.msk"); TMask m("cg4300a.msk");
m.field(CG43_FLD_SELECTED).set("0"); m.field(CG43_FLD_SELECTED).set("0");
_selected.reset(); _selected.reset();
TBit_array selected = _selected; TBit_array selected = _selected;
KEY k; KEY k;
// stampa abilitata per default // stampa abilitata per default
m.set(CG43_CHK_STAMPA,"X"); m.set(CG43_CHK_STAMPA,"X");
do { do {
k = m.run(); k = m.run();
if (k == K_ESC) break; if (k == K_ESC) break;
_what = (wht)atoi(m.get(CG43_RDB_VERS)); _what = (wht)atoi(m.get(CG43_RDB_VERS));
_month = atoi(m.get(CG43_LST_MESE)); _month = atoi(m.get(CG43_LST_MESE));
if (_what == all) if (_what == all)
{ {
if (_month != 3 && _month != 6 && _month != 9 && if (_month != 3 && _month != 6 && _month != 9 &&
_month != 12 && _month != 13) _month != 12 && _month != 13)
_what = mnt; _what = mnt;
} }
else if (_what == quarter) else if (_what == quarter)
_month = atoi(m.get(CG43_LST_TRIM)); _month = atoi(m.get(CG43_LST_TRIM));
_year = m.get(CG43_FLD_ANNO); _year = m.get(CG43_FLD_ANNO);
_date = m.get(CG43_FLD_DATA); _date = m.get(CG43_FLD_DATA);
_isprint = m.get_bool(CG43_CHK_STAMPA); _isprint = m.get_bool(CG43_CHK_STAMPA);
_recalc = (recalc)m.get_long(CG43_LST_CALC); _recalc = (recalc)m.get_long(CG43_LST_CALC);
_isfinal = m.get_bool(CG43_CHK_FINAL); _isfinal = m.get_bool(CG43_CHK_FINAL);
if (_isprint) printer().setdate(_date); if (_isprint) printer().setdate(_date);
TString from = m.get(CG43_FLD_DFR); TString from = m.get(CG43_FLD_DFR);
TString to = m.get(CG43_FLD_DTO); TString to = m.get(CG43_FLD_DTO);
m.field(CG43_FLD_DFR).set(""); m.field(CG43_FLD_DFR).set("");
m.field(CG43_FLD_DTO).set(""); m.field(CG43_FLD_DTO).set("");
// ------------------------------------------------ // ------------------------------------------------
m.first_focus(k); m.first_focus(k);
long j, cnt, chk; int i; long j, cnt, chk; int i;
switch(k) switch(k)
{ {
case DLG_SELECT: case DLG_SELECT:
// build sheet // build sheet
_ditte->destroy(); chk = 0l; _ditte->destroy(); chk = 0l;
for (i = 0; i < _nomiditte.items(); i++) for (i = 0; i < _nomiditte.items(); i++)
{ {
if (_selected[i]) continue; if (_selected[i]) continue;
TToken_string d = (const char*)((TToken_string&)_nomiditte[i]); TToken_string d = (const char*)((TToken_string&)_nomiditte[i]);
TString cod = d.get(0); TString cod = d.get(0);
TString vers = d.get(2); TString vers = d.get(2);
if ((_what == mnt && vers == "T") || if ((_what == mnt && vers == "T") ||
(_what == quarter && vers == "M")) (_what == quarter && vers == "M"))
continue; continue;
_ditte->add(d); _ditte->add(d);
// check // check
if (!from.empty() || !to.empty()) if (!from.empty() || !to.empty())
{ {
if (from.empty()) from = "0"; if (from.empty()) from = "0";
if (to.empty()) to = "999999999"; if (to.empty()) to = "999999999";
if (atol(cod) >= atol(from) && atol(cod) <= atol(to)) if (atol(cod) >= atol(from) && atol(cod) <= atol(to))
_ditte->check(chk++); _ditte->check(chk++);
} }
} }
// seleziona e aggiungi alle gia' selezionate // seleziona e aggiungi alle gia' selezionate
if (_ditte->run() == K_ENTER) if (_ditte->run() == K_ENTER)
{ {
cnt = 0; cnt = 0;
for (j = 0l; j < _n_ditte; j++) for (j = 0l; j < _n_ditte; j++)
{ {
if (_selected[j]) continue; if (_selected[j]) continue;
if (_ditte->checked(cnt++)) if (_ditte->checked(cnt++))
selected.set(j); selected.set(j);
} }
_selected |= selected; _selected |= selected;
selected.reset(); selected.reset();
} }
m.field(CG43_FLD_SELECTED).set(format("%ld",(long)_selected.ones())); m.field(CG43_FLD_SELECTED).set(format("%ld",(long)_selected.ones()));
break; break;
case CG43_BUT_ANN: case CG43_BUT_ANN:
_selected.reset(); _selected.reset();
m.field(CG43_FLD_SELECTED).set("0"); m.field(CG43_FLD_SELECTED).set("0");
break; break;
case CG43_BUT_CHK: case CG43_BUT_CHK:
{ {
_ditte->destroy(); _ditte->destroy();
for (i = 0; i < _nomiditte.items(); i++) for (i = 0; i < _nomiditte.items(); i++)
{ {
TToken_string d = (const char*)((TToken_string&)_nomiditte[i]); TToken_string d = (const char*)((TToken_string&)_nomiditte[i]);
_ditte->add(d); _ditte->add(d);
if (_selected[i]) _ditte->check(i); if (_selected[i]) _ditte->check(i);
} }
_ditte->disable_check(); _ditte->disable_check();
_ditte->run(); _ditte->run();
_ditte->enable_check(); _ditte->enable_check();
} }
break; break;
} }
} }
while (k != K_ENTER && k != K_ESC); while (k != K_ENTER && k != K_ESC);
return k == K_ENTER; return k == K_ENTER;
} }
int cg4300(int argc, char* argv[]) int cg4300(int argc, char* argv[])
{ {
CG4300_App main_app; CG4300_App main_app;
main_app.run(argc, argv, "Liquidazione IVA"); main_app.run(argc, argv, "Liquidazione IVA");
return TRUE; return TRUE;
} }

View File

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.4 1994-08-26 13:07:14 guy Exp $ // $Id: maskfld.cpp,v 1.5 1994-08-26 14:05:29 alex Exp $
#include <xvt.h> #include <xvt.h>
#include <applicat.h> #include <applicat.h>
@ -1160,7 +1160,8 @@ int TBrowse::do_input(bool filter)
else work << _filter[i]; else work << _filter[i];
} }
const char* w = work.empty() ? NULL : (const char*) work; _cursor->setfilter(work);
_cursor->setregion(filtrec, filtrec);
if (filtrec.empty()) _cursor->filter(w); if (filtrec.empty()) _cursor->filter(w);
else _cursor->filter(w, &filtrec, &filtrec); else _cursor->filter(w, &filtrec, &filtrec);

View File

@ -718,7 +718,7 @@ bool TSpreadsheet::on_key(KEY k)
{ {
switch(k) switch(k)
{ {
case K_SHIFT_ENTER: case K_CTRL_ENTER:
case K_ESC: case K_ESC:
mask().send_key(k, 0); mask().send_key(k, 0);
return TRUE; return TRUE;

View File

@ -1,4 +1,4 @@
// $Id: relapp.cpp,v 1.3 1994-08-23 13:52:26 guy Exp $ // $Id: relapp.cpp,v 1.4 1994-08-26 14:05:47 alex Exp $
#include <mailbox.h> #include <mailbox.h>
#include <sheet.h> #include <sheet.h>
#include <urldefid.h> #include <urldefid.h>
@ -829,7 +829,8 @@ bool TRelation_application::filter()
if (campo != NULL) if (campo != NULL)
campo->write(t.mid(u+1), rec); campo->write(t.mid(u+1), rec);
} }
cur->filter("", &rec, &rec); cur->setfilter("");
cur->setregion(rec, rec);
if (s == NULL) id = 0; if (s == NULL) id = 0;
} }
} }

View File

@ -1,4 +1,4 @@
// $Id: relation.cpp,v 1.4 1994-08-24 07:24:04 villa Exp $ // $Id: relation.cpp,v 1.5 1994-08-26 14:06:00 alex Exp $
// relation.cpp // relation.cpp
// fv 12/8/93 // fv 12/8/93
// relation class for isam files // relation class for isam files
@ -845,7 +845,8 @@ TRecnotype TCursor::update()
} }
void TCursor::filter(const char* filter, TRectype *from, TRectype* to) void TCursor::filter(const char* filter, const TRectype *from,
const TRectype* to)
{ {
CHECK(!_frozen, "Impossibile filtrare un cursore congelato"); CHECK(!_frozen, "Impossibile filtrare un cursore congelato");

View File

@ -1,4 +1,4 @@
/* $Id: relation.h,v 1.1.1.1 1994-08-12 10:52:02 alex Exp $ */ /* $Id: relation.h,v 1.2 1994-08-26 14:06:07 alex Exp $ */
// join.h // join.h
// fv 12/8/93 // fv 12/8/93
// join class for isam files // join class for isam files
@ -19,124 +19,124 @@
class TRelation : public TObject class TRelation : public TObject
{ {
friend class TRelationdef; friend class TRelationdef;
// class TRelation : public TLocalisamfile // class TRelation : public TLocalisamfile
// @END // @END
// @DPRIV // @DPRIV
TToken_string _status; // stato della relazione TToken_string _status; // stato della relazione
TArray _files; // file descriptors TArray _files; // file descriptors
TArray _reldefs; // TRelationdef array TArray _reldefs; // TRelationdef array
int _errors; int _errors;
// @END // @END
// @FPROT // @FPROT
protected: protected:
virtual void print_on(ostream& out) const; virtual void print_on(ostream& out) const;
int log2ind(int logicnum) const; int log2ind(int logicnum) const;
int alias2ind(byte alias) const; int alias2ind(byte alias) const;
int name2ind(const char* name) const; int name2ind(const char* name) const;
TRelationdef* reldef(int i) const { return (TRelationdef*)&_reldefs[i]; } TRelationdef* reldef(int i) const { return (TRelationdef*)&_reldefs[i]; }
TLocalisamfile* file(int i = 0) const { return (TLocalisamfile*)&_files[i]; } TLocalisamfile* file(int i = 0) const { return (TLocalisamfile*)&_files[i]; }
// @LONGDES // @LONGDES
// position_rels fa tutto il lavoro: se non trova un record // position_rels fa tutto il lavoro: se non trova un record
// adatto su un file, svuota il record corrente e non ritorna errore. // adatto su un file, svuota il record corrente e non ritorna errore.
// write etc. poi procedono normalmente // write etc. poi procedono normalmente
// @END // @END
int position_rels(TIsamop op = _isequal, TReclock lockop = _nolock, TDate& atdate = botime, int first = 0); int position_rels(TIsamop op = _isequal, TReclock lockop = _nolock, TDate& atdate = botime, int first = 0);
friend class TCursor; friend class TCursor;
public: public:
// @FPUB // @FPUB
int update() { return position_rels(_isequal, _nolock);} int update() { return position_rels(_isequal, _nolock);}
void zero(); void zero();
virtual int next(TReclock lockop = _nolock) { return file()->next(lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); } virtual int next(TReclock lockop = _nolock) { return file()->next(lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); }
virtual int prev(TReclock lockop = _nolock) { return file()->prev(lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); } virtual int prev(TReclock lockop = _nolock) { return file()->prev(lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); }
virtual int next(TDate& atdate) { return file()->next(atdate) == NOERR ? position_rels(_isequal, _nolock, atdate) : file()->status(); } virtual int next(TDate& atdate) { return file()->next(atdate) == NOERR ? position_rels(_isequal, _nolock, atdate) : file()->status(); }
virtual int prev(TDate& atdate) { return file()->prev(atdate) == NOERR ? position_rels(_isequal, _nolock, atdate) : file()->status(); } virtual int prev(TDate& atdate) { return file()->prev(atdate) == NOERR ? position_rels(_isequal, _nolock, atdate) : file()->status(); }
virtual int first(TReclock lockop = _nolock) { return file()->first(lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); } virtual int first(TReclock lockop = _nolock) { return file()->first(lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); }
virtual int last(TReclock lockop = _nolock) { return file()->last(lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); } virtual int last(TReclock lockop = _nolock) { return file()->last(lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); }
virtual int skip(TRecnotype nrec, TReclock lockop = _nolock) { return file()->skip(nrec, lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); } virtual int skip(TRecnotype nrec, TReclock lockop = _nolock) { return file()->skip(nrec, lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); }
virtual int read(TIsamop op = _isgteq, TReclock lockop = _nolock, TDate& atdate = botime) { return file()->read(op, lockop, atdate) == NOERR ? position_rels(_isequal, lockop, atdate) : file()->status();} virtual int read(TIsamop op = _isgteq, TReclock lockop = _nolock, TDate& atdate = botime) { return file()->read(op, lockop, atdate) == NOERR ? position_rels(_isequal, lockop, atdate) : file()->status();}
TLocalisamfile* lfile(int logicnum = 0) const; TLocalisamfile* lfile(int logicnum = 0) const;
TLocalisamfile* lfile(const char* name) const; TLocalisamfile* lfile(const char* name) const;
void write_enable(int logicnum = -1, const bool on = TRUE) ; void write_enable(int logicnum = -1, const bool on = TRUE) ;
void write_enable(const char* name, const bool on = TRUE) ; void write_enable(const char* name, const bool on = TRUE) ;
void write_disable(int logicnum = -1) { write_enable(logicnum, FALSE); } void write_disable(int logicnum = -1) { write_enable(logicnum, FALSE); }
void write_disable(const char* name) { write_enable(name, FALSE); } void write_disable(const char* name) { write_enable(name, FALSE); }
TRectype& curr(int logicnum = 0) const { return lfile(logicnum)->curr(); } TRectype& curr(int logicnum = 0) const { return lfile(logicnum)->curr(); }
// next_match for 0ne-to-many relations; positions logicnum (!= main) // next_match for 0ne-to-many relations; positions logicnum (!= main)
// on next matching record; returns TRUE or FALSE if no more matches; in // on next matching record; returns TRUE or FALSE if no more matches; in
// any case relation is kept consistent except when inconsistent in // any case relation is kept consistent except when inconsistent in
// first place // first place
bool next_match(int logicnum, const char* fieldlist = NULL, int nkey = 0); bool next_match(int logicnum, const char* fieldlist = NULL, int nkey = 0);
// @DES add relation // @DES add relation
// @FPUB // @FPUB
bool add(int logicnum, const char* relexprs, int key = 1, bool add(int logicnum, const char* relexprs, int key = 1,
int linkto = 0, byte alias = 0, bool allow_lock = FALSE); int linkto = 0, byte alias = 0, bool allow_lock = FALSE);
bool add(const char* tabname, const char* relexprs, int key = 1, bool add(const char* tabname, const char* relexprs, int key = 1,
int linkto = 0, byte alias = 0, bool allow_lock = FALSE); int linkto = 0, byte alias = 0, bool allow_lock = FALSE);
// @DES write methods // @DES write methods
// @FPUB // @FPUB
virtual int write (bool force = TRUE, TDate& atdate = botime); virtual int write (bool force = TRUE, TDate& atdate = botime);
virtual int rewrite(bool force = TRUE, TDate& atdate = botime); virtual int rewrite(bool force = TRUE, TDate& atdate = botime);
virtual int remove (TDate& atdate = botime); virtual int remove (TDate& atdate = botime);
// @DES checking methods // @DES checking methods
// @FPUB // @FPUB
bool eof( int logicnum = 0) { return lfile(logicnum)->eof(); } bool eof( int logicnum = 0) { return lfile(logicnum)->eof(); }
bool bof( int logicnum = 0) { return lfile(logicnum)->bof(); } bool bof( int logicnum = 0) { return lfile(logicnum)->bof(); }
// @N // @N
// status(), good() and bad() return the status of the relation when called // status(), good() and bad() return the status of the relation when called
// with no args, or the status of the file when called with // with no args, or the status of the file when called with
// a logical number // a logical number
// @END // @END
bool status(int logicnum = 0) { return lfile(logicnum)->status(); } bool status(int logicnum = 0) { return lfile(logicnum)->status(); }
bool good( int logicnum = 0) { return lfile(logicnum)->good(); } bool good( int logicnum = 0) { return lfile(logicnum)->good(); }
bool bad( int logicnum = 0) { return lfile(logicnum)->bad(); } bool bad( int logicnum = 0) { return lfile(logicnum)->bad(); }
bool empty( int logicnum = 0) { return lfile(logicnum)->empty(); } bool empty( int logicnum = 0) { return lfile(logicnum)->empty(); }
// @END // @END
// @LONGDES // @LONGDES
// isconsistent() returns TRUE if every file in the relation is // isconsistent() returns TRUE if every file in the relation is
// OK, current record is non-empty, and relation is consistent. // OK, current record is non-empty, and relation is consistent.
// If it's not and reset is TRUE, it tries to reset the relation // If it's not and reset is TRUE, it tries to reset the relation
// to a consistent state (based on main record) -- no further check // to a consistent state (based on main record) -- no further check
// is done. // is done.
// Also called internally by update and remove. // Also called internally by update and remove.
// @END // @END
bool isconsistent(bool reset = FALSE); bool isconsistent(bool reset = FALSE);
// TRUE se c'e' un record ed e' il primo match (non si e' mai fatta // TRUE se c'e' un record ed e' il primo match (non si e' mai fatta
// position_rels) // position_rels)
bool is_first_match(int logicnum); bool is_first_match(int logicnum);
void save_status () ; void save_status () ;
void restore_status () ; void restore_status () ;
// @DES positioning operators. return status // @DES positioning operators. return status
// @FPUB // @FPUB
TRecnotype operator +=(const TRecnotype npos) { return skip(npos); } TRecnotype operator +=(const TRecnotype npos) { return skip(npos); }
TRecnotype operator -=(const TRecnotype npos) { return skip(-npos); } TRecnotype operator -=(const TRecnotype npos) { return skip(-npos); }
TRecnotype operator ++() { return next(); } TRecnotype operator ++() { return next(); }
TRecnotype operator --() { return prev(); } TRecnotype operator --() { return prev(); }
TRelation(int logicnum, bool linkrecinst = TRUE); TRelation(int logicnum, bool linkrecinst = TRUE);
TRelation(const char* tabname, bool linkrecinst = TRUE); TRelation(const char* tabname, bool linkrecinst = TRUE);
virtual ~TRelation(); virtual ~TRelation();
}; };
// @C // @C
@ -150,81 +150,83 @@ typedef bool (*FILTERFUNCTION)(const TRelation* r);
class TCursor : public TObject class TCursor : public TObject
{ {
// @DPRIV // @DPRIV
TRelation* _if; TRelation* _if;
int _nkey; int _nkey;
TRecnotype _pos; // Posizione corrente TRecnotype _pos; // Posizione corrente
TRecnotype _totrec; TRecnotype _totrec;
TRecnotype _lastrec; TRecnotype _lastrec;
TRecnotype _lastkrec; TRecnotype _lastkrec;
TFilename _filename; TFilename _filename;
TString _filter; // Filtro TString _filter; // Filtro
TString _keyfrom; // chiave iniziale TString _keyfrom; // chiave iniziale
TString _keyto; // chiave finale TString _keyto; // chiave finale
TExpression* _fexpr; // Espressione relativo filtro TExpression* _fexpr; // Espressione relativo filtro
bool _frozen; bool _frozen;
FILTERFUNCTION _filterfunction; FILTERFUNCTION _filterfunction;
TFilename _indexname; TFilename _indexname;
// @END // @END
// @FPRIV // @FPRIV
virtual TRecnotype buildcursor(TRecnotype rp); virtual TRecnotype buildcursor(TRecnotype rp);
int filtercursor(int pagecnt, TRecnotype* page); int filtercursor(int pagecnt, TRecnotype* page);
bool changed(); bool changed();
FILE* open_index(bool create = FALSE) const; FILE* open_index(bool create = FALSE) const;
TRecnotype update(); TRecnotype update();
protected: protected:
TRecnotype readrec(); TRecnotype readrec();
void filter(const char* filter, const TRectype* from = NULL,
const TRectype* to = NULL);
public: public:
// @FPUB // @FPUB
TRecnotype operator =(const TRecnotype nr); // Assegnazione TRecnotype operator =(const TRecnotype nr); // Assegnazione
TCursor& operator +=(const TRecnotype nr); // Scorri avanti TCursor& operator +=(const TRecnotype nr); // Scorri avanti
TCursor& operator -=(const TRecnotype nr); // Scorri indietro TCursor& operator -=(const TRecnotype nr); // Scorri indietro
TCursor& operator ++(); // Avanti di un record TCursor& operator ++(); // Avanti di un record
TCursor& operator --(); // Indietro di un record TCursor& operator --(); // Indietro di un record
TRecnotype pos() const { return _pos; } TRecnotype pos() const { return _pos; }
TRecnotype items(); TRecnotype items();
TRecnotype size() const { return file()->eod(); } TRecnotype size() const { return file()->eod(); }
const TString& from() const { return _keyfrom; } const TString& from() const { return _keyfrom; }
const TString& to() const { return _keyto; } const TString& to() const { return _keyto; }
TRectype& curr(int log = 0) const { return _if->curr(log); } TRectype& curr(int log = 0) const { return _if->curr(log); }
TRectype& curr(const char * tab) const TRectype& curr(const char * tab) const
{ return _if->lfile(tab)->curr(); } { return _if->lfile(tab)->curr(); }
TRecnotype read(TIsamop op = _isgteq, TReclock lockop = _nolock, TDate& atdate = botime); TRecnotype read(TIsamop op = _isgteq, TReclock lockop = _nolock, TDate& atdate = botime);
virtual bool ok() const; virtual bool ok() const;
void filter(const char* filter, TRectype* from = NULL, TRectype* to = NULL); const char* filter() const { return _filter; }
const char* filter() const { return _filter; } void freeze(bool on = TRUE) { _frozen = on; }
void freeze(bool on = TRUE) { _frozen = on; } bool frozen() const { return _frozen; }
bool frozen() const { return _frozen; } void setfilter(const char* filter_expr) { filter(filter_expr); }
void setregion(TRectype* from = NULL, TRectype* to = NULL) void setregion(const TRectype& from, const TRectype& to)
{ filter(NULL,from,to); } { filter(NULL,&from, &to); }
TRelation* relation() const { return _if; } TRelation* relation() const { return _if; }
TLocalisamfile* file(int lnum = 0) const { return _if->lfile(lnum); } TLocalisamfile* file(int lnum = 0) const { return _if->lfile(lnum); }
TLocalisamfile* file(const char* name) const { return _if->lfile(name); } TLocalisamfile* file(const char* name) const { return _if->lfile(name); }
int repos() { return _if->position_rels(); } int repos() { return _if->position_rels(); }
void setkey() { file()->setkey(_nkey); } void setkey() { file()->setkey(_nkey); }
void setkey(int nkey); void setkey(int nkey);
int key() const { return _nkey; } int key() const { return _nkey; }
bool next_match(int lognum, const char* fl = NULL, int nk = 0); bool next_match(int lognum, const char* fl = NULL, int nk = 0);
bool is_first_match(int ln); bool is_first_match(int ln);
void set_filterfunction(FILTERFUNCTION ff) { _filterfunction = ff; _lastrec = 0L;} void set_filterfunction(FILTERFUNCTION ff) { _filterfunction = ff; _lastrec = 0L;}
bool has_filter() const { return _filter.not_empty() || _filterfunction; } bool has_filter() const { return _filter.not_empty() || _filterfunction; }
void save_status () { _if->save_status(); } void save_status () { _if->save_status(); }
void restore_status () { _if->restore_status(); } void restore_status () { _if->restore_status(); }
TCursor(TRelation* f, const char* filter = "", int key = 1, TRectype* from = NULL, TRectype* to = NULL); TCursor(TRelation* f, const char* filter = "", int key = 1, TRectype* from = NULL, TRectype* to = NULL);
virtual ~TCursor(); virtual ~TCursor();
}; };
@ -234,33 +236,33 @@ class TCursor : public TObject
class TFieldref : public TObject class TFieldref : public TObject
{ {
// @DPRIV // @DPRIV
short _fileid; // Numero del file short _fileid; // Numero del file
TString16 _id; // Nome tabella o stringa col numero del file TString16 _id; // Nome tabella o stringa col numero del file
TString16 _name; // Nome del campo TString16 _name; // Nome del campo
int _from, _to; // Substring int _from, _to; // Substring
protected: protected:
virtual void print_on(ostream& out) const; virtual void print_on(ostream& out) const;
public: public:
// @FPUB // @FPUB
TFieldref(); TFieldref();
TFieldref(const TString&, short defid); TFieldref(const TString&, short defid);
TFieldref& operator =(const TString& s); // Operatore di assegnazione TFieldref& operator =(const TString& s); // Operatore di assegnazione
virtual bool ok() const { return _name.not_empty(); } // Vero se il numero del file e' valido virtual bool ok() const { return _name.not_empty(); } // Vero se il numero del file e' valido
int file() const { return _fileid; } // ritorna il file int file() const { return _fileid; } // ritorna il file
const char* name() const { return (const char*) _name; } // ritorna il nome del campo const char* name() const { return (const char*) _name; } // ritorna il nome del campo
int from() const { return _from; } int from() const { return _from; }
int to() const { return _to; } int to() const { return _to; }
int len(TRectype &rec) const; int len(TRectype &rec) const;
const char* read(const TRelation* = NULL) const; const char* read(const TRelation* = NULL) const;
const char* read(const TRectype&) const; const char* read(const TRectype&) const;
void write(const char* val, TRelation* = NULL) const; void write(const char* val, TRelation* = NULL) const;
void write(const char* val, TRectype& rec) const; void write(const char* val, TRectype& rec) const;
}; };
// Converte una stringa in numero logico o numero tabella // Converte una stringa in numero logico o numero tabella
int name2log(const char* name); int name2log(const char* name);