2010-06-30 14:37:33 +00:00
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <automask.h>
|
|
|
|
|
#include <defmask.h>
|
|
|
|
|
#include <recset.h>
|
|
|
|
|
#include <sheet.h>
|
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
|
|
#include <doc.h>
|
|
|
|
|
|
|
|
|
|
#include "ci0.h"
|
|
|
|
|
#include "cilib.h"
|
|
|
|
|
#include "ci0500a.h"
|
|
|
|
|
#include "../ve/velib.h"
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////
|
|
|
|
|
//// CLASSE TDISP_RISOATT_MSK ////
|
|
|
|
|
////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
//Classe TDisp_risoatt_msk
|
|
|
|
|
class TDisp_risoatt_msk : public TAutomask
|
|
|
|
|
{
|
|
|
|
|
int _preventivo;
|
|
|
|
|
int _consuntivo;
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
|
2010-08-05 15:02:18 +00:00
|
|
|
|
const TString& add_field_to_tab_filter(const short id, int len = 0, const char* empty_value = "");
|
|
|
|
|
const TString& add_field_to_tab_key(TToken_string& row, const short id, int len = 0);
|
2010-06-30 14:37:33 +00:00
|
|
|
|
void riempi_sheet();
|
|
|
|
|
void nuova_riga();
|
|
|
|
|
void azzera_riga(TSheet_field& sheet);
|
|
|
|
|
void azzera_tutto(TSheet_field& sheet);
|
|
|
|
|
void registra();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void esegui() const;
|
|
|
|
|
TDisp_risoatt_msk();
|
|
|
|
|
};
|
|
|
|
|
|
2010-08-05 15:02:18 +00:00
|
|
|
|
//ADD_FIELD_TO_TAB_FILTER: aggiunge un campo al filtro
|
|
|
|
|
const TString& TDisp_risoatt_msk::add_field_to_tab_filter(const short id, int len, const char* empty_value)
|
2010-07-29 22:50:40 +00:00
|
|
|
|
{
|
|
|
|
|
if (len <= 0)
|
|
|
|
|
len = field(id).size();
|
2010-08-05 15:02:18 +00:00
|
|
|
|
|
|
|
|
|
TString& val = get_tmp_string();
|
2010-07-29 22:50:40 +00:00
|
|
|
|
|
|
|
|
|
val = get(id);
|
|
|
|
|
if (val == empty_value)
|
|
|
|
|
val.fill('?', len);
|
|
|
|
|
else
|
|
|
|
|
val.left_just(len);
|
2010-08-05 15:02:18 +00:00
|
|
|
|
|
|
|
|
|
return val;
|
2010-07-29 22:50:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-05 15:02:18 +00:00
|
|
|
|
const TString& TDisp_risoatt_msk::add_field_to_tab_key(TToken_string& row, const short id, int len)
|
2010-07-29 22:50:40 +00:00
|
|
|
|
{
|
2010-08-05 15:02:18 +00:00
|
|
|
|
TSheet_field& sh = sfield(F_SHEET);
|
2010-07-29 22:50:40 +00:00
|
|
|
|
|
|
|
|
|
if (len <= 0)
|
|
|
|
|
len = sh.sheet_mask().field(id).size();
|
|
|
|
|
|
2010-08-05 15:02:18 +00:00
|
|
|
|
TString& val = get_tmp_string();
|
2010-07-29 22:50:40 +00:00
|
|
|
|
|
|
|
|
|
val = row.get(sh.cid2index(id));
|
2010-08-05 15:02:18 +00:00
|
|
|
|
val.left_just(len);
|
|
|
|
|
return val;
|
2010-07-29 22:50:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-30 14:37:33 +00:00
|
|
|
|
//RIEMPI_SHEET: metodo che riempie lo sheet in base ai campi chiave
|
|
|
|
|
//compilati sulla maschera
|
|
|
|
|
void TDisp_risoatt_msk::riempi_sheet()
|
|
|
|
|
{
|
2010-07-29 22:50:40 +00:00
|
|
|
|
TString filtro;
|
|
|
|
|
char risoatt = get(F_RISOATT)[0];
|
2010-06-30 14:37:33 +00:00
|
|
|
|
|
|
|
|
|
//guardo il tipo risorsa / attrezzatura che sto ricercando (se Tutti setto a '?')
|
2010-08-05 15:02:18 +00:00
|
|
|
|
filtro << add_field_to_tab_filter(F_RISOATT, 1, "T");
|
2010-06-30 14:37:33 +00:00
|
|
|
|
//leggo il codice corretto a seconda del tipo selezionato (se vuoto setto a 16 caratteri '?')
|
2010-07-29 22:50:40 +00:00
|
|
|
|
switch(risoatt)
|
2010-06-30 14:37:33 +00:00
|
|
|
|
{
|
2010-08-05 15:02:18 +00:00
|
|
|
|
case 'T': filtro << add_field_to_tab_filter(F_CODICE); break;
|
|
|
|
|
case 'R': filtro << add_field_to_tab_filter(F_CODRIS); break;
|
|
|
|
|
case 'A': filtro << add_field_to_tab_filter(F_CODATT); break;
|
|
|
|
|
default : break;
|
2010-06-30 14:37:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-05 15:02:18 +00:00
|
|
|
|
filtro << add_field_to_tab_filter(F_ANNO);
|
2010-06-30 14:37:33 +00:00
|
|
|
|
//leggo il mese (se vuoto setto a '??')
|
2010-08-05 15:02:18 +00:00
|
|
|
|
filtro << add_field_to_tab_filter(F_MESE, 2);
|
2010-06-30 14:37:33 +00:00
|
|
|
|
|
|
|
|
|
//leggo il tipo ora (se vuoto setto a '??')
|
2010-08-05 15:02:18 +00:00
|
|
|
|
filtro << add_field_to_tab_filter(F_TPORA);
|
2010-06-30 14:37:33 +00:00
|
|
|
|
|
|
|
|
|
TString query;
|
2010-07-29 22:50:40 +00:00
|
|
|
|
|
|
|
|
|
query << "USE &DRA\n";
|
|
|
|
|
if (filtro.full())
|
|
|
|
|
query << "SELECT CODTAB?=\"" << filtro << "\"";
|
|
|
|
|
if(risoatt != 'T')
|
2010-06-30 14:37:33 +00:00
|
|
|
|
{
|
|
|
|
|
query << "\n"
|
|
|
|
|
<< "FROM CODTAB=" << risoatt << "\n"
|
|
|
|
|
<< "TO CODTAB=" << risoatt << "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TISAM_recordset dra(query);
|
|
|
|
|
|
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
|
|
|
|
sheet.destroy();
|
|
|
|
|
|
|
|
|
|
//riempio lo sheet con i dati che soddisfano il filtro preparato prima
|
|
|
|
|
for(bool ok = dra.move_first(); ok; ok = dra.move_next())
|
|
|
|
|
{
|
|
|
|
|
TDisp_risoatt disp(dra.cursor()->curr());
|
|
|
|
|
TRisoatt_key drakey(disp.chiave());
|
|
|
|
|
TToken_string& riga = sheet.row(-1);
|
|
|
|
|
riga.add(drakey.tipo(), sheet.cid2index(S_RISOATT));
|
|
|
|
|
TString16 cod = drakey.cod();
|
|
|
|
|
cod.trim();
|
|
|
|
|
switch(drakey.tipo())
|
|
|
|
|
{
|
|
|
|
|
case 'A': riga.add(cod, sheet.cid2index(S_CODATT)); break;
|
|
|
|
|
case 'R': riga.add(cod, sheet.cid2index(S_CODRIS)); break;
|
|
|
|
|
default : break;
|
|
|
|
|
}
|
|
|
|
|
riga.add(drakey.anno(), sheet.cid2index(S_ANNO));
|
|
|
|
|
riga.add(drakey.mese(), sheet.cid2index(S_MESE));
|
|
|
|
|
riga.add(drakey.tpora(), sheet.cid2index(S_TPORA));
|
|
|
|
|
riga.add(disp.ore_prev(), sheet.cid2index(S_OREPREV));
|
|
|
|
|
riga.add(disp.ore_cons(), sheet.cid2index(S_ORECONS));
|
|
|
|
|
sheet.check_row(sheet.items() - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sheet.force_update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//NUOVA_RIGA: metodo che aggiunge una riga allo sheet
|
|
|
|
|
//tenendo conto dei campi chiave compilati in testata
|
|
|
|
|
void TDisp_risoatt_msk::nuova_riga()
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
2010-08-05 15:02:18 +00:00
|
|
|
|
TToken_string& riga = sheet.row(-1);
|
2010-07-30 13:39:55 +00:00
|
|
|
|
const int r = sheet.items() - 1;
|
|
|
|
|
sheet.select(r);
|
2010-06-30 14:37:33 +00:00
|
|
|
|
TMask& msk = sheet.sheet_mask();
|
2010-07-30 13:39:55 +00:00
|
|
|
|
const bool tutti = get(F_RISOATT)[0] == 'T';
|
|
|
|
|
const TString4 tipo = tutti ? "R" : get(F_RISOATT);
|
|
|
|
|
int mese = get_int(F_MESE);
|
|
|
|
|
int anno = get_int(F_ANNO);
|
|
|
|
|
TString tpora = get(F_TPORA);
|
|
|
|
|
|
|
|
|
|
riga.add(tipo, sheet.cid2index(S_RISOATT));
|
|
|
|
|
if (!tutti)
|
|
|
|
|
{
|
|
|
|
|
if (tipo == "R")
|
|
|
|
|
riga.add(get(F_CODRIS), sheet.cid2index(S_CODRIS));
|
|
|
|
|
else
|
|
|
|
|
riga.add(get(F_CODATT), sheet.cid2index(S_CODATT));
|
|
|
|
|
}
|
|
|
|
|
riga.add(anno, sheet.cid2index(S_ANNO));
|
|
|
|
|
riga.add(mese, sheet.cid2index(S_MESE));
|
|
|
|
|
riga.add(tpora, sheet.cid2index(S_TPORA));
|
|
|
|
|
sheet.update_mask(r);
|
|
|
|
|
msk.enable(S_RISOATT, tutti);
|
|
|
|
|
if (tutti || tipo == "R")
|
|
|
|
|
msk.enable(S_CODRIS);
|
|
|
|
|
if (tutti || tipo == "A")
|
|
|
|
|
msk.enable(S_CODATT);
|
|
|
|
|
msk.enable(S_ANNO, anno == 0);
|
|
|
|
|
msk.enable(S_MESE, mese == 0);
|
|
|
|
|
msk.enable(S_TPORA, tpora.empty());
|
2010-06-30 14:37:33 +00:00
|
|
|
|
//lancio la maschera di riga da compilare
|
2010-09-21 14:36:08 +00:00
|
|
|
|
if (msk.run() == K_ENTER && (msk.get_int(S_OREPREV) > 0 || msk.get_int(S_ORECONS) > 0))
|
|
|
|
|
sheet.update_row(r);
|
|
|
|
|
else
|
|
|
|
|
sheet.destroy(r);
|
2010-06-30 14:37:33 +00:00
|
|
|
|
msk.enable_default();
|
|
|
|
|
sheet.force_update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//AZZERA_RIGA: metodo che azzera il valore unitario della riga selezionata
|
|
|
|
|
//(N.B.: le righe con valore unitario nullo verranno eliminate in fase di registrazione)
|
|
|
|
|
void TDisp_risoatt_msk::azzera_riga(TSheet_field& sheet)
|
|
|
|
|
{
|
|
|
|
|
const int nriga = sheet.selected();
|
|
|
|
|
TToken_string& row = sheet.row(nriga);
|
|
|
|
|
|
|
|
|
|
row.add(0, sheet.cid2index(S_OREPREV));
|
|
|
|
|
row.add(0, sheet.cid2index(S_ORECONS));
|
|
|
|
|
|
|
|
|
|
TMask& msk = sheet.sheet_mask();
|
|
|
|
|
_preventivo = msk.get_int(S_OREPREV);
|
|
|
|
|
_consuntivo = msk.get_int(S_ORECONS);
|
|
|
|
|
msk.set(S_OREPREV, 0L);
|
|
|
|
|
msk.set(S_ORECONS, 0L);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//AZZERA_TUTTO: metodo che azzera il valore unitario di tutte le righe visualizzate sullo sheet
|
|
|
|
|
//(N.B.: le righe con valore unitario nullo verranno eliminate in fase di registrazione)
|
|
|
|
|
void TDisp_risoatt_msk::azzera_tutto(TSheet_field& sheet)
|
|
|
|
|
{
|
|
|
|
|
FOR_EACH_SHEET_ROW(sheet, r, row)
|
|
|
|
|
{
|
|
|
|
|
TToken_string& row = sheet.row(r);
|
|
|
|
|
row.add(0, sheet.cid2index(S_OREPREV));
|
|
|
|
|
row.add(0, sheet.cid2index(S_ORECONS));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//REGISTRA: metodo che salva nella tabella di modulo le
|
|
|
|
|
//righe dello sheet che hanno valore > 0, ed elimina quelle che hanno
|
|
|
|
|
//vaoler pari a zero, e poi ricarica lo sheet
|
|
|
|
|
void TDisp_risoatt_msk::registra()
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile tabmod(LF_TABMOD);
|
|
|
|
|
TModule_table tab("&DRA");
|
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
2010-07-29 22:50:40 +00:00
|
|
|
|
TString80 chiave;
|
2010-06-30 14:37:33 +00:00
|
|
|
|
|
|
|
|
|
FOR_EACH_SHEET_ROW(sheet, r, row)
|
|
|
|
|
{
|
2010-07-29 22:50:40 +00:00
|
|
|
|
chiave.cut(0);
|
2010-06-30 14:37:33 +00:00
|
|
|
|
TToken_string& riga = *(TToken_string*)row;
|
2010-08-05 15:02:18 +00:00
|
|
|
|
|
|
|
|
|
const TString4 tipo = add_field_to_tab_key(riga, S_RISOATT, 1);
|
|
|
|
|
chiave << tipo;
|
|
|
|
|
chiave << add_field_to_tab_key(riga, tipo[0] == 'R' ? S_CODRIS : S_CODATT);
|
|
|
|
|
|
|
|
|
|
TString8 anme; anme << add_field_to_tab_key(riga, S_ANNO) << add_field_to_tab_key(riga, S_MESE, 2);
|
|
|
|
|
chiave << anme;
|
|
|
|
|
chiave << add_field_to_tab_key(riga, S_TPORA);
|
|
|
|
|
const TString80 descr = tipo[0] == 'R' ? riga.get(sheet.cid2index(S_DESRIS)) : riga.get(sheet.cid2index(S_DESATT));
|
2010-06-30 14:37:33 +00:00
|
|
|
|
const int oreprev = riga.get_int(sheet.cid2index(S_OREPREV));
|
|
|
|
|
const int orecons = riga.get_int(sheet.cid2index(S_ORECONS));
|
|
|
|
|
|
|
|
|
|
tab.put("CODTAB", chiave);
|
|
|
|
|
int err = tab.read();
|
|
|
|
|
|
|
|
|
|
if(err == NOERR)
|
|
|
|
|
{
|
|
|
|
|
if(oreprev == 0 && orecons == 0)
|
|
|
|
|
tab.remove();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tab.put("I0", oreprev);
|
|
|
|
|
tab.put("I1", orecons);
|
|
|
|
|
tab.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tab.put("CODTAB", chiave);
|
|
|
|
|
tab.put("S0", descr);
|
|
|
|
|
tab.put("I0", oreprev);
|
|
|
|
|
tab.put("I1", orecons);
|
|
|
|
|
tab.write();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
riempi_sheet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ON_FIELD_EVENT: metodo che gestisce gli eventi sui vari campi della maschera
|
|
|
|
|
bool TDisp_risoatt_msk::on_field_event(TOperable_field& f, TField_event e, long jolly)
|
|
|
|
|
{
|
|
|
|
|
switch (f.dlg())
|
|
|
|
|
{
|
2010-07-29 00:26:58 +00:00
|
|
|
|
case DLG_CERCA:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
riempi_sheet();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
case DLG_NEWREC:
|
2010-06-30 14:37:33 +00:00
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
nuova_riga();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
case DLG_SAVEREC:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
registra();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DLG_RESET:
|
|
|
|
|
if(e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
|
|
|
|
switch(jolly)
|
|
|
|
|
{
|
|
|
|
|
case 0: azzera_tutto(sheet); break;
|
|
|
|
|
case 1: azzera_riga(sheet); break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
sheet.force_update();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DLG_CANCEL:
|
|
|
|
|
if(e == fe_button && jolly == 1)
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
|
|
|
|
TMask& msk = sheet.sheet_mask();
|
|
|
|
|
const int oreprev = msk.get_int(S_OREPREV);
|
|
|
|
|
const int orecons = msk.get_int(S_ORECONS);
|
|
|
|
|
|
|
|
|
|
if(sheet.selected() == sheet.items() - 1)
|
|
|
|
|
{
|
|
|
|
|
sheet.destroy(sheet.items() - 1);
|
|
|
|
|
sheet.force_update();
|
|
|
|
|
}
|
|
|
|
|
else if(_preventivo > 0 && _consuntivo > 0)
|
|
|
|
|
{
|
|
|
|
|
TToken_string& row = sheet.row(sheet.selected());
|
|
|
|
|
row.add(_preventivo, sheet.cid2index(S_OREPREV));
|
|
|
|
|
row.add(_consuntivo, sheet.cid2index(S_ORECONS));
|
|
|
|
|
_preventivo = 0;
|
|
|
|
|
_consuntivo = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case F_ANNO:
|
|
|
|
|
case F_MESE:
|
|
|
|
|
case F_RISOATT:
|
|
|
|
|
case F_CODICE:
|
|
|
|
|
case F_CODRIS:
|
|
|
|
|
case F_CODATT:
|
|
|
|
|
case F_TPORA:
|
2010-07-29 22:50:40 +00:00
|
|
|
|
if (e == fe_modify)
|
2010-06-30 14:37:33 +00:00
|
|
|
|
riempi_sheet();
|
|
|
|
|
break;
|
|
|
|
|
case F_SHEET:
|
|
|
|
|
if (e == se_query_add)
|
|
|
|
|
{
|
|
|
|
|
send_key(K_SPACE, DLG_NEWREC);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TDisp_risoatt_msk::esegui() const
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDisp_risoatt_msk::TDisp_risoatt_msk()
|
|
|
|
|
: TAutomask("ci0500a")
|
|
|
|
|
{
|
|
|
|
|
_preventivo = 0;
|
|
|
|
|
_consuntivo = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////
|
|
|
|
|
//// CLASSE TDisp_risoatt_APP ////
|
|
|
|
|
////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
//classe TDisp_risoatt_app
|
|
|
|
|
class TDisp_risoatt_app : public TSkeleton_application
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual void main_loop();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void TDisp_risoatt_app::main_loop()
|
|
|
|
|
{
|
|
|
|
|
TDisp_risoatt_msk msk;
|
|
|
|
|
while (msk.run() != K_QUIT)
|
|
|
|
|
msk.esegui();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ci0500(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
TDisp_risoatt_app a;
|
2010-07-29 22:50:40 +00:00
|
|
|
|
a.run (argc, argv, TR("Disponibilit<EFBFBD>"));
|
2010-06-30 14:37:33 +00:00
|
|
|
|
return TRUE;
|
2010-07-29 22:50:40 +00:00
|
|
|
|
}
|