diff --git a/cg/cg0200.cpp b/cg/cg0200.cpp index a183d4a0b..1ab06f331 100755 --- a/cg/cg0200.cpp +++ b/cg/cg0200.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -38,18 +39,21 @@ class CG0200_application : public TRelation_application virtual bool changing_mask(int mode) {return FALSE;} virtual bool protected_record(TRectype &rec); virtual const char* get_next_key(); + void init_pages(TMask& m); virtual void init_query_mode(TMask& m); virtual void init_query_insert_mode(TMask& m) {init_query_mode(m);} virtual void init_insert_mode(TMask& m) {init_query_mode(m);} - virtual void init_modify_mode(TMask& m) {init_query_mode(m);} + virtual void init_modify_mode(TMask& m) {init_pages(m);} //////////// static bool indsp_notify(int r, KEY key); - static bool indsp_handler(TMask_field& f, KEY key) { return TRUE; } + static bool indsp_handler(TMask_field& f, KEY key) ; virtual int write(const TMask& m); virtual int rewrite(const TMask& m); virtual int read(TMask& m); TSheet_field& indsp_sheet() const; + TArray_sheet* field_sheet(const int n) const; + void reset_sheet(); void indsp_pack(); void common_f(const TMask& m); /////////// @@ -332,7 +336,7 @@ HIDDEN bool codalleg_handler(TMask_field& f, KEY key) return TRUE; } -void CG0200_application::init_query_mode(TMask& m) +void CG0200_application::init_pages(TMask& m) { TConfig conf(CONFIG_DITTA, "cg"); @@ -341,28 +345,33 @@ void CG0200_application::init_query_mode(TMask& m) m.send_key(K_SHIFT + K_CTRL + (lbcn ? 's' : 'h'), -5); // Se non e' abilitata la gestione delle vendite disabilita le // maschere dalla 4 in poi - if (!gest_vend()) { for (int j=3; j<8;j++) m.disable_page(j); - // for (int i=F_CODINDDOC; i<= F_SHEET_G_VEN; i++) - // m.disable(i); } else { for (int j=3; j<8;j++) m.enable_page(j); - // for (int i=F_CODINDDOC; i<= F_SHEET_G_VEN; i++) - // m.enable(i); } } +void CG0200_application::init_query_mode(TMask& m) + +{ + init_pages(m); + if (gest_vend()) + reset_sheet(); +} + int CG0200_application::read(TMask& m) { + + TToken_string riga(240); + m.autoload(_rel); indsp_sheet().reset(); - TToken_string riga(240); for (int i=0; i< _rel->indirizzi_items();i++) { TRectype& rec=_rel->indirizzo(i); @@ -381,6 +390,17 @@ int CG0200_application::read(TMask& m) riga.add(rec.get("IVARID")); riga.add(rec.get("CODIND")); indsp_sheet().row(i)=riga; + + // Load the sheets of CODINDDOC, CODINDSP, CODINDEFF. + riga.cut(0); + riga.add(rec.get("CODIND")); + riga.add(rec.get("RAGSOC")); + riga.add(rec.get("INDIR")); + riga.add(rec.get("CIV")); + riga.add(rec.get("LOCALITA")); + field_sheet(F_CODINDDOC)->add(riga); + field_sheet(F_CODINDSP)->add(riga); + field_sheet(F_CODINDEFF)->add(riga); } return _rel->status(); } @@ -397,12 +417,31 @@ int CG0200_application::write(const TMask& m) return _rel->write(TRUE); } +TArray_sheet* CG0200_application::field_sheet(const int n) const +{ + TEdit_field& f=(TEdit_field&) _msk->field(n); + TArray_sheet* S=(TArray_sheet*) f.sheet()->sheet(); + return S; +} + TSheet_field& CG0200_application::indsp_sheet() const { TSheet_field& o_sheet=(TSheet_field&) _msk->field(F_SHEET_G_VEN); return o_sheet; } +void CG0200_application::reset_sheet() +{ + TToken_string nulla("|**Nessuno**||||"); + + app().field_sheet(F_CODINDDOC)->destroy(); + app().field_sheet(F_CODINDDOC)->add(nulla); + app().field_sheet(F_CODINDSP)->destroy(); + app().field_sheet(F_CODINDSP)->add(nulla); + app().field_sheet(F_CODINDEFF)->destroy(); + app().field_sheet(F_CODINDEFF)->add(nulla); +} + void CG0200_application::indsp_pack() { TArray& rows = indsp_sheet().rows_array(); @@ -451,6 +490,37 @@ void CG0200_application::common_f(const TMask& m) } } +bool CG0200_application::indsp_handler(TMask_field& f, KEY key) +{ + static int first_time=1; + + if (key == K_TAB && f.dirty()) // Was it changed ? + if (first_time) + { + TArray& righe=app().indsp_sheet().rows_array(); + int n=righe.items(); + reset_sheet(); + // Rebuild Sheets + for (int i=0; iadd(rigav); + app().field_sheet(F_CODINDSP)->add(rigav); + app().field_sheet(F_CODINDEFF)->add(rigav); + } + first_time=0; + } else + first_time=1; + return TRUE; +} + bool CG0200_application::indsp_notify(int r, KEY key) { TSheet_field& indsp=app().indsp_sheet(); @@ -460,7 +530,7 @@ bool CG0200_application::indsp_notify(int r, KEY key) case K_SPACE: { // Request to modify row #r - // Disable field # 101 (CODIND) update # of row + // Disable field CODIND update # of row TMask& m = indsp.sheet_mask(); if (m.get_int(F_CODINDI)==0) // Is it a new row ? @@ -511,6 +581,7 @@ bool CG0200_application::user_create() // initvar e arrmask _msk->set_handler(F_SHEET_G_VEN, indsp_handler); TSheet_field& ind = (TSheet_field&) _msk->field(F_SHEET_G_VEN); + ind.set_notify(indsp_notify); _saldi->setkey(2);