From 5cf33fed7ee34f5fb468f80dbed005a5048e3a75 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 21 May 1997 09:42:14 +0000 Subject: [PATCH] cg2.cpp Aggiunto exit(0) cg2100.cpp Aggiunta funzione protected_record cg2102.h Dichiarata funzione protected_record cg3.cpp Aggiunto exit(0) cg3400.cpp Corretta gestione dell'ultima pagina stampata git-svn-id: svn://10.65.10.50/trunk@4355 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg2.cpp | 1 + cg/cg2100.cpp | 25 ++++++++ cg/cg2102.h | 1 + cg/cg3.cpp | 7 ++- cg/cg3400.cpp | 169 +++++++++++++++++++++++--------------------------- 5 files changed, 110 insertions(+), 93 deletions(-) diff --git a/cg/cg2.cpp b/cg/cg2.cpp index f3ce34ace..c399d2d19 100755 --- a/cg/cg2.cpp +++ b/cg/cg2.cpp @@ -14,5 +14,6 @@ int main(int argc,char** argv) default: cg2100(argc, argv); break; } + exit(0); return 0; } diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index d516cff50..809fec646 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -1736,6 +1736,31 @@ void TPrimanota_application::mask2ini(TMask& msk, TConfig& ini) } } +bool TPrimanota_application::protected_record(TRectype& mov) +{ + bool ok = !TRelation_application::protected_record(mov); + if (ok && autodeleting()) + { + if (mov.get_bool(MOV_STAMPATO)) + { + const long numreg = mov.get_long(MOV_NUMREG); + ok = yesno_box("Il movimento %ld e' gia' stato stampato sul libro giornale:\n" + "si desidera eliminarlo ugualmente?", numreg); + if (ok && mov.get_bool(MOV_REGST)) + { + ok = yesno_box("Il movimento %ld e' gia' stato stampato sul bollato:\n" + "si desidera eliminarlo ugualmente?", numreg); + } + if (ok && mov.get_bool(MOV_INVIATO)) + { + ok = yesno_box("Il movimento %ld e' stato inviato ad un'altra contabilita':\n" + "si desidera eliminarlo ugualmente?", numreg); + } + } + } + return !ok; +} + int cg2100 (int argc, char** argv) { TPrimanota_application* a = new TPrimanota_application; diff --git a/cg/cg2102.h b/cg/cg2102.h index 3abb2a079..b88550c72 100755 --- a/cg/cg2102.h +++ b/cg/cg2102.h @@ -166,6 +166,7 @@ protected: // TRelation_application virtual bool remove(); virtual void write_enable(bool) {} virtual bool firm_change_enabled() const; + virtual bool protected_record(TRectype& rec); protected: void check_saldi(); diff --git a/cg/cg3.cpp b/cg/cg3.cpp index f1f1d793c..b8abbef3a 100755 --- a/cg/cg3.cpp +++ b/cg/cg3.cpp @@ -8,7 +8,7 @@ int main(int argc,char** argv) { - int rt = 0 ; + int rt = 1; int s = atoi(argv[1]+1) ; switch (s) @@ -19,8 +19,9 @@ int main(int argc,char** argv) case 3: rt = cg3400(argc,argv) ; break; case 4: rt = cg3500(argc,argv) ; break; case 5: rt = cg3600(argc,argv) ; break; - default: error_box(usage, argv[0]) ; break; - } + default: error_box(usage, argv[0]); break; + } + exit(rt); return rt; } diff --git a/cg/cg3400.cpp b/cg/cg3400.cpp index 52616eb81..3abdba7ba 100755 --- a/cg/cg3400.cpp +++ b/cg/cg3400.cpp @@ -107,7 +107,7 @@ const TString& TContoOccas::descrizione() return _descrizione; } -class CG3400_application : public TPrintapp +class TStampa_giornale : public TPrintapp { static bool mask_a_cod_reg (TMask_field& f, KEY k); static bool data_a_hndl (TMask_field& f, KEY k); @@ -224,28 +224,25 @@ public: void update_totals (char sezione, real& importo); void set_reg_filter(TMask& m); - CG3400_application() : _pagine_contate(0) {}; - virtual ~CG3400_application() {}; + TStampa_giornale() : _pagine_contate(0) {}; + virtual ~TStampa_giornale() {}; }; -HIDDEN CG3400_application& app() { return (CG3400_application&) main_app(); } +HIDDEN TStampa_giornale& app() { return (TStampa_giornale&)main_app(); } -bool CG3400_application::filtra_reg(const TRelation * r) +bool TStampa_giornale::filtra_reg(const TRelation * r) { - const TRectype& rec = r->lfile().curr(); - const int anno = atoi(rec.get("CODTAB").left(4)); - + bool ok = TRUE; if (app()._ae) { - if (anno == app()._ae) - return TRUE; - else - return FALSE; + const TRectype& rec = r->lfile().curr(); + const int anno = atoi(rec.get("CODTAB").left(4)); + ok = anno == app()._ae; } - return TRUE; + return ok; } -bool CG3400_application::filter_func(const TRelation * r) +bool TStampa_giornale::filter_func(const TRelation * r) { const TRectype& recmov = r->lfile().curr(); @@ -261,7 +258,9 @@ bool CG3400_application::filter_func(const TRelation * r) TRectype& recrmov = r->lfile(LF_RMOV).curr(); recrmov.zero(); recrmov.put("NUMREG", numreg); - recrmov.put("NUMRIG", 1); + recrmov.put("NUMRIG", 1); + + // Guy: non capisco bene come possano esistere movimenti senza la prima riga! if (r->lfile(LF_RMOV).read() != NOERR) { const long numreg2 = recrmov.get_long("NUMREG"); @@ -287,7 +286,7 @@ HIDDEN bool libro_cronologico() return conf.get_bool("GsLbCn"); } -TRectype& CG3400_application::look_com (const char * cod) +TRectype& TStampa_giornale::look_com (const char * cod) { _com->zero(); _com->put(COM_COM, cod); @@ -297,7 +296,7 @@ TRectype& CG3400_application::look_com (const char * cod) return _com->curr(); } -const char* CG3400_application::get_descr_caus (const char * codcaus) +const char* TStampa_giornale::get_descr_caus (const char * codcaus) { TLocalisamfile& caus = *_causali; @@ -309,7 +308,7 @@ const char* CG3400_application::get_descr_caus (const char * codcaus) return tmp; } -void CG3400_application::get_dati_ditta () +void TStampa_giornale::get_dati_ditta () { TString16 codanagr; char tipoa; @@ -358,7 +357,7 @@ void CG3400_application::get_dati_ditta () } } -bool CG3400_application::user_create() +bool TStampa_giornale::user_create() { _ae = 0; _ae_solare = 0; @@ -392,7 +391,7 @@ bool CG3400_application::user_create() return TRUE; } -bool CG3400_application::user_destroy() +bool TStampa_giornale::user_destroy() { delete _rel; delete _cur; @@ -410,7 +409,7 @@ bool CG3400_application::user_destroy() return TRUE; } -void CG3400_application::aggiorna_mov() +void TStampa_giornale::aggiorna_mov() { TLocalisamfile& mov = _cur->file(LF_MOV); long nprog = _nprog_da + 1; @@ -444,7 +443,7 @@ void CG3400_application::aggiorna_mov() // mov.reread(_unlock); } -int CG3400_application::set_totali_giorno(const TDate& data, const int righeiva) +int TStampa_giornale::set_totali_giorno(const TDate& data, const int righeiva) { int r = righeiva + 1; char dep[200]; @@ -500,21 +499,21 @@ int CG3400_application::set_totali_giorno(const TDate& data, const int righeiva) } -void CG3400_application::postclose_print() +void TStampa_giornale::postclose_print() { if (_stampa_definitiva) { - const int ultima_fatta = _pagine_contate; if (yesno_box("La stampa e' corretta ?")) { - aggiorna_mov (); + const int ultima_fatta = _pagine_contate; + aggiorna_mov(); aggiorna_tabreg (_pagina_da, ultima_fatta); } } } -void CG3400_application::preprocess_footer() +void TStampa_giornale::preprocess_footer() { TString progr_dare_ap(22), progr_avere_ap(22); TString progr_dare(25), progr_avere(25), dts(25), ats(25); @@ -575,7 +574,7 @@ void CG3400_application::preprocess_footer() } -int CG3400_application::set_totali_pagina(int righe) +int TStampa_giornale::set_totali_pagina(int righe) { TString progr_dare_ap(22), progr_avere_ap(22); TString progr_dare(22), progr_avere(22), dts(22), ats(22); @@ -680,7 +679,7 @@ int CG3400_application::set_totali_pagina(int righe) return r; } -int CG3400_application::stampa_intestazione_ditta() +int TStampa_giornale::stampa_intestazione_ditta() { int r=1; TString256 intes; @@ -715,7 +714,7 @@ int CG3400_application::stampa_intestazione_ditta() return r; } -int CG3400_application::set_headers() +int TStampa_giornale::set_headers() { int r=1; TString riga(_stampa_width); @@ -784,7 +783,7 @@ int CG3400_application::set_headers() return r; } -void CG3400_application::preprocess_header() +void TStampa_giornale::preprocess_header() { int r = _last_header + 1; int pag = printer().getcurrentpage(); @@ -842,7 +841,7 @@ void CG3400_application::preprocess_header() // set_page_number (stampa_ok) // setfrompage (pagina_da) // -bool CG3400_application::preprocess_print(int file, int counter) +bool TStampa_giornale::preprocess_print(int file, int counter) { switch (file) { @@ -859,7 +858,7 @@ bool CG3400_application::preprocess_print(int file, int counter) } /*** - bool CG3400_application::cancel_hook() + bool TStampa_giornale::cancel_hook() { int ultima_fatta = printer().getcurrentpage() - 1; // int stampate = ultima_fatta - _pagina_da + 1; @@ -875,7 +874,7 @@ bool CG3400_application::preprocess_print(int file, int counter) } ***/ -int CG3400_application::righe_rimaste() const +int TStampa_giornale::righe_rimaste() const { const TPrinter& p = printer(); int rows_left = p.rows_left(); @@ -884,7 +883,7 @@ int CG3400_application::righe_rimaste() const return rows_left; } -void CG3400_application::fill_page(int righe_da_stampare, int righe_iva_settate) +void TStampa_giornale::fill_page(int righe_da_stampare, int righe_iva_settate) { const TPrinter& p = printer(); @@ -925,14 +924,14 @@ void CG3400_application::fill_page(int righe_da_stampare, int righe_iva_settate) } } -print_action CG3400_application::postprocess_print(int file, int counter) +print_action TStampa_giornale::postprocess_print(int file, int counter) { if (file == LF_MOV) _pagine_contate = printer().getcurrentpage() - 1; return NEXT_PAGE; } -print_action CG3400_application::postprocess_page(int file, int counter) +print_action TStampa_giornale::postprocess_page(int file, int counter) { int righe_iva_settate=0; bool FINITO = FALSE; @@ -1007,7 +1006,7 @@ print_action CG3400_application::postprocess_page(int file, int counter) return NEXT_PAGE; } -void CG3400_application::update_totals (char sezione, real& importo) +void TStampa_giornale::update_totals (char sezione, real& importo) { #ifdef DBG TString dgap(_tot_dare_gg_ap.string()); @@ -1056,7 +1055,7 @@ void CG3400_application::update_totals (char sezione, real& importo) -void CG3400_application::set_rows (int file, int counter) +void TStampa_giornale::set_rows (int file, int counter) { TString16 datadoc_str, datareg_str, numdoc, frm, caus; TDate datadoc, datareg; @@ -1224,7 +1223,7 @@ void CG3400_application::set_rows (int file, int counter) // // Non scarto nulla qui, non si deve mai vedere una stampa vuota // -bool CG3400_application::preprocess_page(int file, int counter) +bool TStampa_giornale::preprocess_page(int file, int counter) { if (counter) return TRUE; @@ -1259,7 +1258,7 @@ bool CG3400_application::preprocess_page(int file, int counter) return TRUE; } -void CG3400_application::calcola_iva() +void TStampa_giornale::calcola_iva() { TString codiva; int tipocr, tipodet, tipoatt; @@ -1280,7 +1279,7 @@ void CG3400_application::calcola_iva() } } -int CG3400_application::setta_righe_descr(TParagraph_string& str, enum descr des) +int TStampa_giornale::setta_righe_descr(TParagraph_string& str, enum descr des) { int i = 1; TString16 frm; @@ -1322,7 +1321,7 @@ int CG3400_application::setta_righe_descr(TParagraph_string& str, enum descr des return i; } -const char* CG3400_application::get_codiva_des(const char* codiva) +const char* TStampa_giornale::get_codiva_des(const char* codiva) { _tabiva->zero(); _tabiva->put("CODTAB", codiva); @@ -1336,7 +1335,7 @@ const char* CG3400_application::get_codiva_des(const char* codiva) // Questa funzione ritorna il numero di righe che ha settato. // Se questo e' diverso da 0 viene fatta una REPEAT_PAGE // Attenzione quindi se si modifica la variabile r -int CG3400_application::setta_righe_iva() +int TStampa_giornale::setta_righe_iva() { int r=0, j; TString80 rig; @@ -1389,7 +1388,7 @@ int CG3400_application::setta_righe_iva() return r; } -int CG3400_application::setta_righe_valuta(int riga) +int TStampa_giornale::setta_righe_valuta(int riga) { TString16 codvali; real corrval; @@ -1413,7 +1412,7 @@ int CG3400_application::setta_righe_valuta(int riga) // Cerca l'indirizzo del C/F. // Legge CLIFO o OCCAS a seconda di _occas // Setta le righe 2 e 3 che vengono poi resettate al record successivo -int CG3400_application::setta_righe_indirizzo(char tipocf, long codcf,int rdes) +int TStampa_giornale::setta_righe_indirizzo(char tipocf, long codcf,int rdes) { TString16 prov, comcf, capcf, civcf, statocf; TString80 viacf, comune; @@ -1517,15 +1516,15 @@ int CG3400_application::setta_righe_indirizzo(char tipocf, long codcf,int rdes) // // Lettura/aggiornamento tabella registri // -void CG3400_application::aggiorna_tabreg(int partito_da, int stampate) +void TStampa_giornale::aggiorna_tabreg(int partito_da, int stampate) { TString16 codtab; codtab.format ("%04d%-3s", _ae_solare, (const char*) _reg_cod); - _tabreg->zero(); + _tabreg->zero(); _tabreg->put("CODTAB", codtab); - _tabreg->read(); + _tabreg->read(_isequal, _lock); if (_tabreg->good()) { @@ -1539,33 +1538,20 @@ void CG3400_application::aggiorna_tabreg(int partito_da, int stampate) } } -void CG3400_application::get_date_aep(int aep, TDate* in, TDate* fin) +void TStampa_giornale::get_date_aep(int aep, TDate* in, TDate* fin) { -/* L'anno del giornale non e' piu' un esercizio ma un anno solare - TTable esc("ESC"); - esc.zero(); esc.put("CODTAB", format("%04d",aep)); - if (esc.read() == NOERR) - { - *in = esc.get_date("D0"); - *fin = esc.get_date("D1"); - } -*/ *in = TDate(1,1,aep); *fin = TDate(31,12,aep); } const int es_prec(const int es_corr) { -/* L'anno del giornale non e' piu' un esercizio ma un anno solare - TEsercizi_contabili esc; - return esc.pred(es_corr); -*/ return es_corr-1; } -bool CG3400_application::controlla_mov_aep() +bool TStampa_giornale::controlla_mov_aep() { - begin_wait(); + TWait_cursor hourglass; const int aep = es_prec(_ae); TDate inizio_ep, fine_ep; @@ -1601,11 +1587,10 @@ bool CG3400_application::controlla_mov_aep() } _cur->setfilter(""); - end_wait(); return TRUE; } -bool CG3400_application::leggi_tabreg(const char * reg_cod, int reg_anno) +bool TStampa_giornale::leggi_tabreg(const char * reg_cod, int reg_anno) { TString16 codtab; @@ -1634,7 +1619,7 @@ bool CG3400_application::leggi_tabreg(const char * reg_cod, int reg_anno) return ok; } -void CG3400_application::set_reg_filter(TMask& m) +void TStampa_giornale::set_reg_filter(TMask& m) { TEdit_field& reg = m.efield(CODREG); reg.browse()->cursor()->set_filterfunction(filtra_reg); @@ -1650,7 +1635,7 @@ void CG3400_application::set_reg_filter(TMask& m) // Qui viene compilato app()._ae // L'anno di esercizio e' determinato da DATA_A // -bool CG3400_application::data_a_hndl (TMask_field& f, KEY k) +bool TStampa_giornale::data_a_hndl (TMask_field& f, KEY k) { TMask& m = f.mask(); @@ -1692,7 +1677,7 @@ bool CG3400_application::data_a_hndl (TMask_field& f, KEY k) return TRUE; } -bool CG3400_application::data_da_hndl(TMask_field& f, KEY k) +bool TStampa_giornale::data_da_hndl(TMask_field& f, KEY k) { TMask& m = f.mask(); // if (f.to_check(k)) @@ -1731,12 +1716,12 @@ bool CG3400_application::data_da_hndl(TMask_field& f, KEY k) // // ----------->>>> SCRIVO ANCHE QUI _ae <<<<---------------- // -bool CG3400_application::mask_a_cod_reg (TMask_field& f, KEY k) +bool TStampa_giornale::mask_a_cod_reg (TMask_field& f, KEY k) { if (f.to_check(k)) { TMask& m = f.mask(); - CG3400_application& a = app(); + TStampa_giornale& a = app(); const bool definitiva = m.get_bool(STAMPA_DEF); const TString16 data_astr(m.get(DATA_A)); const TDate data_a(m.get(DATA_A)); @@ -1784,38 +1769,41 @@ bool CG3400_application::mask_a_cod_reg (TMask_field& f, KEY k) // Se premo il bottone rimetto i valori precedenti // dentro ai campi (per ripetere la stampa) // -bool CG3400_application::mask_b_ripristina (TMask_field& f, KEY k) +bool TStampa_giornale::mask_b_ripristina (TMask_field& f, KEY k) { if (k == K_SPACE) - { - CG3400_application& a = (CG3400_application&)main_app(); - f.mask().set(PROGR_DARE, a._tot_dare.string()); - f.mask().set(ULTIMA_DATA, a._last_data.string()); - f.mask().set(N_RIGA_STAMPATO, a._nprog_da); - f.mask().set(PAGINA_DA, a._pagine_stampate); + { + TMask& m = f.mask(); + TStampa_giornale& a = (TStampa_giornale&)main_app(); + m.set(PROGR_DARE, a._tot_dare.string()); + m.set(ULTIMA_DATA, a._last_data.string()); + m.set(N_RIGA_STAMPATO, a._nprog_da); + m.set(PAGINA_DA, a._pagine_stampate); } return TRUE; } -bool CG3400_application::mask_b_warning (TMask_field& f, KEY k) +bool TStampa_giornale::mask_b_warning (TMask_field& f, KEY k) { static bool gia_detto = FALSE; + if (k == K_TAB && !f.mask().is_running()) + gia_detto = FALSE; + if (!gia_detto) + { if (k == K_SPACE) { f.warning_box("Le modifiche a questi progressivi saranno scritte nel registro"); gia_detto = TRUE; return TRUE; } - - if (k == K_ENTER || k == K_ESC) - gia_detto = FALSE; + } return TRUE; } -void CG3400_application::init_print() +void TStampa_giornale::init_print() { // 17.5.95 Leggo parametri di stampa del registro TString16 config; @@ -1843,17 +1831,19 @@ void CG3400_application::init_print() else _stampa_width = 198; +/* Guy: sarebbe interessante ma non funziona mai! // Solo se _pagina_da diversa da 0 if (_pagina_da) - printer().set_from_page (_pagina_da - _pagine_stampate); - + printer().set_from_page(_pagina_da - _pagine_stampate); +*/ + // la stampa precedente era andata male // if (_stampa_ok != -1) set_page_number (_stampa_ok); _last_header = set_headers(); } -void CG3400_application::init_totals() +void TStampa_giornale::init_totals() { _tot_dare_gg_ap = ZERO; _tot_avere_gg_ap = ZERO; @@ -1875,7 +1865,7 @@ void CG3400_application::init_totals() } } -bool CG3400_application::init_cursor() +bool TStampa_giornale::init_cursor() { bool gia_stampati = FALSE; @@ -1887,7 +1877,6 @@ bool CG3400_application::init_cursor() _cur->setregion(da, a); _cur->set_filterfunction(filter_func); - _cur->setfilter(_stampa_definitiva ? "STAMPATO!=\"X\"" : ""); (*_cur) = 0L; @@ -1901,7 +1890,7 @@ bool CG3400_application::init_cursor() return TRUE; } -bool CG3400_application::set_print(int) +bool TStampa_giornale::set_print(int) { TMask ma ("cg3400a"); KEY tasto; @@ -1981,7 +1970,7 @@ bool CG3400_application::set_print(int) int cg3400 (int argc, char * argv[]) { - CG3400_application app; + TStampa_giornale app; app.run(argc, argv, "Stampa libro giornale"); return TRUE; }