987 lines
51 KiB
C#

using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;
using Consulenza.ReportWriter.Business;
using Consulenza.ReportWriter.Business.OBJ_PDF;
using System.Data;
using System.Collections.Generic;
using System.Web;
using Consulenza.ReportCommon;
using Consulenza.ReportWriter.Business.CHART_PDF;
using Consulenza.ReportWriter.Business.Entity;
using System.Linq;
namespace Consulenza.ReportWriter.Manager.Section.Unica
{
/// <summary>
/// Scheda 3. Sintesi Nucleo. IdSezione 46
/// </summary>
public class S3 : Entity.Section
{
public S3(EnvironmentFacade environmentFacade, int idSection)
: base(environmentFacade, idSection)
{
try
{
Draw();
}
catch (Exception ex)
{
SectionLogger.Write("S3", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
}
}
//protected override sealed void Draw()
//{
// var dati = GetDataSet();
// if (getTestoTabella().Length > 0)
// {
// AddElement(new SpacePDF(20));
// AddElement(new FormattedTextAreaPDF(getTestoTabella(), EnvironmentFacade.RendererFacade.XLeftLimit) { TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify, FontSize=7});
// AddElement(new SpacePDF(15));
// }
// if (dati.Tables["infoNucleo"].Rows.Count > 0)
// {
// var tabellaInfoCliente = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["infoNucleo"])
// {
// Style = Style.ConsulenzaUnica,
// Header = false,
// Footer = false,
// AlternateRow = false,
// RowHeight = 25
// };
// tabellaInfoCliente.Columns.Add(new ColumnPDF("descrizione", 150, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo, "descrizione", string.Empty) { HeaderFontSize=7});
// tabellaInfoCliente.Columns.Add(new ColumnPDF("valore", 370, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "valore", string.Empty) { PaddingLeft = 5, HeaderFontSize = 7 });
// tabellaInfoCliente.Cells[1, 0].FontBold = true;
// AddElement(tabellaInfoCliente);
// }
// float tablesHeight = 0;
// if (dati.Tables["clientiNucleo"].Rows.Count > 0)
// {
// TablePDF tabellaclientiNucleo = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["clientiNucleo"])
// {
// Style = Style.ConsulenzaUnica,
// Footer = false,
// AlternateRow = false,
// ShowBorderLastLine = false,
// HeaderHeight = 27
// };
// tabellaclientiNucleo.Columns.Add(new ColumnPDF("CognomeMandato", 104, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Cognome", "Cognome/<br> Mandato") { HeaderFontSize = 7 });
// tabellaclientiNucleo.Columns.Add(new ColumnPDF("Nome", 84, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Nome", "Nome") { HeaderFontSize = 7 });
// tabellaclientiNucleo.Columns.Add(new ColumnPDF("CodiceFiscalePIVA", 104, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "CodiceFiscale", "Codice Fiscale/<br>P.IVA") { HeaderFontSize = 7 });
// tabellaclientiNucleo.Columns.Add(new ColumnPDF("Profilofinanziario", 104, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Profilofinanziario", "Profilo finanziario") { HeaderFontSize = 7 });
// tabellaclientiNucleo.Columns.Add(new ColumnPDF("Contrattoconsulenza", 124, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Contrattoconsulenza", "Contratto consulenza") { HeaderFontSize = 7 });
// AddElement(new SpacePDF(15));
// AddElement(tabellaclientiNucleo);
// AddElement(new SpacePDF(0)); // dont remove
// //tablesHeight = 15f + tabellaclientiNucleo.RowHeight * tabellaclientiNucleo.RowsCount + tabellaclientiNucleo.HeaderHeight;
// tablesHeight += tabellaclientiNucleo.Height;
// }
// if (dati.Tables["patrimonioComplessivo"].Rows.Count > 0)
// {
// if (dati.Tables["distribuzionePatrimonio"].Rows.Count > 0)
// {
// if (getTestoGrafico().Length > 0)
// {
// AddElement(new SpacePDF(20));
// AddElement(new FormattedTextAreaPDF(getTestoGrafico(), EnvironmentFacade.RendererFacade.XLeftLimit) { TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify, FontSize = 7 });
// AddElement(new SpacePDF(20));
// tablesHeight += 60;
// }
// }
// var tabellapatrimonioComplessivo = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables[2])
// {
// Style = Style.ConsulenzaUnica,
// Header = false,
// Footer = false,
// AlternateRow = false,
// RowHeight = 25
// };
// tabellapatrimonioComplessivo.Columns.Add(new ColumnPDF("descrizione", 150, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo, "descrizione", string.Empty));
// tabellapatrimonioComplessivo.Columns.Add(new ColumnPDF("valore", 370, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "valore", string.Empty) { PaddingLeft = 5 });
// AddElement(tabellapatrimonioComplessivo);
// tablesHeight += 25;
// }
// int c = 0;
// bool FirstTwoRowsSumLinked = true;
// bool canUseFirstTwoRowsSumLinked = dati.Tables["distribuzionePatrimonio"].AsEnumerable().Where(o => o.Field<string>("Patrimonio").ToString().Contains("Istituti")) != null;
// foreach (DataRow item in dati.Tables["distribuzionePatrimonio"].Rows)
// {
// if (c < 2 && canUseFirstTwoRowsSumLinked)
// {
// if (Convert.ToDouble(item.ItemArray[4].ToString()) == 0)
// {
// FirstTwoRowsSumLinked = false;
// break;
// }
// }
// c++;
// }
// if (dati.Tables["distribuzionePatrimonio"].Rows.Count > 0)
// {
// var graficoBarre = new StackedPDF(EnvironmentFacade.RendererFacade.XLeftLimit + 100, 1F)
// {
// HeightSingleBar = 40,
// Width = 400,
// MinorGridAxisY = true,
// ShowLineAxisX = true,
// ShowLineAxisY = true,
// LabelFormatAxisY = FormatType.Intero,
// DinamicFloatXEtichettaLateraleBarra = true,
// FirstTwoRowsSumLinked = FirstTwoRowsSumLinked,
// RemoveWhiteSpaceBetweenChartAndAxisX = true,
// MarginAxisY = 0,
// MarginAxisYFromTop = 0
// };
// var serieCollezione = new List<Serie> { new Serie { Name = "Patrimoni", Border = true} };
// foreach (DataRow item in dati.Tables[3].Rows)
// {
// serieCollezione[0].Points.Add(new Point
// {
// ShowLabelAxisY = true,
// LabelAxisY = Helper.FormatCurrency(item["Controvalore"].ToString()),
// FontSizeLabelAxisY = 7,
// Color = new ColorPDF(Convert.ToInt32(item["Red"]), Convert.ToInt32(item["Green"]), Convert.ToInt32(item["Blue"])),
// Value = Convert.ToDouble(item["Controvalore"]),
// ShowLabelAxisX = true,
// LabelAxisX = string.Format("{0}<BR/><i>({1})<i>", item["Patrimonio"].ToString(), Helper.FormatPercentage(Convert.ToDecimal(item["Percentuale"]), 2)),
// FontSizeLabelAxisX = 7,
// FontBoldLabelAxisY = false
// });
// }
// graficoBarre.SeriesCollection = serieCollezione;
// AddElement(new SpacePDF(20));
// tablesHeight += 20;
// List<ObjectPDF> newPageElements = new List<ObjectPDF>();
// newPageElements.Add(new ImagePDF(435, 0.15F, "changepage.png") { AutoIncrementYWritable = false, Y = EnvironmentFacade.RendererFacade.YLowerLimit - 5 });
// newPageElements.Add(new FormattedTextAreaPDF("continua alla pagina successiva", 450, 200) { FontSize = 6, AutoIncrementYWritable = false, Y = EnvironmentFacade.RendererFacade.YLowerLimit - 5, AbsolutePosition = true });
// newPageElements.Add(new PagePDF(PagePDF.PagePDFType.Generic));
// newPageElements.Add(new SpacePDF(2));
// newPageElements.Add(new ImagePDF(EnvironmentFacade.RendererFacade.XLeftLimit, 0.15F, "changepage.png") { Y = EnvironmentFacade.RendererFacade.YUpperLimit + 2, AutoIncrementYWritable = false });
// newPageElements.Add(new FormattedTextAreaPDF("continua dalla pagina precedente", EnvironmentFacade.RendererFacade.XLeftLimit + 15, 200) { Y = EnvironmentFacade.RendererFacade.YUpperLimit + 2, FontSize = 6, AutoIncrementYWritable = true, AbsolutePosition = true });
// //newPageElements.Add(new SpacePDF(20));
// newPageElements.Reverse();
// var availableSpace = 495;
// var stackedBarHeight = graficoBarre.GetHeight() + 25; // + 25 axis X labels
// if (availableSpace - stackedBarHeight - tablesHeight < 0) // missing space, new page needed
// {
// for (int i = 0; i< Elements.Count; i++)
// {
// if (Elements[i] is SpacePDF && ((SpacePDF)Elements[i]).Height == 0)
// {
// //Elements[i] = new PagePDF(PagePDF.PagePDFType.Generic);
// foreach (var element in newPageElements)
// {
// Elements.Insert(i, element);
// }
// break;
// }
// }
// }
// AddElement(graficoBarre);
// }
// #region Nota del PatrimonioCasa
// if (GetNote1().Length > 0)
// {
// AddElement(new SpacePDF(30));
// AddElement(new FormattedTextAreaPDF(GetNote1(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = TextAlign.Justify });
// }
// #endregion
//}
protected override sealed void Draw()
{
var dati = GetDataSet();
if (getTestoTabella().Length > 0)
{
AddElement(new SpacePDF(20));
AddElement(new FormattedTextAreaPDF(getTestoTabella(), EnvironmentFacade.RendererFacade.XLeftLimit) { TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify, FontSize = 7 });
AddElement(new SpacePDF(15));
}
if (dati.Tables["infoNucleo"].Rows.Count > 0)
{
var tabellaInfoCliente = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["infoNucleo"])
{
Style = Style.ConsulenzaUnica,
Header = false,
Footer = false,
AlternateRow = false,
RowHeight = 25
};
tabellaInfoCliente.Columns.Add(new ColumnPDF("descrizione", 150, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo, "descrizione", string.Empty) { HeaderFontSize = 7 });
tabellaInfoCliente.Columns.Add(new ColumnPDF("valore", 370, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "valore", string.Empty) { PaddingLeft = 5, HeaderFontSize = 7 });
tabellaInfoCliente.Cells[1, 0].FontBold = true;
AddElement(tabellaInfoCliente);
}
float tablesHeight = 0;
Int16 iNumeroClienti = Convert.ToInt16(dati.Tables["clientiNucleo"].Rows.Count);
if (dati.Tables["clientiNucleo"].Rows.Count > 0)
{
foreach (DataRow cliente in dati.Tables["clientiNucleo"].Rows)
{
String contrattoConsulenza = (String) cliente[4];
if (contrattoConsulenza.ToLower().Contains("sei"))
{//verifico se è sospeso
DataTable dtSospeso = null;
String query = "Select chiaveCliente from vRfaMinusPerPB where codFis = '" + (String)cliente[2] + "'";
dtSospeso = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerConsulenzaUnica, query, null);
if (dtSospeso.Rows.Count > 0 && !DBNull.Value.Equals(dtSospeso.Rows[0][0]))
{//è sospeso aggiorno la descrizione del contratto
if (contrattoConsulenza.IndexOf("del") != -1) {
cliente[4] = contrattoConsulenza.Substring(0, contrattoConsulenza.IndexOf("del")) + " sospeso " + contrattoConsulenza.Substring(contrattoConsulenza.IndexOf("del"));
}
else
{
cliente[4] = contrattoConsulenza + " sospeso";
}
}
}
}
TablePDF tabellaclientiNucleo = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["clientiNucleo"])
{
Style = Style.ConsulenzaUnica,
Footer = false,
AlternateRow = false,
ShowBorderLastLine = false,
HeaderHeight = 27
};
tabellaclientiNucleo.Columns.Add(new ColumnPDF("CognomeMandato", 104, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Cognome", "Cognome/<br> Mandato") { HeaderFontSize = 7 });
tabellaclientiNucleo.Columns.Add(new ColumnPDF("Nome", 84, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Nome", "Nome") { HeaderFontSize = 7 });
tabellaclientiNucleo.Columns.Add(new ColumnPDF("CodiceFiscalePIVA", 104, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "CodiceFiscale", "Codice Fiscale/<br>P.IVA") { HeaderFontSize = 7 });
tabellaclientiNucleo.Columns.Add(new ColumnPDF("Profilofinanziario", 104, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Profilofinanziario", "Profilo finanziario") { HeaderFontSize = 7 });
tabellaclientiNucleo.Columns.Add(new ColumnPDF("Contrattoconsulenza", 124, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Contrattoconsulenza", "Contratto consulenza") { HeaderFontSize = 7 });
AddElement(new SpacePDF(15));
AddElement(tabellaclientiNucleo);
AddElement(new SpacePDF(0)); // dont remove
//tablesHeight = 15f + tabellaclientiNucleo.RowHeight * tabellaclientiNucleo.RowsCount + tabellaclientiNucleo.HeaderHeight;
tablesHeight += tabellaclientiNucleo.Height;
}
if (dati.Tables["patrimonioComplessivo"].Rows.Count > 0)
{
if (dati.Tables["distribuzionePatrimonio"].Rows.Count > 0)
{
if (getTestoGrafico().Length > 0)
{
AddElement(new SpacePDF(20));
AddElement(new FormattedTextAreaPDF(getTestoGrafico(), EnvironmentFacade.RendererFacade.XLeftLimit) { TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify, FontSize = 7 });
AddElement(new SpacePDF(20));
tablesHeight += 60;
}
}
var tabellapatrimonioComplessivo = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables[2])
{
Style = Style.ConsulenzaUnica,
Header = false,
Footer = false,
AlternateRow = false,
RowHeight = 25
};
tabellapatrimonioComplessivo.Columns.Add(new ColumnPDF("descrizione", 150, HorizontalAlignmentType.Sinistra, true, true, 7, ColumnType.Testo, "descrizione", string.Empty));
tabellapatrimonioComplessivo.Columns.Add(new ColumnPDF("valore", 370, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "valore", string.Empty) { PaddingLeft = 5 });
AddElement(tabellapatrimonioComplessivo);
tablesHeight += 25;
}
int c = 0;
bool FirstTwoRowsSumLinked = true;
bool canUseFirstTwoRowsSumLinked = dati.Tables["distribuzionePatrimonio"].AsEnumerable().Where(o => o.Field<string>("Patrimonio").ToString().Contains("Istituti")) != null;
foreach (DataRow item in dati.Tables["distribuzionePatrimonio"].Rows)
{
if (c < 2 && canUseFirstTwoRowsSumLinked)
{
if (Convert.ToDouble(item.ItemArray[4].ToString()) == 0)
{
FirstTwoRowsSumLinked = false;
break;
}
}
c++;
}
Int64 iTotale = 0;
string sTotale = "";
string sProquota = "";
bool _RemoveWhiteSpaceToTheRightAxisX = true;
if (dati.Tables["distribuzionePatrimonio"].Rows.Count > 0)
{
var graficoBarre = new StackedPDF(EnvironmentFacade.RendererFacade.XLeftLimit + 100, 1F)
{
HeightSingleBar = 40,
Width = 400,
MinorGridAxisY = true,
ShowLineAxisX = true,
ShowLineAxisY = true,
LabelFormatAxisY = FormatType.Intero,
DinamicFloatXEtichettaLateraleBarra = true,
FirstTwoRowsSumLinked = FirstTwoRowsSumLinked,
RemoveWhiteSpaceBetweenChartAndAxisX = _RemoveWhiteSpaceToTheRightAxisX,
MarginAxisY = 0,
MarginAxisYFromTop = 0
};
//var serieCollezione = new List<Serie> { new Serie { Name = "Patrimoni", Border = true} };
var serieCollezione = new List<Serie> { new Serie { Name = "Patrimoni", Border = true }, new Serie { Name = "ProQuota", Border = true } };
double dDelta = 0;
foreach (DataRow item in dati.Tables[3].Rows)
{
if (item["Patrimonio"].ToString().ToUpper() == "IMMOBILIARE" && (Convert.ToDouble(item["Controvalore"]) != Convert.ToDouble(item["Proquota"])))
{
dDelta = Convert.ToDouble(item["Controvalore"]) - Convert.ToDouble(item["Proquota"]);
iTotale = Convert.ToInt64(item["Controvalore"]);
sTotale = Helper.FormatCurrency((Convert.ToDouble(item["Controvalore"])).ToString());
serieCollezione[0].Points.Add(new Point
{
// Proquota
Color = new ColorPDF(148, 180, 198),
Value = Convert.ToDouble(item["Proquota"]),
ShowLabelAxisY = false,
LabelAxisY = Helper.FormatCurrency((Convert.ToDouble(item["Controvalore"])).ToString()),
FontSizeLabelAxisY = 7,
FontBoldLabelAxisY = false,
//FontColorLabelAxisY = ColorPDF.Grigio_TitoloPiccoloImmobiliare
ShowLabelAxisX = true,
LabelAxisX = string.Format("{0}<BR/><i>({1})<i>", item["Patrimonio"].ToString(), Helper.FormatPercentage(Convert.ToDecimal(item["Percentuale"]), 2)),
FontSizeLabelAxisX = 7,
//FontColorLabelAxisX = ColorPDF.Grigio_TitoloPiccoloImmobiliare,
});
sProquota = Helper.FormatCurrency(item["Proquota"].ToString());
serieCollezione[1].Points.Add(new Point
{
// Totale - Proquota
Color = new ColorPDF(Convert.ToInt32(item["Red"]), Convert.ToInt32(item["Green"]), Convert.ToInt32(item["Blue"])),
Value = (Convert.ToDouble(item["Controvalore"]) - Convert.ToDouble(item["Proquota"])),
ShowLabelAxisY = false,
LabelAxisY = Helper.FormatCurrency((Convert.ToDouble(item["Proquota"])).ToString()),
FontSizeLabelAxisY = 7,
FontBoldLabelAxisY = false,
//FontColorLabelAxisY = ColorPDF.Grigio_TitoloPiccoloImmobiliare
ShowLabelAxisX = false,
LabelAxisX = string.Format("{0}<BR/><i>({1})<i>", item["Patrimonio"].ToString(), Helper.FormatPercentage(Convert.ToDecimal(item["Percentuale"]), 2)),
FontSizeLabelAxisX = 7,
//FontColorLabelAxisX = ColorPDF.Grigio_TitoloPiccoloImmobiliare,
});
}
else
{
serieCollezione[0].Points.Add(new Point
{
Color = new ColorPDF(Convert.ToInt32(item["Red"]), Convert.ToInt32(item["Green"]), Convert.ToInt32(item["Blue"])),
Value = Convert.ToDouble(item["Controvalore"]),
ShowLabelAxisY = true,
LabelAxisY = Helper.FormatCurrency(Convert.ToDouble(item["Controvalore"]).ToString()),
FontSizeLabelAxisY = 7,
FontBoldLabelAxisY = false,
//FontColorLabelAxisY = ColorPDF.Grigio_TitoloPiccoloImmobiliare
ShowLabelAxisX = true,
LabelAxisX = string.Format("{0}<BR/><i>({1})<i>", item["Patrimonio"].ToString(), Helper.FormatPercentage(Convert.ToDecimal(item["Percentuale"]), 2)),
FontSizeLabelAxisX = 7,
//FontColorLabelAxisX = ColorPDF.Grigio_TitoloPiccoloImmobiliare,
});
serieCollezione[1].Points.Add(new Point
{
Color = new ColorPDF(148, 180, 198),
Value = 0,
ShowLabelAxisY = false,
LabelAxisY = Helper.FormatCurrency("0,00"),
FontSizeLabelAxisY = 7,
FontBoldLabelAxisY = false,
//FontColorLabelAxisY = ColorPDF.Grigio_TitoloPiccoloImmobiliare
ShowLabelAxisX = false,
LabelAxisX = string.Format("{0}<BR/><i>({1})<i>", item["Patrimonio"].ToString(), Helper.FormatPercentage(Convert.ToDecimal(item["Percentuale"]), 2)),
FontSizeLabelAxisX = 7,
//FontColorLabelAxisX = ColorPDF.Grigio_TitoloPiccoloImmobiliare,
});
}
}
// Riprende Originale
graficoBarre.SeriesCollection = serieCollezione;
AddElement(new SpacePDF(20));
tablesHeight += 20;
List<ObjectPDF> newPageElements = new List<ObjectPDF>();
newPageElements.Add(new ImagePDF(435, 0.15F, "changepage.png") { AutoIncrementYWritable = false, Y = EnvironmentFacade.RendererFacade.YLowerLimit - 5 });
newPageElements.Add(new FormattedTextAreaPDF("continua alla pagina successiva", 450, 200) { FontSize = 6, AutoIncrementYWritable = false, Y = EnvironmentFacade.RendererFacade.YLowerLimit - 5, AbsolutePosition = true });
newPageElements.Add(new PagePDF(PagePDF.PagePDFType.Generic));
newPageElements.Add(new SpacePDF(2));
newPageElements.Add(new ImagePDF(EnvironmentFacade.RendererFacade.XLeftLimit, 0.15F, "changepage.png") { Y = EnvironmentFacade.RendererFacade.YUpperLimit + 2, AutoIncrementYWritable = false });
newPageElements.Add(new FormattedTextAreaPDF("continua dalla pagina precedente", EnvironmentFacade.RendererFacade.XLeftLimit + 15, 200) { Y = EnvironmentFacade.RendererFacade.YUpperLimit + 2, FontSize = 6, AutoIncrementYWritable = true, AbsolutePosition = true });
//newPageElements.Add(new SpacePDF(20));
newPageElements.Reverse();
var availableSpace = 495;
var stackedBarHeight = graficoBarre.GetHeight() + 25; // + 25 axis X labels
if (availableSpace - stackedBarHeight - tablesHeight < 0) // missing space, new page needed
{
for (int i = 0; i < Elements.Count; i++)
{
if (Elements[i] is SpacePDF && ((SpacePDF)Elements[i]).Height == 0)
{
//Elements[i] = new PagePDF(PagePDF.PagePDFType.Generic);
foreach (var element in newPageElements)
{
Elements.Insert(i, element);
}
break;
}
}
}
AddElement(graficoBarre);
// Riprende Modifica 20181123
//double maxValue = Helper.Round(graficoBarre.GetMaximumValuePoints(), false);
//double percentuale_Y = (graficoBarre.GetMaximumValuePoints() * 100) / maxValue;
double maxValue = Convert.ToDouble(sTotale);
double percentuale_Y = (Convert.ToDouble(sTotale) * 100) / maxValue;
Int32 iLabel_X = Convert.ToInt32((percentuale_Y * graficoBarre.Width) / 100) + Convert.ToInt16(EnvironmentFacade.RendererFacade.XLeftLimit) + 70; //450;
if (iLabel_X > 435)
iLabel_X = 435;
Int32 iLabel_Y = 0;
if (GetOption<Opzione1>().ReportAnonimo)
iLabel_Y = 430;
else
switch (iNumeroClienti)
{
case 1:
iLabel_Y = 482;
break;
case 2:
iLabel_Y = 502;
break;
case 3:
iLabel_Y = 521;
break;
case 4:
iLabel_Y = 540;
break;
case 5:
iLabel_Y = 560;
break;
default:
iLabel_Y = 580;
break;
}
#region Immagini e Label per Proquota
if (dDelta > 0 && dDelta != Convert.ToDouble(sTotale))
{
var imageLabelTotale = new ImagePDF(iLabel_X, 0.8F, "LabelTotale.png", Align.Left, iLabel_Y);
var imageLabelProquota = new ImagePDF(iLabel_X, 0.8F, "LabelProquota.png", Align.Left, iLabel_Y + 12);
AddElement(imageLabelProquota);
AddElement(imageLabelTotale);
AddElement(new FormattedTextAreaPDF("Totale: " + sTotale, iLabel_X + 13)
{
FontSize = 7,
Y = iLabel_Y,
});
AddElement(new FormattedTextAreaPDF("Pro quota: " + sProquota, iLabel_X + 13)
{
FontSize = 7,
Y = iLabel_Y + 12,
});
}
else
AddElement(new FormattedTextAreaPDF(sTotale, iLabel_X + 13)
{
FontSize = 7,
Y = iLabel_Y,
//Y = 700
});
#endregion
}
// Commento 20181123 - TEST per Evolutiva ProQuota
//if (dati.Tables["distribuzionePatrimonio"].Rows.Count > 0)
//{
// var graficoBarre = new StackedPDF(EnvironmentFacade.RendererFacade.XLeftLimit + 100, 1F)
// {
// HeightSingleBar = 40,
// Width = 400,
// MinorGridAxisY = true,
// ShowLineAxisX = true,
// ShowLineAxisY = true,
// LabelFormatAxisY = FormatType.Intero,
// DinamicFloatXEtichettaLateraleBarra = true,
// FirstTwoRowsSumLinked = FirstTwoRowsSumLinked,
// RemoveWhiteSpaceBetweenChartAndAxisX = _RemoveWhiteSpaceToTheRightAxisX,
// MarginAxisY = 0,
// MarginAxisYFromTop = 0
// };
// var serieCollezione = new List<Serie> { new Serie { Name = "Patrimoni", Border = true} };
// foreach (DataRow item in dati.Tables[3].Rows)
// {
// serieCollezione[0].Points.Add(new Point
// {
// ShowLabelAxisY = true,
// LabelAxisY = Helper.FormatCurrency(item["Controvalore"].ToString()),
// FontSizeLabelAxisY = 7,
// Color = new ColorPDF(Convert.ToInt32(item["Red"]), Convert.ToInt32(item["Green"]), Convert.ToInt32(item["Blue"])),
// Value = Convert.ToDouble(item["Controvalore"]),
// ShowLabelAxisX = true,
// LabelAxisX = string.Format("{0}<BR/><i>({1})<i>", item["Patrimonio"].ToString(), Helper.FormatPercentage(Convert.ToDecimal(item["Percentuale"]), 2)),
// FontSizeLabelAxisX = 7,
// FontBoldLabelAxisY = false
// });
// }
// graficoBarre.SeriesCollection = serieCollezione;
// AddElement(new SpacePDF(20));
// tablesHeight += 20;
// List<ObjectPDF> newPageElements = new List<ObjectPDF>();
// newPageElements.Add(new ImagePDF(435, 0.15F, "changepage.png") { AutoIncrementYWritable = false, Y = EnvironmentFacade.RendererFacade.YLowerLimit - 5 });
// newPageElements.Add(new FormattedTextAreaPDF("continua alla pagina successiva", 450, 200) { FontSize = 6, AutoIncrementYWritable = false, Y = EnvironmentFacade.RendererFacade.YLowerLimit - 5, AbsolutePosition = true });
// newPageElements.Add(new PagePDF(PagePDF.PagePDFType.Generic));
// newPageElements.Add(new SpacePDF(2));
// newPageElements.Add(new ImagePDF(EnvironmentFacade.RendererFacade.XLeftLimit, 0.15F, "changepage.png") { Y = EnvironmentFacade.RendererFacade.YUpperLimit + 2, AutoIncrementYWritable = false });
// newPageElements.Add(new FormattedTextAreaPDF("continua dalla pagina precedente", EnvironmentFacade.RendererFacade.XLeftLimit + 15, 200) { Y = EnvironmentFacade.RendererFacade.YUpperLimit + 2, FontSize = 6, AutoIncrementYWritable = true, AbsolutePosition = true });
// //newPageElements.Add(new SpacePDF(20));
// newPageElements.Reverse();
// var availableSpace = 495;
// var stackedBarHeight = graficoBarre.GetHeight() + 25; // + 25 axis X labels
// if (availableSpace - stackedBarHeight - tablesHeight < 0) // missing space, new page needed
// {
// for (int i = 0; i< Elements.Count; i++)
// {
// if (Elements[i] is SpacePDF && ((SpacePDF)Elements[i]).Height == 0)
// {
// //Elements[i] = new PagePDF(PagePDF.PagePDFType.Generic);
// foreach (var element in newPageElements)
// {
// Elements.Insert(i, element);
// }
// break;
// }
// }
// }
// AddElement(graficoBarre);
//}
#region Nota del PatrimonioCasa
if (GetNote1().Length > 0)
{
AddElement(new SpacePDF(30));
AddElement(new FormattedTextAreaPDF(GetNote1(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 6, TextHorizontalAlign = TextAlign.Justify });
}
#endregion
}
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("infoNucleo"));
// ds.Tables.Add(new DataTable("clientiNucleo"));
// ds.Tables.Add(new DataTable("patrimonioComplessivo"));
// ds.Tables.Add(new DataTable("distribuzionePatrimonio"));
// var nucleo = datiSeiUnico.nucleiUnit().anagrafica;
// var patrimonioElenco = datiSeiUnico.patrimonioUnit().patrimonioComplessivo;
// decimal patrimoniocomplessivo = patrimonioElenco.totale;
// bool profiloProfessionale;
// bool profiloAggressivo;
// bool profiloProfessionaleAggressivo;
// var profiler = new Profiler(nucleo);
// profiloProfessionale = profiler.ProfiloProfessionale;
// profiloAggressivo = profiler.ProfiloAggressivo;
// profiloProfessionaleAggressivo = profiler.ProfiloProfessionaleAggressivo;
// var displayInfo = datiSeiUnico.displayInfos().tipoPatrimonioDisplayInfos;
// ds.Tables["infoNucleo"].Columns.Add(new DataColumn("Descrizione", typeof(string)));
// ds.Tables["infoNucleo"].Columns.Add(new DataColumn("Valore", typeof(string)));
// ds.Tables["infoNucleo"].Rows.Add("Nucleo", string.Format("{0}", nucleo.nomeNucleo));
// // ds.Tables["infoNucleo"].Rows.Add("Profilo finanziario", string.Format("{0}", nucleo.codProfiloNucleoSpecified ? nucleo.codProfiloNucleo != -1 ? nucleo.codProfiloNucleo.ToString() + " - " + nucleo.profiloNucleo.ToString() : nucleo.profiloNucleo.ToString() : nucleo.profiloNucleo.ToString()));
// ds.Tables["clientiNucleo"].Columns.Add(new DataColumn("Cognome", typeof(string)));
// ds.Tables["clientiNucleo"].Columns.Add(new DataColumn("Nome", typeof(string)));
// ds.Tables["clientiNucleo"].Columns.Add(new DataColumn("CodiceFiscale", typeof(string)));
// ds.Tables["clientiNucleo"].Columns.Add(new DataColumn("Profilofinanziario", typeof(string)));
// ds.Tables["clientiNucleo"].Columns.Add(new DataColumn("Contrattoconsulenza", typeof(string)));
// foreach (var item in nucleo.listaClientiNucleo)
// {
// //string contrattoDiConsulenza = "";
// //if ("Nessun Contratto".Equals(item.contratto))
// // contrattoDiConsulenza = item.contratto;
// //else
// // contrattoDiConsulenza = item.contratto + " del " + item.dtSottoscrizione.ToString("dd/MM/yyyy");
// ds.Tables["clientiNucleo"].Rows.Add(
// item.cognome,
// item.nome,
// item.codiceFiscale,
// item.codProfiloSpecified ? item.codProfilo != -1 ? item.codProfilo.ToString() + " - " + item.profilo : item.profilo : item.profilo,
// //Adriano
// item.contratto // dovrebbe già contenere la descrizione del contratto + "Professionale", come nella scheda 2
// //originale
// //item.contratto
// );
// }
// // tmp Patryk
// //ds.Tables["clientiNucleo"].Rows.RemoveAt(ds.Tables["clientiNucleo"].Rows.Count - 1);
// //ds.Tables["clientiNucleo"].Rows.Add("test", "test", "test", "test", "test");
// //ds.Tables["clientiNucleo"].Rows.Add("test", "test", "test", "test", "test");
// //ds.Tables["clientiNucleo"].Rows.Add("test", "test", "test", "test", "test");
// //ds.Tables["clientiNucleo"].Rows.Add("test", "test", "test", "test", "test");
// //ds.Tables["clientiNucleo"].Rows.Add("test", "test", "test", "test", "test");
// #region Patrimonio complessivo
// ds.Tables["patrimonioComplessivo"].Columns.Add(new DataColumn("Descrizione", typeof(string)));
// ds.Tables["patrimonioComplessivo"].Columns.Add(new DataColumn("Valore", typeof(string)));
// var testoPatrimonio = "Patrimonio complessivo (€)"+ (GetNote1().Length > 0 ? "*" : string.Empty);
// ds.Tables["patrimonioComplessivo"].Rows.Add(testoPatrimonio, Helper.FormatCurrency(Helper.FormatCurrency(datiSeiUnico.CMP_TOTALEPOSITIVO.ToString())));
// #endregion
// #region distribuzione patrimonio
// ds.Tables["distribuzionePatrimonio"].Columns.Add(new DataColumn("Patrimonio", typeof(string)));
// ds.Tables["distribuzionePatrimonio"].Columns.Add(new DataColumn("Red", typeof(int)));
// ds.Tables["distribuzionePatrimonio"].Columns.Add(new DataColumn("Green", typeof(int)));
// ds.Tables["distribuzionePatrimonio"].Columns.Add(new DataColumn("Blue", typeof(int)));
// ds.Tables["distribuzionePatrimonio"].Columns.Add(new DataColumn("Controvalore", typeof(decimal)));
// ds.Tables["distribuzionePatrimonio"].Columns.Add(new DataColumn("Percentuale", typeof(decimal)));
// //dtPatrimoni.Rows.Add("Altro", 196, 138, 137, 20000, 1.33);
// if (patrimonioElenco.elencoSlice != null)
// {
// foreach (var valore in from c in displayInfo
// join l in patrimonioElenco.elencoSlice on c.key equals l.codice
// orderby c.value.order
// select new
// {
// l.descrizione,
// new ColorPDF(c.value.fill).Red,
// new ColorPDF(c.value.fill).Green,
// new ColorPDF(c.value.fill).Blue,
// l.ctv,
// l.peso,
// l.codice
// })
// {
// ds.Tables["distribuzionePatrimonio"].Rows.Add(
// valore.descrizione + (valore.codice.Equals("PTBF") ? GetNotaCasa() : valore.codice.Equals("PTTZ")?GetNotaTerzi():""),
// valore.Red,
// valore.Green,
// valore.Blue,
// valore.ctv,
// valore.peso * 100
// );
// }
// }
// #endregion
// return ds;
//}
protected sealed override DataSet GetDataSet()
{
var ds = new DataSet();
ds.Tables.Add(new DataTable("infoNucleo"));
ds.Tables.Add(new DataTable("clientiNucleo"));
ds.Tables.Add(new DataTable("patrimonioComplessivo"));
ds.Tables.Add(new DataTable("distribuzionePatrimonio"));
var nucleo = datiSeiUnico.nucleiUnit().anagrafica;
var patrimonioElenco = datiSeiUnico.patrimonioUnit().patrimonioComplessivo;
decimal patrimoniocomplessivo = patrimonioElenco.totale;
bool profiloProfessionale;
bool profiloAggressivo;
bool profiloProfessionaleAggressivo;
var profiler = new Profiler(nucleo);
profiloProfessionale = profiler.ProfiloProfessionale;
profiloAggressivo = profiler.ProfiloAggressivo;
profiloProfessionaleAggressivo = profiler.ProfiloProfessionaleAggressivo;
var displayInfo = datiSeiUnico.displayInfos().tipoPatrimonioDisplayInfos;
ds.Tables["infoNucleo"].Columns.Add(new DataColumn("Descrizione", typeof(string)));
ds.Tables["infoNucleo"].Columns.Add(new DataColumn("Valore", typeof(string)));
ds.Tables["infoNucleo"].Rows.Add("Nucleo", string.Format("{0}", nucleo.nomeNucleo));
// ds.Tables["infoNucleo"].Rows.Add("Profilo finanziario", string.Format("{0}", nucleo.codProfiloNucleoSpecified ? nucleo.codProfiloNucleo != -1 ? nucleo.codProfiloNucleo.ToString() + " - " + nucleo.profiloNucleo.ToString() : nucleo.profiloNucleo.ToString() : nucleo.profiloNucleo.ToString()));
ds.Tables["clientiNucleo"].Columns.Add(new DataColumn("Cognome", typeof(string)));
ds.Tables["clientiNucleo"].Columns.Add(new DataColumn("Nome", typeof(string)));
ds.Tables["clientiNucleo"].Columns.Add(new DataColumn("CodiceFiscale", typeof(string)));
ds.Tables["clientiNucleo"].Columns.Add(new DataColumn("Profilofinanziario", typeof(string)));
ds.Tables["clientiNucleo"].Columns.Add(new DataColumn("Contrattoconsulenza", typeof(string)));
foreach (var item in nucleo.listaClientiNucleo)
{
//string contrattoDiConsulenza = "";
//if ("Nessun Contratto".Equals(item.contratto))
// contrattoDiConsulenza = item.contratto;
//else
// contrattoDiConsulenza = item.contratto + " del " + item.dtSottoscrizione.ToString("dd/MM/yyyy");
ds.Tables["clientiNucleo"].Rows.Add(
item.cognome,
item.nome,
item.codiceFiscale,
item.codProfiloSpecified ? item.codProfilo != -1 ? item.codProfilo.ToString() + " - " + item.profilo : item.profilo : item.profilo,
//Adriano
item.contratto // dovrebbe già contenere la descrizione del contratto + "Professionale", come nella scheda 2
//originale
//item.contratto
);
}
// tmp Patryk
//ds.Tables["clientiNucleo"].Rows.RemoveAt(ds.Tables["clientiNucleo"].Rows.Count - 1);
//ds.Tables["clientiNucleo"].Rows.Add("test", "test", "test", "test", "test");
//ds.Tables["clientiNucleo"].Rows.Add("test", "test", "test", "test", "test");
//ds.Tables["clientiNucleo"].Rows.Add("test", "test", "test", "test", "test");
//ds.Tables["clientiNucleo"].Rows.Add("test", "test", "test", "test", "test");
//ds.Tables["clientiNucleo"].Rows.Add("test", "test", "test", "test", "test");
#region Patrimonio complessivo
ds.Tables["patrimonioComplessivo"].Columns.Add(new DataColumn("Descrizione", typeof(string)));
ds.Tables["patrimonioComplessivo"].Columns.Add(new DataColumn("Valore", typeof(string)));
var testoPatrimonio = "Patrimonio complessivo (€)" + (GetNote1().Length > 0 ? "*" : string.Empty);
ds.Tables["patrimonioComplessivo"].Rows.Add(testoPatrimonio, Helper.FormatCurrency(Helper.FormatCurrency(datiSeiUnico.CMP_TOTALEPOSITIVO.ToString())));
#endregion
#region distribuzione patrimonio
ds.Tables["distribuzionePatrimonio"].Columns.Add(new DataColumn("Patrimonio", typeof(string)));
ds.Tables["distribuzionePatrimonio"].Columns.Add(new DataColumn("Red", typeof(int)));
ds.Tables["distribuzionePatrimonio"].Columns.Add(new DataColumn("Green", typeof(int)));
ds.Tables["distribuzionePatrimonio"].Columns.Add(new DataColumn("Blue", typeof(int)));
ds.Tables["distribuzionePatrimonio"].Columns.Add(new DataColumn("Controvalore", typeof(decimal)));
ds.Tables["distribuzionePatrimonio"].Columns.Add(new DataColumn("ProQuota", typeof(decimal)));
ds.Tables["distribuzionePatrimonio"].Columns.Add(new DataColumn("Percentuale", typeof(decimal)));
if (patrimonioElenco.elencoSlice != null)
{
foreach (var valore in from c in displayInfo
join l in patrimonioElenco.elencoSlice on c.key equals l.codice
orderby c.value.order
select new
{
l.descrizione,
new ColorPDF(c.value.fill).Red,
new ColorPDF(c.value.fill).Green,
new ColorPDF(c.value.fill).Blue,
l.ctv,
l.proQuota,
l.peso,
l.codice
})
{
ds.Tables["distribuzionePatrimonio"].Rows.Add(
valore.descrizione + (valore.codice.Equals("PTBF") ? GetNotaCasa() : valore.codice.Equals("PTTZ") ? GetNotaTerzi() : ""),
valore.Red,
valore.Green,
valore.Blue,
valore.ctv,
valore.proQuota,
valore.peso * 100
);
}
}
#endregion
return ds;
}
public virtual string getTestoTabella()
{
//Adriano 20180129
// Modificato testo sulla base del documento di specifiche return "Sono riportati di seguito il nome e il profilo finanziario attribuiti al nucleo, insieme alle principali informazioni anagrafiche dei soggetti da cui è composto.";
return "Sono riportate di seguito il nome attribuito al nucleo e le principali informazioni anagrafiche dei soggetti da cui è composto.";
}
public virtual string getTestoGrafico()
{
return Helper.ReplaceVariables("Il grafico rappresenta la ripartizione, del patrimonio complessivo associato al nucleo, in finanziario ($/Banca/$ e altri Istituti), immobiliare, aziendale e altro.", base.EnvironmentFacade.ReportEnvironment);
}
public virtual string GetNotaCasa()
{
return (datiSeiUnico.CASA_CCN != 0 || datiSeiUnico.CASA_GPELIGO != 0) ? "*" : "";
}
public virtual string GetNotaTerzi()
{
return (datiSeiUnico.TRZ_CCN != 0) ? "*" : "";
}
public virtual string GetNote1()
{
string nota = "";
string token = "";
decimal CCN_CASA = datiSeiUnico.CASA_CCN;
decimal GPELIGOFONDI_CASA = datiSeiUnico.CASA_GPELIGOFONDI;
decimal GPELIGTITOLI_CASA = datiSeiUnico.CASA_GPELIGTITOLI;
decimal CCN_TERZI = datiSeiUnico.TRZ_CCN;
// 20181009 AC
decimal TUOFOGLIO_CASA = datiSeiUnico.CASA_TUOFOGLIO;
//--20181009 AC
// 20181009 AC
//if (CCN_CASA != 0 || GPELIGOFONDI_CASA != 0 || GPELIGTITOLI_CASA != 0 || CCN_TERZI != 0)
if (CCN_CASA != 0 || GPELIGOFONDI_CASA != 0 || GPELIGTITOLI_CASA != 0 || CCN_TERZI != 0 || TUOFOGLIO_CASA != 0)
//--20181009 AC
{
nota += token + "Il controvalore esclude il saldo negativo";
token = " ";
if (CCN_CASA != 0)
{
nota += token + datiSeiUnico.FormatDecimal("dei conti correnti ({0} €)", CCN_CASA);
token = ", ";
}
// 20181009 AC
if (TUOFOGLIO_CASA != 0)
{
nota += token + datiSeiUnico.FormatDecimal("della liquidità sottostante Il Mio Foglio ({0} €)", TUOFOGLIO_CASA);
token = ", ";
}
//--20181009 AC
if (GPELIGOFONDI_CASA != 0)
{
nota += token + datiSeiUnico.FormatDecimal("della liquidità sottostante la GP Eligo Fondi ({0} €)", GPELIGOFONDI_CASA);
token = ", ";
}
if (GPELIGTITOLI_CASA != 0)
{
nota += token + datiSeiUnico.FormatDecimal("della liquidità sottostante la GP Eligo Titoli ({0} €)", GPELIGTITOLI_CASA);
token = ", ";
}
token = " ";
if (CCN_CASA != 0 || GPELIGOFONDI_CASA != 0 || GPELIGTITOLI_CASA != 0)
{
nota += token + "del patrimonio $/Banca/$";
token = ", ";
}
if (CCN_TERZI != 0)
{
nota += token + datiSeiUnico.FormatDecimal("dei conti correnti ({0} €) del patrimonio altri Istituti", CCN_TERZI);
token = ", ";
}
nota += ".";
token = " ";
}
nota = !nota.Equals("") ? "(*) " + nota : nota;
return datiSeiUnico.FormatBanca(nota);
}
////Adriano: serve per determinare se tutti i clienti appartenenti al nucleo hanno un contratto di consulenza professionale (in attesa di un apposito flag fornito dal servizio)
//private bool isNucleoProfessionale(DataServices.fideuram.data.service.rsAnagraficaClienteNucleo[] listaClientiNucleo)
//{
// //In attesa di un flag che dovrebbe essere nella classe Cliente
// //if (listaClientiNucleo.Where(x => x.clienteProfessionale == false).ToList().Count() > 0)
// // return false;
// //else
// // return true;
// return true;
//}
////--Adriano
////Adriano: serve per determinare se tutti i clienti appartenenti al nucleo hanno un profilo aggressivo (codProfilo >=5)
//private bool isNucleoAggressivo(DataServices.fideuram.data.service.rsAnagraficaClienteNucleo[] listaClientiNucleo)
//{
// if(listaClientiNucleo.Min(c => c.codProfilo) >= 5)
// return true;
// else
// return false;
//}
}
}