2009-04-17 16:14:22 +00:00
|
|
|
|
#include <colors.h>
|
|
|
|
|
|
|
|
|
|
#include "../ve/ve0100.h"
|
|
|
|
|
#include "../ve/veini.h"
|
|
|
|
|
#include "../ve/veuml.h"
|
|
|
|
|
#include "../ve/veuml3.h"
|
|
|
|
|
#include "../ve/verig.h"
|
|
|
|
|
#include "../ve/vepriv.h"
|
|
|
|
|
|
|
|
|
|
#include "../ve/velib.h"
|
|
|
|
|
#include "../ve/velib04.h"
|
|
|
|
|
|
|
|
|
|
#define F_K F_USERFLD
|
|
|
|
|
|
|
|
|
|
#define F_DETTAGLIO F_USERFLD+1
|
|
|
|
|
#define FOR_EACH_DOC_ROW_BACK(d, r, row) const TRiga_documento* row = NULL; for (int r = d.rows(); r > 0 && (row = &d[r]) != NULL; r--)
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
//// CLASSE TGestione_preventivo_msk ////
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
//Definizione della classe della maschera
|
|
|
|
|
class TGestione_preventivo_msk : public TDocumento_mask
|
|
|
|
|
{
|
|
|
|
|
int _rule;
|
|
|
|
|
protected:
|
|
|
|
|
//hanlder di documento:
|
|
|
|
|
static bool pe_data_handler(TMask_field& f, KEY k);
|
|
|
|
|
//handler di riga:
|
|
|
|
|
static bool pe_ritirato_handler(TMask_field& f, KEY k);
|
|
|
|
|
static bool pe_codart_handler(TMask_field& f, KEY k);
|
|
|
|
|
static bool pe_umart_handler(TMask_field& f, KEY k);
|
|
|
|
|
|
|
|
|
|
static bool ss_notify(TSheet_field& ss, int r, KEY key);
|
|
|
|
|
|
|
|
|
|
virtual void on_idle();
|
2009-04-20 00:06:09 +00:00
|
|
|
|
virtual void highlight_row(int row, COLOR back = COLOR_INVALID, COLOR fore = COLOR_INVALID, bool dirty = true, bool update = true);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual void user_set_handler( short fieldid, int index);
|
|
|
|
|
virtual void user_set_row_handler(TMask& rm, short field, int index);
|
|
|
|
|
|
|
|
|
|
virtual TVariable_mask * riga_mask(int numriga);
|
2009-04-17 16:26:10 +00:00
|
|
|
|
virtual void doc2mask(bool reload_clifo = true, bool force_load = false, bool update = true);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
|
|
|
|
|
TGestione_preventivo_msk(const char* tipodoc);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
//// CLASSE TGestione_preventivo_APP ////
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// Definizione della classe dell'applicazione motore
|
|
|
|
|
class TGestione_preventivo_app : public TMotore_application
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual TMask* get_mask( int mode );
|
|
|
|
|
virtual int write( const TMask& m );
|
|
|
|
|
virtual int rewrite( const TMask& m );
|
|
|
|
|
virtual int read ( TMask& m );
|
|
|
|
|
virtual void init_insert_mode( TMask& m );
|
|
|
|
|
void elimina_vuote( const TMask& m);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TGestione_preventivo_app() {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inline TGestione_preventivo_app& peapp() { return (TGestione_preventivo_app &)main_app(); };
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
//// CLASSE TGestione_preventivo_MSK ////
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
////////////////////////////
|
|
|
|
|
// HANDLER DI DOCUMENTO //
|
|
|
|
|
////////////////////////////
|
|
|
|
|
|
|
|
|
|
void TGestione_preventivo_msk:: on_idle()
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask::on_idle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//magico metodo per settare, al cambio riga dello sheet, il focus sul campo desiderato (il campo in questione <20>..
|
|
|
|
|
//..definito nella on_idle(); ricordarsi la set_notify() nel costruttore della maschera senno' viene eseguito l'ss_notify()..
|
|
|
|
|
//..standard e non questo qui ridefinito. Allah!
|
|
|
|
|
bool TGestione_preventivo_msk::ss_notify(TSheet_field& ss, int r, KEY key)
|
|
|
|
|
{
|
|
|
|
|
TGestione_preventivo_msk& dmsk = (TGestione_preventivo_msk&) ss.mask();
|
|
|
|
|
TSheet_field & sh = dmsk.sfield(F_SHEET);
|
|
|
|
|
TDocumento& doc = dmsk.doc();
|
|
|
|
|
|
|
|
|
|
switch (key)
|
|
|
|
|
{
|
|
|
|
|
case K_ENTER: // modifica
|
|
|
|
|
{
|
2009-04-20 00:06:09 +00:00
|
|
|
|
TRiga_documento& row = doc[r + 1];
|
2009-04-17 16:14:22 +00:00
|
|
|
|
TMask & m = sh.sheet_row_mask(r);
|
|
|
|
|
const int level = row.get_int(RDOC_LEVEL);
|
|
|
|
|
const bool prodfin = level == 0;
|
2009-04-20 00:06:09 +00:00
|
|
|
|
const bool price_enabled = (r + 1 == doc.physical_rows()) || (level >= doc[r + 2].get_int(RDOC_LEVEL));
|
2009-04-17 16:14:22 +00:00
|
|
|
|
short id;
|
|
|
|
|
|
|
|
|
|
m.enable(FR_PREZZO, price_enabled);
|
|
|
|
|
m.enable(FR_JOLLY2, price_enabled);
|
|
|
|
|
for (id = F_CDC1; id < F_CDC12; id++)
|
|
|
|
|
m.enable(id, prodfin);
|
|
|
|
|
for (id = F_DESCDC1; id < F_DESCDC12; id++)
|
|
|
|
|
m.enable(id, prodfin);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2009-04-20 00:06:09 +00:00
|
|
|
|
case K_CTRL + K_INS: // Inserimento
|
2009-04-17 16:14:22 +00:00
|
|
|
|
{
|
2009-04-20 00:06:09 +00:00
|
|
|
|
const int doc_row = r + 1;
|
2009-04-17 16:14:22 +00:00
|
|
|
|
int level = 0;
|
|
|
|
|
|
2009-04-20 00:06:09 +00:00
|
|
|
|
TRiga_documento & row = doc[doc_row];
|
2009-04-17 16:14:22 +00:00
|
|
|
|
|
|
|
|
|
if (r > 0 && row.is_merce())
|
|
|
|
|
{
|
2009-04-20 00:06:09 +00:00
|
|
|
|
const int father_sheet_row = r - 1;
|
|
|
|
|
TRiga_documento& father_row = doc[father_sheet_row + 1];
|
|
|
|
|
const int rows = doc.physical_rows();
|
2009-04-17 16:14:22 +00:00
|
|
|
|
|
2009-04-20 00:06:09 +00:00
|
|
|
|
level = father_row.get_int(RDOC_LEVEL);
|
|
|
|
|
if (dmsk.get_bool(F_DETTAGLIO) || (doc_row < rows && level < doc[doc_row + 1].get_int(RDOC_LEVEL)))
|
2009-04-17 16:14:22 +00:00
|
|
|
|
level++;
|
|
|
|
|
if (level > 0)
|
|
|
|
|
{
|
2009-04-20 00:06:09 +00:00
|
|
|
|
row.put(RDOC_CODCOSTO, father_row.get(RDOC_CODCOSTO));
|
|
|
|
|
row.put(RDOC_CODCMS, father_row.get(RDOC_CODCMS));
|
|
|
|
|
row.put(RDOC_FASCMS, father_row.get(RDOC_FASCMS));
|
2009-04-17 16:14:22 +00:00
|
|
|
|
|
|
|
|
|
short id;
|
|
|
|
|
|
2009-04-20 00:06:09 +00:00
|
|
|
|
sh.disable_cell(father_sheet_row, sh.cid2index(FR_PREZZO));
|
|
|
|
|
sh.disable_cell(father_sheet_row, sh.cid2index(FR_JOLLY2));
|
|
|
|
|
father_row.zero(RDOC_PREZZO);
|
|
|
|
|
father_row.zero(RDOC_K);
|
|
|
|
|
father_row.autoload(sh);
|
|
|
|
|
sh.force_update(father_sheet_row);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
for (id = F_CDC1; id < F_CDC12; id++)
|
2009-04-20 00:06:09 +00:00
|
|
|
|
sh.disable_cell(r, sh.cid2index(id));
|
2009-04-17 16:14:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-04-20 00:06:09 +00:00
|
|
|
|
row.put(RDOC_LEVEL, level);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
TString tree;
|
|
|
|
|
|
2009-04-20 00:06:09 +00:00
|
|
|
|
if (level < 10)
|
|
|
|
|
{
|
|
|
|
|
if (level > 0)
|
|
|
|
|
tree.fill(' ', level);
|
|
|
|
|
tree << '+';
|
|
|
|
|
tree.rpad(10, '-');
|
|
|
|
|
}
|
2009-04-17 16:14:22 +00:00
|
|
|
|
row.put(RDOC_TREE, tree);
|
2009-04-20 00:06:09 +00:00
|
|
|
|
row.autoload(sh);
|
|
|
|
|
dmsk.reset(F_DETTAGLIO);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2009-04-20 00:06:09 +00:00
|
|
|
|
case K_DEL: // Cancellazione
|
|
|
|
|
{
|
|
|
|
|
const int doc_row = r + 1;
|
|
|
|
|
const int rows = doc.physical_rows();
|
|
|
|
|
|
|
|
|
|
if (doc_row < rows)
|
|
|
|
|
{
|
|
|
|
|
TRiga_documento & row = doc[doc_row];
|
|
|
|
|
const int level = row.get_int(RDOC_LEVEL);
|
|
|
|
|
int i;
|
|
|
|
|
int last_row = doc_row;
|
|
|
|
|
|
|
|
|
|
for (i = doc_row + 1; i <= rows; i++)
|
|
|
|
|
if (level < doc[i].get_int(RDOC_LEVEL))
|
|
|
|
|
last_row = i;
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
for (i = last_row; i > doc_row; i--)
|
|
|
|
|
{
|
|
|
|
|
doc.destroy_row(i, true);
|
|
|
|
|
sh.destroy(i - 1);
|
|
|
|
|
}
|
|
|
|
|
sh.force_update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2009-04-17 16:14:22 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return TDocumento_mask::ss_notify(ss, r, key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-04-20 00:06:09 +00:00
|
|
|
|
void TGestione_preventivo_msk::highlight_row(int row, COLOR back, COLOR fore, bool dirty, bool update)
|
2009-04-17 16:14:22 +00:00
|
|
|
|
{
|
|
|
|
|
TRiga_documento& rigadoc = doc()[row + 1];
|
|
|
|
|
TSheet_field& sf = sfield(F_SHEET);
|
2009-04-20 00:06:09 +00:00
|
|
|
|
COLOR back1 = NORMAL_BACK_COLOR, back2 = COLOR_BLUE;
|
2009-04-17 16:14:22 +00:00
|
|
|
|
const TColor_rule * c = (TColor_rule *) color_rules().objptr(_rule);
|
|
|
|
|
|
|
|
|
|
if (c != NULL)
|
|
|
|
|
c->colors(back2, fore);
|
2009-04-20 00:06:09 +00:00
|
|
|
|
back = blend_colors(back1, back2, 1.0 - (((double) rigadoc.get_int(RDOC_LEVEL)) / 10.0));
|
2009-04-17 16:14:22 +00:00
|
|
|
|
|
2009-04-20 00:06:09 +00:00
|
|
|
|
sf.set_back_and_fore_color(back, fore, row);
|
|
|
|
|
TDocumento_mask::highlight_row(row, back, fore, dirty, update);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TVariable_mask * TGestione_preventivo_msk::riga_mask(int numriga)
|
|
|
|
|
{
|
2009-04-17 16:40:42 +00:00
|
|
|
|
const bool is_new = new_mask(numriga);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
TVariable_mask* m = TDocumento_mask::riga_mask(numriga);
|
|
|
|
|
|
2009-04-17 16:40:42 +00:00
|
|
|
|
if (is_new && m != NULL)
|
2009-04-17 16:14:22 +00:00
|
|
|
|
{
|
|
|
|
|
const TRiga_documento& riga = doc()[numriga + 1];
|
2009-04-20 00:06:09 +00:00
|
|
|
|
TEdit_field & tree = m->add_string(FR_JOLLY1, 0, "Albero ", 2, 20, 10, "D_");
|
|
|
|
|
TEdit_field & k = m->add_string(FR_JOLLY2, 0, "K ", 25, 20, 25);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
|
2009-04-20 00:06:09 +00:00
|
|
|
|
m->set_handler(FR_CODART, pe_codart_handler);
|
|
|
|
|
m->set_handler(FR_UMQTA, pe_umart_handler);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
tree.set_field(RDOC_TREE);
|
|
|
|
|
k.set_field(RDOC_K);
|
|
|
|
|
}
|
|
|
|
|
return m;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-04-17 16:26:10 +00:00
|
|
|
|
void TGestione_preventivo_msk::doc2mask(bool reload_clifo, bool force_load, bool update)
|
2009-04-17 16:14:22 +00:00
|
|
|
|
{
|
2009-04-17 16:26:10 +00:00
|
|
|
|
TDocumento_mask::doc2mask(reload_clifo, force_load, false);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
|
|
|
|
|
TSheet_field& s = sfield(F_SHEET);
|
|
|
|
|
const int righe = s.items();
|
|
|
|
|
const TDocumento & d = doc();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < righe; i++)
|
|
|
|
|
{
|
|
|
|
|
const TRiga_documento & row = d[i + 1];
|
|
|
|
|
const int level = row.get_int(RDOC_LEVEL);
|
|
|
|
|
const bool prodfin = level == 0;
|
2009-04-20 00:06:09 +00:00
|
|
|
|
const bool price_enabled = (i + 1 == d.physical_rows()) || (level >= d[i + 2].get_int(RDOC_LEVEL));
|
2009-04-17 16:14:22 +00:00
|
|
|
|
|
|
|
|
|
s.enable_cell(i, s.cid2index(FR_PREZZO), price_enabled);
|
|
|
|
|
s.enable_cell(i, s.cid2index(FR_JOLLY2), price_enabled);
|
|
|
|
|
for (short id = F_CDC1; id < F_CDC12; id++)
|
|
|
|
|
s.enable_cell(i, s.cid2index(id), prodfin);
|
|
|
|
|
}
|
|
|
|
|
//aggiorna i colori delle righe e forza l'update dello sheet
|
|
|
|
|
highlight();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//PE_TESTATA_HANDLER: handler che si occupa di decodificare i campi data in testata
|
|
|
|
|
bool TGestione_preventivo_msk::pe_data_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
bool ok = true;
|
|
|
|
|
TGestione_preventivo_msk& dmsk = (TGestione_preventivo_msk&)f.mask();
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////
|
|
|
|
|
// HANDLER DI RIGA //
|
|
|
|
|
///////////////////////
|
|
|
|
|
|
|
|
|
|
bool TGestione_preventivo_msk::pe_codart_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
bool ok = codart_handler( f, k );
|
|
|
|
|
|
|
|
|
|
if (ok && (k == K_ENTER || k == K_TAB))
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
|
|
|
|
|
if (row_mask.field(FR_JOLLY2).active())
|
|
|
|
|
{
|
|
|
|
|
TSheet_field * sh = row_mask.get_sheet();
|
|
|
|
|
if (sh != NULL)
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask & mask = (TDocumento_mask &) sh->mask();
|
|
|
|
|
TDocumento & doc = mask.doc();
|
|
|
|
|
|
|
|
|
|
if (f.to_check(k, true))
|
|
|
|
|
{
|
|
|
|
|
const int r = sh->selected();
|
|
|
|
|
const TString& codart = mask.get(FR_CODARTMAG);
|
|
|
|
|
TRiga_documento & row = doc[r + 1];
|
|
|
|
|
|
|
|
|
|
if (codart.full())
|
|
|
|
|
{
|
|
|
|
|
const TArticolo_giacenza & art = cached_article(codart);
|
|
|
|
|
TString80 k = art.get(ANAMAG_PERCRIC);
|
|
|
|
|
|
|
|
|
|
if (k.blank())
|
|
|
|
|
{
|
|
|
|
|
const TString catmer = art.get(ANAMAG_GRMERC);
|
|
|
|
|
k = cache().get("GMC", catmer, "S2");
|
|
|
|
|
if (k.blank())
|
|
|
|
|
k = cache().get("GMC", catmer.left(3), "S2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TGestione_preventivo_msk::pe_umart_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
bool ok = umart_handler( f, k );
|
|
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TSheet_field * sh = row_mask.get_sheet();
|
|
|
|
|
if (sh != NULL)
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask & mask = (TDocumento_mask &) sh->mask();
|
|
|
|
|
TDocumento & doc = mask.doc();
|
|
|
|
|
|
|
|
|
|
if (k == K_F8)
|
|
|
|
|
{
|
|
|
|
|
const int r = sh->selected();
|
|
|
|
|
|
|
|
|
|
if (r > 0)
|
|
|
|
|
{
|
|
|
|
|
TRiga_documento & row = doc[r + 1];
|
|
|
|
|
const int level = row.get_int(RDOC_LEVEL);
|
|
|
|
|
|
|
|
|
|
if (level > 0)
|
|
|
|
|
{
|
|
|
|
|
TRiga_documento & row = doc[r];
|
|
|
|
|
const real qta_prec = row.get_real(RDOC_QTA);
|
|
|
|
|
real qta(f.get());
|
|
|
|
|
TToken_string & shrow = sh->row(r);
|
|
|
|
|
|
|
|
|
|
qta *= qta_prec;
|
|
|
|
|
shrow.add(qta.string(), sh->cid2index(FR_UMQTA));
|
|
|
|
|
sh->force_update(r);
|
2009-04-20 00:06:09 +00:00
|
|
|
|
row.put(RDOC_QTA, qta);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
f.focusdirty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (f.to_check(k, true))
|
|
|
|
|
{
|
|
|
|
|
const int r = sh->selected();
|
|
|
|
|
TRiga_documento & row = doc[r + 1];
|
|
|
|
|
const real old_qta = row.get_real(RDOC_QTA);
|
2009-04-20 00:06:09 +00:00
|
|
|
|
const real qta = row_mask.get_real(FR_QTA);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
const int level = row.get_int(RDOC_LEVEL);
|
|
|
|
|
|
|
|
|
|
if (old_qta != qta)
|
|
|
|
|
{
|
|
|
|
|
const int rows = doc.physical_rows();
|
|
|
|
|
|
2009-04-20 00:06:09 +00:00
|
|
|
|
for (int i = r + 2; i <= rows && level < doc[i].get_int(RDOC_LEVEL); i++)
|
2009-04-17 16:14:22 +00:00
|
|
|
|
{
|
|
|
|
|
TToken_string & shrow = sh->row(i - 1);
|
|
|
|
|
real row_qta(shrow.get(sh->cid2index(FR_UMQTA)));
|
|
|
|
|
|
|
|
|
|
row_qta *= qta;
|
|
|
|
|
row_qta /= old_qta;
|
|
|
|
|
shrow.add(row_qta.string(), sh->cid2index(FR_UMQTA));
|
|
|
|
|
doc[i].put(RDOC_QTA, row_qta);
|
|
|
|
|
}
|
2009-04-20 00:06:09 +00:00
|
|
|
|
row.put(RDOC_QTA, qta);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
sh->force_update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
//metodo che setta gli handler sui campi di riga
|
|
|
|
|
void TGestione_preventivo_msk::user_set_row_handler(TMask& rm, short field, int index)
|
|
|
|
|
{
|
|
|
|
|
switch(index)
|
|
|
|
|
{
|
2009-04-20 00:06:09 +00:00
|
|
|
|
case 5101: rm.set_handler(field, pe_codart_handler); break;
|
|
|
|
|
case 5102: rm.set_handler(field, pe_umart_handler); break;
|
2009-04-17 16:14:22 +00:00
|
|
|
|
default : TDocumento_mask::user_set_row_handler(rm, field, index); break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//metodo che setta l'handler di bolla
|
|
|
|
|
void TGestione_preventivo_msk::user_set_handler( short fieldid, int index)
|
|
|
|
|
{
|
|
|
|
|
switch(index)
|
|
|
|
|
{
|
|
|
|
|
case 5101: set_field_handler(fieldid, pe_data_handler); break;
|
|
|
|
|
default : TDocumento_mask::user_set_handler(fieldid, index); break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TGestione_preventivo_msk::TGestione_preventivo_msk(const char* tipodoc) : TDocumento_mask(tipodoc)
|
|
|
|
|
{
|
|
|
|
|
TConfig* configpe = new TConfig(CONFIG_DITTA, "pe");
|
|
|
|
|
sfield(F_SHEET).set_notify( ss_notify );
|
2009-04-20 00:06:09 +00:00
|
|
|
|
_rule = color_rules().add(new TColor_rule("Livello", "", _numexpr, COLOR_BLUE, FOCUS_COLOR));
|
2009-04-17 16:14:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
//// CLASSE TGESTIONE_PREVENTIVO_APP ////
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
//ridefinisco il metodo get_mask delle TMotore_application
|
|
|
|
|
TMask* TGestione_preventivo_app::get_mask( int mode )
|
|
|
|
|
{
|
|
|
|
|
if (mode == MODE_INS || mode == MODE_MOD)
|
|
|
|
|
{
|
|
|
|
|
TString4 tipodoc;
|
|
|
|
|
if (mode == MODE_MOD)
|
|
|
|
|
tipodoc = get_relation()->curr().get(DOC_TIPODOC); // Lo prendo dalla relazione (Gelai)
|
|
|
|
|
else
|
|
|
|
|
tipodoc = TMotore_application::get_mask(MODE_QUERY)->get(F_TIPODOC);
|
|
|
|
|
if (_doc_masks.objptr(tipodoc) == NULL)
|
|
|
|
|
{
|
|
|
|
|
TGestione_preventivo_msk* m = new TGestione_preventivo_msk(tipodoc);
|
|
|
|
|
_doc_masks.add(tipodoc, m);
|
|
|
|
|
const TTipo_documento& tdoc = m->doc().tipo();
|
|
|
|
|
const TString_array& handlers = tdoc.handlers();
|
|
|
|
|
FOR_EACH_ARRAY_ROW(handlers, i, row)
|
|
|
|
|
{
|
|
|
|
|
m->user_set_handler( row->get_int( 0 ), row->get_int( 1 ) );
|
|
|
|
|
}
|
|
|
|
|
TSheet_field & sh = m->sfield(F_SHEET);
|
2009-04-20 00:06:09 +00:00
|
|
|
|
const int y = m->sh_y() - 1;
|
|
|
|
|
TEdit_field & k = m->add_string(F_K, sh.page(), "K ", 2, y, 25);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
|
|
|
|
|
k.set_field(DOC_K);
|
2009-04-20 00:06:09 +00:00
|
|
|
|
m->add_boolean(F_DETTAGLIO, sh.page(), "Dettaglia ", 60, y);
|
|
|
|
|
sh.enable_column(sh.cid2index(FR_JOLLY1), false);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TMotore_application::get_mask(mode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ridefinisco il metodo write delle TMotore_application
|
|
|
|
|
int TGestione_preventivo_app::write( const TMask& m )
|
|
|
|
|
{
|
|
|
|
|
TDocumento& doc = ((TDocumento_mask&) m).doc();
|
|
|
|
|
const TString k = doc.get(DOC_K);
|
2009-04-20 00:06:09 +00:00
|
|
|
|
int max_level = 0;
|
|
|
|
|
const int rows = doc.physical_rows();
|
|
|
|
|
|
|
|
|
|
for (int r = 1; r <= rows; r++)
|
|
|
|
|
{
|
|
|
|
|
const int level = doc[r].get_int(RDOC_LEVEL);
|
2009-04-17 16:14:22 +00:00
|
|
|
|
|
2009-04-20 00:06:09 +00:00
|
|
|
|
if (max_level < level)
|
|
|
|
|
max_level = level;
|
|
|
|
|
}
|
|
|
|
|
for (int i = 1 ; i <= rows; i++)
|
|
|
|
|
if (doc[i].get_int(RDOC_LEVEL) == max_level && doc[i].get(RDOC_K).blank())
|
2009-04-17 16:14:22 +00:00
|
|
|
|
doc[i].put(RDOC_K, k);
|
|
|
|
|
return TMotore_application::write(m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ridefinisco il metodo rewrite delle TMotore_application
|
|
|
|
|
int TGestione_preventivo_app::rewrite( const TMask& m )
|
|
|
|
|
{
|
|
|
|
|
TDocumento& doc = ((TDocumento_mask&) m).doc();
|
|
|
|
|
const TString k = doc.get(DOC_K);
|
2009-04-20 00:06:09 +00:00
|
|
|
|
int max_level = 0;
|
|
|
|
|
const int rows = doc.physical_rows();
|
2009-04-17 16:14:22 +00:00
|
|
|
|
|
2009-04-20 00:06:09 +00:00
|
|
|
|
for (int r = 1; r <= rows; r++)
|
|
|
|
|
{
|
|
|
|
|
const int level = doc[r].get_int(RDOC_LEVEL);
|
|
|
|
|
|
|
|
|
|
if (max_level < level)
|
|
|
|
|
max_level = level;
|
|
|
|
|
}
|
|
|
|
|
for (int i = 1 ; i <= rows; i++)
|
|
|
|
|
if (doc[i].get_int(RDOC_LEVEL) == max_level && doc[i].get(RDOC_K).blank())
|
2009-04-17 16:14:22 +00:00
|
|
|
|
doc[i].put(RDOC_K, k);
|
|
|
|
|
return TMotore_application::rewrite(m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ridefinisco il metodo read della TMotore_application
|
|
|
|
|
int TGestione_preventivo_app::read(TMask& m)
|
|
|
|
|
{
|
|
|
|
|
const int err = TMotore_application::read(m);
|
|
|
|
|
|
|
|
|
|
if (err == NOERR)
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask& mask = (TDocumento_mask&) m;
|
|
|
|
|
TDocumento& doc = mask.doc();
|
|
|
|
|
const TString k = doc.get(DOC_K);
|
|
|
|
|
|
|
|
|
|
for (int i = 1 ; i <= doc.physical_rows(); i++)
|
|
|
|
|
if (k == doc[i].get(RDOC_K))
|
|
|
|
|
doc[i].zero(RDOC_K);
|
|
|
|
|
}
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ridefinisco il metodo init_insert_mode della TMotore_application
|
|
|
|
|
void TGestione_preventivo_app::init_insert_mode(TMask &m)
|
|
|
|
|
{
|
|
|
|
|
TGestione_preventivo_msk & mask = (TGestione_preventivo_msk&) m;
|
|
|
|
|
TDocumento& d = mask.doc();
|
|
|
|
|
|
|
|
|
|
return TMotore_application::init_insert_mode(m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int pe0400( int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
TGestione_preventivo_app a;
|
|
|
|
|
|
|
|
|
|
a.run( argc, argv, TR("Gestione Preventivi"));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|