From d213fb20d1f6951ea68405e11b0ff6dd505a68e8 Mon Sep 17 00:00:00 2001 From: villa Date: Tue, 31 Jan 1995 10:34:23 +0000 Subject: [PATCH] Ripristino liquidazione git-svn-id: svn://10.65.10.50/trunk@937 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg5600.cpp | 298 +++++++++++++++++++++++++++++++++++++++++++++++++ cg/cg5600a.uml | 32 ++++++ 2 files changed, 330 insertions(+) create mode 100755 cg/cg5600.cpp create mode 100755 cg/cg5600a.uml diff --git a/cg/cg5600.cpp b/cg/cg5600.cpp new file mode 100755 index 000000000..2dd057404 --- /dev/null +++ b/cg/cg5600.cpp @@ -0,0 +1,298 @@ +#include +#include +#include +#include +#include +#include +#include + +#define F_YEAR 101 + + +// ripristino liquidazione +// dati anno e ditta scancella tutte +// le tabelle dimmerda +// piu' che altro serve alla Prassi +// per non far cazzate quando provano + +class TRipristino_liq : public TApplication +{ + long _firm; + TString _year; + TRelation* _nditte; + TArray_sheet* _ditte; + TArray _nomiditte; + + virtual bool create(); + bool menu(MENU_TAG) { return do_restore(); } + + // handuler + static bool ch_year_handler(TMask_field& f, KEY key); + +public: + + void build_ditte_sheet(); + void build_nomiditte(); + void set_year(const char* y) { _year = y; } + + bool do_restore(); + bool restore_firm(long firm); + + static TRipristino_liq& app() { return (TRipristino_liq&)main_app(); } + + TRipristino_liq() {} + virtual ~TRipristino_liq() {} +}; + +bool TRipristino_liq::ch_year_handler(TMask_field& f, KEY key) +{ + if (key == K_TAB && f.focusdirty()) + { + app().begin_wait(); + app().set_year(f.get()); + app().build_nomiditte(); + app().build_ditte_sheet(); + app().end_wait(); + } + return TRUE; +} + + +void TRipristino_liq::build_ditte_sheet() +{ + // build sheet + _ditte->destroy(); + for (int i = 0; i < _nomiditte.items(); i++) + { + TToken_string* d = new TToken_string(64); + *d = (TToken_string&)_nomiditte[i]; + const char vers = d->get_char(2); + + bool selectable = vers == '?'; + d->insert(" |", 0); + + const long pos = _ditte->add(d); + if (selectable) _ditte->disable(pos); + } +} + + +void TRipristino_liq::build_nomiditte() +{ + _nomiditte.destroy(); + // ricostruire _nomiditte e rifare build_ditte_sheet + TLocalisamfile& dt = _nditte->lfile(); + TString fr("??"); + + for (dt.first(); !dt.eof(); dt.next()) + { + // check no archivi + fr = "??"; + bool good = prefhndl->exist(dt.get_long("CODDITTA")); + + if (good) + { + // check no parametri liquidazione + TApplication::set_firm(dt.get_long("CODDITTA")); + TTable lia("LIA"); + lia.put("CODTAB", _year); + if (lia.read() != NOERR) good = FALSE; + else fr = lia.get("S7"); + } + + TToken_string* d = new TToken_string(64); + + // add record + d->add(dt.get("CODDITTA")); + d->add(dt.get("RAGSOC")); + d->add(fr); + + _nomiditte.add(d); + } + TApplication::set_firm(_firm); +} + + +bool TRipristino_liq::create() +{ + TApplication::create(); + _firm = get_firm(); + TDate oggi(TODAY); + _year.format("%d",oggi.year()); + _nditte = new TRelation(LF_NDITTE); + _ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Ditte", + "@1|Cod.@5|Ragione Sociale@50|Vers."); + build_nomiditte(); + build_ditte_sheet(); + + dispatch_e_menu(BAR_ITEM(1)); + return TRUE; +} + +bool TRipristino_liq::do_restore() +{ + KEY k; int i; + TMask m("cg5600a"); + + m.field(F_YEAR).set(_year); + m.set_handler(F_YEAR, ch_year_handler); + _ditte->enable_check(); + + while ((k = m.run()) != K_ESC) + { + if (k == K_QUIT) break; + switch(k) + { + case K_ENTER: + begin_wait(); + for(i = 0; i < _ditte->items(); i++) + { + if (_ditte->checked(i)) + { + TToken_string& rw = _ditte->row(i); + restore_firm(rw.get_long(1)); + } + } + end_wait(); + break; + case DLG_SELECT: + _ditte->run(); + break; + } + } + + set_firm(_firm); + return k != K_QUIT; +} + +bool TRipristino_liq::restore_firm(long firm) +{ + // azzera: campi progressivi in LIA e PLA + // cancella: tutti PPA, LIM, PIM, RMB, PLM, PTM + set_firm(firm); + + TTable lia("LIA"); + TTable pla("PLA"); + TTable pim("PIM"); + TTable plm("PLM"); + TTable ptm("PTM"); + TTable ppa("PPA"); + TTable rmb("RMB"); + TTable lim("LIM"); + + // LIA + for (lia.first(); !lia.eof(); lia.next()) + { + TString codtab(lia.get("CODTAB")); + + if (codtab.mid(0,4) == _year) + { + lia.put("R1",""); + lia.put("R2",""); + lia.put("R3",""); + lia.put("R4",""); + lia.put("R5",""); + lia.put("R6",""); + break; + } + } + lia.rewrite(); + + // PLA + for (pla.first(); !pla.eof(); pla.next()) + { + TString codtab(pla.get("CODTAB")); + + if (codtab.mid(0,4) == _year) + { + pla.put("R0",""); + pla.put("R1",""); + pla.put("R2",""); + pla.put("R3",""); + pla.put("R4",""); + pla.put("R9",""); + pla.put("R10",""); + pla.put("S1",""); + pla.put("S2",""); + pla.put("S3",""); + pla.put("S4",""); + } + } + pla.rewrite(); + + // PIM + for (pim.first(); !pim.eof(); pim.next()) + { + TString codtab(pim.get("CODTAB")); + + if (codtab.mid(0,4) == _year) + pim.remove(); + } + // pim.packfile(); + // pim.packindex(); + + // PLM + for (plm.first(); !plm.eof(); plm.next()) + { + TString codtab(plm.get("CODTAB")); + + if (codtab.mid(0,4) == _year) + plm.remove(); + } + // plm.packfile(); + // plm.packindex(); + + // PTM + for (ptm.first(); !ptm.eof(); ptm.next()) + { + TString codtab(ptm.get("CODTAB")); + + if (codtab.mid(0,4) == _year) + ptm.remove(); + } + // ptm.packfile(); + // ptm.packindex(); + + // PPA + for (ppa.first(); !ppa.eof(); ppa.next()) + { + TString codtab(ppa.get("CODTAB")); + + if (codtab.mid(0,4) == _year) + ppa.remove(); + } + // ppa.packfile(); + // ppa.packindex(); + + // RMB + for (rmb.first(); !rmb.eof(); rmb.next()) + { + TString codtab(rmb.get("CODTAB")); + + if (codtab.mid(0,4) == _year) + rmb.remove(); + } + // rmb.packfile(); + // rmb.packindex(); + + // LIM + for (lim.first(); !lim.eof(); lim.next()) + { + TString codtab(lim.get("CODTAB")); + + if (codtab.mid(0,4) == _year) + lim.remove(); + } + // lim.packfile(); + // lim.packindex(); + + return TRUE; +} + + +int cg5600(int argc, char* argv[]) +{ + TRipristino_liq app; + app.run(argc, argv, "Ripristino liquidazione"); + return 0; +} diff --git a/cg/cg5600a.uml b/cg/cg5600a.uml new file mode 100755 index 000000000..0af9ef11f --- /dev/null +++ b/cg/cg5600a.uml @@ -0,0 +1,32 @@ +/* + * Ripristino liquidazione + */ +#define F_YEAR 101 + +PAGE "Ripristino Liquidazione" -1 -1 64 4 +NUMBER F_YEAR 4 +BEGIN + PROMPT 16 1 "Anno liquidazione " + FLAGS "AR" +END + +BUTTON DLG_SELECT 9 2 +BEGIN + PROMPT -13 -1 "" + MESSAGE EXIT,DLG_SELECT +END + + +BUTTON DLG_OK 9 2 +BEGIN + PROMPT -23 -1 "" +END + +BUTTON DLG_QUIT 9 2 +BEGIN + PROMPT -33 -1 "" + MESSAGE EXIT,K_QUIT +END + +ENDPAGE +ENDMASK