From aa1d73d431ccc4f0cd0e063bc4e7f3b130dfc382 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 26 Jun 2007 11:06:18 +0000 Subject: [PATCH] Patch level : 4.0 Files correlati : ve2 Ricompilazione Demo : [ ] Commento : Corretta gestione codici articoli avanzati git-svn-id: svn://10.65.10.50/trunk@15451 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ve/ve2401.cpp | 65 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/ve/ve2401.cpp b/ve/ve2401.cpp index b78fdeb5c..3f9487a7d 100755 --- a/ve/ve2401.cpp +++ b/ve/ve2401.cpp @@ -37,22 +37,43 @@ static const TRectype& get_sublevel_info(const TString& code) class TCodart_mask : public TAutomask { + static TString4 _restart; + protected: virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); void create_level(int level, const TString& subcode); - void rebuild(); + void build_children(); public: + bool restart() const { return _restart.full(); } + TCodart_mask(); }; +TString4 TCodart_mask::_restart; + bool TCodart_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) { switch (o.dlg()) { case 101: - if (e == fe_modify) // Se cambio il contenuto del primo livello ... - rebuild(); // Ricostruisco la maschera + if (e == fe_init && restart()) + { + o.set(_restart); + _restart.cut(0); + o.check(STARTING_CHECK); + e = fe_modify; + } + if (e == fe_modify) // Se cambio il contenuto del primo livello ... + { + if (id2pos(102) < 0) + build_children(); // Ricostruisco la maschera + else + { + _restart = o.get(); + stop_run(K_FORCE_CLOSE); + } + } break; default: break; @@ -66,7 +87,7 @@ void TCodart_mask::create_level(int level, const TString& subcode) if (!fsa.empty()) { const TString4 code = fsa.get("CODTAB"); // Puo' essere diverso da subcode! - TString80 prompt = fsa.get("S0"); prompt.left_just(21); + TString80 prompt = fsa.get("S0"); prompt.left_just(30); const TString& picture = fsa.get("S1"); const int length = picture.len(); @@ -101,17 +122,14 @@ void TCodart_mask::create_level(int level, const TString& subcode) } } -void TCodart_mask::rebuild() +void TCodart_mask::build_children() { TArray& a = fields_array(); - int i = 0; - for (i = a.last(); i > 3; i--) - a.destroy(i); TString8 code = root_code(); code << get(101); const TString& children = cache().get("GSA", code, "S1"); - for (i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) { const TString& subcode = children.mid(i*3, 3); if (subcode.full()) @@ -132,19 +150,27 @@ TCodart_mask::TCodart_mask() : TAutomask(TR("Articolo guidato"), 1, 78, 13) bool advanced_get_codart(TString& code, TString& desc) { - TCodart_mask m; - const bool ok = m.run() == K_ENTER; - if (ok) + bool ok = false; + bool running = true; + while (running) { - code.cut(0); - desc.cut(0); - for (short id = 101; m.id2pos(id) >= 0; id++) + TCodart_mask m; + ok = m.run() == K_ENTER; + if (ok) { - code << m.get(id); - if (id == 102) - desc << ' '; - desc << m.get(id+100); + code.cut(0); + desc.cut(0); + for (short id = 101; m.id2pos(id) >= 0; id++) + { + code << m.get(id); + if (id == 102) + desc << ' '; + desc << m.get(id+100); + } + running = false; } + else + running = m.restart(); } return ok; } @@ -168,6 +194,7 @@ bool advanced_codart_handler(TMask_field& fld, KEY key) TMask& msk = fld.mask(); msk.set(F_DESCR, desc); msk.set(F_CODART, code, true); + msk.field(F_CODART).set_focus(); } } return true;