From 2c5a56cf7ea4d4f7edff7c837adac07cd1a3db56 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 15 Jun 2011 14:27:52 +0000 Subject: [PATCH] Patch level : 10.1024 Files correlati : ci0.exe ci2.exe Ricompilazione Demo : [ ] Commento : Corretta rilevazione ore git-svn-id: svn://10.65.10.50/branches/R_10_00@22268 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ci/ci0600.cpp | 34 +++++---- ci/ci2100a.uml | 6 -- ci/ci2200.cpp | 193 ++++++++++++++++++++++++++++++++++--------------- ci/ci2200a.uml | 4 +- ci/cilib.cpp | 15 ++-- ci/cilib.h | 4 +- 6 files changed, 164 insertions(+), 92 deletions(-) diff --git a/ci/ci0600.cpp b/ci/ci0600.cpp index e6d60d2c0..07f1e8e6c 100755 --- a/ci/ci0600.cpp +++ b/ci/ci0600.cpp @@ -186,11 +186,6 @@ void TDef_risoatt_msk::riempi_sheet() if (select.full()) select << "&&"; select << "(" << RILORE_CODICE << "==\"" << codice << "\")"; } -/* if (mese > 0) - { - if (select.full()) select << "&&"; - select << "STR(" RILORE_MESE << "==" << mese << ")"; - } */ if (tpora.full()) { if (select.full()) select << "&&"; @@ -214,17 +209,29 @@ void TDef_risoatt_msk::riempi_sheet() if (select.full()) query << "SELECT " << select << "\n"; - TString fromto = RILORE_TIPO "=\"D\""; + TString from = RILORE_TIPO "=\"D\""; + TString to = from; + TDate da(botime); + TDate a(eotime); if (anno > 0) { - fromto << " " << RILORE_ANNO << "=" << anno << " "; + da.set_day(1); + da.set_month(1); + da.set_year(anno); + a.set_year(anno); if (mese > 0) - fromto << " " << RILORE_MESE << "=" << mese << " "; + { + da.set_month(mese); + a.set_month(mese); + } + a.set_end_month(); } + from << " " << RILORE_DADATA << "=" << da.string() << " "; + to << " " << RILORE_DADATA << "=" << a.string() << " "; - query << "FROM " << fromto << "\n" - << "TO " << fromto; + query << "FROM " << from << "\n" + << "TO " << to; TISAM_recordset def(query); @@ -244,7 +251,7 @@ void TDef_risoatt_msk::riempi_sheet() case 'A': riga.add(cod, sheet.cid2index(S_CODATT)); break; default : break; } - TDate d(rilore.get_int(RILORE_GIORNO), rilore.get_int(RILORE_MESE), rilore.get_int(RILORE_ANNO)); + TDate d(rilore.get_date(RILORE_DADATA)); riga.add(d.string(), sheet.cid2index(S_DATA)); riga.add(rilore.get(RILORE_TPORA), sheet.cid2index(S_TPORA)); @@ -385,9 +392,8 @@ void TDef_risoatt_msk::registra() { rilroa.put(RILORE_TIPO, "D"); rilroa.put(RILORE_ID, id); - rilroa.put(RILORE_ANNO, anno); - rilroa.put(RILORE_MESE, mese); - rilroa.put(RILORE_GIORNO, giorno); + TDate d(giorno, mese, anno); + rilroa.put(RILORE_DADATA, d); rilroa.put(RILORE_TIPORA, tipora); rilroa.put(RILORE_CODICE, codice); rilroa.put(RILORE_TPORA, tpora); diff --git a/ci/ci2100a.uml b/ci/ci2100a.uml index 111f0970e..908c4fb40 100755 --- a/ci/ci2100a.uml +++ b/ci/ci2100a.uml @@ -14,12 +14,6 @@ BEGIN PICTURE TOOL_FINDREC END -BUTTON DLG_NEWREC 2 2 -BEGIN - PROMPT 1 1 "Nuovo" - PICTURE TOOL_NEWREC -END - BUTTON DLG_SAVEREC 2 2 BEGIN PROMPT 1 1 "Salva" diff --git a/ci/ci2200.cpp b/ci/ci2200.cpp index c69b60005..f67a44f60 100755 --- a/ci/ci2200.cpp +++ b/ci/ci2200.cpp @@ -50,6 +50,7 @@ public: virtual TObject* curr_node() const; const int pos() const { return _curr_node;} const TString &id() const { return *(TString *)curr_node(); } + const TString &id(int pos) const { return _content.row(pos); } virtual void node2id(const TObject* obj, TString& id) const; virtual bool has_root() const; @@ -130,12 +131,13 @@ void TRil_tree::highlight(const TString & query, int mese, int anno) for (bool ok = recset.move_first(); ok; ok = recset.move_next()) { - const int es = recset.get(RILORE_ANNO).as_int(); + const TDate & d = recset.get(RILORE_DADATA).as_date(); + const int es = esercizi().date2esc(d); full_years.set(es); } for (int i = 0; i < _content.items(); i++) - _t[i] = full_years[atoi(id())] ? _full : _normal; + _t[i] = full_years[atoi(id(i))] ? _full : _normal; } else if (_dett == "M") @@ -145,7 +147,8 @@ void TRil_tree::highlight(const TString & query, int mese, int anno) for (bool ok = recset.move_first(); ok; ok = recset.move_next()) { - const int mese = recset.get(RILORE_MESE).as_int(); + const TDate & d = recset.get(RILORE_DADATA).as_date(); + const int mese = d.month(); full_months.set(mese); } @@ -164,7 +167,8 @@ void TRil_tree::highlight(const TString & query, int mese, int anno) //tutte le celle che corrispondono a una data interessata da qualcosa for (bool ok = recset.move_first(); ok; ok = recset.move_next()) { - const int day = recset.get(RILORE_GIORNO).as_int(); + const TDate & d = recset.get(RILORE_DADATA).as_date(); + const int day = d.day(); full_days.set(day); } @@ -299,9 +303,9 @@ protected: const char * content_query(); void update_tree(); void update_disp(); - void update_prev(); + void update_prev(int r = -1); void update_column(short sid, const bool full); - void nuova_riga(); + void riempi_nuova_riga(int r); void azzera_riga(TSheet_field& sheet); void azzera_tutto(TSheet_field& sheet); void registra(); @@ -591,21 +595,36 @@ void TRilevamento_cons_msk::riempi_sheet(char tipo) query << "SELECT " << select << "\n"; const TString & dett = get(F_INTERVALLO); - TString fromto = RILORE_TIPO; - - fromto << "=\"" << tipo << "\""; + TString from; + from << RILORE_TIPO << "=\"" << tipo << "\""; + TString to(from); + TDate da(botime); + TDate a(eotime); + if (_anno > 0) { - fromto << " " << RILORE_ANNO << "=" << _anno << " "; + da.set_day(1); + da.set_month(1); + da.set_year(_anno); + a.set_year(_anno); if (dett != "A") { - fromto << RILORE_MESE << "=" << _mese << " "; + da.set_month(_mese); + a.set_month(_mese); if (dett != "M" && tipo == 'C') - fromto << RILORE_GIORNO << "=" << _giorno << " "; + { + da.set_day(_giorno); + a.set_day(_giorno); + } + else + a.set_end_month(); } } - query << "FROM " << fromto << "\n" - << "TO " << fromto; + from << " " << RILORE_DADATA << "=" << da.string() << " "; + to << " " << RILORE_DADATA << "=" << a.string() << " "; + + query << "FROM " << from << "\n" + << "TO " << to; TISAM_recordset def(query); @@ -637,7 +656,12 @@ void TRilevamento_cons_msk::riempi_sheet(char tipo) riga.add(rilore.get(RILORE_CIG), sheet.cid2index(S_CIG)); riga.add(tipo == 'D' ? 0 : rilore.get(RILORE_ID), sheet.cid2index(S_ID)); - sheet.check_row(sheet.items() - 1); + const int r = sheet.items() - 1; + + sheet.check_row(r); +// sheet.update_mask(r); + update_prev(r); +// sheet.update_row(r); } if (sheet.items() > 0) { @@ -770,16 +794,15 @@ void TRilevamento_cons_msk::update_disp() set(F_ORECONS, orecons); } -void TRilevamento_cons_msk::update_prev() +void TRilevamento_cons_msk::update_prev(int r) { TSheet_field & sf = sfield(F_SHEET); - if ( sf.items() > 0) - { - const int r = sf.selected(); + if (r < 0) + r = sf.selected(); - if (r < 0) - return; + if (r >= 0 && r < sf.items()) + { TToken_string & row = sf.row(r); //leggo dalla maschera i campi chiave di ricerca TString4 risoatt = row.get(sf.cid2index(S_RISOATT)); @@ -803,8 +826,6 @@ void TRilevamento_cons_msk::update_prev() TToken_string chiave; chiave.add(_anno); - chiave.add(_mese); - chiave.add(_giorno); chiave.add(risoatt); chiave.add(codice); chiave.add(tpora); @@ -818,34 +839,56 @@ void TRilevamento_cons_msk::update_prev() else { TString query; - query << "USE " << LF_RILORE << " KEY 5\n" - << "FROM " << RILORE_TIPO "=\"P\" " + + query << "USE " << LF_RILORE << " KEY 3"; + query << "\nFROM " << RILORE_TIPO "=\"P\" " << RILORE_TIPORA << "=" << risoatt << " " << RILORE_CODICE << "=" << codice << " " - << RILORE_TPORA << "=" << tpora << " " - << RILORE_CODCOSTO << "=" << codcosto << " " - << RILORE_CODCMS << "=" << codcms << " " - << RILORE_CODFASE << "=" << codfase - << " " << RILORE_ANNO << "=" << _anno << " " - << RILORE_MESE << "=" << 1 << " " - << RILORE_GIORNO << "=" << 1 << "\n"; + << RILORE_TPORA << "=" << tpora << " "; + query << RILORE_CODCOSTO << "=" << codcosto << " "; + query << RILORE_CODCMS << "=" << codcms << " "; + query << RILORE_CODFASE << "=" << codfase ; + query << "\n"; query << "TO " << RILORE_TIPO "=\"P\" " << RILORE_TIPORA << "=" << risoatt << " " << RILORE_CODICE << "=" << codice << " " - << RILORE_TPORA << "=" << tpora << " " - << RILORE_CODCOSTO << "=" << codcosto << " " - << RILORE_CODCMS << "=" << codcms << " " - << RILORE_CODFASE << "=" << codfase - << RILORE_ANNO << "=" << _anno << " " - << RILORE_MESE << "=" << 12 << " " - << RILORE_GIORNO << "=" << 31 << "\n"; - + << RILORE_TPORA << "=" << tpora << " "; + query << RILORE_CODCOSTO << "=" << codcosto << " "; + query << RILORE_CODCMS << "=" << codcms << " "; + query << RILORE_CODFASE << "=" << codfase ; + query << "\n"; + + const TString & dett = get(F_INTERVALLO); + + TDate inizio(1, 1, _anno); + TDate fine(31, 12, _anno); + if (dett == "G") + { + inizio.set_month(_mese); + fine.set_month(_mese); + fine.set_end_month(); + } TISAM_recordset def(query); real oreprev; for(bool ok = def.move_first(); ok; ok = def.move_next()) - oreprev += def.cursor()->curr().get_real(RILORE_QTAORE); + { + TDate da(def.get(RILORE_DADATA).as_date()); + TDate a(def.get(RILORE_ADATA).as_date()); + + if (a >= inizio && da <= fine) + { + real ore = def.get(RILORE_QTAORE).as_real(); + + if (da > inizio) + inizio = da; + if (a < fine) + fine = a; + ore = ore * (fine - inizio) / (a - da); + oreprev += ore; + } + } row.add(oreprev.string(), sf.cid2index(S_OREPREV)); sf.force_update(r); _oreprev.add(chiave, oreprev); @@ -907,27 +950,39 @@ const char * TRilevamento_cons_msk::content_query() if (select.full()) query << "SELECT " << select << "\n"; - TString fromto = RILORE_TIPO "=\"C\""; const TString & dett = get(F_INTERVALLO); + TString from = RILORE_TIPO "=\"C\""; + TString to(from); + TDate da(botime); + TDate a(eotime); if (dett != "A") { - fromto << " " << RILORE_ANNO << "=" << _anno << " "; + da.set_day(1); + da.set_month(1); + da.set_year(_anno); + a.set_year(_anno); if (dett != "M") - fromto << RILORE_MESE << "=" << _mese << " "; + { + da.set_month(_mese); + a.set_month(_mese); + } + a.set_end_month(); } - query << "FROM " << fromto << "\n" - << "TO " << fromto; + from << " " << RILORE_DADATA << "=" << da.string() << " "; + to << " " << RILORE_DADATA << "=" << a.string() << " "; + + query << "FROM " << from << "\n" + << "TO " << to; return query; } //NUOVA_RIGA: metodo che aggiunge una riga allo sheet //tenendo conto dei campi chiave compilati in testata -void TRilevamento_cons_msk::nuova_riga() +void TRilevamento_cons_msk::riempi_nuova_riga(int r) { TSheet_field& sheet = sfield(F_SHEET); - TToken_string & riga = sheet.row(-1); - const int r = sheet.items() - 1; + TToken_string & riga = sheet.row(r); TMask& msk = sheet.sheet_mask(); @@ -988,11 +1043,12 @@ void TRilevamento_cons_msk::registra() TString80 codcms; TString16 codfase; int err = NOERR; + const TString4 dett = get(F_INTERVALLO); FOR_EACH_SHEET_ROW(sheet, r, row) { TToken_string& riga = *(TToken_string*)row; - const TString4 del = riga.get(sheet.cid2index(S_DEL)); + const TString4 del = riga.get(sheet.cid2index(S_DEL)); const char tipora = riga.get_char(sheet.cid2index(S_RISOATT)); const TString16 codice = tipora == 'R' ? riga.get(sheet.cid2index(S_CODRIS)) : riga.get(sheet.cid2index(S_CODATT)); const TString4 tpora = riga.get(sheet.cid2index(S_TPORA)); @@ -1024,9 +1080,28 @@ void TRilevamento_cons_msk::registra() { rilroa.put(RILORE_TIPO, "C"); rilroa.put(RILORE_ID, id); - rilroa.put(RILORE_ANNO, _curr_anno); - rilroa.put(RILORE_MESE, _curr_mese); - rilroa.put(RILORE_GIORNO, _curr_giorno); + TDate da(_curr_giorno, _curr_mese, _curr_anno); + TDate a(_curr_giorno, _curr_mese, _curr_anno); + + if (dett == "A") + { + da.set_day(1); + a.set_month(1); + da.set_day(31); + a.set_month(12); + } + else + if (dett =="M") + { + da.set_day(1); + a.set_end_month(); + } + + if (id == 0L || dett == "G") + { + rilroa.put(RILORE_DADATA, da); + rilroa.put(RILORE_ADATA, a); + } rilroa.put(RILORE_TIPORA, tipora); rilroa.put(RILORE_CODICE, codice); rilroa.put(RILORE_TPORA, tpora); @@ -1041,8 +1116,10 @@ void TRilevamento_cons_msk::registra() if (_numcn.full() && _tipocn.full()) { - TDoc_key oldkey(rilroa); - const long ndoc = date2ndoc(TDate(_giorno, _mese, _anno)); + TString8 codnum = rilroa.get(RILORE_CODNUM); + TDoc_key oldkey(rilroa.get_date(RILORE_DADATA).year(), codnum, rilroa.get_long(RILORE_NDOC), rilroa.get_char(RILORE_PROVV)); + + const long ndoc = date2ndoc(da); if (oldkey.provv() != 'D') { @@ -1212,15 +1289,15 @@ bool TRilevamento_cons_msk::on_field_event(TOperable_field& f, TField_event e, l if (dett == "M") _mese = ((TRil_tree *) tfield(F_CALENDARIO).tree())->pos() + 1; else - _giorno = atoi(*((TString *) ((TRil_tree *) tfield(F_CALENDARIO).tree())->curr_node())); + _giorno = atoi(*((TString *) ((TRil_tree *) tfield(F_CALENDARIO).tree())->curr_node())); - riempi_sheet(); + riempi_sheet(); } break; case F_SHEET: if (e == se_notify_add) - nuova_riga(); + riempi_nuova_riga(jolly); else if (e == se_enter || e == se_leave) { diff --git a/ci/ci2200a.uml b/ci/ci2200a.uml index ebb0f5f1d..e484b7999 100755 --- a/ci/ci2200a.uml +++ b/ci/ci2200a.uml @@ -345,9 +345,9 @@ BEGIN PROMPT 45 11 "Prezzo " END -NUMBER S_OREPREV 6 2 +NUMBER S_OREPREV 7 2 BEGIN - PROMPT 60 11 "Ore Prev. " + PROMPT 60 11 "Ore Prev." FLAGS "D" END diff --git a/ci/cilib.cpp b/ci/cilib.cpp index 18f5bd756..40a95934c 100755 --- a/ci/cilib.cpp +++ b/ci/cilib.cpp @@ -724,7 +724,7 @@ int TRilevamento_ore::read(const char tipo, const long id, TReclock lock) return err; } -int TRilevamento_ore::read(const char tipo, const int anno, const int mese, const int giorno, const char tipora, const char *codice, const char *tpora, const char* codcosto, const char* codcms, const char* codfase, TReclock lock) +int TRilevamento_ore::read(const char tipo, const TDate & giorno, const char tipora, const char *codice, const char *tpora, const char* codcosto, const char* codcms, const char* codfase, TReclock lock) { TLocalisamfile rilore(LF_RILORE); int err = NOERR; @@ -732,11 +732,7 @@ int TRilevamento_ore::read(const char tipo, const int anno, const int mese, cons rilore.setkey(2); zero(); put(RILORE_TIPO, tipo); - //put(RILORE_ANNO, anno); - //put(RILORE_MESE, mese); - //put(RILORE_GIORNO, giorno); - TDate dadata(giorno, mese, anno); - put(RILORE_DADATA, dadata); + put(RILORE_DADATA, giorno); put(RILORE_TIPORA, tipora); put(RILORE_CODICE, codice); put(RILORE_TPORA, tpora); @@ -847,10 +843,10 @@ TRilevamento_ore::TRilevamento_ore(const char tipo, const long id) read(tipo, id); } -TRilevamento_ore::TRilevamento_ore(const char tipo, const int anno, const int mese, const int giorno, const char tipora, const char* codice, const char* tpora, const char* codcosto, const char* codcms, const char* codfase) +TRilevamento_ore::TRilevamento_ore(const char tipo, const TDate & giorno, const char tipora, const char* codice, const char* tpora, const char* codcosto, const char* codcms, const char* codfase) : TRectype(LF_RILORE) { - read(tipo, anno, mese, giorno, tipora, codice, tpora, codcosto, codcms, codfase); + read(tipo, giorno, tipora, codice, tpora, codcosto, codcms, codfase); } TRilevamento_ore::TRilevamento_ore() @@ -862,8 +858,7 @@ TRilevamento_ore::TRilevamento_ore() const long date2ndoc(const TDate& data) { - const TDate inizio(1, 1, data.year()); - return data - inizio + 1; + return data.month() * 100 + data.day(); } /////////////////////////// diff --git a/ci/cilib.h b/ci/cilib.h index 7a5d99927..dc81d5583 100755 --- a/ci/cilib.h +++ b/ci/cilib.h @@ -229,7 +229,7 @@ private: public: int read(const char tipo, const long id, TReclock lock = _nolock); - int read(const char tipo, const int anno, const int mese, const int giorno, const char tipora, const char* codice, const char* tpora, const char* codcosto, const char* codcms, const char* codfase, TReclock lock = _nolock); + int read(const char tipo, const TDate & giorno, const char tipora, const char* codice, const char* tpora, const char* codcosto, const char* codcms, const char* codfase, TReclock lock = _nolock); int remove(); void update_id(); int write_rewrite(); @@ -240,7 +240,7 @@ public: TRilevamento_ore(const TRectype& rec); TRilevamento_ore(const TRilevamento_ore& rilore); TRilevamento_ore(const char tipo, const long id); - TRilevamento_ore(const char tipo, const int anno, const int mese, const int giorno, const char tipora, const char* codice, const char* tpora, const char* codcosto, const char* codcms, const char* codfase); + TRilevamento_ore(const char tipo, const TDate & giorno, const char tipora, const char* codice, const char* tpora, const char* codcosto, const char* codcms, const char* codfase); TRilevamento_ore(); };