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

188 lines
7.0 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 DSS152PatrimonioComplessivo : 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];
DataSetS152 ds152 = new DataSetS152();
//il colore è bianco
if (dataThread.TotalNegativeCurrentAccountValue != 0 || dataThread.TotalSelfNegCurrentAccountValue != 0)
{
ds152.DatiPatrimonio.Columns["Controvalore"].Caption = "Controvalore *<br> (€) &nbsp; &nbsp; &nbsp; &nbsp;";
}
else
{
ds152.DatiPatrimonio.Columns["Controvalore"].Caption = "Controvalore <br> (€) &nbsp; &nbsp; &nbsp; &nbsp;";
}
ds152.DatiPatrimonio.Columns["Percentuale"].Caption = "Peso <br> (%) &nbsp;";
DataRow dr = ds152.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;
ds152.DatiPatrimonio.Rows.Add(dr);
//dati per grafico
dr = ds152.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;
ds152.DatiGrafico.Rows.Add(dr);
toBeFound.Codice = "PTIM";
foundIdx = ClsFunzioniGeneriche.findRightColors(toBeFound);
dr = ds152.DatiPatrimonio.NewRow();
dr["Patrimonio"] = "Immobiliare";
dr["Controvalore"] = row["ImmobiliareCTV"];
dr["Percentuale"] = row["ImmobiliarePerc"];
ds152.DatiPatrimonio.Rows.Add(dr);
//dati per grafico
dr = ds152.DatiGrafico.NewRow();
// PROQUOTA 20181221
//dr["Controvalore1"] = row["ImmobiliareCTV"];
dr["Controvalore1"] = row["ImmobiliareCTV"] == row["ImmobiliarePQCTV"] ? "0" : row["ImmobiliarePQCTV"]; ;
dr["Controvalore2"] = (decimal)row["ImmobiliareCTV"] - (decimal)dr["Controvalore1"];
//--PROQUOTA 20181221
//dr["Red"] = ClsFunzioniGeneriche.Colors[foundIdx].Red;
//dr["Green"] = ClsFunzioniGeneriche.Colors[foundIdx].Green;
//dr["Blue"] = ClsFunzioniGeneriche.Colors[foundIdx].Blue;
toBeFound.Codice = "PTIM";
foundIdx = ClsFunzioniGeneriche.findRightColors(toBeFound);
dr["Red1"] = ClsFunzioniGeneriche.Colors[foundIdx].Red;
dr["Green1"] = ClsFunzioniGeneriche.Colors[foundIdx].Green;
dr["Blue1"] = ClsFunzioniGeneriche.Colors[foundIdx].Blue;
// PROQUOTA 20181221
toBeFound.Codice = "PTIMPQ";
foundIdx = ClsFunzioniGeneriche.findRightColors(toBeFound);
dr["Red"] = ClsFunzioniGeneriche.Colors[foundIdx].Red; ;
dr["Green"] = ClsFunzioniGeneriche.Colors[foundIdx].Green;
dr["Blue"] = ClsFunzioniGeneriche.Colors[foundIdx].Blue;
//--PROQUOTA 20181221
ds152.DatiGrafico.Rows.Add(dr);
toBeFound.Codice = "PTAL";
foundIdx = ClsFunzioniGeneriche.findRightColors(toBeFound);
dr = ds152.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;
ds152.DatiPatrimonio.Rows.Add(dr);
//dati per grafico
dr = ds152.DatiGrafico.NewRow();
dr["Controvalore1"] = row["AltroCTV"];
dr["Red"] = ClsFunzioniGeneriche.Colors[foundIdx].Red;
dr["Green"] = ClsFunzioniGeneriche.Colors[foundIdx].Green;
dr["Blue"] = ClsFunzioniGeneriche.Colors[foundIdx].Blue;
ds152.DatiGrafico.Rows.Add(dr);
DataRow drTot = ds152.DatiPatrimonioTotale.NewRow();
drTot["Totale"] = "TOTALE";
drTot["Controvalore"] = Convert.ToDecimal(row["TotaleCTV"]); //+ dataThread.PartiteViaggiantiInvestimento + dataThread.PartiteViaggiantiDisinvestimento;
//V
drTot["Percentuale"] = 100.00;
ds152.DatiPatrimonioTotale.Rows.Add(drTot);
//Normalizzo le percentuali
FormatNum conv = new FormatNum();
if (dt.Rows.Count != 0)
conv.NormalizePerc(ds152.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 = ds152;
}
return dsr;
}
#endregion
}
}