807 lines
44 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using Consulenza.ReportWriter.Business;
using Consulenza.ReportWriter.Business.OBJ_PDF;
using System.Data;
using Consulenza.ReportCommon;
using Consulenza.ReportWriter.Business.CHART_PDF;
using Consulenza.ReportWriter.Business.Entity;
using System.Collections.Generic;
using System.Linq;
namespace Consulenza.ReportWriter.Manager.Section.Unica
{
/// <summary>
/// S34.PatrimonioAltriIstitutiMacroCategoriaProdotto idSezione = 77
/// </summary>
public class S34 : Entity.Section
{
public S34(EnvironmentFacade environmentFacade, int idSection)
: base(environmentFacade, idSection)
{
try
{
Draw();
}
catch (Exception ex)
{
SectionLogger.Write("S34", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
}
}
//protected override sealed void OLD_Draw()
//{
// var dati = GetDataSet();
// if (presenzaGraficoBarre())
// {
// #region Testo introduttivo grafico
// AddElement(new SpacePDF(20));
// AddElement(new FormattedTextAreaPDF(getTesto1(), EnvironmentFacade.RendererFacade.XLeftLimit) {FontSize=7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
// AddElement(new SpacePDF(15));
// #endregion
// #region Tabella patrimonio
// var tabellaPatrimonio = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["patrimonio"])
// {
// Style = Style.ConsulenzaUnica,
// Header = false,
// Footer = false,
// AlternateRow = false,
// RowHeight = 25
// };
// tabellaPatrimonio.Columns.Add(new ColumnPDF("descrizione", 190, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo, "descrizione", string.Empty) { HeaderFontSize = 7, FontSize = 7 });
// tabellaPatrimonio.Columns.Add(new ColumnPDF("valore", 330, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "valore", string.Empty) { HeaderFontSize = 7, FontSize = 7, PaddingLeft = 5 });
// AddElement(tabellaPatrimonio);
// AddElement(new SpacePDF(25));
// #endregion
// #region Grafico a barre
// AddElement(new FormattedTextAreaPDF("Macro categoria", EnvironmentFacade.RendererFacade.XLeftLimit, 100) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, AutoIncrementYWritable = false, BackGroundMarginLeft = 5 });
// AddElement(new FormattedTextAreaPDF(string.Format("Distribuzione ({0})", isControvalore() ? "€" : "%"), EnvironmentFacade.RendererFacade.XLeftLimit + 110, 410) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, BackGroundMarginLeft = 5 });
// AddElement(new SpacePDF(10));
// var graficoBarre = new StackedPDF(EnvironmentFacade.RendererFacade.XLeftLimit + 110, 1F)
// {
// HeightSingleBar = 25,
// Width = 400,
// LabelFormatAxisY = isControvalore() ? FormatType.Intero : FormatType.Decimale2,
// ShowLineAxisX = true,
// PageBreak = true,
// DinamicFloatXEtichettaLateraleBarra = true,
// MinorGridAxisY = true,
// RemoveWhiteSpaceToTheRightAxisX = true,
// RemoveWhiteSpaceBetweenChartAndAxisX = true,
// MarginAxisY = 0,
// MarginAxisYFromTop = 0
// };
// //var dtGraficoBarre = dati.Tables["categorie"];
// var serieCollezione = new List<Serie> { new Serie { Name = "MacroCategoria", Border = true } };
// DataTable dtcate = new DataTable();
// dtcate = dati.Tables["categorie"].AsEnumerable().OrderBy(o=>o.Field<int>("Ordinamento")).CopyToDataTable();
// foreach (DataRow item in dtcate.Rows)
// {
// serieCollezione[0].Points.Add(new Point
// {
// ShowLabelAxisY = true,
// LabelAxisY = isControvalore() ? Helper.FormatCurrency(item["Controvalore"].ToString()) : Helper.FormatDecimal(item["Percentuale"].ToString(), 2),
// FontSizeLabelAxisY = 7,
// Color = new ColorPDF(Convert.ToInt32(item["Red"]), Convert.ToInt32(item["Green"]), Convert.ToInt32(item["Blue"])),
// Value = isControvalore() ? (Convert.ToDouble(item["Controvalore"]) == 0 ? 0.01 : Convert.ToDouble(item["Controvalore"])) : Convert.ToDouble(item["Percentuale"]) == 0 ? 0.01 : Convert.ToDouble(item["Percentuale"]), // Convert.ToDouble(Helper.FormatPercentage(Convert.ToDecimal(item["Percentuale"]), 2)),
// ShowLabelAxisX = true,
// LabelAxisX = item["MacroCategoria"].ToString(),
// FontSizeLabelAxisX = 7,
// FontBoldLabelAxisY = false
// });
// }
// graficoBarre.SeriesCollection = serieCollezione;
// AddElement(graficoBarre);
// #endregion
// #region Nota del Patrimonio
// if (GetNote1().Length > 0)
// {
// AddElement(new SpacePDF(20));
// AddElement(new FormattedTextAreaPDF(GetNote1(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
// }
// #endregion
// }
// if (presenzaTabella()) {
// #region Testo introduttivo tabella prodotti
// AddElement(new SpacePDF(25));
// AddElement(new FormattedTextAreaPDF(getTestoTabella(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
// AddElement(new SpacePDF(15));
// #endregion
// #region Tabella Prodotti X MacroCategoria
// var tabellaProdottiPerMacroCategoria = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["prodottoPerCategoria"], dati.Tables["prodottoPerCategoriaFooter"])
// {
// Style = Style.ConsulenzaUnica,
// Header = true,
// Footer = true,
// AlternateRow = false,
// HeaderHeight = 30,
// HeaderMargin = 2,
// HeaderFontSize = 7,
// PageBreak = true
// };
// #region Columns e FooterColumns
// tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Immagine", 15+150, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Objectpdf, string.Empty, "Intermediario") { HeaderFontSize = 7, FontSize = 7, DeltaYContent = 4, PaddingLeft = 5, HeaderPaddingLeft = 1 });
// //tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Intermediario", 150, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo, "Intermediario", "Intermediario") { FontSize = 7, HeaderFontSize = 7 });
// tabellaProdottiPerMacroCategoria.FooterColumns.Add(new ColumnPDF("Patrimonio", 165, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo) { FontSize = 7});
// tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Prodotto", 145, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo, "Prodotto", "Prodotto") { FontSize = 7, HeaderFontSize = 7 });
// tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Categoria", 80, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo, "Categoria", "Categoria") { HeaderFontSize = 7, FontSize = 7, HeaderPaddingLeft = 3, PaddingLeft = 3 });
// tabellaProdottiPerMacroCategoria.FooterColumns.Add(new ColumnPDF("Intermediario", 225, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo) { FontSize = 7, PaddingLeft = -4});
// tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Controvalore", 90, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Decimale, "Controvalore", "Controvalore<BR>attuale (€)") {HeaderFontSize=7, FontSize = 7, PaddingRight = 4 });
// tabellaProdottiPerMacroCategoria.FooterColumns.Add(new ColumnPDF("Controvalore", 90, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo) { FontSize = 7, PaddingRight = 3 });
// tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Peso", 40, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Decimale, "Peso", "Peso (%)") { HeaderFontSize = 7, FontSize = 7, PaddingRight = 5 });
// tabellaProdottiPerMacroCategoria.FooterColumns.Add(new ColumnPDF("Peso", 40, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo) { FontSize = 7 });
// int a = 0;
// foreach (var item in dati.Tables["prodottoPerCategoria"].Rows)
// {
// tabellaProdottiPerMacroCategoria.Cells[4, a].HorizontalAlignment = HorizontalAlignmentType.Destra;
// tabellaProdottiPerMacroCategoria.Cells[3, a].HorizontalAlignment = HorizontalAlignmentType.Destra;
// a++;
// }
// #endregion
// #region Cells
// int i = 0;
// foreach (DataRow row in dati.Tables["prodottoPerCategoria"].Rows)
// {
// if (Convert.ToBoolean(row["IsTotal"]))
// {
// // Sfondo grigio per la riga identificata con IsTotal [quella di intestazione di macro categoria]
// for (int c = 0; c < tabellaProdottiPerMacroCategoria.Columns.Count; c++)
// {
// tabellaProdottiPerMacroCategoria.Cells[c, i].BackgroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella;
// }
// var listaOggetti = new List<ObjectPDF> {
// new RectanglePDF(10, 10, new ColorPDF(row["CodiceHexMacroCategoria"].ToString())),
// new FormattedTextAreaPDF {
// Text = row["Intermediario"].ToString(),
// FontBold = true,
// FontColor = ColorPDF.Nero,
// DeltaX = 13.5F,
// FontSize = 7,
// DeltaY = 0.5F
// },
// };
// tabellaProdottiPerMacroCategoria.Cells[0, i].ValueObjectList.AddRange(listaOggetti);
// //tabellaProdottiPerMacroCategoria.Cells[0, i].ValueObject = new RectanglePDF(10, 10, new ColorPDF(row["CodiceHexMacroCategoria"].ToString()));
// }
// else
// {
// var listaOggetti = new List<ObjectPDF> {
// new FormattedTextAreaPDF {
// Text = row["Intermediario"].ToString(),
// FontBold = false,
// FontColor = ColorPDF.Nero,
// FontSize = 7,
// DeltaY = 0.5F
// },
// };
// tabellaProdottiPerMacroCategoria.Cells[0, i].ValueObjectList.AddRange(listaOggetti);
// }
// i++;
// }
// i = 0;
// foreach (DataRow row in dati.Tables["prodottoPerCategoriaFooter"].Rows)
// {
// if (Convert.ToBoolean(row["IsTotal"]))
// {
// // Sfondo grigio per la riga identificata con IsTotal [quella di intestazione di macro categoria]
// for (int c = 0; c < tabellaProdottiPerMacroCategoria.FooterColumns.Count; c++)
// {
// tabellaProdottiPerMacroCategoria.FooterCells[c, i].BackgroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella;
// }
// }
// i++;
// }
// #endregion
// #endregion
// AddElement(tabellaProdottiPerMacroCategoria);
// }
//}
protected override sealed void Draw()
{
var dati = GetDataSet();
#region Modifiche 20190628 per Evolutiva
string sVerticalText;
if (EnvironmentFacade.ReportEnvironment.ReportType.Equals(ReportType.Unica_Nucleo))
{
sVerticalText = "";
}
else
{
sVerticalText = "Le eventuali informazioni riguardanti investimenti da lei detenuti presso altri intermediari vengono elaborate secondo le indicazioni da lei ";
if (EnvironmentFacade.ReportEnvironment.PrivateBanker.CodiceRete.Equals("F"))
{
sVerticalText = sVerticalText + "fornite e/ o disponibili sul mercato, per le quali Fideuram non garantisce la completezza e la veridicità. ";
sVerticalText = sVerticalText + "La preghiamo di comunicare a Fideuram ogni successiva variazione a tali informazioni, al fine di consentire a Fideuram la correzione e laggiornamento dei dati contenuti ";
sVerticalText = sVerticalText + "nel presente report.Gli investimenti detenuti presso altri intermediari vengono utilizzati da Fideuram con finalità meramente informative e secondo le indicazioni da lei fornite, ";
sVerticalText = sVerticalText + "in modo da offrire una rappresentazione unitaria degli investimenti, senza con ciò formare oggetto di raccomandazioni personalizzate o di rendicontazione ufficiale.";
}
else
{
sVerticalText = sVerticalText + "fornite e/ o disponibili sul mercato, per le quali Sanpaolo Invest SIM non garantisce la completezza e la veridicità. ";
sVerticalText = sVerticalText + "La preghiamo di comunicare a Sanpaolo Invest SIM ogni successiva variazione a tali informazioni, al fine di consentire a Sanpaolo Invest SIM la correzione e laggiornamento dei dati contenuti ";
sVerticalText = sVerticalText + "nel presente report.Gli investimenti detenuti presso altri intermediari vengono utilizzati da Sanpaolo Invest SIM con finalità meramente informative e secondo le indicazioni da lei fornite, ";
sVerticalText = sVerticalText + "in modo da offrire una rappresentazione unitaria degli investimenti, senza con ciò formare oggetto di raccomandazioni personalizzate o di rendicontazione ufficiale.";
}
}
FormattedTextAreaPDF testoPaginaVerticale = null;
testoPaginaVerticale = new FormattedTextAreaPDF(sVerticalText, EnvironmentFacade.RendererFacade.XLeftLimit - 35, 620)
{
TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify,
FontSize = 5,
TextVerticalDirection = true,
Y = 745
};
var listaOggettiDaRipetere = new List<ObjectPDF> { testoPaginaVerticale };
AddElement(listaOggettiDaRipetere);
AddElement(new RepeaterPDF(listaOggettiDaRipetere));
#endregion
if (presenzaGraficoBarre())
{
#region Testo introduttivo grafico
#region Modifiche 20190628 per Evolutiva
//AddElement(new SpacePDF(20));
#endregion
AddElement(new FormattedTextAreaPDF(getTesto1(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
AddElement(new SpacePDF(15));
#endregion
#region Tabella patrimonio
var tabellaPatrimonio = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["patrimonio"])
{
Style = Style.ConsulenzaUnica,
Header = false,
Footer = false,
AlternateRow = false,
RowHeight = 25
};
tabellaPatrimonio.Columns.Add(new ColumnPDF("descrizione", 190, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo, "descrizione", string.Empty) { HeaderFontSize = 7, FontSize = 7 });
tabellaPatrimonio.Columns.Add(new ColumnPDF("valore", 330, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "valore", string.Empty) { HeaderFontSize = 7, FontSize = 7, PaddingLeft = 5 });
AddElement(tabellaPatrimonio);
AddElement(new SpacePDF(25));
#endregion
#region Grafico a barre
AddElement(new FormattedTextAreaPDF("Macro categoria", EnvironmentFacade.RendererFacade.XLeftLimit, 100) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, AutoIncrementYWritable = false, BackGroundMarginLeft = 5 });
AddElement(new FormattedTextAreaPDF(string.Format("Distribuzione ({0})", isControvalore() ? "€" : "%"), EnvironmentFacade.RendererFacade.XLeftLimit + 110, 410) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, BackGroundMarginLeft = 5 });
AddElement(new SpacePDF(10));
var graficoBarre = new StackedPDF(EnvironmentFacade.RendererFacade.XLeftLimit + 110, 1F)
{
HeightSingleBar = 25,
Width = 400,
LabelFormatAxisY = isControvalore() ? FormatType.Intero : FormatType.Decimale2,
ShowLineAxisX = true,
PageBreak = true,
DinamicFloatXEtichettaLateraleBarra = true,
MinorGridAxisY = true,
RemoveWhiteSpaceToTheRightAxisX = true,
RemoveWhiteSpaceBetweenChartAndAxisX = true,
MarginAxisY = 0,
MarginAxisYFromTop = 0
};
//var dtGraficoBarre = dati.Tables["categorie"];
var serieCollezione = new List<Serie> { new Serie { Name = "MacroCategoria", Border = true } };
DataTable dtcate = new DataTable();
dtcate = dati.Tables["categorie"].AsEnumerable().OrderBy(o => o.Field<int>("Ordinamento")).CopyToDataTable();
foreach (DataRow item in dtcate.Rows)
{
serieCollezione[0].Points.Add(new Point
{
ShowLabelAxisY = true,
LabelAxisY = isControvalore() ? Helper.FormatCurrency(item["Controvalore"].ToString()) : Helper.FormatDecimal(item["Percentuale"].ToString(), 2),
FontSizeLabelAxisY = 7,
Color = new ColorPDF(Convert.ToInt32(item["Red"]), Convert.ToInt32(item["Green"]), Convert.ToInt32(item["Blue"])),
Value = isControvalore() ? (Convert.ToDouble(item["Controvalore"]) == 0 ? 0.01 : Convert.ToDouble(item["Controvalore"])) : Convert.ToDouble(item["Percentuale"]) == 0 ? 0.01 : Convert.ToDouble(item["Percentuale"]), // Convert.ToDouble(Helper.FormatPercentage(Convert.ToDecimal(item["Percentuale"]), 2)),
ShowLabelAxisX = true,
LabelAxisX = item["MacroCategoria"].ToString(),
FontSizeLabelAxisX = 7,
FontBoldLabelAxisY = false
});
}
graficoBarre.SeriesCollection = serieCollezione;
AddElement(graficoBarre);
#endregion
#region Nota del Patrimonio
if (GetNote1().Length > 0)
{
AddElement(new SpacePDF(20));
AddElement(new FormattedTextAreaPDF(GetNote1(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
}
#endregion
}
if (presenzaTabella())
{
#region Testo introduttivo tabella prodotti
AddElement(new SpacePDF(25));
AddElement(new FormattedTextAreaPDF(getTestoTabella(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
AddElement(new SpacePDF(15));
#endregion
#region Tabella Prodotti X MacroCategoria
var tabellaProdottiPerMacroCategoria = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["prodottoPerCategoria"], dati.Tables["prodottoPerCategoriaFooter"])
{
Style = Style.ConsulenzaUnica,
Header = true,
Footer = true,
AlternateRow = false,
HeaderHeight = 30,
HeaderMargin = 2,
HeaderFontSize = 7,
PageBreak = true
};
#region Columns e FooterColumns
tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Immagine", 15 + 150, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Objectpdf, string.Empty, "Intermediario") { HeaderFontSize = 7, FontSize = 7, DeltaYContent = 4, PaddingLeft = 5, HeaderPaddingLeft = 1 });
//tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Intermediario", 150, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo, "Intermediario", "Intermediario") { FontSize = 7, HeaderFontSize = 7 });
tabellaProdottiPerMacroCategoria.FooterColumns.Add(new ColumnPDF("Patrimonio", 165, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo) { FontSize = 7 });
tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Prodotto", 145, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo, "Prodotto", "Prodotto") { FontSize = 7, HeaderFontSize = 7 });
tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Categoria", 80, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo, "Categoria", "Categoria") { HeaderFontSize = 7, FontSize = 7, HeaderPaddingLeft = 3, PaddingLeft = 3 });
tabellaProdottiPerMacroCategoria.FooterColumns.Add(new ColumnPDF("Intermediario", 225, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo) { FontSize = 7, PaddingLeft = -4 });
tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Controvalore", 90, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Decimale, "Controvalore", "Controvalore<BR>attuale (€)") { HeaderFontSize = 7, FontSize = 7, PaddingRight = 4 });
tabellaProdottiPerMacroCategoria.FooterColumns.Add(new ColumnPDF("Controvalore", 90, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo) { FontSize = 7, PaddingRight = 3 });
tabellaProdottiPerMacroCategoria.Columns.Add(new ColumnPDF("Peso", 40, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Decimale, "Peso", "Peso (%)") { HeaderFontSize = 7, FontSize = 7, PaddingRight = 5 });
tabellaProdottiPerMacroCategoria.FooterColumns.Add(new ColumnPDF("Peso", 40, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo) { FontSize = 7 });
int a = 0;
foreach (var item in dati.Tables["prodottoPerCategoria"].Rows)
{
tabellaProdottiPerMacroCategoria.Cells[4, a].HorizontalAlignment = HorizontalAlignmentType.Destra;
tabellaProdottiPerMacroCategoria.Cells[3, a].HorizontalAlignment = HorizontalAlignmentType.Destra;
a++;
}
#endregion
#region Cells
int i = 0;
foreach (DataRow row in dati.Tables["prodottoPerCategoria"].Rows)
{
if (Convert.ToBoolean(row["IsTotal"]))
{
// Sfondo grigio per la riga identificata con IsTotal [quella di intestazione di macro categoria]
for (int c = 0; c < tabellaProdottiPerMacroCategoria.Columns.Count; c++)
{
tabellaProdottiPerMacroCategoria.Cells[c, i].BackgroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella;
}
var listaOggetti = new List<ObjectPDF> {
new RectanglePDF(10, 10, new ColorPDF(row["CodiceHexMacroCategoria"].ToString())),
new FormattedTextAreaPDF {
Text = row["Intermediario"].ToString(),
FontBold = true,
FontColor = ColorPDF.Nero,
DeltaX = 13.5F,
FontSize = 7,
DeltaY = 0.5F
},
};
tabellaProdottiPerMacroCategoria.Cells[0, i].ValueObjectList.AddRange(listaOggetti);
//tabellaProdottiPerMacroCategoria.Cells[0, i].ValueObject = new RectanglePDF(10, 10, new ColorPDF(row["CodiceHexMacroCategoria"].ToString()));
}
else
{
var listaOggetti = new List<ObjectPDF> {
new FormattedTextAreaPDF {
Text = row["Intermediario"].ToString(),
FontBold = false,
FontColor = ColorPDF.Nero,
FontSize = 7,
DeltaY = 0.5F
},
};
tabellaProdottiPerMacroCategoria.Cells[0, i].ValueObjectList.AddRange(listaOggetti);
}
i++;
}
i = 0;
foreach (DataRow row in dati.Tables["prodottoPerCategoriaFooter"].Rows)
{
if (Convert.ToBoolean(row["IsTotal"]))
{
// Sfondo grigio per la riga identificata con IsTotal [quella di intestazione di macro categoria]
for (int c = 0; c < tabellaProdottiPerMacroCategoria.FooterColumns.Count; c++)
{
tabellaProdottiPerMacroCategoria.FooterCells[c, i].BackgroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella;
}
}
i++;
}
#endregion
#endregion
AddElement(tabellaProdottiPerMacroCategoria);
}
}
/// <summary>
/// Recupera i dati necessari alla Section restituendo un DataTable.
/// </summary>
/// <returns></returns>
protected sealed override DataTable GetDataTable()
{
return null;
}
/// <summary>
/// Recupera i dati necessari alla Section restituendo un DataSet.
/// </summary>
/// <returns></returns>
protected sealed override DataSet GetDataSet()
{
var ds = new DataSet();
ds.Tables.Add(new DataTable("patrimonio"));
ds.Tables.Add(new DataTable("categorie"));
ds.Tables.Add(new DataTable("prodotto"));
ds.Tables.Add(new DataTable("prodottoPerCategoria"));
ds.Tables.Add(new DataTable("prodottoPerCategoriaFooter"));
const string stringReplaceIfZero = "0,00";
var dataMacroCategoria = datiSeiUnico.patrimonioUnit().patrimonioTerzi.macroCategoria; ;
var dataDettaglioProdotti = datiSeiUnico.patrimonioUnit().patrimonioTerzi.dettaglioProdotti.dettaglioProdotti.ToList();
var displayInfo = datiSeiUnico.displayInfos().macroCategoriaDisplayInfos.ToList();
var totaleAltri = Convert.ToDecimal(dataMacroCategoria.totaliPatrimonio.risorseFinanziarie +
dataMacroCategoria.totaliPatrimonio.contoCorrente);
var pesoAltri = Helper.FormatDecimal((dataMacroCategoria.distribuzione.pesoCCTot * 100).ToString(),2);
string RisorseFinanziarie = datiSeiUnico.patrimonioUnit().patrimonioTerzi.patrimonioTerziBean.risorseFinanziarieTerzi.ToString();
var patrimonio = dataMacroCategoria.totaliPatrimonio;
#region Patrimonio terzi
ds.Tables["patrimonio"].Columns.Add(new DataColumn("Descrizione", typeof(string)));
ds.Tables["patrimonio"].Columns.Add(new DataColumn("Valore", typeof(string)));
ds.Tables["patrimonio"].Rows.Add(string.Format(
"Patrimonio altri Istituti (€){0}", (GetNote1().Length>0 ? "*" : "")),
Helper.FormatCurrency(datiSeiUnico.TRZ_TOTALEPOSITIVO.ToString())
);
#endregion
#region Macro Categorie di Prodotto
ds.Tables["categorie"].Columns.Add(new DataColumn("MacroCategoria", typeof(string)));
ds.Tables["categorie"].Columns.Add(new DataColumn("Red", typeof(int)));
ds.Tables["categorie"].Columns.Add(new DataColumn("Green", typeof(int)));
ds.Tables["categorie"].Columns.Add(new DataColumn("Blue", typeof(int)));
ds.Tables["categorie"].Columns.Add(new DataColumn("Controvalore", typeof(decimal)));
ds.Tables["categorie"].Columns.Add(new DataColumn("Percentuale", typeof(decimal)));
ds.Tables["categorie"].Columns.Add(new DataColumn("Ordinamento", typeof(int)));
foreach (var itemDistribuzione in dataMacroCategoria.distribuzione.elencoSlice)
{
if (itemDistribuzione.sliceRappresentabile)
{
var mapDisplayInfo = displayInfo.FirstOrDefault(o => o.key.Equals(itemDistribuzione.codice)).value;
var colore = new ColorPDF(mapDisplayInfo.fill);
var ordinamento = mapDisplayInfo.order;
ds.Tables["categorie"].Rows.Add(itemDistribuzione.descrizione, colore.Red, colore.Green, colore.Blue, itemDistribuzione.ctvCC, itemDistribuzione.pesoCC * 100, ordinamento);
}
}
ds.Tables["categorie"].AsEnumerable().OrderBy(r => r.Field<int>("Ordinamento"));
#endregion
#region Prodotti
ds.Tables["prodotto"].Columns.Add(new DataColumn("OrdinamentoMacroCategoria", typeof(int)));
ds.Tables["prodotto"].Columns.Add(new DataColumn("CodiceHexMacroCategoria", typeof(string)));
ds.Tables["prodotto"].Columns.Add(new DataColumn("Intermediario", typeof(string)));
ds.Tables["prodotto"].Columns.Add(new DataColumn("Prodotto", typeof(string)));
ds.Tables["prodotto"].Columns.Add(new DataColumn("MacroCategoria", typeof(string)));
ds.Tables["prodotto"].Columns.Add(new DataColumn("Categoria", typeof(string)));
ds.Tables["prodotto"].Columns.Add(new DataColumn("Controvalore", typeof(decimal)));
ds.Tables["prodotto"].Columns.Add(new DataColumn("Peso", typeof(decimal)));
ds.Tables["prodotto"].Columns.Add(new DataColumn("FontBold", typeof(bool)));
ds.Tables["prodotto"].Columns.Add(new DataColumn("ReplaceIfZero", typeof(string)));
ds.Tables["prodotto"].Columns.Add(new DataColumn("CanLastRow", typeof(bool)));
ds.Tables["prodotto"].Columns.Add(new DataColumn("IsTotal", typeof(bool)));
foreach (var itemMacroCategoria in dataMacroCategoria.distribuzionePerProdotti.listaProdotti)
{
if (itemMacroCategoria.rappresentabile)
{
var itemPosizione = dataDettaglioProdotti.FirstOrDefault(o => o.chiaveProdottoTerzi.Equals(itemMacroCategoria.chiaveAggregazione));
var mapDisplayInfo = displayInfo.FirstOrDefault(o => o.key.Equals(dataMacroCategoria.distribuzione.elencoSlice.FirstOrDefault(oo => oo.descrizione.Equals(itemMacroCategoria.listaSlice[0].descrizione)).codice)).value;
var rowProdotti = ds.Tables["prodotto"].NewRow();
rowProdotti["OrdinamentoMacroCategoria"] = mapDisplayInfo.order;
rowProdotti["CodiceHexMacroCategoria"] = mapDisplayInfo.fill;
rowProdotti["Intermediario"] = itemPosizione.nomeIntermediario;
rowProdotti["Prodotto"] = itemPosizione.prodotto.nomeProdotto;
rowProdotti["MacroCategoria"] = itemMacroCategoria.listaSlice[0].descrizione;
rowProdotti["Categoria"] = itemPosizione.prodotto.alberatura.livello2;
rowProdotti["Controvalore"] = itemMacroCategoria.listaSlice[0].ctv;
rowProdotti["Peso"] = itemMacroCategoria.listaSlice[0].pesoCC * 100;
rowProdotti["FontBold"] = false;
rowProdotti["ReplaceIfZero"] = stringReplaceIfZero;
rowProdotti["CanLastRow"] = true;
rowProdotti["IsTotal"] = false;
ds.Tables["prodotto"].Rows.Add(rowProdotti);
}
}
ds.Tables["prodotto"].AsEnumerable().OrderBy(o => o.Field<int>("OrdinamentoMacroCategoria"));
#endregion
#region Prodotti raggruppati per MacroCategoria
ds.Tables["prodottoPerCategoria"].Columns.Add(new DataColumn("OrdinamentoMacroCategoria", typeof(int)));
ds.Tables["prodottoPerCategoria"].Columns.Add(new DataColumn("CodiceHexMacroCategoria", typeof(string)));
ds.Tables["prodottoPerCategoria"].Columns.Add(new DataColumn("Intermediario", typeof(string)));
ds.Tables["prodottoPerCategoria"].Columns.Add(new DataColumn("Prodotto", typeof(string)));
ds.Tables["prodottoPerCategoria"].Columns.Add(new DataColumn("MacroCategoria", typeof(string)));
ds.Tables["prodottoPerCategoria"].Columns.Add(new DataColumn("Categoria", typeof(string)));
ds.Tables["prodottoPerCategoria"].Columns.Add(new DataColumn("Controvalore", typeof(decimal)));
ds.Tables["prodottoPerCategoria"].Columns.Add(new DataColumn("Peso", typeof(decimal)));
ds.Tables["prodottoPerCategoria"].Columns.Add(new DataColumn("FontBold", typeof(bool)));
ds.Tables["prodottoPerCategoria"].Columns.Add(new DataColumn("ReplaceIfZero", typeof(string)));
ds.Tables["prodottoPerCategoria"].Columns.Add(new DataColumn("CanLastRow", typeof(bool)));
ds.Tables["prodottoPerCategoria"].Columns.Add(new DataColumn("IsTotal", typeof(bool)));
var viewMacroCategoria = new DataView(ds.Tables["prodotto"]) { Sort = "OrdinamentoMacroCategoria" };
var dtMacroCategoria = viewMacroCategoria.ToTable(true, "MacroCategoria", "OrdinamentoMacroCategoria", "CodiceHexMacroCategoria");
var macroCategoria = string.Empty;
#region Prodotti delle Risorse Finanziarie
foreach (DataRow rowMacroCategoria in dtMacroCategoria.Rows)
{
macroCategoria = rowMacroCategoria["MacroCategoria"].ToString();
// subset di prodotti filtrati per Area
var dt = ds.Tables["prodotto"].Select("MacroCategoria='" + macroCategoria + "'").CopyToDataTable();
#region riga con background grigio di intestazione per ogni macrocategoria
DataRow rowProdottiPerMacroCategoria = ds.Tables["prodottoPerCategoria"].NewRow();
rowProdottiPerMacroCategoria["CodiceHexMacroCategoria"] = rowMacroCategoria["CodiceHexMacroCategoria"];
rowProdottiPerMacroCategoria["Intermediario"] = rowMacroCategoria["MacroCategoria"];
rowProdottiPerMacroCategoria["Controvalore"] = dt.AsEnumerable().Sum(x => x.Field<decimal>("Controvalore"));
rowProdottiPerMacroCategoria["Peso"] = dt.AsEnumerable().Sum(x => x.Field<decimal>("Peso"));
rowProdottiPerMacroCategoria["FontBold"] = true;
rowProdottiPerMacroCategoria["ReplaceIfZero"] = stringReplaceIfZero;
rowProdottiPerMacroCategoria["CanLastRow"] = false;
rowProdottiPerMacroCategoria["IsTotal"] = true;
ds.Tables["prodottoPerCategoria"].Rows.Add(rowProdottiPerMacroCategoria);
#endregion
// I prodotti della dtProdotti vengono mergiati sulla dtProdottiPerArea
ds.Tables["prodottoPerCategoria"].Merge(dt.AsEnumerable().OrderByDescending(o => o.Field<decimal>("Controvalore")).CopyToDataTable());
}
ds.Tables["prodottoPerCategoria"].AsEnumerable().OrderBy(r => r.Field<int>("OrdinamentoMacroCategoria"));
#endregion
#region Footer Prodotti raggruppati per MacroCategoria
var CCN = datiSeiUnico.patrimonioUnit().patrimonioTerzi.dettaglioProdotti.dettaglioProdotti.Where(r => r.prodotto.contoCorrente == true).Where(r => r.ctv < 0).ToList();
ds.Tables["prodottoPerCategoriaFooter"].Columns.Add(new DataColumn("Patrimonio", typeof(string)));
ds.Tables["prodottoPerCategoriaFooter"].Columns.Add(new DataColumn("Intermediario", typeof(string)));
ds.Tables["prodottoPerCategoriaFooter"].Columns.Add(new DataColumn("Controvalore", typeof(string)));
ds.Tables["prodottoPerCategoriaFooter"].Columns.Add(new DataColumn("Peso", typeof(string)));
ds.Tables["prodottoPerCategoriaFooter"].Columns.Add(new DataColumn("FontBold", typeof(bool)));
ds.Tables["prodottoPerCategoriaFooter"].Columns.Add(new DataColumn("ReplaceIfZero", typeof(string)));
ds.Tables["prodottoPerCategoriaFooter"].Columns.Add(new DataColumn("CanLastRow", typeof(bool)));
ds.Tables["prodottoPerCategoriaFooter"].Columns.Add(new DataColumn("IsTotal", typeof(bool)));
if (CCN.Count > 0)
{
ds.Tables["prodottoPerCategoriaFooter"].Rows.Add(
"Totale risorse finanziarie",
" ",
Helper.FormatCurrency(datiSeiUnico.TRZ_SUBTOTALE.ToString()),
Helper.FormatDecimal((dataMacroCategoria.distribuzione.pesoCCTot * 100).ToString(), 2),
true,
"",
false,
true
);
if(CCN.Count > 0)
for (int i = 0; i < CCN.Count; i++)
{
ds.Tables["prodottoPerCategoriaFooter"].Rows.Add(
CCN[i].nomeIntermediario,
CCN[i].prodotto.nomeProdotto,
Helper.FormatCurrency(CCN[i].ctv.ToString()),
"",
false,
"-",
false,
false );
}
}
ds.Tables["prodottoPerCategoriaFooter"].Rows.Add(
"Patrimonio altri Istituti",
"",
Helper.FormatCurrency(datiSeiUnico.TRZ_TOTALE.ToString()),
(CCN.Count > 0 ? "" : Helper.FormatDecimal((dataMacroCategoria.distribuzione.pesoCCTot * 100).ToString(), 2)),
true,
"",
true,
true );
#endregion
#endregion
return ds;
}
public virtual bool presenzaGraficoBarre()
{
return GetOption<Opzione4_1>().Valore;
}
public virtual bool presenzaContocorrenteInMonterio() { return true; }
public virtual bool isControvalore()
{
return !GetOption<Opzione3>().Valore;
}
public virtual bool presenzaTabella()
{
return GetOption<Opzione4_2>().Valore;
}
public virtual string getTesto1()
{
var testoGrafico = !isControvalore() ?
Helper.ReplaceVariables(GetText().Rows[0]["testo1"].ToString(), EnvironmentFacade.ReportEnvironment) :
Helper.ReplaceVariables(GetText().Rows[0]["testo2"].ToString(), EnvironmentFacade.ReportEnvironment);
return testoGrafico;
}
public virtual string getTestoTabella()
{
return "Nella tabella sottostante sono riportati i prodotti che lei detiene presso altri Istituti, raggruppati per macro categoria di appartenenza, con evidenza dell'intermediario, della categoria, del controvalore e del relativo peso percentuale.";
}
public virtual string GetNote1()
{
string nota = "";
string token = "";
var macroCategoria = datiSeiUnico.patrimonioUnit().patrimonioTerzi.macroCategoria;
if (datiSeiUnico.TRZ_CCN != 0)
{
nota += datiSeiUnico.FormatDecimal("Il controvalore esclude il saldo negativo dei conti correnti ({0} €).", datiSeiUnico.TRZ_CCN);
token = " ";
}
decimal GC = (presenzaContocorrenteInMonterio() ? macroCategoria.distribuzione.coverageCC : macroCategoria.distribuzione.coverage) * 100;
decimal CC_TERZI = presenzaContocorrenteInMonterio() ? 0 : datiSeiUnico.TRZ_CC;
decimal PNR_TERZI = macroCategoria.distribuzione.totaleNonRappr;
if (GC < 100)
{
nota += token + datiSeiUnico.FormatDecimal("Grado di copertura (%) della rappresentazione grafica per macro asset class pari a {0}", GC);
token = ": ";
if (PNR_TERZI != 0 || CC_TERZI != 0)
{
nota += token + "non sono considerati";
token = " ";
if (PNR_TERZI != 0 || CC_TERZI != 0)
{
if (PNR_TERZI != 0)
{
nota += token + datiSeiUnico.FormatDecimal("i prodotti non rappresentabili ({0} €)", PNR_TERZI);
token = ", ";
}
if (CC_TERZI != 0)
{
nota += token + datiSeiUnico.FormatDecimal("i conti correnti ({0} €)", CC_TERZI);
token = ", ";
}
token = ", ";
}
}
nota += ".";
token = " ";
}
nota = !nota.Equals("") ? "(*) " + nota : nota;
return datiSeiUnico.FormatBanca(nota);
}
}
}