2010-07-19 10:42:18 +00:00
|
|
|
#include <applicat.h>
|
|
|
|
#include <automask.h>
|
|
|
|
#include <defmask.h>
|
2010-07-29 00:26:58 +00:00
|
|
|
#include <lffiles.h>
|
2010-07-19 10:42:18 +00:00
|
|
|
#include <recset.h>
|
|
|
|
#include <sheet.h>
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
#include <doc.h>
|
|
|
|
|
|
|
|
#include "ci0.h"
|
|
|
|
#include "cilib.h"
|
|
|
|
#include "ci0600a.h"
|
2010-07-30 13:39:55 +00:00
|
|
|
#include "rilore.h"
|
|
|
|
#include "../ca/calib01.h"
|
2010-07-19 10:42:18 +00:00
|
|
|
#include "../ve/velib.h"
|
|
|
|
|
|
|
|
////////////////////////////////////////
|
|
|
|
//// CLASSE TDef_risoatt_msk ////
|
|
|
|
////////////////////////////////////////
|
|
|
|
|
|
|
|
//Classe TDef_risoatt_msk
|
|
|
|
class TDef_risoatt_msk : public TAutomask
|
|
|
|
{
|
2010-07-24 07:19:41 +00:00
|
|
|
int _qtaore;
|
2010-07-30 13:39:55 +00:00
|
|
|
short _cdc_sid, _cdc_lid;
|
|
|
|
short _cms_sid, _cms_lid;
|
|
|
|
short _fase_sid, _fase_lid;
|
|
|
|
short _scdc_sid, _scdc_lid;
|
|
|
|
short _scms_sid, _scms_lid;
|
|
|
|
short _sfase_sid, _sfase_lid;
|
|
|
|
|
2010-07-19 10:42:18 +00:00
|
|
|
protected:
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
2010-07-30 13:39:55 +00:00
|
|
|
void get_anal_fields(TString & cdc, TString & cms, TString & fase);
|
|
|
|
void get_row_anal_fields(TToken_string & row, TString & cdc, TString & cms, TString & fase);
|
2010-07-31 06:58:44 +00:00
|
|
|
void put_row_anal_fields(TToken_string & row, const TString & cdc, const TString & cms, const TString & fase);
|
2010-07-19 10:42:18 +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;
|
|
|
|
TDef_risoatt_msk();
|
|
|
|
};
|
|
|
|
|
2010-07-30 13:39:55 +00:00
|
|
|
void TDef_risoatt_msk::get_anal_fields(TString & cdc, TString & cms, TString & fase)
|
|
|
|
{
|
|
|
|
TString val;
|
|
|
|
|
|
|
|
cdc.cut(0);
|
|
|
|
if (_cdc_sid >= 0)
|
|
|
|
for ( short id = _cdc_sid; id <= _cdc_lid; id++)
|
|
|
|
{
|
|
|
|
val = get(id);
|
2010-07-31 06:58:44 +00:00
|
|
|
val.rpad(field(id).size());
|
2010-07-30 13:39:55 +00:00
|
|
|
cdc << val;
|
|
|
|
}
|
2010-07-31 06:58:44 +00:00
|
|
|
cdc.trim();
|
2010-07-30 13:39:55 +00:00
|
|
|
cms.cut(0);
|
|
|
|
if (_cms_sid >= 0)
|
|
|
|
for ( short id = _cms_sid; id <= _cms_lid; id++)
|
|
|
|
{
|
|
|
|
val = get(id);
|
2010-07-31 06:58:44 +00:00
|
|
|
val.rpad(field(id).size());
|
2010-07-30 13:39:55 +00:00
|
|
|
cms << val;
|
|
|
|
}
|
2010-07-31 06:58:44 +00:00
|
|
|
cms.trim();
|
2010-07-30 13:39:55 +00:00
|
|
|
fase.cut(0);
|
|
|
|
if (_fase_sid >= 0)
|
|
|
|
for ( short id = _fase_sid; id <= _fase_lid; id++)
|
|
|
|
{
|
|
|
|
val = get(id);
|
2010-07-31 06:58:44 +00:00
|
|
|
val.rpad(field(id).size());
|
2010-07-30 13:39:55 +00:00
|
|
|
fase << val;
|
|
|
|
}
|
2010-07-31 06:58:44 +00:00
|
|
|
fase.trim();
|
2010-07-30 13:39:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TDef_risoatt_msk::get_row_anal_fields(TToken_string & row, TString & cdc, TString & cms, TString & fase)
|
|
|
|
{
|
|
|
|
TMask & m = sfield(F_SHEET).sheet_mask();
|
|
|
|
TString val;
|
|
|
|
|
|
|
|
cdc.cut(0);
|
|
|
|
if (_scdc_sid >= 0)
|
|
|
|
for ( short id = _scdc_sid; id <= _scdc_lid; id++)
|
|
|
|
{
|
|
|
|
val = m.get(id);
|
2010-07-31 06:58:44 +00:00
|
|
|
val.rpad(m.field(id).size());
|
2010-07-30 13:39:55 +00:00
|
|
|
cdc << val;
|
|
|
|
}
|
2010-07-31 06:58:44 +00:00
|
|
|
cdc.trim();
|
2010-07-30 13:39:55 +00:00
|
|
|
cms.cut(0);
|
|
|
|
if (_scms_sid >= 0)
|
|
|
|
for ( short id = _scms_sid; id <= _scms_lid; id++)
|
|
|
|
{
|
|
|
|
val = m.get(id);
|
2010-07-31 06:58:44 +00:00
|
|
|
val.rpad(m.field(id).size());
|
2010-07-30 13:39:55 +00:00
|
|
|
cms << val;
|
|
|
|
}
|
2010-07-31 06:58:44 +00:00
|
|
|
cms.trim();
|
2010-07-30 13:39:55 +00:00
|
|
|
fase.cut(0);
|
|
|
|
if (_sfase_sid >= 0)
|
|
|
|
for ( short id = _sfase_sid; id <= _sfase_lid; id++)
|
|
|
|
{
|
|
|
|
val = m.get(id);
|
2010-07-31 06:58:44 +00:00
|
|
|
val.rpad(m.field(id).size());
|
2010-07-30 13:39:55 +00:00
|
|
|
fase << val;
|
|
|
|
}
|
2010-07-31 06:58:44 +00:00
|
|
|
fase.trim();
|
2010-07-30 13:39:55 +00:00
|
|
|
}
|
|
|
|
|
2010-07-31 06:58:44 +00:00
|
|
|
void TDef_risoatt_msk::put_row_anal_fields(TToken_string & row, const TString & cdc, const TString & cms, const TString & fase)
|
2010-07-30 13:39:55 +00:00
|
|
|
{
|
|
|
|
TSheet_field & s = sfield(F_SHEET);
|
|
|
|
TMask & m = s.sheet_mask();
|
|
|
|
int pos = 0;
|
|
|
|
|
|
|
|
if (_scdc_sid >= 0)
|
|
|
|
for (short id = _scdc_sid; id <= _scdc_lid; id++)
|
|
|
|
{
|
|
|
|
const int len = m.field(id).size();
|
|
|
|
row.add(cdc.mid(pos, len), s.cid2index(id));
|
|
|
|
pos += len;
|
|
|
|
}
|
|
|
|
pos = 0;
|
|
|
|
if (_scms_sid >= 0)
|
|
|
|
for (short id = _scms_sid; id <= _scms_lid; id++)
|
|
|
|
{
|
|
|
|
const int len = m.field(id).size();
|
|
|
|
row.add(cms.mid(pos, len), s.cid2index(id));
|
|
|
|
pos += len;
|
|
|
|
}
|
|
|
|
pos = 0;
|
|
|
|
if (_sfase_sid >= 0)
|
|
|
|
for (short id = _sfase_sid; id <= _sfase_lid; id++)
|
|
|
|
{
|
|
|
|
const int len = m.field(id).size();
|
|
|
|
row.add(fase.mid(pos, len), s.cid2index(id));
|
|
|
|
pos += len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-19 10:42:18 +00:00
|
|
|
//RIEMPI_SHEET: metodo che riempie lo sheet in base ai campi chiave
|
|
|
|
//compilati sulla maschera
|
|
|
|
void TDef_risoatt_msk::riempi_sheet()
|
|
|
|
{
|
2010-07-24 07:19:41 +00:00
|
|
|
//leggo dalla maschera i campi chiave di ricerca
|
|
|
|
const TString4 anno = get(F_ANNO);
|
|
|
|
const TString4 risoatt = get(F_RISOATT) == "T" ? "" : get(F_RISOATT);
|
|
|
|
const TString4 mese = get(F_MESE);
|
|
|
|
const TString4 tpora = get(F_TPORA);
|
2010-07-30 13:39:55 +00:00
|
|
|
TString80 codcosto;
|
|
|
|
TString80 codcms;
|
|
|
|
TString16 codfase;
|
2010-07-19 10:42:18 +00:00
|
|
|
TString16 codice;
|
|
|
|
switch(get(F_RISOATT)[0])
|
|
|
|
{
|
2010-07-24 07:19:41 +00:00
|
|
|
case 'T': codice = get(F_CODICE); break;
|
|
|
|
case 'R': codice = get(F_CODRIS); break;
|
|
|
|
case 'A': codice = get(F_CODATT); break;
|
2010-07-19 10:42:18 +00:00
|
|
|
default: break;
|
|
|
|
}
|
2010-07-30 13:39:55 +00:00
|
|
|
|
|
|
|
get_anal_fields(codcosto, codcms, codfase);
|
2010-07-19 10:42:18 +00:00
|
|
|
|
2010-07-31 06:58:44 +00:00
|
|
|
TString query;
|
|
|
|
query << "USE " << LF_RILORE << "\n";
|
|
|
|
if (risoatt.full())
|
|
|
|
query << "SELECT (BETWEEN(" << RILORE_TIPORA << ",\"" << risoatt << "\",\"" << risoatt << "\"))";
|
|
|
|
if (codice.full())
|
|
|
|
query << "&&(BETWEEN(" << RILORE_CODICE << ",\"" << codice << "\",\"" << codice << "\"))";
|
|
|
|
if (anno.full())
|
|
|
|
query << "&&(BETWEEN(" << RILORE_ANNO << ",\"" << anno << "\",\"" << anno << "\"))";
|
|
|
|
if (mese.full())
|
|
|
|
query << "&&(BETWEEN(" << RILORE_MESE << ",\"" << mese << "\",\"" << mese << "\"))";
|
|
|
|
if (tpora.full())
|
|
|
|
query << "&&(BETWEEN(" << RILORE_TPORA << ",\"" << tpora << "\",\"" << tpora << "\"))";
|
|
|
|
if (codcosto.full())
|
|
|
|
query << "&&(BETWEEN(" << RILORE_CODCOSTO << ",\"" << codcosto << "\",\"" << codcosto << "\"))";
|
|
|
|
if (codcms.full())
|
|
|
|
query << "&&(BETWEEN(" << RILORE_CODCMS << ",\"" << codcms << "\",\"" << codcms << "\"))";
|
|
|
|
if (codfase.full())
|
|
|
|
query << "&&(BETWEEN(" << RILORE_CODFASE << ",\"" << codfase << "\",\"" << codfase << "\"))";
|
|
|
|
query << "\n";
|
2010-07-30 13:39:55 +00:00
|
|
|
|
|
|
|
TString fromto = RILORE_TIPO "=\"D\"";
|
2010-07-24 07:19:41 +00:00
|
|
|
if(risoatt != 'T')
|
2010-07-19 10:42:18 +00:00
|
|
|
{
|
2010-07-30 13:39:55 +00:00
|
|
|
fromto << " " << RILORE_TIPORA << "=\"" << risoatt << "\"";
|
2010-07-24 07:19:41 +00:00
|
|
|
if(codice.full())
|
|
|
|
{
|
2010-07-30 13:39:55 +00:00
|
|
|
fromto << " " << RILORE_CODICE << "=\"" << codice << "\"";
|
2010-07-24 07:19:41 +00:00
|
|
|
if(anno.full())
|
|
|
|
{
|
2010-07-30 13:39:55 +00:00
|
|
|
fromto << " " << RILORE_ANNO << "=\"" << anno << "\"";
|
2010-07-24 07:19:41 +00:00
|
|
|
if(mese.full())
|
|
|
|
{
|
2010-07-30 13:39:55 +00:00
|
|
|
fromto << " " << RILORE_MESE << "=\"" << mese << "\"";
|
2010-07-24 07:19:41 +00:00
|
|
|
if(tpora.full())
|
2010-07-30 13:39:55 +00:00
|
|
|
fromto << " " << RILORE_TPORA << "=\"" << tpora << "\"";
|
2010-07-24 07:19:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-19 10:42:18 +00:00
|
|
|
}
|
|
|
|
|
2010-07-24 07:19:41 +00:00
|
|
|
query << "FROM " << fromto << "\n"
|
|
|
|
<< "TO " << fromto;
|
|
|
|
|
|
|
|
TISAM_recordset def(query);
|
2010-07-19 10:42:18 +00:00
|
|
|
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
|
|
|
sheet.destroy();
|
|
|
|
|
|
|
|
//riempio lo sheet con i dati che soddisfano il filtro preparato prima
|
2010-07-24 07:19:41 +00:00
|
|
|
for(bool ok = def.move_first(); ok; ok = def.move_next())
|
2010-07-19 10:42:18 +00:00
|
|
|
{
|
2010-07-24 07:19:41 +00:00
|
|
|
TRilevamento_ore rilore(def.cursor()->curr());
|
2010-07-19 10:42:18 +00:00
|
|
|
TToken_string& riga = sheet.row(-1);
|
2010-07-24 07:19:41 +00:00
|
|
|
riga.add(rilore.tipora(), sheet.cid2index(S_RISOATT));
|
|
|
|
switch(rilore.tipora())
|
2010-07-19 10:42:18 +00:00
|
|
|
{
|
2010-07-30 13:39:55 +00:00
|
|
|
case 'R': riga.add(rilore.codice(), sheet.cid2index(S_CODRIS)); break;
|
|
|
|
case 'A': riga.add(rilore.codice(), sheet.cid2index(S_CODATT)); break;
|
|
|
|
default : break;
|
2010-07-19 10:42:18 +00:00
|
|
|
}
|
2010-07-24 07:19:41 +00:00
|
|
|
riga.add(rilore.anno(), sheet.cid2index(S_ANNO));
|
|
|
|
riga.add(rilore.mese(), sheet.cid2index(S_MESE));
|
|
|
|
riga.add(rilore.tpora(), sheet.cid2index(S_TPORA));
|
2010-07-31 06:58:44 +00:00
|
|
|
put_row_anal_fields(riga, rilore.codcosto(), rilore.codcms(), rilore.codfase());
|
2010-07-24 07:19:41 +00:00
|
|
|
riga.add(rilore.qtaore(), sheet.cid2index(S_QTAORE));
|
|
|
|
riga.add(rilore.costo().string(), sheet.cid2index(S_COSTO));
|
2010-07-30 13:39:55 +00:00
|
|
|
|
2010-07-19 10:42:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sheet.force_update();
|
|
|
|
}
|
|
|
|
|
|
|
|
//NUOVA_RIGA: metodo che aggiunge una riga allo sheet
|
|
|
|
//tenendo conto dei campi chiave compilati in testata
|
|
|
|
void TDef_risoatt_msk::nuova_riga()
|
|
|
|
{
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
2010-07-30 13:39:55 +00:00
|
|
|
TToken_string & riga = sheet.row(-1);
|
|
|
|
const int r = sheet.items() - 1;
|
|
|
|
sheet.select(r);
|
2010-07-19 10:42:18 +00:00
|
|
|
TMask& msk = sheet.sheet_mask();
|
|
|
|
|
|
|
|
//guardo il tipo risorsa / attrezzatura che sto ricercando
|
2010-07-30 13:39:55 +00:00
|
|
|
const bool tutti = get(F_RISOATT)[0] == 'T';
|
|
|
|
const TString4 tipo = tutti ? "R" : get(F_RISOATT);
|
|
|
|
TString codice;
|
|
|
|
int mese = get_int(F_MESE);
|
|
|
|
int anno = get_int(F_ANNO);
|
|
|
|
TString tpora = get(F_TPORA);
|
|
|
|
TString codcosto;
|
|
|
|
TString codcms;
|
|
|
|
TString codfase;
|
|
|
|
|
|
|
|
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));
|
|
|
|
get_anal_fields(codcosto, codcms, codfase);
|
|
|
|
put_row_anal_fields(riga, codcosto, codcms, codfase);
|
|
|
|
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());
|
|
|
|
if (_scdc_sid >= 0)
|
|
|
|
for ( short id = _scdc_sid; id <= _scdc_lid; id++)
|
|
|
|
msk.enable(id, codcosto.blank());
|
|
|
|
if (_scms_sid >= 0)
|
|
|
|
for ( short id = _scms_sid; id <= _scms_lid; id++)
|
|
|
|
msk.enable(id, codcms.blank());
|
|
|
|
if (_sfase_sid >= 0)
|
|
|
|
for ( short id = _sfase_sid; id <= _sfase_lid; id++)
|
|
|
|
msk.enable(id, codfase.blank());
|
2010-07-19 10:42:18 +00:00
|
|
|
|
|
|
|
//lancio la maschera di riga da compilare
|
|
|
|
if(msk.run() == K_ENTER)
|
|
|
|
{
|
2010-07-24 07:19:41 +00:00
|
|
|
const int qtaore = msk.get_int(S_QTAORE);
|
|
|
|
const real prezzo = msk.get_real(S_COSTO);
|
2010-07-19 10:42:18 +00:00
|
|
|
|
2010-07-24 07:19:41 +00:00
|
|
|
if(qtaore > 0)
|
2010-07-30 13:39:55 +00:00
|
|
|
sheet.update_row(r);
|
2010-07-19 10:42:18 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sheet.destroy(sheet.items() - 1);
|
|
|
|
sheet.force_update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
msk.enable_default();
|
|
|
|
|
|
|
|
sheet.check_row(sheet.items() - 1);
|
|
|
|
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 TDef_risoatt_msk::azzera_riga(TSheet_field& sheet)
|
|
|
|
{
|
|
|
|
const int nriga = sheet.selected();
|
|
|
|
TToken_string& row = sheet.row(nriga);
|
|
|
|
|
2010-07-24 07:19:41 +00:00
|
|
|
row.add(0, sheet.cid2index(S_QTAORE));
|
2010-07-19 10:42:18 +00:00
|
|
|
|
|
|
|
TMask& msk = sheet.sheet_mask();
|
2010-07-24 07:19:41 +00:00
|
|
|
_qtaore = msk.get_int(S_QTAORE);
|
|
|
|
msk.set(S_QTAORE, 0L);
|
2010-07-19 10:42:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//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 TDef_risoatt_msk::azzera_tutto(TSheet_field& sheet)
|
|
|
|
{
|
|
|
|
FOR_EACH_SHEET_ROW(sheet, r, row)
|
|
|
|
{
|
|
|
|
TToken_string& row = sheet.row(r);
|
2010-07-24 07:19:41 +00:00
|
|
|
row.add(0, sheet.cid2index(S_QTAORE));
|
2010-07-19 10:42:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//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 TDef_risoatt_msk::registra()
|
|
|
|
{
|
2010-07-29 14:15:32 +00:00
|
|
|
TLocalisamfile file(LF_RILORE);
|
2010-07-19 10:42:18 +00:00
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
|
|
|
|
|
|
|
FOR_EACH_SHEET_ROW(sheet, r, row)
|
|
|
|
{
|
2010-07-24 07:19:41 +00:00
|
|
|
TToken_string& riga = *(TToken_string*)row;
|
|
|
|
const char tipora = riga.get_char(sheet.cid2index(S_RISOATT));
|
|
|
|
const TString16 codice = tipora == 'R' ? riga.get(sheet.cid2index(S_CODRIS)) : riga.get(sheet.cid2index(S_CODATT));
|
|
|
|
const int anno = riga.get_int(sheet.cid2index(S_ANNO));
|
2010-07-19 10:42:18 +00:00
|
|
|
const TString4 mese = riga.get(sheet.cid2index(S_MESE));
|
|
|
|
const TString4 tpora = riga.get(sheet.cid2index(S_TPORA));
|
2010-07-30 13:39:55 +00:00
|
|
|
TString80 codcosto;
|
|
|
|
TString80 codcms;
|
|
|
|
TString80 codfase;
|
2010-07-24 07:19:41 +00:00
|
|
|
const int qtaore = riga.get_int(sheet.cid2index(S_QTAORE));
|
|
|
|
const TString& tmp = riga.get(sheet.cid2index(S_COSTO));
|
|
|
|
const real costo(tmp);
|
2010-07-19 10:42:18 +00:00
|
|
|
|
2010-07-30 13:39:55 +00:00
|
|
|
get_row_anal_fields(riga, codcosto, codcms, codfase);
|
|
|
|
|
2010-07-24 07:19:41 +00:00
|
|
|
TRilevamento_ore rilroa('D', tipora, codice, anno, mese, tpora);
|
|
|
|
if(!rilroa.empty() && qtaore == 0)
|
|
|
|
rilroa.remove(file);
|
2010-07-19 10:42:18 +00:00
|
|
|
else
|
|
|
|
{
|
2010-07-24 07:19:41 +00:00
|
|
|
TRilevamento_ore rilroa;
|
|
|
|
rilroa.set_tipo('D');
|
|
|
|
rilroa.set_tipora(tipora);
|
|
|
|
rilroa.set_codice(codice);
|
|
|
|
rilroa.set_anno(anno);
|
|
|
|
rilroa.set_mese(mese);
|
|
|
|
rilroa.set_tpora(tpora);
|
|
|
|
rilroa.set_codcosto(codcosto);
|
|
|
|
rilroa.set_codcms(codcms);
|
|
|
|
rilroa.set_codfase(codfase);
|
|
|
|
rilroa.set_qtaore(qtaore);
|
|
|
|
rilroa.set_costo(costo);
|
|
|
|
|
|
|
|
int err = rilroa.rewrite_write(file);
|
2010-07-19 10:42:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
riempi_sheet();
|
|
|
|
}
|
|
|
|
|
|
|
|
//ON_FIELD_EVENT: metodo che gestisce gli eventi sui vari campi della maschera
|
|
|
|
bool TDef_risoatt_msk::on_field_event(TOperable_field& f, TField_event e, long jolly)
|
|
|
|
{
|
|
|
|
switch (f.dlg())
|
|
|
|
{
|
2010-07-24 07:19:41 +00:00
|
|
|
case DLG_CERCA:
|
|
|
|
if (e == fe_button)
|
|
|
|
{
|
|
|
|
riempi_sheet();
|
|
|
|
return false;
|
|
|
|
}
|
2010-07-19 10:42:18 +00:00
|
|
|
case DLG_NEWREC:
|
|
|
|
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();
|
2010-07-24 07:19:41 +00:00
|
|
|
const int qtaore = msk.get_int(S_QTAORE);
|
2010-07-19 10:42:18 +00:00
|
|
|
|
|
|
|
if(sheet.selected() == sheet.items() - 1)
|
|
|
|
{
|
|
|
|
sheet.destroy(sheet.items() - 1);
|
|
|
|
sheet.force_update();
|
|
|
|
}
|
2010-07-24 07:19:41 +00:00
|
|
|
else if(_qtaore > 0)
|
2010-07-19 10:42:18 +00:00
|
|
|
{
|
|
|
|
TToken_string& row = sheet.row(sheet.selected());
|
2010-07-24 07:19:41 +00:00
|
|
|
row.add(_qtaore, sheet.cid2index(S_QTAORE));
|
|
|
|
_qtaore = 0;
|
2010-07-19 10:42:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2010-07-29 22:50:40 +00:00
|
|
|
case F_ANNO:
|
|
|
|
case F_MESE:
|
|
|
|
case F_RISOATT:
|
|
|
|
case F_CODICE:
|
|
|
|
case F_CODRIS:
|
|
|
|
case F_CODATT:
|
|
|
|
case F_TPORA:
|
|
|
|
if (e == fe_modify)
|
|
|
|
riempi_sheet();
|
|
|
|
break;
|
2010-07-19 10:42:18 +00:00
|
|
|
case F_SHEET:
|
|
|
|
if (e == se_query_add)
|
|
|
|
{
|
|
|
|
send_key(K_SPACE, DLG_NEWREC);
|
|
|
|
return false;
|
2010-07-29 22:50:40 +00:00
|
|
|
} default: break;
|
2010-07-19 10:42:18 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDef_risoatt_msk::esegui() const
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TDef_risoatt_msk::TDef_risoatt_msk()
|
2010-07-24 07:19:41 +00:00
|
|
|
: TAutomask("ci0600a")
|
2010-07-19 10:42:18 +00:00
|
|
|
{
|
2010-07-30 13:39:55 +00:00
|
|
|
const TMultilevel_code_info& fasinfo = ca_multilevel_code_info(LF_FASI);
|
|
|
|
TConfig& ini = ca_config();
|
|
|
|
TSheet_field & s = sfield(F_SHEET);
|
|
|
|
TMask & sm = s.sheet_mask();
|
|
|
|
int y = 3;
|
|
|
|
int sy = 8;
|
|
|
|
short dlg = F_ANAL; // id del primo campo da generare
|
|
|
|
short sdlg = S_CDC1 + 100; // id del primo campo da generare
|
|
|
|
|
|
|
|
_cdc_sid = _cdc_lid = _cms_sid = _cms_lid = _fase_sid = _fase_lid = -1;
|
|
|
|
_scdc_sid = _scdc_lid = _scms_sid = _scms_lid = _sfase_sid = _sfase_lid = -1;
|
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
{
|
|
|
|
const TString& level = ini.get("Level", NULL, i+1); // Legge il livello 1 o 2
|
|
|
|
|
|
|
|
if (level == "CDC") // Crea centro di costo
|
|
|
|
{
|
|
|
|
if (fasinfo.parent() == LF_CDC)
|
|
|
|
{
|
2010-07-31 06:58:44 +00:00
|
|
|
int h = ca_multilevel_code_info(LF_CDC).levels();
|
|
|
|
const int h1 = ca_create_fields_compact(*this, 0, LF_FASI, 2, y, dlg, dlg + 100);
|
|
|
|
y += 2;
|
|
|
|
_cdc_sid = dlg;
|
|
|
|
_cdc_lid = dlg + h - 1;
|
|
|
|
_fase_sid = _cdc_lid + 1;
|
|
|
|
_fase_lid = dlg + h1 - 1;
|
|
|
|
dlg += h1;
|
|
|
|
const int sh = ca_create_fields_compact(sm, 0, LF_FASI, 2, sy, sdlg, sdlg + 50);
|
|
|
|
sy += 2;
|
|
|
|
_scdc_sid = sdlg;
|
|
|
|
_scdc_lid = sdlg + h - 1;
|
|
|
|
_sfase_sid = _scdc_lid + 1;
|
2010-07-30 13:39:55 +00:00
|
|
|
_sfase_lid = sdlg + sh - 1;
|
2010-07-31 06:58:44 +00:00
|
|
|
sdlg += sh;
|
2010-07-30 13:39:55 +00:00
|
|
|
}
|
2010-07-31 06:58:44 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
const int h = ca_create_fields_compact(*this, 0, LF_CDC, 2, y++, dlg, dlg + 100);
|
|
|
|
_cdc_sid = dlg;
|
|
|
|
_cdc_lid = dlg + h - 1;
|
|
|
|
dlg += h;
|
|
|
|
const int sh = ca_create_fields_compact(sm, 0, LF_CDC, 2, sy++, sdlg, sdlg + 50);
|
|
|
|
_scdc_sid = sdlg;
|
|
|
|
_scdc_lid = sdlg + sh - 1;
|
|
|
|
sdlg += h;
|
|
|
|
}
|
2010-07-30 13:39:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if (level == "CMS") // Crea commessa
|
|
|
|
{
|
|
|
|
if (fasinfo.parent() == LF_COMMESSE)
|
|
|
|
{
|
2010-07-31 06:58:44 +00:00
|
|
|
int h = ca_multilevel_code_info(LF_COMMESSE).levels();
|
|
|
|
const int h1 = ca_create_fields_compact(*this, 0, LF_FASI, 2, y, dlg, dlg + 100);
|
|
|
|
y += 2;
|
|
|
|
_cms_sid = dlg;
|
|
|
|
_cms_lid = dlg + h - 1;
|
|
|
|
_fase_sid = _cms_lid + 1;
|
|
|
|
_fase_lid = dlg + h1 - 1;
|
|
|
|
dlg += h1;
|
|
|
|
const int sh = ca_create_fields_compact(sm, 0, LF_FASI, 2, sy, sdlg, sdlg + 50);
|
|
|
|
sy += 2;
|
|
|
|
_scms_sid = sdlg;
|
|
|
|
_scms_lid = sdlg + h - 1;
|
|
|
|
_sfase_sid = _scms_lid + 1;
|
2010-07-30 13:39:55 +00:00
|
|
|
_sfase_lid = sdlg + sh - 1;
|
2010-07-31 06:58:44 +00:00
|
|
|
sdlg += sh;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const int h = ca_create_fields_compact(*this, 0, LF_COMMESSE, 2, y++, dlg, dlg + 100);
|
|
|
|
_cms_sid = dlg;
|
|
|
|
_cms_lid = dlg + h - 1;
|
|
|
|
dlg += h;
|
|
|
|
const int sh = ca_create_fields_compact(sm, 0, LF_COMMESSE, 2, sy++, sdlg, sdlg + 50);
|
|
|
|
_scms_sid = sdlg;
|
|
|
|
_scms_lid = sdlg + sh - 1;
|
|
|
|
sdlg += sh;
|
2010-07-30 13:39:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fasinfo.levels() > 0 && fasinfo.parent() <= 0)
|
|
|
|
{
|
2010-07-31 06:58:44 +00:00
|
|
|
const int h = ca_create_fields_compact(*this, 0, LF_FASI, 2, y++, dlg, dlg + 100);
|
2010-07-30 13:39:55 +00:00
|
|
|
_fase_sid = dlg;
|
|
|
|
_fase_lid = dlg + h - 1;
|
|
|
|
dlg += h;
|
2010-07-31 06:58:44 +00:00
|
|
|
const int sh = ca_create_fields_compact(sm, 0, LF_FASI, 2, sy++, sdlg, sdlg + 50);
|
2010-07-30 13:39:55 +00:00
|
|
|
_sfase_sid = sdlg;
|
|
|
|
_sfase_lid = sdlg + sh - 1;
|
|
|
|
sdlg += h;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (short id = S_CDC12 + 100; id >= S_CDC1 + 100; id--)
|
|
|
|
{
|
|
|
|
const int pos = sm.id2pos(id);
|
|
|
|
if (pos >= 0)
|
|
|
|
{
|
|
|
|
TMask_field& f = sm.fld(pos);
|
|
|
|
const int size = f.size();
|
|
|
|
const TString& prompt = f.prompt();
|
|
|
|
s.set_column_header(id, prompt);
|
|
|
|
s.set_column_justify(id, f.is_kind_of(CLASS_REAL_FIELD));
|
|
|
|
s.set_column_width(id, (max(3+size, prompt.len()+1)) * CHARX);
|
|
|
|
s.enable_column(id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
s.delete_column(id);
|
|
|
|
}
|
2010-07-24 07:19:41 +00:00
|
|
|
_qtaore = 0;
|
2010-07-30 13:39:55 +00:00
|
|
|
|
2010-07-19 10:42:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////
|
|
|
|
//// CLASSE TDef_risoatt_app ////
|
|
|
|
////////////////////////////////////////
|
|
|
|
|
|
|
|
//classe TDef_risoatt_app
|
|
|
|
class TDef_risoatt_app : public TSkeleton_application
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void main_loop();
|
|
|
|
};
|
|
|
|
|
|
|
|
void TDef_risoatt_app::main_loop()
|
|
|
|
{
|
|
|
|
TDef_risoatt_msk msk;
|
|
|
|
while (msk.run() != K_QUIT)
|
|
|
|
msk.esegui();
|
|
|
|
}
|
|
|
|
|
|
|
|
int ci0600(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
TDef_risoatt_app a;
|
2010-07-30 13:39:55 +00:00
|
|
|
a.run (argc, argv, TR("Gestione dati predefiniti"));
|
2010-07-19 10:42:18 +00:00
|
|
|
return TRUE;
|
2010-07-29 22:50:40 +00:00
|
|
|
}
|