292 lines
13 KiB
C#
292 lines
13 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.Diagnosi
|
||
{
|
||
/// <summary>
|
||
/// Patrimonio Immobiliare Sintesi (id 35)
|
||
/// </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 tipologia 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 tipologia", 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("tipologia", 90, HorizontalAlignmentType.Sinistra, false, false, 8, ColumnType.Testo, "tipologia", "Tipologia"));
|
||
tabella.Columns.Add(new ColumnPDF("immobili", 50, HorizontalAlignmentType.Centrato, false, false, 8, ColumnType.Intero, "numeroimmobili", "Numero<BR>immobili"));
|
||
tabella.Columns.Add(new ColumnPDF("stimatoproprieta", 90, HorizontalAlignmentType.Destra, false, false, 8, ColumnType.Decimale, "valorestimatoproprieta", "Valore stimato<BR>pro quota (€)"));
|
||
tabella.Columns.Add(new ColumnPDF("stimatototale", 90, HorizontalAlignmentType.Destra, false, false, 8, ColumnType.Decimale, "valorestimatototale", "Valore stimato<BR>totale (€)"));
|
||
|
||
tabella.FooterColumns.Add(new ColumnPDF("tipologia", 90, 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", 90, HorizontalAlignmentType.Destra, false, true, 8, ColumnType.Decimale));
|
||
tabella.FooterColumns.Add(new ColumnPDF("stimatototale", 90, 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) + 15;
|
||
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 totaleValoreStimatoFabbricati = dati.Tables[0].Select("tipologia = 'fabbricati'").Length == 0 ? 0 : Convert.ToDecimal(dati.Tables[0].Select("tipologia = 'fabbricati'").FirstOrDefault()["ValoreStimatoTotale"]);
|
||
var totaleValoreStimatoTerreni = dati.Tables[0].Select("tipologia = 'terreni'").Length == 0 ? 0 : Convert.ToDecimal(dati.Tables[0].Select("tipologia = 'terreni'").FirstOrDefault()["ValoreStimatoTotale"]);
|
||
|
||
serieCollezione.Add(new Serie { Name = "DistribuzioneTipologia" });
|
||
|
||
foreach (DataRow item in dati.Tables[0].Rows)
|
||
{
|
||
serieCollezione[0].Points.Add(new Point
|
||
{
|
||
LabelAxisX = item["Tipologia"].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:", Convert.ToDecimal(dati.Tables[0].Compute("Sum(valorestimatototale)", string.Empty)).ToString("C")),
|
||
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 + 120;
|
||
if (totaleValoreStimatoFabbricati > 0)
|
||
{
|
||
var legendaFabbricatiRettangolo = new RectanglePDF(xLegenda, 10, 25, new ColorPDF(153, 185, 166)) { AutoIncrementYWritable = false };
|
||
var legendaFabbricatiTesto = new FormattedTextAreaPDF(string.Format("{0}<BR>{1}", "Fabbricati", totaleValoreStimatoFabbricati.ToString("C")), xLegenda + 30) { FontSize = 8, AutoIncrementYWritable = false };
|
||
xLegenda += 100;
|
||
|
||
AddElement(legendaFabbricatiRettangolo);
|
||
AddElement(legendaFabbricatiTesto);
|
||
}
|
||
if (totaleValoreStimatoTerreni > 0)
|
||
{
|
||
var legendaTerreniRettangolo = new RectanglePDF(xLegenda, 10, 25, new ColorPDF(206, 219, 209)) { AutoIncrementYWritable = false };
|
||
var legendaTerreniTesto = new FormattedTextAreaPDF(string.Format("{0}<BR>{1}", "Terreni", totaleValoreStimatoTerreni.ToString("C")), xLegenda + 30) { FontSize = 8, AutoIncrementYWritable = false };
|
||
|
||
AddElement(legendaTerreniRettangolo);
|
||
AddElement(legendaTerreniTesto);
|
||
}
|
||
|
||
#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>pro quota (€)"));
|
||
|
||
|
||
//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) + 15;
|
||
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,
|
||
DinamicFloatXEtichettaLateraleBarra = false
|
||
};
|
||
|
||
serieCollezione = new List<Serie> { new Serie { Name = "DistribuzioneTipologia" } };
|
||
|
||
foreach (DataRow item in datiGrafico.Rows)
|
||
{
|
||
serieCollezione[0].Points.Add(new Point
|
||
{
|
||
LabelAxisY = item["Nominativo"].ToString().Trim(),
|
||
Color = new ColorPDF(Convert.ToInt32(item["Red"]), Convert.ToInt32(item["Green"]), Convert.ToInt32(item["Blue"])),
|
||
Value = Convert.ToDouble(item["ValoreStimatoProprieta"]),
|
||
ShowLabelAxisY = true,
|
||
ShowLabelAxisX = false
|
||
|
||
});
|
||
}
|
||
|
||
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
|
||
|
||
return EnvironmentFacade.ReportEnvironment.Immobiliare.ImmobiliareCEUnica ? DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_Immobiliare_S2_Sintesi", parametri)
|
||
: DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaEvoluta, "REP_Immobiliare_S2_Sintesi", parametri);
|
||
}
|
||
}
|
||
}
|