5fde0436de
Nuovi dari per CU git-svn-id: svn://10.65.10.50/branches/R_10_00@23176 c028cbd2-c16b-5b4b-a496-9718f37d4682
229 lines
4.9 KiB
C++
Executable File
229 lines
4.9 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <tabutil.h>
|
|
#include <sheet.h>
|
|
#include <relation.h>
|
|
#include <recarray.h>
|
|
#include <urldefid.h>
|
|
#include <utility.h>
|
|
|
|
#include <nditte.h>
|
|
|
|
#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;
|
|
int _year;
|
|
TArray_sheet* _ditte;
|
|
TString_array _nomiditte;
|
|
|
|
virtual bool create();
|
|
virtual bool destroy();
|
|
|
|
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(int y) { _year = y; }
|
|
|
|
bool do_restore();
|
|
bool restore_firm(long firm);
|
|
void zero_cursor(const char * tablename);
|
|
|
|
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().set_year(atoi(f.get()));
|
|
app().build_nomiditte();
|
|
app().build_ditte_sheet();
|
|
}
|
|
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_row(pos);
|
|
}
|
|
}
|
|
|
|
|
|
void TRipristino_liq::build_nomiditte()
|
|
{
|
|
TString16 cod;
|
|
prefix().firms(_nomiditte);
|
|
FOR_EACH_ARRAY_ROW(_nomiditte, i, row)
|
|
{
|
|
const long firm = atol(*row);
|
|
row->add(cache().get(LF_NDITTE, firm).get(NDT_RAGSOC));
|
|
|
|
// check no parametri liquidazione
|
|
cod.format("%05ld%04d", firm, _year);
|
|
const TString& fr = cache().get("%LIA", cod, "S7");
|
|
row->add(fr.blank() ? "??" : fr);
|
|
}
|
|
TApplication::set_firm(_firm);
|
|
}
|
|
|
|
|
|
bool TRipristino_liq::create()
|
|
{
|
|
TApplication::create();
|
|
_firm = get_firm();
|
|
TDate oggi(TODAY);
|
|
_year = oggi.year();
|
|
_ditte = new TArray_sheet(-1, -1, 65, 20, TR("Selezione Ditte"),
|
|
HR("@1|Cod.@5|Ragione Sociale@50|Vers."));
|
|
build_nomiditte();
|
|
build_ditte_sheet();
|
|
|
|
dispatch_e_menu(BAR_ITEM_ID(1));
|
|
return true;
|
|
}
|
|
|
|
bool TRipristino_liq::destroy()
|
|
{
|
|
delete _ditte;
|
|
return TApplication::destroy();
|
|
}
|
|
|
|
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:
|
|
for(i = 0; i < _ditte->items(); i++) if (_ditte->checked(i))
|
|
{
|
|
TToken_string& rw = _ditte->row(i);
|
|
restore_firm(rw.get_long(1));
|
|
}
|
|
break;
|
|
case DLG_SELECT:
|
|
_ditte->run();
|
|
break;
|
|
}
|
|
}
|
|
|
|
set_firm(_firm);
|
|
return k != K_QUIT;
|
|
}
|
|
|
|
void TRipristino_liq::zero_cursor(const char * tablename)
|
|
{
|
|
TRelation rel(tablename);
|
|
TRectype& rec = rel.curr();
|
|
|
|
rec.put("CODTAB", _year);
|
|
|
|
TCursor cur(&rel, "", 1, &rec, &rec);
|
|
const TRecnotype items = cur.items();
|
|
|
|
cur.freeze();
|
|
for (cur = 0L; cur.pos() < items; ++cur)
|
|
rel.remove();
|
|
}
|
|
|
|
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");
|
|
TString cod;
|
|
|
|
cod.format("%05ld%04d", firm, _year);
|
|
lia.put("CODTAB", cod);
|
|
|
|
if (lia.read(_isequal, _lock) == NOERR)
|
|
{
|
|
lia.zero("R1");
|
|
lia.zero("R2");
|
|
lia.zero("R3");
|
|
lia.zero("R4");
|
|
lia.zero("R5");
|
|
lia.zero("R6");
|
|
lia.rewrite();
|
|
}
|
|
|
|
TRelation relpla("%PLA");
|
|
TRectype & pla = relpla.curr();
|
|
|
|
pla.put("CODTAB", cod);
|
|
|
|
TCursor cur(&relpla, "", 1, &pla, &pla);
|
|
const TRecnotype items = cur.items();
|
|
|
|
cur.freeze();
|
|
for (cur = 0L; cur.pos() < items; ++cur)
|
|
{
|
|
relpla.lfile().reread(_lock);
|
|
pla.zero("R0");
|
|
pla.zero("R1");
|
|
pla.zero("R2");
|
|
pla.zero("R3");
|
|
pla.zero("R4");
|
|
pla.zero("R9");
|
|
pla.zero("R10");
|
|
pla.zero("S1");
|
|
pla.zero("S2");
|
|
pla.zero("S3");
|
|
pla.zero("S4");
|
|
relpla.rewrite();
|
|
}
|
|
zero_cursor("PIM");
|
|
zero_cursor("PLM");
|
|
zero_cursor("PTM");
|
|
zero_cursor("PPA");
|
|
zero_cursor("RMB");
|
|
zero_cursor("LIM");
|
|
return true;
|
|
}
|
|
|
|
|
|
int cg5600(int argc, char* argv[])
|
|
{
|
|
TRipristino_liq app;
|
|
app.run(argc, argv, TR("Ripristino liquidazione"));
|
|
return 0;
|
|
}
|