From 4b217258348218a577617ba79759f525d3310657 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 21 May 2009 13:20:02 +0000 Subject: [PATCH] Patch level : 10.0 308 Files correlati : cg3 Ricompilazione Demo : [ ] Commento : 0001299: richiamo registrazioni da mastrini Se richiamo le registrazioni contabili da mastrini, la prima volta funziona, dalla seconda il prgramma sembra bloccarsi, nel task manager ci sono aperi 2 volte il cg2.exe ed una volta il cg3. git-svn-id: svn://10.65.10.50/trunk@18900 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg2103.cpp | 17 ++-- cg/cg3600.cpp | 242 ++++++------------------------------------------- cg/cg3600a.uml | 2 +- 3 files changed, 35 insertions(+), 226 deletions(-) diff --git a/cg/cg2103.cpp b/cg/cg2103.cpp index 7595ffad5..cb658c5d4 100755 --- a/cg/cg2103.cpp +++ b/cg/cg2103.cpp @@ -155,18 +155,13 @@ const TString& TCausale::tipodoc() const bool TCausale::saldaconto(const TDate& datareg) const { - static TDate _data_sal(8,8,3); - if (datareg.ok()) + bool yes = tipomov() > 0; + if (yes && datareg.ok()) { - if (_data_sal.year() == 3) - { - TConfig cfg(CONFIG_DITTA, "cg"); - _data_sal = TDate(cfg.get("DatSal")); - } - if (datareg < _data_sal) - return false; + static TDate _data_sal = ini_get_string(CONFIG_DITTA, "cg", "DatSal"); + yes = datareg >= _data_sal; } - return tipomov() > 0; + return yes; } int TCausale::link_m770() const @@ -278,7 +273,7 @@ const TString& TCausale::compatible(const TCausale& c) const if (tipomov() != c.tipomov()) err = TR("il tipo di movimento"); - if (err != NULL) + if (err != NULL) { TString& msg = get_tmp_string(); msg.format(FR("La causale e' incompatibile per %s"), err); diff --git a/cg/cg3600.cpp b/cg/cg3600.cpp index 65a7a6250..7428f7049 100755 --- a/cg/cg3600.cpp +++ b/cg/cg3600.cpp @@ -1,12 +1,11 @@ #include #include "cg3.h" -#include "cglib01.h" #include "cglib02.h" #include "cg3600.h" #include -#include +#include #include #include #include @@ -14,7 +13,6 @@ #include #include #include -#include #include #include @@ -73,7 +71,7 @@ enum tipo_riga_mastrino { riga_mastrino, riga_contropartita }; class TRiga_mastrino : public TObject { tipo_riga_mastrino _type; // Tipo della riga - TRecnotype _mov, _rmov; // Numero fisico di record movivento e riga movimento + TRecnotype _mov, _rmov; // Numero fisico di record movimento e riga movimento real _dare, _avere; // Progressivi dare ed avere TDate _data; // Data di registrazione (Ottimizzazione) @@ -1543,200 +1541,26 @@ void TGrid_field::save_columns_order() const /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -// Maschere per colori +// Maschera per colori /////////////////////////////////////////////////////////// -class TRow_mask : public TMask -{ +class TColor_mask : public TSelect_color_mask +{ public: - virtual void update(); - - TRow_mask(); - virtual ~TRow_mask() { } + void get_colors(COLOR& mb, COLOR& mf, COLOR& cb, COLOR& cf); + TColor_mask(); }; -class TColor_mask : public TVariable_mask -{ - static TRow_mask* _sheet_mask; - static TMask* get_mask(int, TMask&) { return _sheet_mask; } - - COLOR _mas_back, _mas_fore; - COLOR _con_back, _con_fore; - -protected: - static bool color_handler(TMask_field& f, KEY k); - static bool reset_handler(TMask_field& f, KEY k); - - void type2colors(char tipo, COLOR& back, COLOR& fore) const; - -public: - void get_cur_colors(COLOR& back, COLOR& fore) const; - void set_cur_colors(COLOR back, COLOR fore); - - void get_colors(COLOR& mb, COLOR& mf, COLOR& cb, COLOR& cf) const; - - TColor_mask(COLOR mb, COLOR mf, COLOR cb, COLOR cf); - virtual ~TColor_mask(); -}; - -/////////////////////////////////////////////////////////// -// TRow_mask -/////////////////////////////////////////////////////////// - -TRow_mask* TColor_mask::_sheet_mask = NULL; - -TRow_mask::TRow_mask() : TMask("cg2100k", 1) -{ } - -void TRow_mask::update() +void TColor_mask::get_colors(COLOR& mb, COLOR& mf, COLOR& cb, COLOR& cf) { - TSheet_field* s = get_sheet(); - TColor_mask& m = (TColor_mask&)s->mask(); - COLOR back, fore; - m.get_cur_colors(back, fore); - - _pixmap = true; - set_pen(COLOR_BLACK); - - RCT rct; field(100).get_rect(rct); - set_brush(back); - frame(rct.left, 2*rct.top - rct.bottom - CHARY/2, rct.right, rct.top - CHARY/2, 0); - - field(99).get_rect(rct); - set_brush(fore); - frame(rct.left, 2*rct.top - rct.bottom - CHARY/2, rct.right, rct.top - CHARY/2, 0); - - _pixmap = false; - + get_color("M", mb, mf); + get_color("C", cb, cf); } -/////////////////////////////////////////////////////////// -// TColor_mask -/////////////////////////////////////////////////////////// - -void TColor_mask::type2colors(char tipo, COLOR& back, COLOR& fore) const +TColor_mask::TColor_mask() : TSelect_color_mask("cg3600b") { - if (toupper(tipo) == 'M') - { - back = _mas_back; - fore = _mas_fore; - } - else - { - back = _con_back; - fore = _con_fore; - } -} - -void TColor_mask::get_cur_colors(COLOR& back, COLOR& fore) const -{ - TSheet_field& s = (TSheet_field&)fld(0); - TToken_string& row = s.row(s.selected()); - const char tipo = row[5]; - type2colors(tipo, back, fore); -} - -void TColor_mask::set_cur_colors(COLOR back, COLOR fore) -{ - TSheet_field& s = (TSheet_field&)fld(0); - const int cur = s.selected(); - TToken_string& row = s.row(cur); - const char tipo = toupper(row[5]); - if (tipo == 'M') - { - _mas_back = back; - _mas_fore = fore; - } - else - { - _con_back = back; - _con_fore = fore; - } - s.set_back_and_fore_color(back, fore, cur); - s.force_update(cur); -} - -bool TColor_mask::color_handler(TMask_field& f, KEY k) -{ - if (k == K_SPACE) - { - TMask& m = f.mask(); - TColor_mask& cm = (TColor_mask&)m.get_sheet()->mask(); - - COLOR back, fore; - cm.get_cur_colors(back, fore); - const bool use_back = f.dlg() == 100; - - const COLOR col = choose_color(use_back ? back : fore, m.win()); - if (col != COLOR_INVALID) - { - if (use_back) - back = col; - else - fore = col; - cm.set_cur_colors(back, fore); - cm._sheet_mask->update(); - m.set_focus(); - } - } - return true; -} - -bool TColor_mask::reset_handler(TMask_field& f, KEY k) -{ - if (k == K_SPACE && f.yesno_box(TR("Si desidera azzerare tutti i colori?"))) - { - TColor_mask& m = (TColor_mask&) f.mask(); - - m._mas_back = NORMAL_BACK_COLOR; - m._mas_fore = NORMAL_COLOR; - m._con_back = NORMAL_BACK_COLOR; - m._con_fore = NORMAL_COLOR; - TSheet_field& s = (TSheet_field&)f.mask().field(101); - s.set_back_and_fore_color(NORMAL_BACK_COLOR, NORMAL_COLOR, -1); - s.force_update(); - } - return true; -} - -void TColor_mask::get_colors(COLOR& mb, COLOR& mf, COLOR& cb, COLOR& cf) const -{ - mb = _mas_back; - mf = _mas_fore; - cb = _con_back; - cf = _con_fore; -} - -TColor_mask::TColor_mask(COLOR mb, COLOR mf, COLOR cb, COLOR cf) - : TVariable_mask("cg2100k"), - _mas_back(mb), _mas_fore(mf), _con_back(cb), _con_fore(cf) -{ - set_handler(102, reset_handler); - set_caption("Colori delle righe mastrini"); - CHECK(_sheet_mask == NULL, "One color at time, please"); - _sheet_mask = new TRow_mask; - _sheet_mask->set_handler(99, color_handler); - _sheet_mask->set_handler(100, color_handler); - - TVariable_sheet_field& s = (TVariable_sheet_field&)fld(0); - s.set_getmask(get_mask); - - const char* const tipi = "MC"; - int row = 0; - for (const char* c = tipi; *c; c++) - { - COLOR back, fore; - type2colors(*c, back, fore); - TToken_string& riga = s.row(-1); - riga << TR("Riga ") << (*c == 'M' ? TR("mastrino") : TR("contropartita")); - s.set_back_and_fore_color(back, fore, row++); - } -} - -TColor_mask::~TColor_mask() -{ - delete _sheet_mask; - _sheet_mask = NULL; + add_color_def("M", TR("Riga mastrino"), REQUIRED_BACK_COLOR, FOCUS_COLOR); + add_color_def("C", TR("Riga contropartita"), NORMAL_BACK_COLOR, NORMAL_COLOR); } /////////////////////////////////////////////////////////// @@ -1750,8 +1574,10 @@ class TMastrini_grid : public TGrid_field TDecoder _causali; TEsercizi_contabili _esercizi; + TColor_mask _colmsk; COLOR _mas_back, _mas_fore; COLOR _con_back, _con_fore; + bool _primanoting; protected: // TGrid_field virtual bool on_record(long rec); @@ -1783,7 +1609,7 @@ public: }; TMastrini_grid::TMastrini_grid(TMask* m) - : TGrid_field(m), _causali(LF_CAUSALI, CAU_DESCR) + : TGrid_field(m), _causali(LF_CAUSALI, CAU_DESCR), _primanoting(false) { load_colors(); } @@ -2054,10 +1880,15 @@ void TMastrini_grid::on_grid_button() void TMastrini_grid::on_record_button(long rec) { - const TRectype& testata = _mastrino.testata(rec); - bool refresh = testata.edit(); - if (refresh && yesno_box(TR("Si desidera aggiornare il mastrino?"))) - reread(); + if (!_primanoting) + { + _primanoting = true; + const TRectype& testata = _mastrino.testata(rec); + bool refresh = testata.edit(); + if (refresh && yesno_box(TR("Si desidera aggiornare il mastrino?"))) + reread(); + _primanoting = false; + } } // Posso ridimensionare solo le descrizioni, le altre devono rimanere fisse per @@ -2117,30 +1948,13 @@ void TMastrini_grid::update_mask() const void TMastrini_grid::load_colors() { - TConfig conf(CONFIG_GUI, "cg3600b"); - _mas_back = conf.get_color("ColorMB", NULL, -1, REQUIRED_BACK_COLOR); - _mas_fore = conf.get_color("ColorMF", NULL, -1, FOCUS_COLOR); - _con_back = conf.get_color("ColorCB", NULL, -1, NORMAL_BACK_COLOR); - _con_fore = conf.get_color("ColorCF", NULL, -1, NORMAL_COLOR); -} - -void TMastrini_grid::save_colors() -{ - TConfig conf(CONFIG_GUI, "cg3600b"); - conf.set_color("ColorMB", _mas_back); - conf.set_color("ColorMF", _mas_fore); - conf.set_color("ColorCB", _con_back); - conf.set_color("ColorCF", _con_fore); + _colmsk.get_colors(_mas_back, _mas_fore, _con_back, _con_fore); } void TMastrini_grid::set_colors() { - TColor_mask m(_mas_back, _mas_fore, _con_back, _con_fore); - if (m.run() == K_ENTER) - { - m.get_colors(_mas_back, _mas_fore, _con_back, _con_fore); - save_colors(); - } + if (_colmsk.run() == K_ENTER) + load_colors(); } /////////////////////////////////////////////////////////// diff --git a/cg/cg3600a.uml b/cg/cg3600a.uml index eeab4387c..e6c820e9e 100755 --- a/cg/cg3600a.uml +++ b/cg/cg3600a.uml @@ -16,7 +16,7 @@ END BUTTON DLG_CONFIG 10 2 BEGIN PROMPT -25 -11 "Opzioni" - PICTURE TOOL_PRPERTIES + PICTURE TOOL_CONFIG END #include