From 6bc84c0a2ecc794248519b0bae90838368021ce8 Mon Sep 17 00:00:00 2001 From: luca Date: Wed, 9 Jun 2010 10:23:22 +0000 Subject: [PATCH] Patch level :10.0 Files correlati : Ricompilazione Demo : [ ] Commento : stampa registro sintetico cespiti con filtro analitico funzionante (ma secondo me inutile) git-svn-id: svn://10.65.10.50/trunk@20556 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ce/ce3900.cpp | 86 +++++++++++++------- ce/ce3900a.rep | 214 ++++++++++++++++++++++++------------------------- ce/celib.cpp | 25 ++++-- 3 files changed, 180 insertions(+), 145 deletions(-) diff --git a/ce/ce3900.cpp b/ce/ce3900.cpp index d8f97e647..619514a05 100755 --- a/ce/ce3900.cpp +++ b/ce/ce3900.cpp @@ -105,9 +105,11 @@ TStampa_sintetica_mask::TStampa_sintetica_mask() : TAutomask("ce3900"), _preview /////////////////////////////////////////////////////////////// // RECORDSET /////////////////////////////////////////////////////////////// - class TStampa_sintetica_recordset : public TISAM_recordset { +protected: + virtual void set_custom_filter(TCursor& cursor) const; + public: void set_filter(const TStampa_sintetica_mask& msk); TStampa_sintetica_recordset(const TString& sql) : TISAM_recordset(sql) { } @@ -115,6 +117,43 @@ public: static const TStampa_sintetica_recordset* myself = NULL; +static bool percutil_func(const TRelation* rel) +{ + const long dacat = myself->get_var("#DACAT").as_int(); + const long acat = myself->get_var("#ACAT").as_int(); + if (dacat > 0L || acat > 0L) + { + const long cespi_cat = rel->curr().get_long(CESPI_CODCAT); + if (cespi_cat < dacat || (acat > 0L && cespi_cat > acat)) + return false; + } + const TString16 idcespite = rel->curr().get(CESPI_IDCESPITE); + const int codes = myself->get_var("#CODES").as_int(); + const TString& codcdc = myself->get_var("#CODCDC").as_string(); + const TString& codcms = myself->get_var("#CODCMS").as_string(); + const TString& codfase = myself->get_var("#CODFASE").as_string(); + + const real percutil = ceca_percutil(idcespite, codes, codcdc, codcms, codfase); + return percutil > ZERO; +} + +void TStampa_sintetica_recordset::set_custom_filter(TCursor& cursor) const +{ + const TString& codcdc = get_var("#CODCDC").as_string(); + const TString& codcms = get_var("#CODCMS").as_string(); + const TString& codfase = get_var("#CODFASE").as_string(); + if (codcdc.full() || codcms.full() || codfase.full()) + { + myself = this; + cursor.set_filterfunction(percutil_func); + } + else + { + myself = NULL; + cursor.set_filterfunction(NULL); + } +} + //metodo per caricare i valori nel recordset dalla maschera...fighissimo!! void TStampa_sintetica_recordset::set_filter(const TStampa_sintetica_mask& msk) { @@ -133,32 +172,10 @@ void TStampa_sintetica_recordset::set_filter(const TStampa_sintetica_mask& msk) if (dacat.full() || acat.full()) { if (dacat == acat) - query << "&&(CODCAT==" << dacat << ")"; + query << "&&(STR(CODCAT==#DACAT))"; else - query << "&&(BETWEEN(CODCAT," << dacat << ',' << acat << "))"; + query << "&&(STR(BETWEEN(CODCAT,#DACAT,#ACAT)))"; } - - //parte analitica - const TString& codcdc = msk.get(F_CODCDC); - const TString& codcms = msk.get(F_CODCMS); - const TString& codfase = msk.get(F_CODFASE); - if (codcdc.full() || codcms.full() || codfase.full()) - { - query << "&&"; - - if (codcdc.full()) - query << "(BETWEEN(SALCECMS.CODCDC,#CODCDC,#CODCDC))&&"; - - if (codcms.full()) - query << "(BETWEEN(SALCECMS.CODCMS,#CODCMS,#CODCMS))&&"; - - if (codfase.full()) - query << "(BETWEEN(SALCECMS.CODFASE,#CODFASE,#CODFASE))&&"; - - query.rtrim(2); - query << "\nJOIN SALCECMS INTO IDCESPITE=IDCESPITE"; - } - //ordinamenti query << "\nBY CODCAT|CODIMP|CODLOC|IDCESPITE"; @@ -169,13 +186,20 @@ void TStampa_sintetica_recordset::set_filter(const TStampa_sintetica_mask& msk) if (exclude_aliens) set_var("#DATAINIZIO", msk.get_date(F_DATAINIZIO).date2ansi()); - //set var condizionali in analitica + //parte analitica + const int codes = msk.get_int(F_ESERCIZIO); + const TString& codcdc = msk.get(F_CODCDC); + const TString& codcms = msk.get(F_CODCMS); + const TString& codfase = msk.get(F_CODFASE); + set_var("#CODES", long(codes), true); + set_var("#DACAT", dacat, true); + set_var("#ACAT", acat, true); if (codcdc.full()) - set_var("#CODCDC", codcdc); + set_var("#CODCDC", codcdc, true); if (codcms.full()) - set_var("#CODCMS", codcms); + set_var("#CODCMS", codcms, true); if (codfase.full()) - set_var("#CODFASE", codfase); + set_var("#CODFASE", codfase, true); } @@ -226,7 +250,9 @@ void TStampa_sintetica_rep::set_filter(const TStampa_sintetica_mask& msk) _codcms = msk.get(F_CODCMS); _codfase = msk.get(F_CODFASE); - ((TStampa_sintetica_recordset*) recordset())->set_filter(msk); + TStampa_sintetica_recordset* rs = new TStampa_sintetica_recordset(EMPTY_STRING); + set_recordset(rs); + rs->set_filter(msk); } real TStampa_sintetica_rep::val_amm(const TRectype& rec_saldi) const diff --git a/ce/ce3900a.rep b/ce/ce3900a.rep index 6a563d399..c61677800 100755 --- a/ce/ce3900a.rep +++ b/ce/ce3900a.rep @@ -2,29 +2,29 @@ Registro cespiti sintetico -
+
- - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + +
-
+
MESSAGE RESET,F1.103 MESSAGE RESET,F1.102 @@ -36,26 +36,26 @@ MESSAGE RESET,F1.107 - - + + #SYSTEM.RAGSOC - + - + #SYSTEM.DATE - + - + #ANNO - + #SITUAZIONE @@ -64,24 +64,24 @@ MESSAGE RESET,F1.107
  • - + - + #CODCDC - + - + #CODCMS - + - + #CODFASE @@ -96,12 +96,12 @@ MESSAGE RESET,F2.104 MESSAGE RESET,F2.105 MESSAGE RESET,F2.106 MESSAGE RESET,F2.107 - - + + #DESCAT MESSAGE COPY,F2.98 - + CODCAT MESSAGE COPY,F2.97 @@ -125,15 +125,15 @@ MESSAGE RESET,F3.104 MESSAGE RESET,F3.105 MESSAGE RESET,F3.106 MESSAGE RESET,F3.107 - + - + CODIMP MESSAGE COPY,F3.97 - + MESSAGE TABLEREAD,CIM,CODIMP,S0 MESSAGE COPY,F3.98 @@ -158,172 +158,172 @@ MESSAGE RESET,F4.104 MESSAGE RESET,F4.105 MESSAGE RESET,F4.106 MESSAGE RESET,F4.107 - - + + CODLOC MESSAGE COPY,F4.97 - + MESSAGE TABLEREAD,LOC,CODLOC,S0 MESSAGE COPY,F4.98
  • -
    -
    - +
    +
    + IDCESPITE - + DTALIEN - + DTCOMP - + DTFUNZ - + DESC - + #PERCAMM - + #COSTOINI MESSAGE ADD,F2.101 MESSAGE ADD,F3.101 MESSAGE ADD,F4.101 - + #COSTOFIN MESSAGE ADD,F2.102 MESSAGE ADD,F3.102 MESSAGE ADD,F4.102 - + #102-#101 MESSAGE ADD,F2.103 MESSAGE ADD,F3.103 MESSAGE ADD,F4.103 - + #QAMM+#QAMMMV MESSAGE ADD,F2.104 MESSAGE ADD,F3.104 MESSAGE ADD,F4.104 - + #FAMM MESSAGE ADD,F2.105 MESSAGE ADD,F3.105 MESSAGE ADD,F4.105 - + #CESSELIM+#QAMMMV MESSAGE ADD,F2.106 MESSAGE ADD,F3.106 MESSAGE ADD,F4.106 - + #104+#105-#106 MESSAGE ADD,F2.107 MESSAGE ADD,F3.107 MESSAGE ADD,F4.107 - + #RESAMM-#QAMM MESSAGE ADD,F2.108 MESSAGE ADD,F3.108 MESSAGE ADD,F4.108
    -
    - - +
    + + - + #REPORT.PAGE
    - - - - - - - - - - + + + + + + + + + +
    - - - + + + - + MESSAGE ADD,F1.101 - + MESSAGE ADD,F1.102 - + MESSAGE ADD,F1.103 - + MESSAGE ADD,F1.104 - + MESSAGE ADD,F1.105 - + MESSAGE ADD,F1.106 - + MESSAGE ADD,F1.107 - + MESSAGE ADD,F1.108
    USE CESPI KEY 2 \ No newline at end of file diff --git a/ce/celib.cpp b/ce/celib.cpp index d8b56ea05..667eb61b2 100755 --- a/ce/celib.cpp +++ b/ce/celib.cpp @@ -441,6 +441,13 @@ bool null_fields(const TRectype& rec, const char* fld0, const char* fld1, const real ceca_percutil(const TString& idcespite, int anno, const TString& cdc, const TString& cms, const TString& fase) { + TLocalisamfile salcecms(LF_SALCECMS); + salcecms.put(SALCECMS_IDCESPITE, idcespite); + salcecms.put(SALCECMS_CODES, anno); + salcecms.put(SALCECMS_NRIGA, 1); + if (salcecms.read() != NOERR) + return ZERO; + TString query; query << "USE SALCECMS"; //se c'è almeno un filtro su cdc/cms/fase scatta la select analitica! @@ -456,7 +463,7 @@ real ceca_percutil(const TString& idcespite, int anno, query.rtrim(2); } else //se non si è scelto alcun parametro analitico -> la percentuale è 100% comunque! - return 1; + return UNO; query << "\nFROM IDCESPITE=#IDCESPITE CODES=#CODES"; query << "\nTO IDCESPITE=#IDCESPITE CODES=#CODES"; @@ -473,15 +480,17 @@ real ceca_percutil(const TString& idcespite, int anno, if (fase.full()) recset.set_var("#CODFASE", fase); - const long items = recset.items(); - real percutil = ZERO; - for (bool ok = recset.move_first(); ok; ok = recset.move_next()) + const long items = recset.items(); + if (items > 0) { - real perc = recset.get(SALCECMS_PERCUTIL).as_real(); - percutil += perc; + for (bool ok = recset.move_first(); ok; ok = recset.move_next()) + { + real perc = recset.get(SALCECMS_PERCUTIL).as_real(); + percutil += perc; + } + percutil /= CENTO; } - - percutil /= CENTO; + return percutil; } \ No newline at end of file