Aggiunto programma e relativa maschera per il ripristino della stampa

degli indici del libro unico


git-svn-id: svn://10.65.10.50/trunk@1007 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-02-15 17:02:05 +00:00
parent 8e70389266
commit 6308e82c35
4 changed files with 242 additions and 88 deletions

View File

@ -26,7 +26,7 @@ enum pw { clienti = 1, fornitori = 2, both = 3 };
bool mask2_reset_fields(TMask_field& mf, KEY k); bool mask2_reset_fields(TMask_field& mf, KEY k);
class CG1200_App : public TPrintapp class TPrintclifo_app : public TPrintapp
{ {
friend bool mask2_reset_fields(TMask_field& mf, KEY k); friend bool mask2_reset_fields(TMask_field& mf, KEY k);
@ -81,7 +81,7 @@ public:
const char* descrizione_conto_ric(int,int,long); const char* descrizione_conto_ric(int,int,long);
const char* descrizione_allegato(char,long); const char* descrizione_allegato(char,long);
CG1200_App() : TPrintapp(),_piva(18), _cpercip(10), _fax(50), _telex(50), TPrintclifo_app() : TPrintapp(),_piva(18), _cpercip(10), _fax(50), _telex(50),
_name(60), _telefono(90), _indir(70), _localita(90) _name(60), _telefono(90), _indir(70), _localita(90)
{ {
_rel = NULL; _pr_type = undefined; _startrow = 2; _startcol = 3; _rel = NULL; _pr_type = undefined; _startrow = 2; _startcol = 3;
@ -97,18 +97,18 @@ public:
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
void CG1200_App::process_link(int id, const char* txt) void TPrintclifo_app::process_link(int id, const char* txt)
{ {
TString ss = "1|"; TString ss = "1|";
ss << txt; ss << txt;
TMessage fs(cmd2name("cg0","-1"), MSG_LN, ss); TMessage fs("cg0 -1", MSG_LN, ss);
TMailbox m; TMailbox m;
m.send(fs); m.send(fs);
TExternal_app cg0("cg0 -1"); TExternal_app cg0("cg0 -1");
if (cg0.run()) beep(); if (cg0.run()) beep();
} }
const char* CG1200_App::look_tab(const char* tabname, TString& cod, const char* TPrintclifo_app::look_tab(const char* tabname, TString& cod,
const char* fld) const char* fld)
{ {
TTable tab(tabname); TTable tab(tabname);
@ -119,7 +119,7 @@ const char* CG1200_App::look_tab(const char* tabname, TString& cod,
return tab.curr().get(fld); return tab.curr().get(fld);
} }
const char* CG1200_App::descrizione_conto_ric(int gruppo, int conto, long sottoc) const char* TPrintclifo_app::descrizione_conto_ric(int gruppo, int conto, long sottoc)
{ {
TLocalisamfile pconti(LF_PCON, FALSE); TLocalisamfile pconti(LF_PCON, FALSE);
@ -136,7 +136,7 @@ const char* CG1200_App::descrizione_conto_ric(int gruppo, int conto, long sottoc
return tmp; return tmp;
} }
const char* CG1200_App::descrizione_allegato(char tipocf,long cod) const char* TPrintclifo_app::descrizione_allegato(char tipocf,long cod)
{ {
TLocalisamfile clifo(LF_CLIFO, FALSE); TLocalisamfile clifo(LF_CLIFO, FALSE);
@ -153,7 +153,7 @@ const char* CG1200_App::descrizione_allegato(char tipocf,long cod)
return tmp; return tmp;
} }
bool CG1200_App::preprocess_page(int file, int counter) bool TPrintclifo_app::preprocess_page(int file, int counter)
{ {
TString s; TString s;
int g_ric,c_ric; int g_ric,c_ric;
@ -288,7 +288,7 @@ default:
return TRUE; return TRUE;
} }
print_action CG1200_App::postprocess_print(int file, int counter) print_action TPrintclifo_app::postprocess_print(int file, int counter)
{ {
/* /*
static bool more = FALSE; static bool more = FALSE;
@ -341,7 +341,7 @@ bool mask_ctrl_handler(TMask_field& mf, KEY k)
// set printrows // set printrows
void CG1200_App::set_page(int file, int counter) void TPrintclifo_app::set_page(int file, int counter)
{ {
switch(_pr_type) switch(_pr_type)
{ {
@ -364,7 +364,7 @@ void CG1200_App::set_page(int file, int counter)
} }
} }
void CG1200_App::ultimo_codice(char tipocf) void TPrintclifo_app::ultimo_codice(char tipocf)
{ {
TLocalisamfile clifo(LF_CLIFO,FALSE); TLocalisamfile clifo(LF_CLIFO,FALSE);
@ -384,7 +384,7 @@ void CG1200_App::ultimo_codice(char tipocf)
} }
} }
const char* CG1200_App::compatta_ragsoc(TString& ragsoc,char tipoa) const char* TPrintclifo_app::compatta_ragsoc(TString& ragsoc,char tipoa)
{ {
if (tipoa == 'F') if (tipoa == 'F')
{ {
@ -402,7 +402,7 @@ const char* CG1200_App::compatta_ragsoc(TString& ragsoc,char tipoa)
return tmp; return tmp;
} }
void CG1200_App::preprocess_header() void TPrintclifo_app::preprocess_header()
{ {
switch(_pr_type) switch(_pr_type)
{ {
@ -417,7 +417,7 @@ void CG1200_App::preprocess_header()
} }
} }
void CG1200_App::header_elenco() void TPrintclifo_app::header_elenco()
{ {
reset_header(); reset_header();
// intestazione // intestazione
@ -494,7 +494,7 @@ void CG1200_App::header_elenco()
set_header(j, (const char *)(TString(132).fill('-'))); set_header(j, (const char *)(TString(132).fill('-')));
} }
void CG1200_App::header_rubriche() void TPrintclifo_app::header_rubriche()
{ {
reset_header(); reset_header();
// intestazione // intestazione
@ -567,7 +567,7 @@ void CG1200_App::header_rubriche()
set_header(j++, (const char *)(TString(132).fill('-'))); set_header(j++, (const char *)(TString(132).fill('-')));
} }
void CG1200_App::set_elenco() void TPrintclifo_app::set_elenco()
{ {
// body // body
set_row(1,"$[r]@1s$[n] $[r]@pn$[n] #t", FLD(LF_CLIFO, CLI_TIPOCF), set_row(1,"$[r]@1s$[n] $[r]@pn$[n] #t", FLD(LF_CLIFO, CLI_TIPOCF),
@ -586,7 +586,7 @@ void CG1200_App::set_elenco()
set_row(i+5,""); set_row(i+5,"");
} }
void CG1200_App::set_rubriche() void TPrintclifo_app::set_rubriche()
{ {
// body // body
set_row(1,"$[r]@1s$[n] $[r]@pn$[n] #t", FLD(LF_CLIFO,CLI_TIPOCF), set_row(1,"$[r]@1s$[n] $[r]@pn$[n] #t", FLD(LF_CLIFO,CLI_TIPOCF),
@ -603,7 +603,7 @@ bool mask2_reset_fields(TMask_field& mf, KEY k)
{ {
if (k == K_SPACE) if (k == K_SPACE)
{ {
CG1200_App& a = (CG1200_App&)main_app(); TPrintclifo_app& a = (TPrintclifo_app&)main_app();
TMask& m = mf.mask(); TMask& m = mf.mask();
m.set(FLD_CGB_STARTROW, a._startrow); m.set(FLD_CGB_STARTROW, a._startrow);
m.set(FLD_CGB_STARTCOL, a._startcol); m.set(FLD_CGB_STARTCOL, a._startcol);
@ -613,7 +613,7 @@ bool mask2_reset_fields(TMask_field& mf, KEY k)
return TRUE; return TRUE;
} }
void CG1200_App::set_etichette() void TPrintclifo_app::set_etichette()
{ {
int r=_startrow; int r=_startrow;
TString loccf=get_field(LF_CLIFO,CLI_LOCCF); TString loccf=get_field(LF_CLIFO,CLI_LOCCF);
@ -638,7 +638,7 @@ void CG1200_App::set_etichette()
set_row(i,""); set_row(i,"");
} }
void CG1200_App::set_vendite(int f, int c) void TPrintclifo_app::set_vendite(int f, int c)
{ TString* rigs = new TString(132); { TString* rigs = new TString(132);
@ -767,7 +767,7 @@ void CG1200_App::set_vendite(int f, int c)
delete rigs; delete rigs;
} }
bool CG1200_App::set_print(int) bool TPrintclifo_app::set_print(int)
{ {
disable_links(); disable_links();
set_multiple_link(FALSE); set_multiple_link(FALSE);
@ -808,7 +808,8 @@ bool CG1200_App::set_print(int)
// set defaults // set defaults
mask2.run(); if (mask2.run() == K_ESC)
return FALSE;
_startrow = atoi(mask2.get(FLD_CGB_STARTROW)); _startrow = atoi(mask2.get(FLD_CGB_STARTROW));
_startcol = atoi(mask2.get(FLD_CGB_STARTCOL)); _startcol = atoi(mask2.get(FLD_CGB_STARTCOL));
@ -891,7 +892,7 @@ bool CG1200_App::set_print(int)
} }
bool CG1200_App::preprocess_print(int file, int counter) bool TPrintclifo_app::preprocess_print(int file, int counter)
{ {
reset_print(); reset_print();
if (_pr_type == undefined) if (_pr_type == undefined)
@ -904,7 +905,7 @@ bool CG1200_App::preprocess_print(int file, int counter)
return TRUE; return TRUE;
} }
bool CG1200_App::user_create() bool TPrintclifo_app::user_create()
{ {
// set relation and cursors // set relation and cursors
_rel = new TRelation(LF_CLIFO); _rel = new TRelation(LF_CLIFO);
@ -930,7 +931,7 @@ bool CG1200_App::user_create()
return TRUE; return TRUE;
} }
bool CG1200_App::user_destroy() bool TPrintclifo_app::user_destroy()
{ {
if (_rel) if (_rel)
delete _rel; delete _rel;
@ -941,7 +942,7 @@ bool CG1200_App::user_destroy()
int cg1200(int argc, char* argv[]) int cg1200(int argc, char* argv[])
{ {
CG1200_App app; TPrintclifo_app app;
app.run(argc, argv, "Stampa Clienti/Fornitori"); app.run(argc, argv, "Stampa Clienti/Fornitori");
return 0; return 0;
} }

View File

@ -15,14 +15,19 @@
class TRipristina_stampa : public TApplication class TRipristina_stampa : public TApplication
{ {
enum TOperation { restore_reg, restore_inl };
TOperation _op;
protected: // TApplication
virtual bool create() ; virtual bool create() ;
bool menu(MENU_TAG); virtual bool menu(MENU_TAG);
bool do_restore(long firm, const char * reg, int year, int month,
int day, bool giornale);
static bool firm_handler(TMask_field& f, KEY key);
public: public:
TRipristina_stampa() {} bool reg_restore(const TString& reg, int year, int month, int day, bool giornale);
bool inl_restore(const TString& lbu, int year, int month);
static bool firm_handler(TMask_field& f, KEY key);
TRipristina_stampa() : _op(restore_reg) {}
}; };
bool TRipristina_stampa::firm_handler(TMask_field& f, KEY key) bool TRipristina_stampa::firm_handler(TMask_field& f, KEY key)
@ -31,18 +36,14 @@ bool TRipristina_stampa::firm_handler(TMask_field& f, KEY 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 errato"); return f.error_box("Codice ditta errato");
else
if (firm == 0)
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 %ld non sono stati ancora generati", firm); return f.error_box("Gli archivi della ditta %ld non sono stati ancora generati", firm);
else else
{ {
main_app().set_firm(firm); main_app().set_firm(firm);
TMask_field& r = f.mask().field(F_REG); TMask_field& r = f.mask().field(F_REG);
r.set_dirty(); r.set_dirty();
r.on_key(K_TAB); r.on_key(K_TAB);
@ -51,26 +52,22 @@ bool TRipristina_stampa::firm_handler(TMask_field& f, KEY key)
return TRUE; return TRUE;
} }
bool TRipristina_stampa::do_restore(long firm, const char * regist, bool TRipristina_stampa::reg_restore(const TString& regist,
int year, int month, int day, int year, int month, int day,
bool giornale) bool giornale)
{ {
CHECK(firm > 0, "Non posso ripristinare sui dati comuni");
CHECKS(regist && *regist && strlen(regist) <= 3, "Registro errato ", regist);
CHECKD(month > 0 && month < 13, "Mese errato ", month); CHECKD(month > 0 && month < 13, "Mese errato ", month);
set_firm(firm);
bool ok = TRUE; bool ok = TRUE;
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; s.format("%04d%s", year, regist); TString16 s; s.format("%04d%s", year, (const char*)regist);
reg.zero(); reg.zero();
reg.put("CODTAB", s); reg.put("CODTAB", s);
TDate inizio_anno(1, 1, year); TDate inizio_anno(1, 1, year);
if (reg.read(_isequal, _lock) == NOERR) if (reg.read(_isequal, _lock) == NOERR)
{ {
@ -159,9 +156,56 @@ bool TRipristina_stampa::do_restore(long firm, const char * regist,
return ok; return ok;
} }
bool TRipristina_stampa::inl_restore(const TString& lib, int year, int month)
{
TLocalisamfile inl(LF_INDLIB);
inl.zero();
inl.put("ANNO", year);
inl.put("CODLIB", lib);
const TRectype filter(inl.curr());
bool ok = FALSE;
// Azzera il flag di stampato sugli indici con mese >= month
for (inl.read(_isgteq); inl.good() && inl.curr() == filter; inl.next())
if (inl.get_int("MESEREG") >= month && inl.get_bool("STAMPATO"))
{
inl.zero("STAMPATO");
ok = inl.rewrite() == NOERR;
if (!ok)
{
error_box("Errore di ripristino dell'indice %ld", inl.get_long("NUMREG"));
break;
}
}
if (ok) // Se e' stato ripristinato almeno un indice e non ci sono stati errori
{
TTable lbu("%LBU");
lbu.put("CODTAB", format("%4d%s", year, (const char*)lib));
ok = lbu.read() == NOERR;
if (ok)
{
TDate d(1, month, year); // Riporta la data di ultima stampa
lbu.put("D0", d);
ok = lbu.rewrite() == NOERR;
}
if (!ok)
error_box("Impossibile aggiornare il libro unico %s per l'anno %d", (const char*)lib, year);
}
return ok;
}
bool TRipristina_stampa::create() bool TRipristina_stampa::create()
{ {
TApplication::create(); TApplication::create();
if (argc() > 2 && stricmp(argv(2), "INL") == 0)
_op = restore_inl;
dispatch_e_menu(BAR_ITEM(1)); dispatch_e_menu(BAR_ITEM(1));
return TRUE; return TRUE;
} }
@ -169,14 +213,18 @@ bool TRipristina_stampa::create()
bool TRipristina_stampa::menu(MENU_TAG) bool TRipristina_stampa::menu(MENU_TAG)
{ {
TMask msk("cg5400a") ; TMask msk(_op == restore_inl ? "cg5400b" : "cg5400a") ;
msk.set_handler(F_FIRM, firm_handler); msk.set_handler(F_FIRM, firm_handler);
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;
bool giornale = FALSE;
if (_op == restore_reg)
giornale = msk.get_int(F_TIPO) == 5;
const int year = msk.get_int(giornale ? F_ESER : F_YEAR); const int year = msk.get_int(giornale ? F_ESER : F_YEAR);
const int month = msk.get_int(F_MESE); const int month = msk.get_int(F_MESE);
int day = giornale ? msk.get_int(F_DAY) : 1; int day = giornale ? msk.get_int(F_DAY) : 1;
@ -184,18 +232,30 @@ bool TRipristina_stampa::menu(MENU_TAG)
if (prefhndl->exist(firm)) if (prefhndl->exist(firm))
{ {
TString256 mess("Attenzione sara' ripristinata la stampa del registro "); TString256 mess("Attenzione ripristino della stampa de");
mess << reg << "\ndell'" << (giornale ? "esercizio " : "anno ") << year if (_op == restore_reg)
mess << (giornale ? "l giornale" : "l registro");
else
mess << "gli indici del libro ";
mess << ' ' << reg << "\ndell'" << (giornale ? "esercizio " : "anno ") << year
<< " della ditta " << firm << " dal " << day << '-' << month << '-' << year; << " della ditta " << firm << " dal " << day << '-' << month << '-' << year;
if (yesno_box((const char *) mess)) if (yesno_box(mess))
{ {
mess << "\nSi desidera veramente continuare?"; mess << "\nSi desidera veramente continuare?";
if (yesno_box((const char *) mess)) if (yesno_box(mess))
do_restore(firm, reg, year, month, day, giornale); {
switch (_op)
{
case restore_inl:
inl_restore(reg, year, month); break;
default:
reg_restore(reg, year, month, day, giornale); break;
} }
} }
else error_box("Gli archivi della ditta %d non sono stati ancora generati",firm); }
}
else error_box("Gli archivi della ditta %ld non sono stati ancora generati", firm);
msk.reset(); msk.reset();
} }
return FALSE; return FALSE;

View File

@ -30,9 +30,32 @@ BEGIN
WARNING "Ditta assente" WARNING "Ditta assente"
END END
NUMBER F_YEAR 4
BEGIN
PROMPT 4 3 "Anno "
FLAGS "AR"
CHECKTYPE REQUIRED
HELP "Anno IVA da cui ripristinare la stampa"
WARNING "L'anno deve essere specificato"
END
STRING F_ESER 4
BEGIN
PROMPT 4 3 "Esercizio "
USE ESC
INPUT CODTAB F_ESER
DISPLAY "Anno esercizio" CODTAB
DISPLAY "Data inizio esercizio" D0
DISPLAY "Data fine esercizio" D1
OUTPUT F_ESER CODTAB
CHECKTYPE REQUIRED
HELP "Esercizio da cui ripristinare la stampa"
WARNING "Esercizio assente"
END
STRING F_REG 3 STRING F_REG 3
BEGIN BEGIN
PROMPT 4 3 "Registro " PROMPT 4 5 "Registro "
FLAGS "UZ" FLAGS "UZ"
USE REG SELECT I0<6 USE REG SELECT I0<6
INPUT CODTAB[1,4] F_YEAR INPUT CODTAB[1,4] F_YEAR
@ -52,7 +75,7 @@ END
STRING F_DREG 50 STRING F_DREG 50
BEGIN BEGIN
PROMPT 22 3 "" PROMPT 22 5 ""
USE REG KEY 2 SELECT I0<6 USE REG KEY 2 SELECT I0<6
INPUT S0 F_DREG INPUT S0 F_DREG
DISPLAY "Descrizione @50" S0 DISPLAY "Descrizione @50" S0
@ -74,30 +97,6 @@ BEGIN
ITEM "5|Giornale" MESSAGE SHOW,F_ESER|HIDE,F_YEAR|SHOW,F_DAY ITEM "5|Giornale" MESSAGE SHOW,F_ESER|HIDE,F_YEAR|SHOW,F_DAY
END END
NUMBER F_YEAR 4
BEGIN
PROMPT 4 5 "Anno "
FLAGS "AR"
CHECKTYPE REQUIRED
HELP "Anno IVA da cui ripristinare la stampa"
WARNING "L' anno deve essere specificato"
END
STRING F_ESER 4
BEGIN
PROMPT 4 5 "Esercizio "
USE ESC
INPUT CODTAB F_ESER
DISPLAY "Anno esercizio" CODTAB
DISPLAY "Data inizio esercizio" D0
DISPLAY "Data fine esercizio" D1
OUTPUT F_ESER CODTAB
CHECKTYPE REQUIRED
HELP "Esercizio da cui ripristinare la stampa"
WARNING "Esercizio assente"
END
NUMBER F_DAY 2 NUMBER F_DAY 2
BEGIN BEGIN
PROMPT 4 6 "Giorno " PROMPT 4 6 "Giorno "

94
cg/cg5400b.uml Executable file
View File

@ -0,0 +1,94 @@
#include "cg5400.h"
PAGE "Ripristino stampa indici libro unico" -1 -1 78 11
NUMBER F_FIRM 5
BEGIN
PROMPT 4 1 "Ditta "
FLAGS "RF"
USE LF_NDITTE KEY 1
CHECKTYPE NORMAL
INPUT CODDITTA F_FIRM
DISPLAY "Codice" CODDITTA
DISPLAY "Ragione sociale @50" RAGSOC
OUTPUT F_FIRM CODDITTA
OUTPUT F_DFIRM RAGSOC
HELP "Codice della ditta da cui prelevare i dati"
WARNING "Ditta assente"
END
STRING F_DFIRM 50
BEGIN
PROMPT 22 1 ""
USE LF_NDITTE KEY 2
CHECKTYPE NORMAL
INPUT RAGSOC F_DFIRM
DISPLAY "Ragione sociale @50" RAGSOC
DISPLAY "Codice" CODDITTA
COPY OUTPUT F_FIRM
HELP "Ragione sociale della ditta da cui prelevare i dati"
WARNING "Ditta assente"
END
NUMBER F_YEAR 4
BEGIN
PROMPT 4 3 "Anno "
FLAGS "AR"
CHECKTYPE REQUIRED
HELP "Anno IVA"
WARNING "L'anno deve essere specificato"
END
STRING F_REG 3
BEGIN
PROMPT 4 5 "Libro unico "
FLAGS "UZ"
USE %LBU
INPUT CODTAB[1,4] F_YEAR
INPUT CODTAB[5,7] F_REG
DISPLAY "Anno" CODTAB[1,4]
DISPLAY "Codice" CODTAB[5,7]
DISPLAY "Descrizione @50" S0
OUTPUT F_YEAR CODTAB[1,4]
OUTPUT F_REG CODTAB[5,7]
OUTPUT F_DREG S0
CHECKTYPE REQUIRED
HELP "Codice del libro unico di cui ripristinare la stampa"
WARNING "Libro unico assente"
END
STRING F_DREG 50
BEGIN
PROMPT 22 5 ""
USE %LBU KEY 2
INPUT S0 F_DREG
DISPLAY "Descrizione @50" S0
DISPLAY "Anno" CODTAB[1,4]
DISPLAY "Codice" CODTAB[5,7]
COPY OUTPUT F_REG
CHECKTYPE NORMAL
HELP "Denominazione del libro di cui ripristinare la stampa"
WARNING "Libro unico assente"
END
LIST F_MESE 10
BEGIN
PROMPT 4 7 "Mese "
FLAGS "M"
HELP "Mese da cui ripristinare la stampa degli indici"
END
BUTTON DLG_OK 9 2
BEGIN
PROMPT -12 -1 ""
END
BUTTON DLG_QUIT 9 2
BEGIN
PROMPT -22 -1 ""
MESSAGE EXIT,K_QUIT
END
ENDPAGE
ENDMASK