Corrette le create delle TApplication

Corretta ricerca saldi da visualizzare


git-svn-id: svn://10.65.10.50/trunk@737 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-12-07 11:08:53 +00:00
parent 034dfd861c
commit 2dc933c084
16 changed files with 368 additions and 490 deletions

View File

@ -36,6 +36,7 @@ public:
bool TStampa_deleghe_IVA::create() bool TStampa_deleghe_IVA::create()
{ {
TApplication::create();
CHECK(_ditte == NULL, "Eh la vaca!"); CHECK(_ditte == NULL, "Eh la vaca!");
_ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Deleghe da stampare" ,"@1|Cod.@5|Ragione Sociale@50|Importo@15|Azienda|Dipend."); _ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Deleghe da stampare" ,"@1|Cod.@5|Ragione Sociale@50|Importo@15|Azienda|Dipend.");
dispatch_e_menu(BAR_ITEM(1)); dispatch_e_menu(BAR_ITEM(1));
@ -45,7 +46,7 @@ bool TStampa_deleghe_IVA::create()
bool TStampa_deleghe_IVA::destroy() bool TStampa_deleghe_IVA::destroy()
{ {
delete _ditte; delete _ditte;
return TRUE; return TApplication::destroy();
} }

View File

@ -36,6 +36,7 @@ public:
bool TStampa_deleghe_IVA::create() bool TStampa_deleghe_IVA::create()
{ {
TApplication::create();
CHECK(_ditte == NULL, "Eh la vaca!"); CHECK(_ditte == NULL, "Eh la vaca!");
_ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Deleghe da stampare" ,"@1|Cod.@5|Ragione Sociale@50|Importo@15|Azienda|Dipend."); _ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Deleghe da stampare" ,"@1|Cod.@5|Ragione Sociale@50|Importo@15|Azienda|Dipend.");
dispatch_e_menu(BAR_ITEM(1)); dispatch_e_menu(BAR_ITEM(1));
@ -45,7 +46,7 @@ bool TStampa_deleghe_IVA::create()
bool TStampa_deleghe_IVA::destroy() bool TStampa_deleghe_IVA::destroy()
{ {
delete _ditte; delete _ditte;
return TRUE; return TApplication::destroy();
} }

View File

@ -13,7 +13,7 @@
#include <rcausali.h> #include <rcausali.h>
TPrimanota_application::TPrimanota_application() TPrimanota_application::TPrimanota_application()
: _rel(NULL), _lastreg(0), _mode(0), _iva(nessuna_iva) : _rel(NULL), _lastreg(0), _mode(0), _iva(nessuna_iva), _causale(NULL), _giornale(NULL)
{ {
memset(_msk, 0, sizeof(_msk)); memset(_msk, 0, sizeof(_msk));
} }
@ -137,8 +137,10 @@ bool TPrimanota_application::user_create()
_rel = new TMovimentoPN; _rel = new TMovimentoPN;
_rel->add(LF_PARTITE, "NREG=NUMREG", 2); _rel->add(LF_PARTITE, "NREG=NUMREG", 2);
set_search_field(F_NUMREG); // Set field for default search _causale = new TCausale();
_giornale = new TLibro_giornale();
set_search_field(F_NUMREG); // Set field for default search
load_mask(0); load_mask(0);
return TRUE; return TRUE;
@ -153,7 +155,9 @@ bool TPrimanota_application::user_destroy()
{ {
for (int m = 3; m >= 0; m--) for (int m = 3; m >= 0; m--)
if (_msk[m] != NULL) delete _msk[m]; if (_msk[m] != NULL) delete _msk[m];
delete _giornale;
delete _causale;
delete _rel; delete _rel;
delete _nditte; delete _nditte;
delete _occas; delete _occas;
@ -177,17 +181,17 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
bool ok = TRUE; bool ok = TRUE;
if (cod != NULL) if (cod != NULL)
ok = _causale.read(cod, year); ok = causale().read(cod, year);
bool nob = FALSE, dob = FALSE, sal = FALSE; bool nob = FALSE, dob = FALSE, sal = FALSE;
TipoIVA iva = nessuna_iva; TipoIVA iva = nessuna_iva;
if (ok) if (ok)
{ {
sal = gestione_saldaconto() && _causale.saldaconto(); sal = gestione_saldaconto() && causale().saldaconto();
dob = sal | _causale.data_doc(); dob = sal | causale().data_doc();
nob = sal | _causale.num_doc(); nob = sal | causale().num_doc();
iva = _causale.iva(); iva = causale().iva();
} }
TMask* m = _msk[iva == nessuna_iva ? 1 : 2]; TMask* m = _msk[iva == nessuna_iva ? 1 : 2];
@ -201,7 +205,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
if (iva != nessuna_iva) if (iva != nessuna_iva)
{ {
m->efield(F_CODPAG).check_type(sal ? CHECK_REQUIRED : CHECK_NORMAL);// Cod. pag. obbligatorio m->efield(F_CODPAG).check_type(sal ? CHECK_REQUIRED : CHECK_NORMAL);// Cod. pag. obbligatorio
const bool av = _causale.reg().agenzia_viaggi(); const bool av = causale().reg().agenzia_viaggi();
m->show(F_DATA74TER, av); m->show(F_DATA74TER, av);
if (!av) m->reset(F_DATA74TER); if (!av) m->reset(F_DATA74TER);
@ -212,7 +216,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
if (ins) if (ins)
{ {
const long protiva = _causale.reg().protocol() + 1; const long protiva = causale().reg().protocol() + 1;
m->set(F_PROTIVA, protiva); // Aggiorna protocollo IVA m->set(F_PROTIVA, protiva); // Aggiorna protocollo IVA
} }
} }
@ -220,18 +224,18 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
if (ins && !ci_sono_importi()) if (ins && !ci_sono_importi())
{ {
cgs().reset(); cgs().reset();
for (int i = 1; i < _causale.size(); i++) for (int i = 1; i < causale().size(); i++)
{ {
const TRectype* rcaus = (TRectype*)_causale.objptr(i); const TRectype* rcaus = (TRectype*)causale().objptr(i);
if (rcaus == NULL) continue; // Evita eventuali righe nulle if (rcaus == NULL) continue; // Evita eventuali righe nulle
const int nriga = rcaus->get_int(RCA_NRIGA); const int nriga = rcaus->get_int(RCA_NRIGA);
if (nriga < 1) continue; // Considera solo righe reali (non riempimenti) if (nriga < 1) continue; // Considera solo righe reali (non riempimenti)
TBill tc; _causale.bill(nriga, tc); TBill tc; causale().bill(nriga, tc);
if (tc.gruppo() < 1) continue; // Considera solo gruppi validi if (tc.gruppo() < 1) continue; // Considera solo gruppi validi
if (tc.tipo() > ' ' && tc.sottoconto() != 0) if (tc.tipo() > ' ' && tc.ok())
{ {
TBill clifo(0, 0, tc.sottoconto(), tc.tipo()); TBill clifo(0, 0, tc.sottoconto(), tc.tipo());
clifo.descrizione(); clifo.descrizione();
@ -241,7 +245,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
const char sezione = rcaus->get_char(RCA_SEZIONE); const char sezione = rcaus->get_char(RCA_SEZIONE);
const TImporto zero('D', ZERO); const TImporto zero('D', ZERO);
const TString80 desc(_causale.desc_agg(i)); const TString80 desc(causale().desc_agg(i));
if (nriga == 1) m->set(F_DESCR, desc); if (nriga == 1) m->set(F_DESCR, desc);
@ -257,7 +261,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
continue; // Conti per IVA detraibile e non, ritenute sociali e fiscali continue; // Conti per IVA detraibile e non, ritenute sociali e fiscali
const char tipo = nriga == 1 ? 'T' : ' '; const char tipo = nriga == 1 ? 'T' : ' ';
if (nriga == 1 && tc.tipo() > ' ' && tc.sottoconto() != 0) if (nriga == 1 && tc.tipo() > ' ' && tc.ok())
m->set(tc.tipo() == 'C' ? F_CLIENTE : F_FORNITORE, tc.sottoconto()); m->set(tc.tipo() == 'C' ? F_CLIENTE : F_FORNITORE, tc.sottoconto());
set_cgs_row(-1,zero,tc,desc,tipo); set_cgs_row(-1,zero,tc,desc,tipo);
} }
@ -320,9 +324,12 @@ TMask* TPrimanota_application::get_mask(int mode)
default: default:
return load_mask(0); return load_mask(0);
} }
giornale().read(annoes); if (giornale().year() != annoes)
causale().read(caus, annoiva); giornale().read(annoes);
if (caus != causale().codice() || causale().reg().year() != annoiva)
causale().read(caus, annoiva);
_iva = causale().iva(); _iva = causale().iva();
return load_mask(_iva == nessuna_iva ? 1 : 2); return load_mask(_iva == nessuna_iva ? 1 : 2);
@ -350,8 +357,8 @@ void TPrimanota_application::init_mask(TMask& m)
read_caus(NULL, 0); // Setta campi obbligatori read_caus(NULL, 0); // Setta campi obbligatori
fill_sheet(m); fill_sheet(m);
const bool valintra = _causale.valintra(); const bool valintra = causale().valintra();
const bool corrisp = _causale.corrispettivi(); const bool corrisp = causale().corrispettivi();
if (_iva != nessuna_iva) if (_iva != nessuna_iva)
{ {
@ -377,13 +384,8 @@ void TPrimanota_application::init_mask(TMask& m)
} }
// Show/Hide campi valuta: F_VALUTA, F_CAMBIO, F_VISVAL (GROUP 3) // Show/Hide campi valuta: F_VALUTA, F_CAMBIO, F_VISVAL (GROUP 3)
const bool valuta = _ges_val && _causale.valuta(); const bool valuta = _ges_val && causale().valuta();
m.show(-3, valuta); m.show(-3, valuta);
if (valuta)
{
const bool ok = m.get(F_VALUTA).not_empty();
m.field(F_VISVAL).set(ok ? "X" : " ");
}
} }
void TPrimanota_application::init_query_mode(TMask& m) void TPrimanota_application::init_query_mode(TMask& m)
@ -442,7 +444,7 @@ void TPrimanota_application::init_insert_mode(TMask& m)
init_mask(m); init_mask(m);
_saldi.reset(); // Inizializza saldi _saldi.reset(); // Inizializza saldi
_saldi.set_movprovv(_rel->lfile().get_char("PROVVIS") > ' ' ? TRUE : FALSE); _saldi.set_movprovv(_rel->lfile().get_char("PROVVIS") > ' ' ? TRUE : FALSE);
_saldi.set_movap(_causale.apertura()); _saldi.set_movap(causale().apertura());
_saldi.set_anno_es(m.get_int(F_ANNOES)); _saldi.set_anno_es(m.get_int(F_ANNOES));
_saldi.set_num_ulmov(m.get_long(F_NUMREG)); _saldi.set_num_ulmov(m.get_long(F_NUMREG));
_saldi.set_data_ulmov((TDate)m.get(F_DATAREG)); _saldi.set_data_ulmov((TDate)m.get(F_DATAREG));
@ -517,7 +519,7 @@ int TPrimanota_application::read(TMask& m)
_saldi.reset(); // Azzera saldi _saldi.reset(); // Azzera saldi
_saldi.set_movprovv(_rel->lfile().get_bool("PROVVIS")); _saldi.set_movprovv(_rel->lfile().get_bool("PROVVIS"));
_saldi.set_movap(_causale.apertura()); _saldi.set_movap(causale().apertura());
_saldi.set_anno_es(m.get_int(F_ANNOES)); _saldi.set_anno_es(m.get_int(F_ANNOES));
_saldi.set_num_ulmov(m.get_long(F_NUMREG)); _saldi.set_num_ulmov(m.get_long(F_NUMREG));
_saldi.set_data_ulmov((TDate)m.get(F_DATAREG)); _saldi.set_data_ulmov((TDate)m.get(F_DATAREG));
@ -612,7 +614,7 @@ void TPrimanota_application::mask2rel(const TMask& m)
const int annoes = m.get_int(F_ANNOES); const int annoes = m.get_int(F_ANNOES);
_saldi.set_movprovv(m.get_bool(F_PROVVISORIO)); _saldi.set_movprovv(m.get_bool(F_PROVVISORIO));
_saldi.set_movap(_causale.apertura()); _saldi.set_movap(causale().apertura());
_saldi.set_anno_es(annoes); _saldi.set_anno_es(annoes);
_rel->destroy_rows(); // Destroy all records _rel->destroy_rows(); // Destroy all records
@ -765,7 +767,7 @@ int TPrimanota_application::rewrite(const TMask& m)
const int err = _rel->rewrite(TRUE); const int err = _rel->rewrite(TRUE);
if (err == NOERR) if (err == NOERR)
_saldi.registra(); _saldi.registra();
if (gestione_saldaconto() && _causale.saldaconto()) if (gestione_saldaconto() && causale().saldaconto())
aggiorna_scadenzario(m); aggiorna_scadenzario(m);
return err; return err;
} }

View File

@ -124,7 +124,6 @@ int TMovimentoPN::cancella(TLocalisamfile& f, int da, int a)
const long numreg = lfile().get_long(MOV_NUMREG); const long numreg = lfile().get_long(MOV_NUMREG);
for (int i = da; i <= a; i++) for (int i = da; i <= a; i++)
{ {
f.zero();
f.put(MOV_NUMREG, numreg); f.put(MOV_NUMREG, numreg);
f.put(RMV_NUMRIG, i); f.put(RMV_NUMRIG, i);
if (f.read(_isequal, _lock) == NOERR) if (f.read(_isequal, _lock) == NOERR)
@ -143,10 +142,12 @@ char TMovimentoPN::frequenza_versamenti(int year) const
TString16 key; TString16 key;
key << year; key << year;
TTable lia("LIA"); TTable lia("LIA");
lia.setkey(1);
lia.put("CODTAB", key); lia.put("CODTAB", key);
if (lia.read() != NOERR) if (lia.read() != NOERR)
{ {
TLocalisamfile nditte(LF_NDITTE); TLocalisamfile nditte(LF_NDITTE);
nditte.setkey(1);
nditte.put("CODDITTA", main_app().get_firm()); nditte.put("CODDITTA", main_app().get_firm());
nditte.read(); nditte.read();
last_freq = nditte.get_char("FREQVIVA"); last_freq = nditte.get_char("FREQVIVA");
@ -177,9 +178,10 @@ bool TMovimentoPN::controlla_liquidazione(const TDate& data, bool reset) const
const int mese = date2liq(data); const int mese = date2liq(data);
// Chiave di LIM: Anno (1-4), Mese (5-6) // Chiave di LIM: Anno (1-4), Mese (5-6)
TTable lim("LIM");
TString16 key; TString16 key;
key << anno << mese; key << anno << mese;
TTable lim("LIM");
lim.setkey(1);
lim.put("CODTAB", key); lim.put("CODTAB", key);
if (lim.read() == NOERR) if (lim.read() == NOERR)
calcolata = lim.get_bool("B1"); // Controlla se calcolata in definitivo calcolata = lim.get_bool("B1"); // Controlla se calcolata in definitivo
@ -268,6 +270,7 @@ int TMovimentoPN::registra(bool re, bool force)
const int att = att_mista ? 2 : 1; const int att = att_mista ? 2 : 1;
// Chiave di PLM: Anno (1-4), Cod. Att. (5-9), Tipo att. (10-10), Mese (11-12) // Chiave di PLM: Anno (1-4), Cod. Att. (5-9), Tipo att. (10-10), Mese (11-12)
TTable plm("PLM"); TTable plm("PLM");
plm.setkey(1);
for (int a = 1; a <= att; a++) for (int a = 1; a <= att; a++)
{ {
TString16 chiave; TString16 chiave;

View File

@ -1356,7 +1356,7 @@ void TPrimanota_application::add_cgs_tot(TMask& m)
if (conto == 0 || causale().corrispettivi()) if (conto == 0 || causale().corrispettivi())
{ {
// Se l'utente non ha ancora specificato un conto lo prendo dalla prima riga della causale // Se l'utente non ha ancora specificato un conto lo prendo dalla prima riga della causale
TBill bill; _causale.bill(1, bill); TBill bill; causale().bill(1, bill);
gruppo = bill.gruppo(); gruppo = bill.gruppo();
conto = bill.conto(); conto = bill.conto();
if (causale().corrispettivi()) if (causale().corrispettivi())
@ -1528,8 +1528,8 @@ void TPrimanota_application::add_cgs_rit(bool fiscali)
if (pos < 0) if (pos < 0)
{ {
const int riga = fiscali ? 8 : 9; const int riga = fiscali ? 8 : 9;
TBill conto; _causale.bill(riga, conto); TBill conto; causale().bill(riga, conto);
const TString80 desc(_causale.desc_agg(riga)); const TString80 desc(causale().desc_agg(riga));
set_cgs_row(-1, real2imp(imp, tipo), conto, desc, tipo); set_cgs_row(-1, real2imp(imp, tipo), conto, desc, tipo);
} }
else else

View File

@ -36,8 +36,8 @@ class TPrimanota_application : public TRelation_application
TLocalisamfile* _occas; TLocalisamfile* _occas;
TLocalisamfile* _nditte; TLocalisamfile* _nditte;
TCausale _causale; // Causale corrente TCausale* _causale; // Causale corrente
TLibro_giornale _giornale; // Libro giornale corrente TLibro_giornale* _giornale; // Libro giornale corrente
TipoIVA _iva; // Tipo di IVA corrente TipoIVA _iva; // Tipo di IVA corrente
bool _ges_val, _ges_sal; // Gestione valuta e saldaconto bool _ges_val, _ges_sal; // Gestione valuta e saldaconto
bool _savenew; // Registra e nuovo bool _savenew; // Registra e nuovo
@ -146,8 +146,8 @@ protected:
TBill& ivas_bill(TBill& tc); TBill& ivas_bill(TBill& tc);
bool read_caus(const char* cod, int year); bool read_caus(const char* cod, int year);
TCausale& causale() { return _causale; } TCausale& causale() { return *_causale; }
TLibro_giornale& giornale() { return _giornale; } TLibro_giornale& giornale() { return *_giornale; }
bool test_swap(bool ritsoc); bool test_swap(bool ritsoc);
TImporto real2imp(const real& r, char tipo); TImporto real2imp(const real& r, char tipo);

View File

@ -55,8 +55,7 @@ bool TRegistro::read(const char* cod, int year)
} }
_rec = reg.curr(); _rec = reg.curr();
if (_att.ok()) _att.zero();
_att.zero();
if (err != NOERR) if (err != NOERR)
_rec.zero(); _rec.zero();
@ -76,22 +75,15 @@ bool TRegistro::reread()
int TRegistro::year() const int TRegistro::year() const
{ {
int anno = 0; TString16 anno(_rec.get("CODTAB"));
if (ok()) anno.cut(4);
{ return atoi(anno);
TString16 sanno(_rec.get("CODTAB")); sanno.cut(4);
anno = atoi(sanno);
}
return anno;
} }
static TString16 n;
const TString& TRegistro::name() const const TString& TRegistro::name() const
{ {
if (ok()) n = _rec.get("CODTAB").mid(4); return _rec.get("CODTAB").mid(4);
else n = "";
return n;
} }
@ -106,14 +98,14 @@ TRegistro& TRegistro::operator =(const TRegistro& r)
int TRegistro::tipo() const int TRegistro::tipo() const
{ {
const int t = ok() ? _rec.get_int("I0") : 0; const int t = _rec.get_int("I0");
return t; return t;
} }
bool TRegistro::corrispettivi() const bool TRegistro::corrispettivi() const
{ {
const bool c = ok() ? _rec.get_bool("B0") : FALSE; const bool c = _rec.get_bool("B0");
return c; return c;
} }
@ -355,41 +347,41 @@ const char* TCausale::desc_agg(int num) const
} }
const char* TCausale::descrizione() const const char* TCausale::descrizione() const
{ return _rec.ok() ? _rec.get(CAU_DESCR) : ""; } { return _rec.get(CAU_DESCR); }
const char* TCausale::codice() const const char* TCausale::codice() const
{ return _rec.ok() ? _rec.get(CAU_CODCAUS) : ""; } { return _rec.get(CAU_CODCAUS); }
bool TCausale::data_doc() const bool TCausale::data_doc() const
{ return _rec.ok() ? _rec.get_bool("DATADOC") : FALSE; } { return _rec.get_bool("DATADOC"); }
bool TCausale::num_doc() const bool TCausale::num_doc() const
{ return _rec.ok() ? _rec.get_bool("NUMDOC") : FALSE; } { return _rec.get_bool("NUMDOC"); }
bool TCausale::apertura() const bool TCausale::apertura() const
{ return _rec.ok() ? _rec.get_char("MOVAP") == 'A' : FALSE; } { return _rec.get_char("MOVAP") == 'A'; }
bool TCausale::sezionale() const bool TCausale::sezionale() const
{ return _rec.ok() ? _rec.get_bool("MOVSEZ") : FALSE; } { return _rec.get_bool("MOVSEZ"); }
bool TCausale::valuta() const bool TCausale::valuta() const
{ return _rec.ok() ? _rec.get_bool("MOVVAL") : FALSE; } { return _rec.get_bool("MOVVAL"); }
bool TCausale::intra() const bool TCausale::intra() const
{ return _rec.ok() ? _rec.get_bool("INTRACOM") : FALSE; } { return _rec.get_bool("INTRACOM"); }
bool TCausale::valintra() const bool TCausale::valintra() const
{ return _rec.ok() ? _rec.get_bool("VALINTRA") : FALSE; } { return _rec.get_bool("VALINTRA"); }
const char* TCausale::causale_inc_imm() const const char* TCausale::causale_inc_imm() const
{ return _rec.ok() ? _rec.get("CODCAUSIM") : ""; } { return _rec.get("CODCAUSIM"); }
const char* TCausale::tipo_doc() const const char* TCausale::tipo_doc() const
{ return _rec.ok() ? _rec.get("TIPODOC") : ""; } { return _rec.get("TIPODOC"); }
bool TCausale::saldaconto() const bool TCausale::saldaconto() const
{ return _rec.ok() ? (_rec.get_int("TIPOMOV") > 0) : FALSE; } { return _rec.get_int("TIPOMOV") > 0; }
bool TCausale::ok() const bool TCausale::ok() const
{ {

View File

@ -46,13 +46,14 @@ public:
bool TDeleteprovv_app::create() bool TDeleteprovv_app::create()
{ {
TApplication::create();
dispatch_e_menu(BAR_ITEM(1)); dispatch_e_menu(BAR_ITEM(1));
return TRUE; return TRUE;
} }
bool TDeleteprovv_app::destroy() bool TDeleteprovv_app::destroy()
{ {
return TRUE; return TApplication::destroy();
} }
bool TDeleteprovv_app::menu(MENU_TAG) bool TDeleteprovv_app::menu(MENU_TAG)

View File

@ -6,20 +6,19 @@
// *TBI* Aggiornamento cespiti // *TBI* Aggiornamento cespiti
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
#include <applicat.h>
#include <isam.h>
#include <sort.h>
#include <lffiles.h>
#include <urldefid.h>
#include <stdlib.h> #include <stdlib.h>
#include <utility.h>
#include <mask.h>
#include <progind.h>
//#if XVT_OS == XVT_OS_SCOUNIX //#if XVT_OS == XVT_OS_SCOUNIX
#include <signal.h> #include <signal.h>
//#endif //#endif
#include <applicat.h>
#include <isam.h>
#include <mask.h>
#include <progind.h>
#include <sort.h>
#include <urldefid.h>
#include <utility.h>
#define FLD_CG41_YEAR 100 #define FLD_CG41_YEAR 100
#define MAX_CNT 300 #define MAX_CNT 300
@ -28,14 +27,8 @@
#include <rmoviva.h> #include <rmoviva.h>
#include <saldi.h> #include <saldi.h>
#include <causali.h> #include <causali.h>
#include "cglib.h"
// for access() #include "cglib.h"
#if XVT_OS == XVT_OS_DOS || XVT_OS == XVT_OS_WIN
#include <io.h>
#else
#include <unistd.h>
#endif
struct therec { struct therec {
char DATAREG[9]; char DATAREG[9];

View File

@ -1,15 +1,15 @@
#include <applicat.h> #include <applicat.h>
#include <assoc.h>
#include <isam.h> #include <isam.h>
#include <mask.h> #include <mask.h>
#include <pconti.h>
#include <assoc.h>
#include <urldefid.h>
#include <prefix.h> #include <prefix.h>
#include <urldefid.h>
#include "cg4.h" #include "cg4.h"
#include "cg4200.h" #include "cg4200.h"
#include <pconti.h>
class TCopia_archivi : public TApplication class TCopia_archivi : public TApplication
{ {
TMask* _msk; TMask* _msk;
@ -141,6 +141,7 @@ void TCopia_archivi::copyivd(long from, long to)
bool TCopia_archivi::create() bool TCopia_archivi::create()
{ {
TApplication::create();
_msk = new TMask("cg4200a") ; _msk = new TMask("cg4200a") ;
_default_firm = get_firm(); _default_firm = get_firm();
dispatch_e_menu(BAR_ITEM(1)); dispatch_e_menu(BAR_ITEM(1));
@ -150,7 +151,7 @@ bool TCopia_archivi::create()
bool TCopia_archivi::destroy() bool TCopia_archivi::destroy()
{ {
if (_msk != NULL) delete _msk; if (_msk != NULL) delete _msk;
return TRUE; return TApplication::destroy();
} }
bool TCopia_archivi::menu(MENU_TAG) bool TCopia_archivi::menu(MENU_TAG)

View File

@ -22,7 +22,7 @@ int main(int argc,char** argv)
case 4: case 4:
cg5400(argc,argv) ; break; cg5400(argc,argv) ; break;
case 5: case 5:
cg5500(argc,argv) ; break; // cg5500(argc,argv) ; break;
default: default:
error_box(usage, argv[0]) ; error_box(usage, argv[0]) ;
} }

View File

@ -1,6 +1,6 @@
extern int cg5000 (int argc, char* argv[]); int cg5000 (int argc, char* argv[]);
extern int cg5100 (int argc, char* argv[]); int cg5100 (int argc, char* argv[]);
extern int cg5200 (int argc, char* argv[]); int cg5200 (int argc, char* argv[]);
extern int cg5300 (int argc, char* argv[]); int cg5300 (int argc, char* argv[]);
extern int cg5400 (int argc, char* argv[]); int cg5400 (int argc, char* argv[]);
extern int cg5500 (int argc, char* argv[]); int cg5500 (int argc, char* argv[]);

View File

@ -1,9 +1,7 @@
// cg5200.cpp - Visualizzazione saldi // cg5200.cpp - Visualizzazione saldi
#include <brwapp.h> #include <brwapp.h>
#include <config.h>
#include <msksheet.h> #include <msksheet.h>
#include <relapp.h>
#include <tabutil.h> #include <tabutil.h>
#include <utility.h> #include <utility.h>
#include <urldefid.h> #include <urldefid.h>
@ -96,7 +94,11 @@ bool TRiga_array::add_riga(const TRectype& rec_saldi)
add(r); add(r);
} }
return found; return found;
} }
///////////////////////////////////////////////////////////
// Visualizzazione saldi
///////////////////////////////////////////////////////////
class TSaldibrowse_application : public TBrowse_application class TSaldibrowse_application : public TBrowse_application
{ {
@ -106,7 +108,7 @@ class TSaldibrowse_application : public TBrowse_application
TCursor * _cur; TCursor * _cur;
TRelation * _rel,* _rel1; TRelation * _rel,* _rel1;
TRiga_array _riga; TRiga_array _riga;
int _items, _anno, _g, _c; int _anno, _g, _c;
long _s; long _s;
bool _saldo_conto, _saldo_gruppo, _saldo_sottoc; bool _saldo_conto, _saldo_gruppo, _saldo_sottoc;
@ -126,9 +128,7 @@ public:
void add_r(int,int,real&,real&,real&,char,real&,real&, void add_r(int,int,real&,real&,real&,char,real&,real&,
real&,real&,TDate&,long,real&,real&,real&); real&,real&,TDate&,long,real&,real&,real&);
void compilasheet(); void compilasheet();
void disable_all();
bool fai_filtro(); bool fai_filtro();
TMask* main_mask() const {return _msk;}
TSheet_field& ss() const { return (TSheet_field&)_msk->field(F_SHEET_SALDI);} TSheet_field& ss() const { return (TSheet_field&)_msk->field(F_SHEET_SALDI);}
TSaldibrowse_application() {} TSaldibrowse_application() {}
@ -153,16 +153,16 @@ bool TSaldibrowse_application::fai_filtro()
char tipo; char tipo;
_saldo_gruppo = _saldo_conto = _saldo_sottoc = FALSE; _saldo_gruppo = _saldo_conto = _saldo_sottoc = FALSE;
TMask* m = app().main_mask(); TMask& m = curr_mask();
tipo = m->get(F_TIPOCF)[0]; tipo = m.get(F_TIPOCF)[0];
_anno = m->get_int(F_ANNO); _anno = m.get_int(F_ANNO);
_g = m->get_int(F_GRUPPO); _g = m.get_int(F_GRUPPO);
_c = m->get_int(F_CONTO); _c = m.get_int(F_CONTO);
if (tipo == '\0') if (tipo == '\0')
_s = m->get_long(F_SOTTOCONTO); _s = m.get_long(F_SOTTOCONTO);
else if (tipo == 'C') else if (tipo == 'C')
_s = m->get_long(F_SOTTOC_CLIENTE); _s = m.get_long(F_SOTTOC_CLIENTE);
else _s = m->get_long(F_SOTTOC_FORN); else _s = m.get_long(F_SOTTOC_FORN);
if (_c == 0) if (_c == 0)
_saldo_gruppo = TRUE; _saldo_gruppo = TRUE;
else if (_s == 0l) else if (_s == 0l)
@ -211,101 +211,64 @@ bool TSaldibrowse_application::fai_filtro()
bool TSaldibrowse_application::sottoc_handler(TMask_field& f, KEY key) bool TSaldibrowse_application::sottoc_handler(TMask_field& f, KEY key)
{ {
if ( key == K_TAB) bool ok = TRUE;
{
const int gruppo = f.mask().get_int(F_GRUPPO);
const int conto = f.mask().get_int(F_CONTO);
if (gruppo == 0 || conto == 0) return TRUE;
const short id = f.dlg(); if (key == K_TAB)
{
TMask& m = f.mask();
int gruppo = m.get_int(F_GRUPPO);
int conto = m.get_int(F_CONTO);
const long sottoconto = atol(f.get()); const long sottoconto = atol(f.get());
const short id = f.dlg();
TLocalisamfile& pconti = app().get_relation()->lfile(); TLocalisamfile& pconti = app().get_relation()->lfile();
/* if (sottoconto > 0)
if (!f.focusdirty() && gruppo == 0 && conto == 0) return TRUE;
if (sottoconto != 0 && conto == 0)
{
f.warning_box("Manca il CONTO");
f.mask().stop_run(K_ESC);
return FALSE;
}
if (conto != 0 && gruppo == 0)
{
f.warning_box("Manca il GRUPPO");
f.mask().stop_run(K_ESC);
return FALSE;
}
*/
if (id == F_SOTTOCONTO)
{ {
if (id == F_SOTTOCONTO)
{
if (gruppo == 0 || conto == 0)
return TRUE;
pconti.setkey(1);
pconti.put(PCN_GRUPPO, gruppo) ;
pconti.put(PCN_CONTO, conto);
pconti.put(PCN_SOTTOCONTO, sottoconto);
ok = pconti.read(_isequal, _nolock) == NOERR;
}
else
{
const char tipo = id == F_SOTTOC_CLIENTE ? 'C' : 'F';
TLocalisamfile clifo (LF_CLIFO);
clifo.setkey(1);
clifo.put(CLI_TIPOCF,tipo);
clifo.put(CLI_CODCF, sottoconto) ;
ok = clifo.read(_isequal, _nolock) == NOERR;
if (ok && (gruppo == 0 || conto == 0))
{
m.set(F_GRUPPO, gruppo = clifo.get_int("GRUPPO"));
m.set(F_CONTO, conto = clifo.get_int("CONTO"));
ok = gruppo != 0 && conto != 0;
}
}
}
else
{
pconti.setkey(1);
pconti.zero(); pconti.zero();
pconti.put(PCN_GRUPPO, gruppo) ; pconti.put(PCN_GRUPPO, gruppo) ;
pconti.put(PCN_CONTO, conto); pconti.put(PCN_CONTO, conto);
pconti.put(PCN_SOTTOCONTO, sottoconto); ok = pconti.read(_isequal, _nolock) == NOERR;
pconti.setkey(1); if (ok)
pconti.read(_isequal, _nolock);
if (pconti.good())
{ {
TString ds = pconti.get(PCN_DESCR); m.set(id, pconti.get(PCN_DESCR));
f.mask().set(F_DESCR_CONTO, ds); m.disable(id);
f.mask().set(F_DESCR_CLIENTE, ds); }
f.mask().set(F_DESCR_FORN, ds); else m.reset(id);
f.mask().stop_run(K_AUTO_ENTER);
}
else return f.warning_box("Registrazione assente");
}
else
{
const char tipo = id == F_SOTTOC_CLIENTE ? 'C' : 'F';
TLocalisamfile clifo (LF_CLIFO);
if (sottoconto != 0)
{
clifo.zero();
clifo.put(CLI_TIPOCF,tipo);
clifo.put(CLI_CODCF, sottoconto) ;
clifo.setkey(1);
if (clifo.read(_isequal, _nolock) == NOERR)
{
TString80 rs = clifo.get(CLI_RAGSOC);
char tipoa = clifo.get_char("TIPOAPER");
if (tipoa == 'F')
{
TString80 cognome, nome;
cognome = rs.mid(0,30);
nome = rs.mid(30,20);
cognome.trim(); nome.trim();
rs = cognome;
rs << " " << nome;
}
f.mask().set(F_DESCR_CLIENTE, rs);
f.mask().set(F_DESCR_FORN, rs);
f.mask().stop_run(K_AUTO_ENTER);
}
else return f.warning_box("Registrazione assente");
}
else
if (gruppo != 0 && conto != 0)
{
pconti.zero();
pconti.put(PCN_GRUPPO, gruppo) ;
pconti.put(PCN_CONTO, conto);
pconti.setkey(1);
pconti.read(_isequal, _nolock);
if (pconti.good())
{
TString ds = pconti.get(PCN_DESCR);
f.mask().set(F_DESCR_CLIENTE, ds);
f.mask().set(F_DESCR_FORN, ds);
f.mask().set(F_DESCR_CONTO, ds);
}
f.mask().stop_run(K_AUTO_ENTER);
}
} }
if (ok) m.stop_run(K_AUTO_ENTER);
} }
return TRUE;
return ok;
} }
bool TSaldibrowse_application::user_create() bool TSaldibrowse_application::user_create()
@ -314,7 +277,7 @@ bool TSaldibrowse_application::user_create()
_msk->set_handler(F_SOTTOCONTO, sottoc_handler); _msk->set_handler(F_SOTTOCONTO, sottoc_handler);
_msk->set_handler(F_SOTTOC_CLIENTE, sottoc_handler); _msk->set_handler(F_SOTTOC_CLIENTE, sottoc_handler);
_msk->set_handler(F_SOTTOC_FORN, sottoc_handler); _msk->set_handler(F_SOTTOC_FORN, sottoc_handler);
disable_all(); ss().disable();
_clifo = new TLocalisamfile(LF_CLIFO); _clifo = new TLocalisamfile(LF_CLIFO);
_rel = new TRelation(LF_PCON); _rel = new TRelation(LF_PCON);
_rel1 = new TRelation(LF_SALDI); _rel1 = new TRelation(LF_SALDI);
@ -324,11 +287,6 @@ bool TSaldibrowse_application::user_create()
return TRUE; return TRUE;
} }
void TSaldibrowse_application::disable_all()
{
ss().disable();
}
bool TSaldibrowse_application::user_destroy() bool TSaldibrowse_application::user_destroy()
{ {
delete _msk; delete _msk;
@ -357,16 +315,6 @@ void TSaldibrowse_application::add_r(int numrig,int a,real& pds,real& pas,real&
char segno = ' '; char segno = ' ';
TToken_string& riga = cs.row(numrig); TToken_string& riga = cs.row(numrig);
/*
TString dep (18);
if (sc > ZERO)
dep << sc.string(REAL_PICTURE) << " D";
else if (sc < ZERO)
{
sc = -sc;
dep << sc.string(REAL_PICTURE) << " A";
}
*/
riga.add(a, 0); riga.add(a, 0);
riga.add(si.string(),1); riga.add(si.string(),1);
if (si != ZERO) if (si != ZERO)

View File

@ -2,12 +2,10 @@
#define F_TIPOCF 102 #define F_TIPOCF 102
#define F_GRUPPO 103 #define F_GRUPPO 103
#define F_CONTO 104 #define F_CONTO 104
#define F_CONTO_CLIENTE 105 #define F_SOTTOCONTO 105
#define F_CONTO_FORN 106 #define F_SOTTOC_CLIENTE 106
#define F_SOTTOCONTO 107 #define F_SOTTOC_FORN 107
#define F_DESCR_CONTO 108 #define F_DESCR_CONTO 108
#define F_SOTTOC_CLIENTE 109 #define F_DESCR_CLIENTE 109
#define F_DESCR_CLIENTE 110 #define F_DESCR_FORN 110
#define F_SOTTOC_FORN 111 #define F_SHEET_SALDI 111
#define F_DESCR_FORN 112
#define F_SHEET_SALDI 113

View File

@ -58,7 +58,7 @@ NUMBER F_CONTO 3
BEGIN BEGIN
PROMPT 40 3 "Conto " PROMPT 40 3 "Conto "
HELP "Codice del conto da visualizzare" HELP "Codice del conto da visualizzare"
USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="") && (TMCF="") USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="")
FIELD LF_PCON->CONTO FIELD LF_PCON->CONTO
KEY 1 KEY 1
INPUT GRUPPO F_GRUPPO INPUT GRUPPO F_GRUPPO
@ -66,64 +66,14 @@ BEGIN
DISPLAY "Gruppo" GRUPPO DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO DISPLAY "Conto" CONTO
DISPLAY "Descrizione@50" DESCR DISPLAY "Descrizione@50" DESCR
OUTPUT F_CONTO CONTO DISPLAY "Tipo" TMCF
OUTPUT F_TIPOCF TMCF
OUTPUT F_GRUPPO GRUPPO OUTPUT F_GRUPPO GRUPPO
//OUTPUT F_DESCR_CLIENTE DESCR OUTPUT F_CONTO CONTO
//OUTPUT F_DESCR_FORN DESCR
OUTPUT F_DESCR_CONTO DESCR OUTPUT F_DESCR_CONTO DESCR
FLAGS "R" FLAGS "R"
CHECKTYPE NORMAL CHECKTYPE NORMAL
WARNING "Conto inesistente o mancante" WARNING "Conto inesistente o mancante"
MESSAGE COPY,F_CONTO_CLIENTE|COPY,F_CONTO_FORN
GROUP 1
END
NUMBER F_CONTO_CLIENTE 3
BEGIN
PROMPT 40 3 "Conto "
HELP "Codice del conto da visualizzare"
USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="") && (TMCF="C")
FIELD LF_PCON->CONTO
KEY 1
INPUT GRUPPO F_GRUPPO
INPUT CONTO F_CONTO_CLIENTE
DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO
DISPLAY "Descrizione@50" DESCR
OUTPUT F_CONTO_CLIENTE CONTO
OUTPUT F_GRUPPO GRUPPO
//OUTPUT F_DESCR_CLIENTE DESCR
//OUTPUT F_DESCR_FORN DESCR
//OUTPUT F_DESCR_CONTO DESCR
FLAGS "R"
CHECKTYPE NORMAL
WARNING "Conto inesistente o mancante"
MESSAGE COPY,F_CONTO|COPY,F_CONTO_FORN
GROUP 2
END
NUMBER F_CONTO_FORN 3
BEGIN
PROMPT 40 3 "Conto "
HELP "Codice del conto da visualizzare"
USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="") && (TMCF="F")
FIELD LF_PCON->CONTO
KEY 1
INPUT GRUPPO F_GRUPPO
INPUT CONTO F_CONTO_FORN
DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO
DISPLAY "Descrizione@50" DESCR
OUTPUT F_CONTO_FORN CONTO
OUTPUT F_GRUPPO GRUPPO
//OUTPUT F_DESCR_CLIENTE DESCR
//OUTPUT F_DESCR_FORN DESCR
//OUTPUT F_DESCR_CONTO DESCR
FLAGS "R"
CHECKTYPE NORMAL
WARNING "Conto inesistente o mancante"
MESSAGE COPY,F_CONTO_CLIENTE|COPY,F_CONTO
GROUP 3
END END
NUMBER F_SOTTOCONTO 6 NUMBER F_SOTTOCONTO 6
@ -144,13 +94,8 @@ BEGIN
OUTPUT F_CONTO CONTO OUTPUT F_CONTO CONTO
OUTPUT F_SOTTOCONTO SOTTOCONTO OUTPUT F_SOTTOCONTO SOTTOCONTO
OUTPUT F_DESCR_CONTO DESCR OUTPUT F_DESCR_CONTO DESCR
//OUTPUT F_DESCR_CLIENTE DESCR
//OUTPUT F_DESCR_FORN DESCR
//MESSAGE COPY,F_SOTTOC_FORN
//MESSAGE COPY,F_SOTTOC_CLIENTE
FLAGS "R" FLAGS "R"
CHECKTYPE NORMAL CHECKTYPE NORMAL
//VALIDATE AUTOEXIT_FUNC 3 F_GRUPPO F_CONTO F_SOTTOCONTO //come pure questo
GROUP 1 GROUP 1
WARNING "Conto inesistente" WARNING "Conto inesistente"
END END
@ -160,7 +105,6 @@ BEGIN
PROMPT 54 3 "Cliente " PROMPT 54 3 "Cliente "
HELP "Codice del conto da visualizzare" HELP "Codice del conto da visualizzare"
USE LF_CLIFO USE LF_CLIFO
//FIELD LF_CLIFO->CODCF
INPUT TIPOCF "C" INPUT TIPOCF "C"
INPUT CODCF F_SOTTOC_CLIENTE INPUT CODCF F_SOTTOC_CLIENTE
DISPLAY "Codice" CODCF DISPLAY "Codice" CODCF
@ -168,16 +112,11 @@ BEGIN
DISPLAY "Gruppo" GRUPPO DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO DISPLAY "Conto" CONTO
OUTPUT F_SOTTOC_CLIENTE CODCF OUTPUT F_SOTTOC_CLIENTE CODCF
OUTPUT F_GRUPPO GRUPPO
OUTPUT F_CONTO_CLIENTE CONTO
//OUTPUT F_DESCR_CONTO RAGSOC
OUTPUT F_DESCR_CLIENTE RAGSOC OUTPUT F_DESCR_CLIENTE RAGSOC
//OUTPUT F_DESCR_FORN RAGSOC
FLAGS "R" FLAGS "R"
CHECKTYPE NORMAL CHECKTYPE NORMAL
KEY 1 KEY 1
WARNING "Cliente inesistente" WARNING "Cliente inesistente"
//VALIDATE AUTOEXIT_FUNC 3 F_GRUPPO F_CONTO F_SOTTOC_CLIENTE
GROUP 2 GROUP 2
END END
@ -193,16 +132,11 @@ BEGIN
DISPLAY "Gruppo" GRUPPO DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO DISPLAY "Conto" CONTO
OUTPUT F_SOTTOC_FORN CODCF OUTPUT F_SOTTOC_FORN CODCF
OUTPUT F_GRUPPO GRUPPO
OUTPUT F_CONTO_FORN CONTO
OUTPUT F_DESCR_FORN RAGSOC OUTPUT F_DESCR_FORN RAGSOC
// OUTPUT F_DESCR_CONTO RAGSOC
// OUTPUT F_DESCR_CLIENTE RAGSOC
FLAGS "R" FLAGS "R"
CHECKTYPE NORMAL CHECKTYPE NORMAL
KEY 1 KEY 1
WARNING "Fornitore inesistente" WARNING "Fornitore inesistente"
//VALIDATE AUTOEXIT_FUNC 3 F_GRUPPO F_CONTO F_SOTTOC_FORN
GROUP 3 GROUP 3
END END
@ -304,6 +238,7 @@ STRING 103 1
BEGIN BEGIN
PROMPT 44 3 "" PROMPT 44 3 ""
HELP "Sezione del saldo iniziale" HELP "Sezione del saldo iniziale"
FLAGS ""
END END
NUMBER 104 15 NUMBER 104 15
@ -333,6 +268,7 @@ END
STRING 107 1 STRING 107 1
BEGIN BEGIN
PROMPT 44 5 "" PROMPT 44 5 ""
FLAGS "R"
HELP "Sezione del saldo attuale del conto" HELP "Sezione del saldo attuale del conto"
END END
@ -364,6 +300,7 @@ STRING 111 1
BEGIN BEGIN
PROMPT 44 7 "" PROMPT 44 7 ""
HELP "Sezione del saldo attuale complessivo del conto" HELP "Sezione del saldo attuale complessivo del conto"
FLAGS "R"
END END
DATE 112 DATE 112
@ -407,7 +344,8 @@ END
STRING 117 1 STRING 117 1
BEGIN BEGIN
PROMPT 44 11 "" PROMPT 44 11 ""
HELP "Sezione del saldo progressivi dei moviemnti provvisori del conto" HELP "Sezione del saldo progressivi dei movimenti provvisori del conto"
FLAGS "R"
END END
BUTTON DLG_CANCEL 9 2 BUTTON DLG_CANCEL 9 2

View File

@ -1,197 +1,197 @@
#include <applicat.h> #include <applicat.h>
#include <date.h> #include <isam.h>
#include <isam.h> #include <mask.h>
#include <relation.h> #include <prefix.h>
#include <tabutil.h> #include <progind.h>
#include <mask.h> #include <relation.h>
#include <prefix.h> #include <tabutil.h>
#include <progind.h> #include <utility.h>
#include <utility.h>
#include <mov.h>
#include <mov.h> #include <urldefid.h>
#include <urldefid.h>
#include "cg5.h"
#include "cg5.h" #include "cg5400.h"
#include "cg5400.h"
class TRipristina_stampa : public TApplication
class TRipristina_stampa : public TApplication {
{ TMask* _msk;
TMask* _msk; long _default_firm;
long _default_firm;
virtual bool create() ;
virtual bool create() ; virtual bool destroy() ;
virtual bool destroy() ; bool menu(MENU_TAG);
bool menu(MENU_TAG); bool do_restore(long firm, const char * reg, const char * year, int month,
bool do_restore(long firm, const char * reg, const char * year, int month, bool giornale);
bool giornale); static bool firm_handler(TMask_field& f, KEY key);
static bool firm_handler(TMask_field& f, KEY key);
public:
public: TRipristina_stampa() : _msk(NULL) {}
TRipristina_stampa() : _msk(NULL) {} };
};
bool TRipristina_stampa::firm_handler(TMask_field& f, KEY key)
bool TRipristina_stampa::firm_handler(TMask_field& f, KEY key) {
{ if (f.to_check(key))
if (f.to_check(key)) {
{ const long firm = atol(f.get());
const long firm = atol(f.get());
if (firm < 0)
if (firm < 0) return f.error_box("Codice ditta impossibile");
return f.error_box("Codice ditta impossibile"); else
else if (firm == 0)
if (firm == 0) return f.error_box("La ditta e' obbligatoria");
return f.error_box("La ditta e' obbligatoria"); else
else if (!prefhndl->exist(firm))
if (!prefhndl->exist(firm)) return f.error_box("Gli archivi della ditta %d non sono stati ancora generati",firm);
return f.error_box("Gli archivi della ditta %d non sono stati ancora generati",firm); else
else main_app().set_firm(firm);
main_app().set_firm(firm); }
} return TRUE;
return TRUE; }
}
bool TRipristina_stampa::do_restore(long firm, const char * regist,
bool TRipristina_stampa::do_restore(long firm, const char * regist, const char * year, int month,
const char * year, int month, bool giornale)
bool giornale) {
{ bool ok = TRUE;
bool ok = TRUE; CHECK(firm > 0, "Non posso ripristinare sui dati comuni");
CHECK(firm > 0, "Non posso ripristinare sui dati comuni"); CHECK(regist != NULL && strlen(regist) < 4, "Registro impossibile");
CHECK(regist != NULL && strlen(regist) < 4, "Registro impossibile"); CHECK(month > 0 && month < 13, "Mese impossibile");
CHECK(month > 0 && month < 13, "Mese impossibile"); set_firm(firm);
set_firm(firm);
const char * const fieldname = giornale ? MOV_STAMPATO : MOV_REGST;
const char * const fieldname = giornale ? MOV_STAMPATO : MOV_REGST; TRelation rel(LF_MOV);
TRelation rel(LF_MOV); TLocalisamfile & mov = rel.lfile();
TLocalisamfile & mov = rel.lfile(); TTable reg("REG");
TTable reg("REG"); TString16 s;
TString16 s;
s.format("%-4s%s", year, regist);
s.format("%-4s%s", year, regist);
reg.zero();
reg.zero(); reg.put("CODTAB", s);
reg.put("CODTAB", s); if (reg.read(_isequal, _lock) == NOERR)
if (reg.read(_isequal, _lock) == NOERR) {
{ TDate dlast(reg.get_date("D3"));
TDate dlast(reg.get_date("D3")); int wyear = atoi(year);
int wyear = atoi(year);
if (giornale)
if (giornale) {
{ TTable esc("ESC");
TTable esc("ESC"); esc.zero();
esc.zero(); esc.put("CODTAB", year);
esc.put("CODTAB", year); if (esc.read() != NOERR)
if (esc.read() != NOERR) {
{ set_firm(_default_firm);
set_firm(_default_firm); return error_box("Esercizio %s assente", year);
return error_box("Esercizio %s assente", year); }
}
TDate wd(esc.get_date("D0"));
TDate wd(esc.get_date("D0"));
wyear = wd.year();
wyear = wd.year(); if (wd.month() > month)
if (wd.month() > month) wyear++;
wyear++; }
} TDate d(1, month, wyear);
TDate d(1, month, wyear);
TRectype from(mov.curr()); from.zero();
TRectype from(mov.curr()); from.zero(); TRectype to(from);
TRectype to(from); TString16 filter;
TString16 filter;
from.put(MOV_DATAREG, d);
from.put(MOV_DATAREG, d); to.put(MOV_DATAREG, dlast);
to.put(MOV_DATAREG, dlast); if (!giornale)
if (!giornale) filter.format("%s==\"%s\"", MOV_REG, regist);
filter.format("%s==\"%s\"", MOV_REG, regist);
TCursor cursor(&rel, filter, 2, &from, &to);
TCursor cursor(&rel, filter, 2, &from, &to); long last_num = 0L;
long last_num = 0L;
cursor = 0L;
cursor = 0L; const long nitems = cursor.items();
const long nitems = cursor.items();
TProgind p(nitems ? nitems : 1, format("Ripristino stampa del registro %s", (const char *) regist) , TRUE, TRUE, 70);
TProgind p(nitems ? nitems : 1, format("Ripristino stampa del registro %s", (const char *) regist) , TRUE, TRUE, 70);
if (giornale)
if (giornale) {
{ last_num = mov.get_long(MOV_NUMGIO);
last_num = mov.get_long(MOV_NUMGIO); if (last_num > 0) last_num--;
if (last_num > 0) last_num--; CHECK(last_num >= 0, "Ultimo numero stampato impossibile");
CHECK(last_num >= 0, "Ultimo numero stampato impossibile"); }
} for (; ok && cursor.pos() < cursor.items(); ++cursor)
for (; ok && cursor.pos() < cursor.items(); ++cursor) {
{ p.addstatus(1);
p.addstatus(1); mov.read(_isequal, _lock);
mov.read(_isequal, _lock); mov.zero(fieldname);
mov.zero(fieldname); ok = (mov.rewrite() == NOERR);
ok = (mov.rewrite() == NOERR); if (!ok)
if (!ok) error_box("Errore nell' aggiornamento del movimento %ld.\n Errore n. %d",
error_box("Errore nell' aggiornamento del movimento %ld.\n Errore n. %d", mov.get_long(MOV_NUMREG), mov.status());
mov.get_long(MOV_NUMREG), mov.status()); }
} --d;
--d; reg.put("D3", d);
reg.put("D3", d); if (giornale)
if (giornale) reg.put("I6", last_num);
reg.put("I6", last_num); ok = (reg.rewrite() == NOERR);
ok = (reg.rewrite() == NOERR); if (!ok)
if (!ok) error_box("Errore nell' aggiornamento del registro %s.\n Errore n. %d",
error_box("Errore nell' aggiornamento del registro %s.\n Errore n. %d", (const char * ) regist, mov.status());
(const char * ) regist, mov.status());
}
} else
else ok = error_box("Non riesco a leggere il registro %s anno %s", (const char *) regist, (const char *) year);
ok = error_box("Non riesco a leggere il registro %s anno %s", (const char *) regist, (const char *) year);
set_firm(_default_firm);
set_firm(_default_firm); return ok;
return ok; }
}
bool TRipristina_stampa::create()
bool TRipristina_stampa::create() {
{ TApplication::create();
_msk = new TMask("cg5400a") ; _msk = new TMask("cg5400a") ;
_msk->set_handler(F_FIRM, firm_handler); _msk->set_handler(F_FIRM, firm_handler);
_default_firm = get_firm(); _default_firm = get_firm();
dispatch_e_menu(BAR_ITEM(1)); dispatch_e_menu(BAR_ITEM(1));
return TRUE; return TRUE;
} }
bool TRipristina_stampa::destroy() bool TRipristina_stampa::destroy()
{ {
if (_msk != NULL) delete _msk; if (_msk != NULL) delete _msk;
return TRUE; return TApplication::destroy();
} }
bool TRipristina_stampa::menu(MENU_TAG) bool TRipristina_stampa::menu(MENU_TAG)
{ {
while (_msk->run() == K_ENTER) while (_msk->run() == K_ENTER)
{ {
const long firm = _msk->get_long(F_FIRM); const long firm = _msk->get_long(F_FIRM);
const TString16 reg = _msk->get(F_REG); const TString16 reg = _msk->get(F_REG);
const bool giornale = _msk->get_int(F_TIPO) == 5; const bool giornale = _msk->get_int(F_TIPO) == 5;
const TString16 year = _msk->get(giornale ? F_ESER : F_YEAR); const TString16 year = _msk->get(giornale ? F_ESER : F_YEAR);
int month = _msk->get_int(F_MESE); int month = _msk->get_int(F_MESE);
if (prefhndl->exist(firm)) if (prefhndl->exist(firm))
{ {
TString mess; TString mess;
mess.format("Attenzione sara' ripristinata la stampa\n del registro %s %s %s della ditta %ld dal mese di %s. Devo continuare", mess.format("Attenzione sara' ripristinata la stampa\n del registro %s %s %s della ditta %ld dal mese di %s. Devo continuare",
(const char *) reg, giornale ? "esercizio" : "anno", (const char *) reg, giornale ? "esercizio" : "anno",
(const char *) year, (const char *) firm, itom(month)); (const char *) year, (const char *) firm, itom(month));
if (yesno_box((const char *) mess)) if (yesno_box((const char *) mess))
{ {
mess.rtrim(16); mess << " Devo veramente continuare"; mess.rtrim(16); mess << " Devo veramente continuare";
if (yesno_box((const char *) mess)) if (yesno_box((const char *) mess))
do_restore(firm, reg, year, month, giornale); do_restore(firm, reg, year, month, giornale);
} }
} }
else error_box("Gli archivi della ditta %d non sono stati ancora generati",firm); else error_box("Gli archivi della ditta %d non sono stati ancora generati",firm);
_msk->reset(); _msk->reset();
} }
return FALSE; return FALSE;
} }
int cg5400(int argc, char* argv[]) int cg5400(int argc, char* argv[])
{ {
TRipristina_stampa a ; TRipristina_stampa a ;
a.run(argc, argv, "Ripristino stampa registri"); a.run(argc, argv, "Ripristino stampa registri");
return 0; return 0;
} }