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

164 lines
6.2 KiB
C#

using System;
using System.Web;
//using System.Web.Services;
//using System.Web.Services.Protocols;
using System.Text;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace PDFGenerator.BusinessLayer.DataSection
{
public class DSS1PatrimonioComplessivo : IDataSection
{
#region IDataSection Members
StructColor toBeFound = new StructColor();
public DataSectionResult getDataSection(List<SessionStruct> tabelleSessione,string querySql,DataThread dataThread)
{
DataSectionResult dsr = new DataSectionResult();
int foundIdx = 0;
DataTable dt = null;
dt = SectionManager.GetDataSection(tabelleSessione, querySql, dataThread);
dsr.Esito = dt.Rows.Count;
if (dt.Rows.Count == 0)
{
return dsr;
}
toBeFound.Tipo = "TipoPatrimonio";
//prendo la prima ed unica riga del datatable
DataRow row = dt.Rows[0];
DataSetS1 ds1 = new DataSetS1();
//il colore è bianco
if (dataThread.TotalNegativeCurrentAccountValue != 0)
{
ds1.DatiPatrimonio.Columns["Controvalore"].Caption = "Controvalore *<br> (€) &nbsp; &nbsp; &nbsp; &nbsp;";
}
else
{
ds1.DatiPatrimonio.Columns["Controvalore"].Caption = "Controvalore <br> (€) &nbsp; &nbsp; &nbsp; &nbsp;";
}
ds1.DatiPatrimonio.Columns["Percentuale"].Caption = "Peso <br> (%) &nbsp;";
DataRow dr = ds1.DatiPatrimonio.NewRow();
dr["Patrimonio"] = "Finanziario";
dr["Controvalore"] = Convert.ToDecimal(row["FinanziarioCTV"]); //V + dataThread.PartiteViaggiantiDisinvestimento + dataThread.PartiteViaggiantiInvestimento;//V + dataThread.PartiteViaggiantiInv;
dr["Percentuale"] = row["FinanziarioPerc"];
dr["Red"] = 255;
dr["Green"] = 255;
dr["Blue"] = 255;
ds1.DatiPatrimonio.Rows.Add(dr);
//dati per grafico
dr = ds1.DatiGrafico.NewRow();
dr["Controvalore1"] = Convert.ToDecimal(row["BFCTV"]);// +dataThread.PartiteViaggiantiInvestimento + dataThread.PartiteViaggiantiDisinvestimento;
dr["Controvalore2"] = row["PatrimonioTerziCTV"];
//doppio colore perchè sulla prima riga del grafico e della tabella ci sono
//il patrimonio BF e il patrimonio Terzi
toBeFound.Codice = "PTBF";
foundIdx = ClsFunzioniGeneriche.findRightColors(toBeFound);
dr["Red"] = ClsFunzioniGeneriche.Colors[foundIdx].Red;
dr["Green"] = ClsFunzioniGeneriche.Colors[foundIdx].Green;
dr["Blue"] = ClsFunzioniGeneriche.Colors[foundIdx].Blue;
toBeFound.Codice = "PTTZ";
foundIdx = ClsFunzioniGeneriche.findRightColors(toBeFound);
dr["Red1"] = ClsFunzioniGeneriche.Colors[foundIdx].Red;
dr["Green1"] = ClsFunzioniGeneriche.Colors[foundIdx].Green;
dr["Blue1"] = ClsFunzioniGeneriche.Colors[foundIdx].Blue;
ds1.DatiGrafico.Rows.Add(dr);
toBeFound.Codice = "PTIM";
foundIdx = ClsFunzioniGeneriche.findRightColors(toBeFound);
dr = ds1.DatiPatrimonio.NewRow();
dr["Patrimonio"] = "Immobiliare";
dr["Controvalore"] = row["ImmobiliareCTV"];
dr["Percentuale"] = row["ImmobiliarePerc"];
dr["Red"] = ClsFunzioniGeneriche.Colors[foundIdx].Red;
dr["Green"] = ClsFunzioniGeneriche.Colors[foundIdx].Green;
dr["Blue"] = ClsFunzioniGeneriche.Colors[foundIdx].Blue;
ds1.DatiPatrimonio.Rows.Add(dr);
//dati per grafico
dr = ds1.DatiGrafico.NewRow();
dr["Controvalore1"] = row["ImmobiliareCTV"];
dr["Red"] = ClsFunzioniGeneriche.Colors[foundIdx].Red;
dr["Green"] = ClsFunzioniGeneriche.Colors[foundIdx].Green;
dr["Blue"] = ClsFunzioniGeneriche.Colors[foundIdx].Blue;
ds1.DatiGrafico.Rows.Add(dr);
toBeFound.Codice = "PTAL";
foundIdx = ClsFunzioniGeneriche.findRightColors(toBeFound);
dr = ds1.DatiPatrimonio.NewRow();
dr["Patrimonio"] = "Altro";
dr["Controvalore"] = row["AltroCTV"];
dr["Percentuale"] = row["AltroPerc"];
dr["Red"] = ClsFunzioniGeneriche.Colors[foundIdx].Red;
dr["Green"] = ClsFunzioniGeneriche.Colors[foundIdx].Green;
dr["Blue"] = ClsFunzioniGeneriche.Colors[foundIdx].Blue;
ds1.DatiPatrimonio.Rows.Add(dr);
//dati per grafico
dr = ds1.DatiGrafico.NewRow();
dr["Controvalore1"] = row["AltroCTV"];
dr["Red"] = ClsFunzioniGeneriche.Colors[foundIdx].Red;
dr["Green"] = ClsFunzioniGeneriche.Colors[foundIdx].Green;
dr["Blue"] = ClsFunzioniGeneriche.Colors[foundIdx].Blue;
ds1.DatiGrafico.Rows.Add(dr);
DataRow drTot = ds1.DatiPatrimonioTotale.NewRow();
drTot["Totale"] = "TOTALE";
drTot["Controvalore"] = Convert.ToDecimal(row["TotaleCTV"]); //+ dataThread.PartiteViaggiantiInvestimento + dataThread.PartiteViaggiantiDisinvestimento;
//V
drTot["Percentuale"] = 100.00;
ds1.DatiPatrimonioTotale.Rows.Add(drTot);
//Normalizzo le percentuali
FormatNum conv = new FormatNum();
if (dt.Rows.Count != 0)
conv.NormalizePerc(ds1.DatiPatrimonio, "Percentuale");
// 10/09/2009 il cliente ha chiesto di non visualizzare la sezione in caso di totale del patrimonio complessivo negativo.
if (Convert.ToDecimal(row["TotaleCTV"]) < 0)
{
dsr.Esito = 0;
dsr.DatiSezione = null;
}
else
{
dsr.Esito = dt.Rows.Count;
dsr.DatiSezione = ds1;
}
return dsr;
}
#endregion
}
}