Statistica per sesso e età: aggiunto percentuale sul totale

git-svn-id: svn://10.65.10.50/trunk@6121 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
cris 1998-02-05 07:50:15 +00:00
parent e4bd566b98
commit 1c11ff53f3

View File

@ -240,17 +240,24 @@ void TStatSogxEta::crea_intestazione()
sep = ""; sep = "";
sep << "Categoria "; sep << "Categoria ";
sep << _catdon; sep << _catdon;
sep << " ";
TTable ctd("CTD");
ctd.zero();
ctd.put("CODTAB", _catdon);
ctd.read();
if (ctd.good())
sep << ctd.get("S0");
sep.center_just(80); sep.center_just(80);
row.reset(); row.reset();
row.put(sep); row.put(sep);
printer().setheaderline(3, row); printer().setheaderline(3, row);
sep = ""; sep = "";
sep << "Fascia di eta' Sconosciuto Maschi Femmine Non spec. Totale"; sep << "Fascia di eta' Sconosc. Maschi Femmine Non spec. Totale";
row.reset(); row.reset();
row.put(sep); row.put(sep);
printer().setheaderline(5, row); printer().setheaderline(5, row);
sep = ""; sep = "";
sep.fill('-'); sep.fill('-',95);
row.reset(); row.reset();
row.put(sep); row.put(sep);
printer().setheaderline(6, row); printer().setheaderline(6, row);
@ -346,6 +353,13 @@ void TStatSogxEta::stampa_sezione(TString16 codsez, TString16 codsot)
row.put(rigastampa); row.put(rigastampa);
printer().setheaderline(1, row); printer().setheaderline(1, row);
real totalegenerale = ZERO;
for (int t=0;t<_etaini.items();t++)
{
TRigaSFascia& riga = (TRigaSFascia&)_righe[t];
for (int i=0;i<_colonne->items();i++)
totalegenerale+=riga[i];
}
TRigaSFascia rigatotali(0,0); TRigaSFascia rigatotali(0,0);
TString16 valore; TString16 valore;
real totalefascia = ZERO; real totalefascia = ZERO;
@ -364,33 +378,41 @@ void TStatSogxEta::stampa_sezione(TString16 codsez, TString16 codsot)
rigastampa << valreal.string(); rigastampa << valreal.string();
rigastampa << " anni"; rigastampa << " anni";
totalefascia = ZERO; totalefascia = ZERO;
// ciclo per totali
for (int i=0;i<_colonne->items();i++)
{
rigatotali.aggiorna_valore(i,riga[i]);
totalefascia+=riga[i];
}
// ciclo per stampa // ciclo per stampa
int pos = 15; int pos = 15;
for (int j=0;j<_colonne->items();j++) for (int j=0;j<_colonne->items();j++)
{ {
//rigatotali.aggiorna_valore(i,riga[i]); rigatotali.aggiorna_valore(j,riga[j]);
//totalefascia+=riga[i]; totalefascia+=riga[j];
valore = ""; valore = "";
valore.format("%8d",riga[i].integer()); valore.format("%8d",riga[j].integer());
rigastampa.overwrite((const char*)valore, pos); rigastampa.overwrite((const char*)valore, pos);
real perc = (riga[j]/totalefascia)*100; if (totalegenerale != ZERO)
pos=pos+6; {
valore = ""; real perc = (riga[j]/totalegenerale)*100;
valore << perc.string(3,2); pos=pos+10;
rigastampa.overwrite((const char*)valore, pos); valore = "";
pos = pos+10; valore << perc.string(3,2);
rigastampa.overwrite((const char*)valore, pos);
pos = pos+6;
}
else
pos = pos+16;
} }
if (totalefascia != 0) if (totalefascia != ZERO)
{ {
valore = ""; valore = "";
valore.format("%8d",totalefascia.integer()); valore.format("%8d",totalefascia.integer());
rigastampa.overwrite((const char*)valore, pos+4); rigastampa.overwrite((const char*)valore, pos);
if (totalegenerale != ZERO)
{
real perc = (totalefascia/totalegenerale)*100;
pos=pos+10;
valore = "";
valore << perc.string(3,2);
rigastampa.overwrite((const char*)valore, pos);
pos = pos+6;
}
row.put((const char*) rigastampa); row.put((const char*) rigastampa);
printer().print(row); printer().print(row);
} }
@ -398,7 +420,7 @@ void TStatSogxEta::stampa_sezione(TString16 codsez, TString16 codsot)
// stampa totali per sezione // stampa totali per sezione
rigastampa = ""; rigastampa = "";
rigastampa.fill('-'); rigastampa.fill('-',95);
row.reset(); row.reset();
row.put(rigastampa); row.put(rigastampa);
printer().print(row); printer().print(row);
@ -407,18 +429,28 @@ void TStatSogxEta::stampa_sezione(TString16 codsez, TString16 codsot)
rigastampa = "Totale"; rigastampa = "Totale";
real totale; real totale;
totale = ZERO; totale = ZERO;
int pos = 21; int pos = 15;
for (int i=0;i<_colonne->items();i++) for (int i=0;i<_colonne->items();i++)
{ {
totale+=rigatotali[i]; totale+=rigatotali[i];
valore = ""; valore = "";
valore.format("%8d",rigatotali[i].integer()); valore.format("%8d",rigatotali[i].integer());
rigastampa.overwrite((const char*)valore, pos); rigastampa.overwrite((const char*)valore, pos);
pos = pos+10; if (totalegenerale != ZERO)
{
real perc = (rigatotali[i]/totalegenerale)*100;
pos=pos+10;
valore = "";
valore << perc.string(3,2);
rigastampa.overwrite((const char*)valore, pos);
pos = pos+6;
}
else
pos = pos+16;
} }
valore = ""; valore = "";
valore.format("%8d",totale.integer()); valore.format("%8d",totale.integer());
rigastampa.overwrite((const char*)valore, pos+4); rigastampa.overwrite((const char*)valore, pos);
row.put((const char*) rigastampa); row.put((const char*) rigastampa);
printer().print(row); printer().print(row);
printer().formfeed(); printer().formfeed();