776 lines
43 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>
/// S35.PatrimonioAltriIstitutiCategorieProdotto idSezione = 78
/// </summary>
public class S35 : Entity.Section
{
public S35(EnvironmentFacade environmentFacade, int idSection)
: base(environmentFacade, idSection)
{
try
{
Draw();
}
catch (Exception ex)
{
SectionLogger.Write("S35", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
}
}
//protected override sealed void OLD_Draw()
//{
// var dati = GetDataSet();
// if (presenzaGraficoBarre() && dati.Tables["Patrimonio"].Rows.Count > 0)
// {
// #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));
// tabellaPatrimonio.Columns.Add(new ColumnPDF("valore", 330, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "valore", string.Empty) { PaddingLeft = 5 });
// AddElement(tabellaPatrimonio);
// AddElement(new SpacePDF(25));
// #endregion
// #region Grafico a barre
// AddElement(new FormattedTextAreaPDF("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["Categoria"].AsEnumerable().OrderBy(o => o.Field<int>("Ordinamento")).CopyToDataTable();
// var serieCollezione = new List<Serie> { new Serie { Name = "Categoria", Border = true } };
// foreach (DataRow item in dtGraficoBarre.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["Categoria"].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() && dati.Tables["ProdottoPerCategoria"].Rows.Count > 0)
// {
// #region Testo introduttivo tabella prodotti
// AddElement(new SpacePDF(20));
// var testoTabellaProdotti = Helper.ReplaceVariables(GetText().Rows[0]["testo4"].ToString(), EnvironmentFacade.ReportEnvironment);
// AddElement(new FormattedTextAreaPDF(testoTabellaProdotti, EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
// AddElement(new SpacePDF(15));
// #endregion
// #region Tabella Prodotti prt Categoria
// DataTable datasource = dati.Tables["ProdottoPerCategoria"];
// for (int col = 0; col < datasource.Columns.Count; col++)
// {
// for (int row = 0; row < datasource.Rows.Count; row++)
// {
// if (datasource.Columns.Contains("ReplaceIfZero"))
// datasource.Rows[row]["ReplaceIfZero"] = "";
// }
// }
// var tabellaProdottiPerCategoria = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, datasource, (dati.Tables["ccn"].Rows.Count > 0) ? dati.Tables["ProdottoPerCategoriaFooter"] : dati.Tables["ccnFooter"])
// {
// Style = Style.ConsulenzaUnica,
// Header = true,
// Footer = true,
// AlternateRow = false,
// HeaderHeight = 30,
// HeaderMargin = 2.55F,
// PageBreak=true
// };
// #region Columns e FooterColumns
// tabellaProdottiPerCategoria.Columns.Add(new ColumnPDF("Immagine", 15, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Objectpdf, string.Empty, string.Empty) { HeaderFontSize = 7, DeltaYContent = 4, PaddingLeft = 2 });
// tabellaProdottiPerCategoria.Columns.Add(new ColumnPDF("Intermediario", 150, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo, "Intermediario", "Intermediario") { HeaderFontSize = 7 });
// tabellaProdottiPerCategoria.Columns.Add(new ColumnPDF("Prodotto", 145, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo, "Prodotto", "Prodotto") { HeaderFontSize = 7 });
// tabellaProdottiPerCategoria.Columns.Add(new ColumnPDF("Tipologia", 80, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo, "Tipologia", "Tipologia") { HeaderFontSize = 7, HeaderPaddingLeft = 3, PaddingLeft = 3 });
// tabellaProdottiPerCategoria.Columns.Add(new ColumnPDF("Controvalore", 90, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Decimale, "Controvalore", "Controvalore<BR>attuale (€)") {HeaderPaddingRight=6, HeaderFontSize = 7, PaddingRight = 4 });
// tabellaProdottiPerCategoria.Columns.Add(new ColumnPDF("Peso", 40, HorizontalAlignmentType.Destra, false, true, 7, ColumnType.Decimale, "Peso", "Peso (%)") { PaddingRight = 4, HeaderFontSize = 7 });
// tabellaProdottiPerCategoria.FooterColumns.Add(new ColumnPDF("Totale", 390, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo) { HeaderFontSize = 7 });
// tabellaProdottiPerCategoria.FooterColumns.Add(new ColumnPDF("Controvalore", 90, HorizontalAlignmentType.Destra, true, true, 7, ColumnType.Decimale) { PaddingRight = 4, HeaderFontSize = 7 });
// tabellaProdottiPerCategoria.FooterColumns.Add(new ColumnPDF("Peso", 40, HorizontalAlignmentType.Destra, true, true, 7, ColumnType.Decimale) { HeaderFontSize = 7 });
// #endregion
// int a = 0;
// foreach (var item in dati.Tables["ProdottoPerCategoria"].Rows)
// {
// tabellaProdottiPerCategoria.Cells[4, a].HorizontalAlignment = HorizontalAlignmentType.Destra;
// tabellaProdottiPerCategoria.Cells[5, a].HorizontalAlignment = HorizontalAlignmentType.Destra;
// a++;
// }
// #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 < tabellaProdottiPerCategoria.Columns.Count; c++)
// {
// tabellaProdottiPerCategoria.Cells[c, i].BackgroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella;
// }
// tabellaProdottiPerCategoria.Cells[0, i].ValueObject = new RectanglePDF(10, 10, new ColorPDF(row["CodiceHexCategoria"].ToString()));
// }
// i++;
// }
// #endregion
// AddElement(tabellaProdottiPerCategoria);
// if (dati.Tables["ccn"].Rows.Count > 0)
// {
// var tabellaCCN = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["ccn"], dati.Tables["ccnFooter"])
// {
// Style = Style.ConsulenzaUnica,
// Header = true,
// //Footer = true,
// AlternateRow = false,
// HeaderHeight = 1,
// HeaderMargin = 2
// };
// tabellaCCN.Columns.Add(new ColumnPDF("Patrimonio", 170, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo) { PaddingLeft = 10, HeaderFontSize = 7 });
// tabellaCCN.Columns.Add(new ColumnPDF("Intermediario", 200, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo) { HeaderFontSize = 7 });
// tabellaCCN.Columns.Add(new ColumnPDF("Controvalore", 110, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Decimale) { HeaderFontSize = 7, PaddingRight = 4 });
// tabellaCCN.Columns.Add(new ColumnPDF("Peso", 40, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Decimale) { HeaderFontSize = 7 });
// tabellaCCN.FooterColumns.Add(new ColumnPDF("Patrimonio", 370, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo) { HeaderFontSize = 7 });
// tabellaCCN.FooterColumns.Add(new ColumnPDF("Controvalore", 110, HorizontalAlignmentType.Destra, true, true, 7, ColumnType.Decimale) { HeaderFontSize = 7, PaddingRight = 4 });
// tabellaCCN.FooterColumns.Add(new ColumnPDF("Peso", 40, HorizontalAlignmentType.Destra, true, true, 7, ColumnType.Decimale) { HeaderFontSize = 7 });
// AddElement(tabellaCCN);
// }
// #endregion
// }
//}
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() && dati.Tables["Patrimonio"].Rows.Count > 0)
{
#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));
tabellaPatrimonio.Columns.Add(new ColumnPDF("valore", 330, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "valore", string.Empty) { PaddingLeft = 5 });
AddElement(tabellaPatrimonio);
AddElement(new SpacePDF(25));
#endregion
#region Grafico a barre
AddElement(new FormattedTextAreaPDF("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["Categoria"].AsEnumerable().OrderBy(o => o.Field<int>("Ordinamento")).CopyToDataTable();
var serieCollezione = new List<Serie> { new Serie { Name = "Categoria", Border = true } };
foreach (DataRow item in dtGraficoBarre.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["Categoria"].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() && dati.Tables["ProdottoPerCategoria"].Rows.Count > 0)
{
#region Testo introduttivo tabella prodotti
AddElement(new SpacePDF(20));
var testoTabellaProdotti = Helper.ReplaceVariables(GetText().Rows[0]["testo4"].ToString(), EnvironmentFacade.ReportEnvironment);
AddElement(new FormattedTextAreaPDF(testoTabellaProdotti, EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify });
AddElement(new SpacePDF(15));
#endregion
#region Tabella Prodotti prt Categoria
DataTable datasource = dati.Tables["ProdottoPerCategoria"];
for (int col = 0; col < datasource.Columns.Count; col++)
{
for (int row = 0; row < datasource.Rows.Count; row++)
{
if (datasource.Columns.Contains("ReplaceIfZero"))
datasource.Rows[row]["ReplaceIfZero"] = "";
}
}
var tabellaProdottiPerCategoria = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, datasource, (dati.Tables["ccn"].Rows.Count > 0) ? dati.Tables["ProdottoPerCategoriaFooter"] : dati.Tables["ccnFooter"])
{
Style = Style.ConsulenzaUnica,
Header = true,
Footer = true,
AlternateRow = false,
HeaderHeight = 30,
HeaderMargin = 2.55F,
PageBreak = true
};
#region Columns e FooterColumns
tabellaProdottiPerCategoria.Columns.Add(new ColumnPDF("Immagine", 15, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Objectpdf, string.Empty, string.Empty) { HeaderFontSize = 7, DeltaYContent = 4, PaddingLeft = 2 });
tabellaProdottiPerCategoria.Columns.Add(new ColumnPDF("Intermediario", 150, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo, "Intermediario", "Intermediario") { HeaderFontSize = 7 });
tabellaProdottiPerCategoria.Columns.Add(new ColumnPDF("Prodotto", 145, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo, "Prodotto", "Prodotto") { HeaderFontSize = 7 });
tabellaProdottiPerCategoria.Columns.Add(new ColumnPDF("Tipologia", 80, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo, "Tipologia", "Tipologia") { HeaderFontSize = 7, HeaderPaddingLeft = 3, PaddingLeft = 3 });
tabellaProdottiPerCategoria.Columns.Add(new ColumnPDF("Controvalore", 90, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Decimale, "Controvalore", "Controvalore<BR>attuale (€)") { HeaderPaddingRight = 6, HeaderFontSize = 7, PaddingRight = 4 });
tabellaProdottiPerCategoria.Columns.Add(new ColumnPDF("Peso", 40, HorizontalAlignmentType.Destra, false, true, 7, ColumnType.Decimale, "Peso", "Peso (%)") { PaddingRight = 4, HeaderFontSize = 7 });
tabellaProdottiPerCategoria.FooterColumns.Add(new ColumnPDF("Totale", 390, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo) { HeaderFontSize = 7 });
tabellaProdottiPerCategoria.FooterColumns.Add(new ColumnPDF("Controvalore", 90, HorizontalAlignmentType.Destra, true, true, 7, ColumnType.Decimale) { PaddingRight = 4, HeaderFontSize = 7 });
tabellaProdottiPerCategoria.FooterColumns.Add(new ColumnPDF("Peso", 40, HorizontalAlignmentType.Destra, true, true, 7, ColumnType.Decimale) { HeaderFontSize = 7 });
#endregion
int a = 0;
foreach (var item in dati.Tables["ProdottoPerCategoria"].Rows)
{
tabellaProdottiPerCategoria.Cells[4, a].HorizontalAlignment = HorizontalAlignmentType.Destra;
tabellaProdottiPerCategoria.Cells[5, a].HorizontalAlignment = HorizontalAlignmentType.Destra;
a++;
}
#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 < tabellaProdottiPerCategoria.Columns.Count; c++)
{
tabellaProdottiPerCategoria.Cells[c, i].BackgroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella;
}
tabellaProdottiPerCategoria.Cells[0, i].ValueObject = new RectanglePDF(10, 10, new ColorPDF(row["CodiceHexCategoria"].ToString()));
}
i++;
}
#endregion
AddElement(tabellaProdottiPerCategoria);
if (dati.Tables["ccn"].Rows.Count > 0)
{
var tabellaCCN = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["ccn"], dati.Tables["ccnFooter"])
{
Style = Style.ConsulenzaUnica,
Header = true,
//Footer = true,
AlternateRow = false,
HeaderHeight = 1,
HeaderMargin = 2
};
tabellaCCN.Columns.Add(new ColumnPDF("Patrimonio", 170, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo) { PaddingLeft = 10, HeaderFontSize = 7 });
tabellaCCN.Columns.Add(new ColumnPDF("Intermediario", 200, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo) { HeaderFontSize = 7 });
tabellaCCN.Columns.Add(new ColumnPDF("Controvalore", 110, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Decimale) { HeaderFontSize = 7, PaddingRight = 4 });
tabellaCCN.Columns.Add(new ColumnPDF("Peso", 40, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Decimale) { HeaderFontSize = 7 });
tabellaCCN.FooterColumns.Add(new ColumnPDF("Patrimonio", 370, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo) { HeaderFontSize = 7 });
tabellaCCN.FooterColumns.Add(new ColumnPDF("Controvalore", 110, HorizontalAlignmentType.Destra, true, true, 7, ColumnType.Decimale) { HeaderFontSize = 7, PaddingRight = 4 });
tabellaCCN.FooterColumns.Add(new ColumnPDF("Peso", 40, HorizontalAlignmentType.Destra, true, true, 7, ColumnType.Decimale) { HeaderFontSize = 7 });
AddElement(tabellaCCN);
}
#endregion
}
}
/// <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("Categoria"));
ds.Tables.Add(new DataTable("Prodotto"));
ds.Tables.Add(new DataTable("ProdottoPerCategoria"));
ds.Tables.Add(new DataTable("ProdottoPerCategoriaFooter"));
ds.Tables.Add(new DataTable("ccn"));
ds.Tables.Add(new DataTable("ccnFooter"));
const string stringReplaceIfZero = " ";
var patrimonioTerzi = datiSeiUnico.patrimonioUnit().patrimonioTerzi;
var dataCategoria = patrimonioTerzi.categoria;
var dataDettaglioProdotti = patrimonioTerzi.dettaglioProdotti;
var displayInfo = datiSeiUnico.displayInfos().categoriaDisplayInfos.ToList();
#region Patrimonio terzi
//var dtPatrimonio = new DataTable("dtPatrimonio");
ds.Tables["Patrimonio"].Columns.Add(new DataColumn("Descrizione", typeof(string)));
ds.Tables["Patrimonio"].Columns.Add(new DataColumn("Valore", typeof(string)));
var testoPatrimonio = string.Format("Patrimonio altri Istituti (€){0}", (GetNote1().Length>0 ? "*" : ""));
ds.Tables["Patrimonio"].Rows.Add(testoPatrimonio, Helper.FormatCurrency(datiSeiUnico.TRZ_TOTALEPOSITIVO.ToString()));
#endregion
#region Categorie di Prodotto
//var dtCategorie = new DataTable("dtCategorie");
ds.Tables["Categoria"].Columns.Add(new DataColumn("Categoria", typeof(string)));
ds.Tables["Categoria"].Columns.Add(new DataColumn("Red", typeof(int)));
ds.Tables["Categoria"].Columns.Add(new DataColumn("Green", typeof(int)));
ds.Tables["Categoria"].Columns.Add(new DataColumn("Blue", typeof(int)));
ds.Tables["Categoria"].Columns.Add(new DataColumn("Controvalore", typeof(decimal)));
ds.Tables["Categoria"].Columns.Add(new DataColumn("Percentuale", typeof(decimal)));
ds.Tables["Categoria"].Columns.Add(new DataColumn("Ordinamento", typeof(int)));
foreach (var itemDistribuzione in dataCategoria.distribuzione.elencoSlice)
{
if (itemDistribuzione.sliceRappresentabile)
{
//var mapDisplayInfo = DataServices.DisplayInfo.TryGetValue(displayInfo, itemDistribuzione.codice);
var mapDisplayInfo = displayInfo.Where(l => l.key == itemDistribuzione.codice).ToArray();
var colore = new ColorPDF(mapDisplayInfo[0].value.fill);
var ordinamento = mapDisplayInfo[0].value.order;
ds.Tables["Categoria"].Rows.Add(itemDistribuzione.descrizione, colore.Red, colore.Green, colore.Blue, itemDistribuzione.ctvCC, itemDistribuzione.pesoCC * 100, ordinamento);
}
}
//ds.Tables.Add(dtCategorie.AsEnumerable().OrderBy(r => r.Field<int>("Ordinamento")).CopyToDataTable());
ds.Tables["Categoria"].AsEnumerable().OrderBy(r => r.Field<int>("Ordinamento"));
#endregion
#region Prodotti
//var dtProdotti = new DataTable("dtProdotti");
ds.Tables["Prodotto"].Columns.Add(new DataColumn("OrdinamentoCategoria", typeof(int)));
ds.Tables["Prodotto"].Columns.Add(new DataColumn("CodiceHexCategoria", 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("Categoria", typeof(string)));
ds.Tables["Prodotto"].Columns.Add(new DataColumn("Tipologia", typeof(string)));
ds.Tables["Prodotto"].Columns.Add(new DataColumn("Controvalore", typeof(decimal)));
ds.Tables["Prodotto"].Columns.Add(new DataColumn("Peso", typeof(string)));
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 itemCategoria in dataCategoria.distribuzionePerProdotti.listaProdotti)
{
if (itemCategoria.rappresentabile)
{
var itemPosizione = dataDettaglioProdotti.dettaglioProdotti.FirstOrDefault(o => o.chiaveProdottoTerzi.Equals(itemCategoria.chiaveAggregazione));
//var mapDisplayInfo = DataServices.DisplayInfo.TryGetValue(displayInfo, dataCategoria.distribuzione.elencoSlice.FirstOrDefault(o => o.descrizione.Equals(itemCategoria.listaSlice[0].descrizione)).codice);
var mapDisplayInfo = displayInfo.FirstOrDefault(o => o.key == dataCategoria.distribuzione.elencoSlice.FirstOrDefault(l => l.descrizione.Equals(itemCategoria.listaSlice[0].descrizione)).codice);
var rowProdotti = ds.Tables["Prodotto"].NewRow();
rowProdotti["OrdinamentoCategoria"] = mapDisplayInfo.value.order;
rowProdotti["CodiceHexCategoria"] = mapDisplayInfo.value.fill;
rowProdotti["Intermediario"] = itemPosizione.nomeIntermediario;
rowProdotti["Prodotto"] = itemPosizione.prodotto.nomeProdotto;
rowProdotti["Categoria"] = itemCategoria.listaSlice[0].descrizione;
rowProdotti["Tipologia"] = itemPosizione.prodotto.alberatura.livello3;
rowProdotti["Controvalore"] = itemCategoria.listaSlice[0].ctv;
rowProdotti["Peso"] = itemCategoria.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(r => r.Field<int>("OrdinamentoCategoria"));
//ds.Tables.Add(ds.Tables["Prodotto"]);
#endregion
#region Prodotti raggruppati per Categoria
//var dtProdottiPerCategoria = dtProdotti.Clone(); // Clono la struttura
//dtProdottiPerCategoria.TableName = "dtProdottiPerCategoria";
ds.Tables["ProdottoPerCategoria"].Columns.Add(new DataColumn("OrdinamentoCategoria", typeof(int)));
ds.Tables["ProdottoPerCategoria"].Columns.Add(new DataColumn("CodiceHexCategoria", 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("Categoria", typeof(string)));
ds.Tables["ProdottoPerCategoria"].Columns.Add(new DataColumn("Tipologia", typeof(string)));
ds.Tables["ProdottoPerCategoria"].Columns.Add(new DataColumn("Controvalore", typeof(decimal)));
ds.Tables["ProdottoPerCategoria"].Columns.Add(new DataColumn("Peso", typeof(string)));
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 viewCategoria = new DataView(ds.Tables["Prodotto"]) { Sort = "OrdinamentoCategoria" };
var dtCategoria = viewCategoria.ToTable(true, "Categoria", "OrdinamentoCategoria", "CodiceHexCategoria");
var categoria = string.Empty;
#region Prodotti delle Risorse Finanziarie
foreach (DataRow rowCategoria in dtCategoria.Rows)
{
categoria = rowCategoria["Categoria"].ToString();
// subset di prodotti filtrati per Area
var dt = ds.Tables["Prodotto"].Select("Categoria='" + categoria + "'").CopyToDataTable();
#region Riga con Background grigio per ogni macrocategoria
DataRow rowProdottiPerCategoria = ds.Tables["ProdottoPerCategoria"].NewRow();
rowProdottiPerCategoria["CodiceHexCategoria"] = rowCategoria["CodiceHexCategoria"];
rowProdottiPerCategoria["Intermediario"] = rowCategoria["Categoria"];
rowProdottiPerCategoria["Controvalore"] = dataCategoria.distribuzione.elencoSlice.FirstOrDefault(o => o.descrizione.Equals(categoria)).ctvCC;// dt.AsEnumerable().Sum(x => x.Field<decimal>("Controvalore"));
rowProdottiPerCategoria["Peso"] = dataCategoria.distribuzione.elencoSlice.FirstOrDefault(o => o.descrizione.Equals(categoria)).pesoCC * 100;// dt.AsEnumerable().Sum(x => x.Field<decimal>("Peso"));
rowProdottiPerCategoria["FontBold"] = true;
rowProdottiPerCategoria["ReplaceIfZero"] = stringReplaceIfZero;
rowProdottiPerCategoria["CanLastRow"] = false;
rowProdottiPerCategoria["IsTotal"] = true;
ds.Tables["ProdottoPerCategoria"].Rows.Add(rowProdottiPerCategoria);
#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>("OrdinamentoCategoria"));
#endregion
//ds.Tables.Add(dtProdottiPerCategoria);
#region Footer
ds.Tables["ProdottoPerCategoriaFooter"].Columns.Add(new DataColumn("Totale", 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"].Rows.Add(
"Totale risorse finanziarie",
Helper.FormatCurrency(datiSeiUnico.TRZ_SUBTOTALE.ToString()),
Helper.FormatDecimal((dataCategoria.distribuzione.pesoCCTot * 100).ToString(), 2)
);
#endregion
#region CCN
var CCN = datiSeiUnico.patrimonioUnit().patrimonioTerzi.dettaglioProdotti.dettaglioProdotti.Where(r => r.prodotto.contoCorrente == true).Where(r => r.ctv < 0).ToList();
ds.Tables["ccn"].Columns.Add(new DataColumn("Patrimonio", typeof(string)));
ds.Tables["ccn"].Columns.Add(new DataColumn("Intermediario", typeof(string)));
ds.Tables["ccn"].Columns.Add(new DataColumn("Controvalore", typeof(string)));
ds.Tables["ccn"].Columns.Add(new DataColumn("Peso", typeof(string)));
for (int i = 0; i < CCN.Count; i++)
{
ds.Tables["ccn"].Rows.Add(CCN[i].nomeIntermediario,
CCN[i].prodotto.nomeProdotto,
Helper.FormatCurrency(CCN[i].ctv.ToString()),
"");
}
#endregion
var patrimonio = dataCategoria.totaliPatrimonio;
#region Patrimonio Fideuram
ds.Tables["ccnFooter"].Columns.Add(new DataColumn("Patrimonio", typeof(string)));
ds.Tables["ccnFooter"].Columns.Add(new DataColumn("Controvalore", typeof(string)));
ds.Tables["ccnFooter"].Columns.Add(new DataColumn("Peso", typeof(string)));
ds.Tables["ccnFooter"].Rows.Add(
"Patrimonio altri Istituti",
Helper.FormatCurrency(datiSeiUnico.TRZ_TOTALE.ToString()),
ds.Tables["ccn"].Rows.Count > 0 ? "" : Helper.FormatDecimal((dataCategoria.distribuzione.pesoCCTot * 100).ToString(), 2));
#endregion
#endregion
return ds;
}
public virtual string getTesto1()
{
return !isControvalore() ?
Helper.ReplaceVariables(GetText().Rows[0]["testo1"].ToString(), EnvironmentFacade.ReportEnvironment) :
Helper.ReplaceVariables(GetText().Rows[0]["testo2"].ToString(), EnvironmentFacade.ReportEnvironment);
}
public virtual bool isControvalore()
{
return !GetOption<Opzione3>().Valore;
}
public virtual bool presenzaContocorrenteInMonterio() { return true; }
public virtual bool presenzaGraficoBarre()
{
return GetOption<Opzione4_1>().Valore;
}
public virtual bool presenzaTabella()
{
return GetOption<Opzione4_2>().Valore;
}
public virtual string GetNote1()
{
string nota = "";
string token = "";
var categoria = datiSeiUnico.patrimonioUnit().patrimonioTerzi.categoria;
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() ? categoria.distribuzione.coverageCC : categoria.distribuzione.coverage) * 100;
decimal CC_TERZI = presenzaContocorrenteInMonterio() ? 0 : datiSeiUnico.TRZ_CC;
decimal PNR_TERZI = categoria.distribuzione.totaleNonRappr;
if (GC < 100)
{
nota += token + datiSeiUnico.FormatDecimal("Grado di copertura (%) della rappresentazione grafica per categorie 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);
}
}
}