313 lines
16 KiB
C#
313 lines
16 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using Consulenza.ReportWriter.Business;
|
||
using Consulenza.ReportWriter.Business.OBJ_PDF;
|
||
using System.Data;
|
||
using ceTe.DynamicPDF;
|
||
using Consulenza.ReportWriter.Business.CHART_PDF;
|
||
using Consulenza.ReportCommon;
|
||
|
||
namespace Consulenza.ReportWriter.Manager.Section.Immobiliare.Finalita
|
||
{
|
||
/// <summary>
|
||
/// Patrimonio Immobiliare Sintesi (id 141)
|
||
/// </summary>
|
||
public class S2 : Entity.Section
|
||
{
|
||
public S2(EnvironmentFacade environmentFacade, int idSection)
|
||
: base(environmentFacade, idSection)
|
||
{
|
||
try
|
||
{
|
||
Draw();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SectionLogger.Write("S2", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Scheda2. Patrimonio immobiliare –Sintesi (distribuzione del patrimonio complessivo del cliente diviso per finalità e cointestatari)
|
||
/// </summary>
|
||
protected override sealed void Draw()
|
||
{
|
||
var dati = GetDataSet();
|
||
|
||
if (dati.Tables[0].Rows.Count == 0) return;
|
||
|
||
var serieCollezione = new List<Serie>();
|
||
|
||
|
||
#region Distribuzione per tipologia
|
||
|
||
AddElement(new SpacePDF(30));
|
||
|
||
var icona = new ImagePDF(EnvironmentFacade.RendererFacade.XLeftLimit, 0.20F, "DistrFabbricati.png") { AutoIncrementYWritable = false };
|
||
var titolo = new FormattedTextAreaPDF("Distribuzione per finalità", 82) { FontSize = 14, FontColor = ColorPDF.Immobiliare_Grigio_TitoloGrande };
|
||
|
||
#region Tabella
|
||
|
||
var tabella = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit + 30, dati.Tables[0])
|
||
{
|
||
Style = Style.Immobiliare,
|
||
HeaderMargin = 8
|
||
};
|
||
|
||
tabella.Columns.Add(new ColumnPDF("descrizione", 100, HorizontalAlignmentType.Sinistra, false, false, 8, ColumnType.Testo, "descrizione", "Finalità"));
|
||
tabella.Columns.Add(new ColumnPDF("immobili", 50, HorizontalAlignmentType.Centrato, false, false, 8, ColumnType.Intero, "numeroimmobili", "Numero<BR>immobili"));
|
||
tabella.Columns.Add(new ColumnPDF("stimatoproprieta", 100, HorizontalAlignmentType.Destra, false, false, 8, ColumnType.Decimale, "valorestimatoproprieta", "Valore stimato<BR>quota di proprietà (€)"));
|
||
tabella.Columns.Add(new ColumnPDF("stimatototale", 80, HorizontalAlignmentType.Destra, false, false, 8, ColumnType.Decimale, "valorestimatototale", "Valore stimato<BR>totale (€)"));
|
||
|
||
tabella.FooterColumns.Add(new ColumnPDF("descrizione", 100, HorizontalAlignmentType.Sinistra, false, true, 8, ColumnType.Testo));
|
||
tabella.FooterColumns.Add(new ColumnPDF("immobili", 50, HorizontalAlignmentType.Centrato, false, true, 8, ColumnType.Intero));
|
||
tabella.FooterColumns.Add(new ColumnPDF("stimatoproprieta", 100, HorizontalAlignmentType.Destra, false, true, 8, ColumnType.Decimale));
|
||
tabella.FooterColumns.Add(new ColumnPDF("stimatototale", 80, HorizontalAlignmentType.Destra, false, true, 8, ColumnType.Decimale));
|
||
|
||
tabella.FooterCells[0, 0].Value = "Totale";
|
||
tabella.FooterCells[1, 0].Value = Convert.ToDecimal(dati.Tables[0].Compute("Sum(numeroimmobili)", string.Empty)).ToString();
|
||
tabella.FooterCells[2, 0].Value = Convert.ToDecimal(dati.Tables[0].Compute("Sum(valorestimatoproprieta)", string.Empty)).ToString();
|
||
tabella.FooterCells[3, 0].Value = Convert.ToDecimal(dati.Tables[0].Compute("Sum(valorestimatototale)", string.Empty)).ToString();
|
||
|
||
#endregion
|
||
|
||
AddElement(icona);
|
||
AddElement(titolo);
|
||
AddElement(new SpacePDF(30));
|
||
AddElement(tabella);
|
||
|
||
#endregion
|
||
|
||
#region Linea verticale
|
||
|
||
var xLinea = (EnvironmentFacade.RendererFacade.XRightLimit / 2) + 40;
|
||
var y1Linea = EnvironmentFacade.RendererFacade.YUpperLimit + 50;
|
||
var y2Linea = y1Linea + 170;
|
||
|
||
var lineaVerticaleSeparazione = new LinePDF(xLinea, y1Linea, xLinea, y2Linea, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = false };
|
||
AddElement(lineaVerticaleSeparazione);
|
||
|
||
#endregion
|
||
|
||
#region Grafico a torta
|
||
|
||
#region Valorizzazione Serie
|
||
|
||
var totaleValoreStimatoUsoAbitativo = dati.Tables[0].Select("codFinalita = 'U'").Length == 0 ? 0 : Convert.ToDecimal(dati.Tables[0].Select("codFinalita = 'U'").FirstOrDefault()["ValoreStimatoTotale"]);
|
||
var totaleValoreStimatoStrumentale = dati.Tables[0].Select("codFinalita = 'S'").Length == 0 ? 0 : Convert.ToDecimal(dati.Tables[0].Select("codFinalita = 'S'").FirstOrDefault()["ValoreStimatoTotale"]);
|
||
var totaleValoreStimatoInvestimento = dati.Tables[0].Select("codFinalita = 'I'").Length == 0 ? 0 : Convert.ToDecimal(dati.Tables[0].Select("codFinalita = 'I'").FirstOrDefault()["ValoreStimatoTotale"]);
|
||
var totaleValoreStimatoNonSpecificata = dati.Tables[0].Select("codFinalita = 'NS'").Length == 0 ? 0 : Convert.ToDecimal(dati.Tables[0].Select("codFinalita = 'NS'").FirstOrDefault()["ValoreStimatoTotale"]);
|
||
|
||
|
||
ColorPDF coloriUsoAbitativo = totaleValoreStimatoUsoAbitativo > 0 ? new ColorPDF(Convert.ToInt32(dati.Tables[0].Select("codFinalita = 'U'").FirstOrDefault()["Red"]), Convert.ToInt32(dati.Tables[0].Select("codFinalita = 'U'").FirstOrDefault()["Green"]), Convert.ToInt32(dati.Tables[0].Select("codFinalita = 'U'").FirstOrDefault()["Blue"])) : null;
|
||
ColorPDF coloriStrumentale = totaleValoreStimatoStrumentale > 0 ? new ColorPDF(Convert.ToInt32(dati.Tables[0].Select("codFinalita = 'S'").FirstOrDefault()["Red"]), Convert.ToInt32(dati.Tables[0].Select("codFinalita = 'S'").FirstOrDefault()["Green"]), Convert.ToInt32(dati.Tables[0].Select("codFinalita = 'S'").FirstOrDefault()["Blue"])) : null;
|
||
ColorPDF coloriInvestimento = totaleValoreStimatoInvestimento > 0 ? new ColorPDF(Convert.ToInt32(dati.Tables[0].Select("codFinalita = 'I'").FirstOrDefault()["Red"]), Convert.ToInt32(dati.Tables[0].Select("codFinalita = 'I'").FirstOrDefault()["Green"]), Convert.ToInt32(dati.Tables[0].Select("codFinalita = 'I'").FirstOrDefault()["Blue"])) : null;
|
||
ColorPDF coloriNonSpecificata = totaleValoreStimatoNonSpecificata > 0 ? new ColorPDF(Convert.ToInt32(dati.Tables[0].Select("codFinalita = 'NS'").FirstOrDefault()["Red"]), Convert.ToInt32(dati.Tables[0].Select("codFinalita = 'NS'").FirstOrDefault()["Green"]), Convert.ToInt32(dati.Tables[0].Select("codFinalita = 'NS'").FirstOrDefault()["Blue"])) : null;
|
||
|
||
|
||
serieCollezione.Add(new Serie { Name = "DistribuzioneFinalita" });
|
||
|
||
foreach (DataRow item in dati.Tables[0].Rows)
|
||
{
|
||
serieCollezione[0].Points.Add(new Point
|
||
{
|
||
LabelAxisX = item["Descrizione"].ToString(),
|
||
Color = new ColorPDF(Convert.ToInt32(item["Red"]), Convert.ToInt32(item["Green"]), Convert.ToInt32(item["Blue"])),
|
||
Value = Convert.ToDouble(item["PercentualeValoreStimato"]) == 0 ? 0.01 : Convert.ToDouble(item["PercentualeValoreStimato"]),
|
||
ShowLabelAxisX = false,
|
||
ShowLabelAxisY = false
|
||
|
||
});
|
||
}
|
||
|
||
#endregion
|
||
|
||
var intestazione = new FormattedTextAreaPDF(string.Format("{0} {1}", "Valore stimato totale:", Helper.FormatCurrencyWithSymbol(Convert.ToDecimal(dati.Tables[0].Compute("Sum(valorestimatototale)", string.Empty)).ToString())),
|
||
xLinea,
|
||
EnvironmentFacade.RendererFacade.XRightLimit - xLinea,
|
||
TextAlign.Center) { FontSize = 8, FontBold = true };
|
||
|
||
var torta = new PiePDF(xLinea + 130, 1F, y1Linea + 10)
|
||
{
|
||
ShowLabelPoints = false,
|
||
Height = 150,
|
||
Width = 150,
|
||
StartAngle = 90,
|
||
SeriesCollection = serieCollezione
|
||
|
||
};
|
||
|
||
AddElement(new ResetterYPDF(y1Linea));
|
||
AddElement(intestazione);
|
||
AddElement(torta);
|
||
AddElement(new SpacePDF(150));
|
||
|
||
var xLegenda = xLinea + 20;
|
||
if (totaleValoreStimatoUsoAbitativo > 0)
|
||
{
|
||
var legendaUsoAbitativoRettangolo = new RectanglePDF(xLegenda, 8, 17, coloriUsoAbitativo) { AutoIncrementYWritable = false };
|
||
var legendaUsoAbitativoTesto = new FormattedTextAreaPDF(string.Format("{0}<BR>{1}", "Uso Abitativo", Helper.FormatCurrencyWithSymbol(totaleValoreStimatoUsoAbitativo.ToString())), xLegenda + 20) { FontSize = 8, AutoIncrementYWritable = false };
|
||
xLegenda += 85;
|
||
|
||
AddElement(legendaUsoAbitativoRettangolo);
|
||
AddElement(legendaUsoAbitativoTesto);
|
||
}
|
||
if (totaleValoreStimatoStrumentale > 0)
|
||
{
|
||
var legendaStrumentaleRettangolo = new RectanglePDF(xLegenda, 8, 17, coloriStrumentale) { AutoIncrementYWritable = false };
|
||
var legendaStrumentaleTesto = new FormattedTextAreaPDF(string.Format("{0}<BR>{1}", "Strumentale", Helper.FormatCurrencyWithSymbol(totaleValoreStimatoStrumentale.ToString())), xLegenda + 20) { FontSize = 8, AutoIncrementYWritable = false };
|
||
xLegenda += 85;
|
||
|
||
AddElement(legendaStrumentaleRettangolo);
|
||
AddElement(legendaStrumentaleTesto);
|
||
}
|
||
if (totaleValoreStimatoInvestimento > 0)
|
||
{
|
||
var legendaInvestimentoRettangolo = new RectanglePDF(xLegenda, 8, 17, coloriInvestimento) { AutoIncrementYWritable = false };
|
||
var legendaInvestimentoTesto = new FormattedTextAreaPDF(string.Format("{0}<BR>{1}", "Investimento", Helper.FormatCurrencyWithSymbol(totaleValoreStimatoInvestimento.ToString())), xLegenda + 20) { FontSize = 8, AutoIncrementYWritable = false };
|
||
xLegenda += 85;
|
||
|
||
AddElement(legendaInvestimentoRettangolo);
|
||
AddElement(legendaInvestimentoTesto);
|
||
}
|
||
if (totaleValoreStimatoNonSpecificata > 0)
|
||
{
|
||
var legendaNonSpecificataRettangolo = new RectanglePDF(xLegenda, 8, 17, coloriNonSpecificata) { AutoIncrementYWritable = false };
|
||
var legendaNonSpecificataTesto = new FormattedTextAreaPDF(string.Format("{0}<BR>{1}", "Non specificata", Helper.FormatCurrencyWithSymbol(totaleValoreStimatoNonSpecificata.ToString())), xLegenda + 20) { FontSize = 8, AutoIncrementYWritable = false };
|
||
xLegenda += 85;
|
||
|
||
AddElement(legendaNonSpecificataRettangolo);
|
||
AddElement(legendaNonSpecificataTesto);
|
||
}
|
||
|
||
#endregion
|
||
|
||
//---------------------------------//
|
||
|
||
#region Linea orizzontale
|
||
|
||
var lineaOrizzonataleSeparazione = new LinePDF(EnvironmentFacade.RendererFacade.XLeftLimit, EnvironmentFacade.RendererFacade.XRightLimit, 1F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo);
|
||
|
||
AddElement(new SpacePDF(40));
|
||
AddElement(lineaOrizzonataleSeparazione);
|
||
|
||
#endregion
|
||
|
||
//---------------------------------//
|
||
|
||
#region Distribuzione per tipologia
|
||
|
||
AddElement(new SpacePDF(30));
|
||
|
||
icona = new ImagePDF(EnvironmentFacade.RendererFacade.XLeftLimit, 0.20F, "DistrFabbricati.png") { AutoIncrementYWritable = false };
|
||
titolo = new FormattedTextAreaPDF("Distribuzione della proprietà degli immobili", 82) { FontSize = 14, FontColor = ColorPDF.Immobiliare_Grigio_TitoloGrande };
|
||
|
||
#region Tabella
|
||
|
||
tabella = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit + 30, dati.Tables[1])
|
||
{
|
||
Style = Style.Immobiliare,
|
||
Footer = false,
|
||
ShowBorderLastLine = true,
|
||
HeaderMargin = 8
|
||
};
|
||
|
||
tabella.Columns.Add(new ColumnPDF("nominativo", 205, HorizontalAlignmentType.Sinistra, false, false, 8, ColumnType.Testo, "nominativo", "Nominativo"));
|
||
tabella.Columns.Add(new ColumnPDF("stimatoproprieta", 110, HorizontalAlignmentType.Destra, false, false, 8, ColumnType.Decimale, "valorestimatoproprieta", "Valore stimato<BR>quota di proprietà (€)"));
|
||
|
||
|
||
//tabella.FooterColumns.Add(new ColumnPDF("nominativo", 205, HorizontalAlignmentType.SINISTRA, false, true, 8, ColumnType.TESTO));
|
||
//tabella.FooterColumns.Add(new ColumnPDF("stimatoproprieta", 110, HorizontalAlignmentType.DESTRA, false, true, 8, ColumnType.DECIMALE));
|
||
|
||
|
||
//tabella.FooterCell[0].Value = "Totale";
|
||
//tabella.FooterCell[1].Value = Convert.ToDecimal(dati.Tables[1].Compute("Sum(ValoreStimatoProprieta)", string.Empty)).ToString();
|
||
|
||
|
||
#endregion
|
||
|
||
AddElement(icona);
|
||
AddElement(titolo);
|
||
AddElement(new SpacePDF(10));
|
||
AddElement(tabella);
|
||
|
||
#endregion
|
||
|
||
#region Linea verticale
|
||
|
||
xLinea = (EnvironmentFacade.RendererFacade.XRightLimit / 2) + 40;
|
||
y1Linea = EnvironmentFacade.RendererFacade.YUpperLimit + 290;
|
||
y2Linea = y1Linea + 170;
|
||
|
||
lineaVerticaleSeparazione = new LinePDF(xLinea, y1Linea, xLinea, y2Linea, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = false };
|
||
AddElement(lineaVerticaleSeparazione);
|
||
|
||
#endregion
|
||
|
||
#region Grafico
|
||
|
||
var datiGrafico = dati.Tables[1];
|
||
|
||
var xGrafico = xLinea + 20;
|
||
var graficoBarre = new StackedPDF(xGrafico, 1F) { HeightSingleBar = 16, Width = 300,MarginAxisYFromTop=0,MarginAxisY=7 };
|
||
serieCollezione = new List<Serie> { new Serie { Name = "DistribuzioneFinalita" } };
|
||
|
||
foreach (DataRow item in datiGrafico.Rows)
|
||
{
|
||
serieCollezione[0].Points.Add(new Point
|
||
{
|
||
LabelAxisY = item["Nominativo"].ToString(),
|
||
Color = new ColorPDF(Convert.ToInt32(item["Red"]), Convert.ToInt32(item["Green"]), Convert.ToInt32(item["Blue"])),
|
||
Value = Convert.ToDouble(item["ValoreStimatoProprieta"]),
|
||
ShowLabelAxisY = true
|
||
});
|
||
}
|
||
|
||
graficoBarre.SeriesCollection = serieCollezione;
|
||
|
||
AddElement(new ResetterYPDF(y1Linea + 50));
|
||
|
||
AddElement(graficoBarre);
|
||
|
||
|
||
#endregion
|
||
}
|
||
|
||
/// <summary>
|
||
/// Recupera i dati necessari alla Section restituendo un DataTable.
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
protected override DataTable GetDataTable()
|
||
{
|
||
return null;
|
||
}
|
||
|
||
/// <summary>
|
||
/// Recupera i dati necessari alla Section restituendo un DataSet.
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
protected override DataSet GetDataSet()
|
||
{
|
||
#region Definizione dei parametri
|
||
|
||
var parametri = new List<Parametro>
|
||
{
|
||
new Parametro
|
||
{
|
||
Direction = ParameterDirection.Input,
|
||
DbType = DbType.Int64,
|
||
ParameterName = "ChiaveClientePB",
|
||
Value = EnvironmentFacade.ReportEnvironment.Cliente.Chiave
|
||
}
|
||
};
|
||
|
||
#endregion
|
||
var dt = new DataSet();
|
||
dt = EnvironmentFacade.ReportEnvironment.FinalitaImmobiliare.ImmobiliareCEUnica ? DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_FinalitaImmobiliare_S2_Sintesi", parametri)
|
||
: DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaEvoluta, "REP_FinalitaImmobiliare_S2_Sintesi", parametri);
|
||
return dt;
|
||
}
|
||
}
|
||
}
|