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

View File

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

View File

@ -309,7 +309,7 @@ STRING FLD_GD1_COMAA_COMUNI_DESCR 50
BEGIN
PROMPT 8 12 ": Nome "
USE LF_COMUNI KEY 2 SELECT STATO=""
INPUT COM FLD_GD1_COMAA_COMUNI_DESCR
INPUT DENCOM FLD_GD1_COMAA_COMUNI_DESCR
#include <comdden.h>
OUTPUT FLD_GD1_COMAA COM
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_COM ,codicefine);
current_cursor()->setregion(&da, &a);
current_cursor()->setregion(da, a);
}
else
if (scelta == 2)
@ -207,7 +207,7 @@ bool BA6200_application::set_print(int)
a.put (COM_DENCOM, denomfine);
current_cursor()->setregion(&da, &a);
current_cursor()->setregion(da, a);
}
//set_print_zero();
@ -257,7 +257,7 @@ void BA6200_application::user_create()
_comuni = new TLocalisamfile (LF_COMUNI);
_descr_comune = new TParagraph_string ("",25);
_descr_comune = new TParagraph_string ("",25);
_msk = new TMask("ba6200a");
}

View File

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

View File

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

View File

@ -718,7 +718,7 @@ bool TSpreadsheet::on_key(KEY k)
{
switch(k)
{
case K_SHIFT_ENTER:
case K_CTRL_ENTER:
case K_ESC:
mask().send_key(k, 0);
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 <sheet.h>
#include <urldefid.h>
@ -829,7 +829,8 @@ bool TRelation_application::filter()
if (campo != NULL)
campo->write(t.mid(u+1), rec);
}
cur->filter("", &rec, &rec);
cur->setfilter("");
cur->setregion(rec, rec);
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
// fv 12/8/93
// 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");

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