2025-04-15 12:10:19 +02:00

113 lines
4.7 KiB
C#

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using PDFGenerator.BusinessLayer.DataSection;
using PDFGenerator.BusinessLayer;
using System.Collections.Generic;
namespace PDFGenerator.BusinessLayer.DataSection
{
class DSS145DistibuzionePerTassoRendimento: IDataSection
{
public DSS145DistibuzionePerTassoRendimento()
{
}
#region IDataSection Members
public DataSectionResult getDataSection(List<SessionStruct> tabelleSessione, string querySql, DataThread dataThread)
{
try
{
FormatNum num = new FormatNum();
DataSectionResult dsr = new DataSectionResult();
DataTable dt = SectionManager.GetDataSection(tabelleSessione, querySql, dataThread);
DataSetS145 ds145 = new DataSetS145();
decimal Totale = 0;
decimal TotPerc = 100;
decimal TotaleRap = 0;
decimal TotPercRap = 0;
for (int r = 0; r < dt.Rows.Count; r++) {
DataRow drTasso = ds145.Tasso.NewRow();
drTasso["TipoTasso"] = dt.Rows[r]["TipoTasso"].ToString();
drTasso["Controvalore"] = num.ConvertNum(dt.Rows[r]["Controvalore"]);
Totale += decimal.Parse(drTasso["Controvalore"].ToString());
drTasso["Percentage"] = Decimal.Round(Convert.ToDecimal(dt.Rows[r]["Percentage"]), 2, MidpointRounding.AwayFromZero);
TotPerc -= decimal.Parse(drTasso["Percentage"].ToString());
drTasso["Red"] = dt.Rows[r]["Red"];
drTasso["Green"] = dt.Rows[r]["Green"];
drTasso["Blue"] = dt.Rows[r]["Blue"];
ds145.Tasso.Rows.Add(drTasso);
}
if (ds145.Tasso.Rows.Count > 0)
ds145.Tasso.Rows[0]["Percentage"] = decimal.Parse(ds145.Tasso.Rows[0]["Percentage"].ToString()) + TotPerc;
foreach (DataSetS145.TassoRow Tasso in ds145.Tasso.Rows) {
if (Tasso["TipoTasso"].Equals("")) {
DataRow drNoRap = ds145.TassoNoRap.NewRow();
drNoRap["TipoTasso"] = "Patrimonio non rappresentabile";
drNoRap["Controvalore"] = Tasso["Controvalore"];
//Fc 17/12/2013
// Eliminazione rappresentazione percentuale Non Rappresentabile
//drNoRap["Percentage"] = Tasso["Percentage"];
drNoRap["Red"] = Tasso["Red"];
drNoRap["Green"] = Tasso["Green"];
drNoRap["Blue"] = Tasso["Blue"];
ds145.TassoNoRap.Rows.Add(drNoRap);
} else {
DataRow drRap = ds145.TassoRap.NewRow();
drRap["TipoTasso"] = Tasso["TipoTasso"];
drRap["Controvalore"] = Tasso["Controvalore"];
drRap["Percentage"] = Tasso["Percentage"];
drRap["Red"] = Tasso["Red"];
drRap["Green"] = Tasso["Green"];
drRap["Blue"] = Tasso["Blue"];
TotaleRap += decimal.Parse(Tasso["Controvalore"].ToString());
TotPercRap += decimal.Parse(Tasso["Percentage"].ToString());
ds145.TassoRap.Rows.Add(drRap);
}
}
//Fc 17/12/2013
// modifiche Descrizione secondo specifiche di F.Scirocco
DataRow drtotRap = ds145.TotaleRap.NewRow();
drtotRap["Descrizione"] = "Totale rappresentato";
drtotRap["Controvalore"] = num.ConvertNum(TotaleRap);
drtotRap["Percentage"] = num.ConvertNum(TotPercRap);
ds145.TotaleRap.Rows.Add(drtotRap);
// modifiche Descrizione secondo specifiche di F.Scirocco
DataRow drtot = ds145.Totale.NewRow();
drtot["Descrizione"] = "Totale";
drtot["Controvalore"] = num.ConvertNum(Totale);
drtot["Percentage"] = num.ConvertNum(100);
ds145.Totale.Rows.Add(drtot);
dsr.DatiSezione = ds145;
dsr.Esito = ds145.Tasso.Rows.Count;
return dsr;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}