Patch level : 10.0 360

Files correlati     : pe0.exe
Ricompilazione Demo : [ ]
Commento

Gestione revisioni (preventivi)


git-svn-id: svn://10.65.10.50/trunk@19085 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2009-06-30 09:36:17 +00:00
parent 1e74cee123
commit 263c5d765c

View File

@ -23,6 +23,7 @@
#define F_SHRINK_ROW F_USERFLD+7 #define F_SHRINK_ROW F_USERFLD+7
#define F_ZOOM_ROW F_USERFLD+8 #define F_ZOOM_ROW F_USERFLD+8
#define F_USEK F_USERFLD+9 #define F_USEK F_USERFLD+9
#define F_REVISION F_USERFLD+10
#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--) #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--)
////////////////////////////////////////// //////////////////////////////////////////
@ -52,12 +53,14 @@ protected:
virtual void on_idle(); virtual void on_idle();
virtual void highlight_row(int row, COLOR back = COLOR_INVALID, COLOR fore = COLOR_INVALID, bool dirty = true, bool update = true); virtual void highlight_row(int row, COLOR back = COLOR_INVALID, COLOR fore = COLOR_INVALID, bool dirty = true, bool update = true);
const TString & build_tree_string(int level); const TString & build_tree_string(int level);
bool new_revision(const char* codnum, long& ndoc) const;
public: public:
static bool pe_espandi_handler(TMask_field& f, KEY k); static bool pe_espandi_handler(TMask_field& f, KEY k);
static bool pe_espandi_riga_handler(TMask_field& f, KEY k); static bool pe_espandi_riga_handler(TMask_field& f, KEY k);
static bool pe_copia_handler(TMask_field& f, KEY k); static bool pe_copia_handler(TMask_field& f, KEY k);
static bool pe_incolla_handler(TMask_field& f, KEY k); static bool pe_incolla_handler(TMask_field& f, KEY k);
static bool pe_new_revision_handler(TMask_field& f, KEY k);
virtual void user_set_handler( short fieldid, int index); virtual void user_set_handler( short fieldid, int index);
virtual void user_set_row_handler(TMask& rm, short field, int index); virtual void user_set_row_handler(TMask& rm, short field, int index);
@ -85,7 +88,9 @@ class TGestione_preventivo_app : public TMotore_application
virtual int rewrite( const TMask& m ); virtual int rewrite( const TMask& m );
virtual int read ( TMask& m ); virtual int read ( TMask& m );
virtual void init_insert_mode( TMask& m ); virtual void init_insert_mode( TMask& m );
virtual void init_modify_mode(TMask &m);
void elimina_vuote( const TMask& m); void elimina_vuote( const TMask& m);
virtual bool last_doc(char provv, int anno, const char* codnum, long& ndoc, TDate& datadoc) const;
public: public:
TGestione_preventivo_app() {} TGestione_preventivo_app() {}
@ -210,6 +215,7 @@ void TGestione_preventivo_msk::update_costi_ricavi(int nrow, bool update_sheet)
break; break;
} }
} }
bool TGestione_preventivo_msk::ss_notify(TSheet_field& ss, int r, KEY key) bool TGestione_preventivo_msk::ss_notify(TSheet_field& ss, int r, KEY key)
{ {
TGestione_preventivo_msk& mask = (TGestione_preventivo_msk&) ss.mask(); TGestione_preventivo_msk& mask = (TGestione_preventivo_msk&) ss.mask();
@ -322,7 +328,6 @@ bool TGestione_preventivo_msk::ss_notify(TSheet_field& ss, int r, KEY key)
return TDocumento_mask::ss_notify(ss, r, key); return TDocumento_mask::ss_notify(ss, r, key);
} }
void TGestione_preventivo_msk::highlight_row(int row, COLOR back, COLOR fore, bool dirty, bool update) void TGestione_preventivo_msk::highlight_row(int row, COLOR back, COLOR fore, bool dirty, bool update)
{ {
TDocumento_mask::highlight_row(row, back, fore, dirty, false); TDocumento_mask::highlight_row(row, back, fore, dirty, false);
@ -365,7 +370,6 @@ TVariable_mask * TGestione_preventivo_msk::riga_mask(int numriga)
} }
void TGestione_preventivo_msk::doc2mask(bool reload_clifo, bool force_load, bool update) void TGestione_preventivo_msk::doc2mask(bool reload_clifo, bool force_load, bool update)
{ {
TDocumento_mask::doc2mask(reload_clifo, force_load, false); TDocumento_mask::doc2mask(reload_clifo, force_load, false);
@ -534,29 +538,49 @@ bool TGestione_preventivo_msk::pe_incolla_handler(TMask_field& f, KEY k)
return ok; return ok;
} }
/*bool TGestione_preventivo_msk::pe_usek_handler(TMask_field& f, KEY k) bool TGestione_preventivo_msk::pe_new_revision_handler(TMask_field& f, KEY k)
{ {
bool ok = true;
if (k == K_SPACE) if (k == K_SPACE)
{ {
TGestione_preventivo_msk& mask = (TGestione_preventivo_msk&)f.mask(); TGestione_preventivo_msk& mask = (TGestione_preventivo_msk&)f.mask();
const bool has_k = mask.get_bool(F_USEK); TDocumento & d = mask.doc();
const TDocumento & d = mask.doc(); TDocumento backup(d);
const int righe = d.physical_rows(); const TTipo_documento & td = cached_tipodoc(d.get(DOC_TIPODOC));
TSheet_field & sh = mask.sfield(F_SHEET); const char stato_iniziale = d.stato();
for (int i = 0; i < righe; i++) d.put(DOC_STATO, td.stato_bloccato());
if (d.rewrite() == NOERR)
{ {
const TRiga_documento & row = d[i + 1]; long ndoc = d.get_long(DOC_NDOC);
const int level = row.get_int(RDOC_LEVEL);
const bool prodfin = level == 0;
const bool price_enabled = (i + 1 == d.physical_rows()) || (level >= d[i + 2].get_int(RDOC_LEVEL));
sh.enable_cell(i, sh.cid2index(FR_JOLLY2), price_enabled && has_k); if (mask.new_revision(d.get(DOC_CODNUM), ndoc))
{
d.renum_ndoc(ndoc);
d.put(DOC_STATO, td.stato_finale_inserimento());
ok = d.write() == NOERR;
if (ok)
{
mask.doc2mask(false);
mask.load_checks();
mask.mask2doc();
}
}
else
ok = false;
}
else
ok = false;
if (!ok)
{
backup.stato(stato_iniziale);
ok = backup.rewrite() == NOERR;
} }
sh.force_update();
} }
return true; return ok;
} */ }
/////////////////////// ///////////////////////
// HANDLER DI RIGA // // HANDLER DI RIGA //
@ -908,6 +932,28 @@ void TGestione_preventivo_msk::user_set_handler( short fieldid, int index)
} }
} }
bool TGestione_preventivo_msk::new_revision(const char* codnum, long& ndoc) const
{
const TCodice_numerazione& num = cached_numerazione(codnum);
const int revlen = num.revision_len();
if (revlen > 0)
{
real fattore = exp10(revlen); fattore.round(0);
const long divisore = fattore.integer();
const long newndoc = ndoc + 1;
if (((newndoc - ndoc) / divisore) != 0)
return false;
else
{
ndoc = newndoc;
return true;
}
}
return false;
}
TGestione_preventivo_msk::TGestione_preventivo_msk(const char* tipodoc) : TDocumento_mask(tipodoc), _clipboard_row(-1) TGestione_preventivo_msk::TGestione_preventivo_msk(const char* tipodoc) : TDocumento_mask(tipodoc), _clipboard_row(-1)
{ {
TConfig* configpe = new TConfig(CONFIG_DITTA, "pe"); TConfig* configpe = new TConfig(CONFIG_DITTA, "pe");
@ -947,6 +993,9 @@ TMask* TGestione_preventivo_app::get_mask( int mode )
TSheet_field & sh = m->sfield(F_SHEET); TSheet_field & sh = m->sfield(F_SHEET);
const int y = m->sh_y() - 1; const int y = m->sh_y() - 1;
m->add_button(F_REVISION, sh.page(), "Rev.", 76, y - 2, 1, 1, "");
m->set_handler(F_REVISION, TGestione_preventivo_msk::pe_new_revision_handler);
m->add_button(F_SHRINK_ALL, sh.page(), "--", 61, y - 1, 1, 1, "", BMP_DARROWU); m->add_button(F_SHRINK_ALL, sh.page(), "--", 61, y - 1, 1, 1, "", BMP_DARROWU);
m->set_handler(F_SHRINK_ALL, TGestione_preventivo_msk::pe_espandi_handler); m->set_handler(F_SHRINK_ALL, TGestione_preventivo_msk::pe_espandi_handler);
m->add_button(F_ZOOM_ALL, sh.page(), "++", 66, y -1, 1, 1, "", BMP_DARROWD); m->add_button(F_ZOOM_ALL, sh.page(), "++", 66, y -1, 1, 1, "", BMP_DARROWD);
@ -982,6 +1031,28 @@ TMask* TGestione_preventivo_app::get_mask( int mode )
return TMotore_application::get_mask(mode); return TMotore_application::get_mask(mode);
} }
bool TGestione_preventivo_app::last_doc(char provv, int anno, const char* codnum,
long& ndoc, TDate& ddoc) const
{
bool ok = TMotore_application::last_doc(provv, anno, codnum, ndoc, ddoc);
const TCodice_numerazione& num = cached_numerazione(codnum);
const int revlen = num.revision_len();
if (revlen > 0)
{
real fattore = exp10(revlen); fattore.round(0);
const long divisore = fattore.integer();
if (ok)
ndoc /= divisore;
else
ndoc = 1;
ndoc++;
ndoc *= divisore;
return true;
}
return ok;
}
//ridefinisco il metodo write delle TMotore_application //ridefinisco il metodo write delle TMotore_application
int TGestione_preventivo_app::write( const TMask& m ) int TGestione_preventivo_app::write( const TMask& m )
{ {
@ -1051,9 +1122,22 @@ int TGestione_preventivo_app::read(TMask& m)
void TGestione_preventivo_app::init_insert_mode(TMask &m) void TGestione_preventivo_app::init_insert_mode(TMask &m)
{ {
TGestione_preventivo_msk & mask = (TGestione_preventivo_msk&) m; TGestione_preventivo_msk & mask = (TGestione_preventivo_msk&) m;
TDocumento& d = mask.doc();
return TMotore_application::init_insert_mode(m); mask.disable(F_REVISION);
return TMotore_application::init_insert_mode(m);
}
void TGestione_preventivo_app::init_modify_mode(TMask &m)
{
TGestione_preventivo_msk & mask = (TGestione_preventivo_msk&) m;
TDocumento& d = mask.doc();
const TCodice_numerazione& num = cached_numerazione(d.get(DOC_CODNUM));
mask.enable(F_REVISION, num.revision_len() > 0);
return TMotore_application::init_modify_mode(m);
} }
int pe0400( int argc, char* argv[]) int pe0400( int argc, char* argv[])