263 lines
15 KiB
C#
263 lines
15 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using Consulenza.ExternalServices;
|
||
using Consulenza.ReportWriter.Business;
|
||
using Consulenza.ReportWriter.Business.OBJ_PDF;
|
||
using System.Data;
|
||
using Consulenza.ReportWriter.Business.CHART_PDF;
|
||
using Consulenza.ReportCommon;
|
||
using Consulenza.ReportWriter.Business.Entity;
|
||
using System.Text;
|
||
using Consulenza.ReportWriter.Business.Headers;
|
||
|
||
namespace Consulenza.ReportWriter.Manager.Section.Immobiliare.MonitoraggioNucleo
|
||
{
|
||
/// <summary>
|
||
/// Scheda 21
|
||
/// </summary>
|
||
public class S21 : Entity.Section
|
||
{
|
||
|
||
public S21(EnvironmentFacade environmentFacade, int idSection)
|
||
: base(environmentFacade, idSection)
|
||
{
|
||
try
|
||
{
|
||
Draw();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SectionLogger.Write("S21", 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()
|
||
{
|
||
// OLD CODE - ES 21.08.2017
|
||
//var dataset = GetDataSet();
|
||
//FormattedTextAreaPDF testoPagina = null;
|
||
|
||
//foreach (DataTable table in dataset.Tables)
|
||
//{
|
||
// if (table != null && table.Rows.Count > 0)
|
||
// {
|
||
// AddElement(new SpacePDF(55));
|
||
// testoPagina = new FormattedTextAreaPDF("Di seguito si rappresenta l'elenco degli immobili con finalità non specificata.", 35) { FontSize = 6, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, AutoIncrementYWritable = true, Width = 740, FixedHeight = 20 };
|
||
|
||
// var listaOggettiDaRipetere = new List<ObjectPDF> { new SpacePDF(55), testoPagina, new SpacePDF(10) };
|
||
// AddElement(new RepeaterPDF(listaOggettiDaRipetere));
|
||
|
||
// TablePDF tablePDF = new TablePDF(35, table)
|
||
// {
|
||
// Style = Style.Immobiliare,
|
||
// AlternateRow = false,
|
||
// HeaderHeight = 25,
|
||
// Footer = false,
|
||
// PageBreak = true,
|
||
// ShowBorderLastLine = true
|
||
// };
|
||
|
||
// tablePDF.Columns.Add(new ColumnPDF("descrizione", 340, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "descrizione", "Immobili con finalità non specificata") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1 });
|
||
// tablePDF.Columns.Add(new ColumnPDF("codTipologiaCatasto", 60, HorizontalAlignmentType.Centrato, false, false, 7, ColumnType.Testo, "codTipologiaCatasto", "Categoria<br>catastale") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1 });
|
||
// tablePDF.Columns.Add(new ColumnPDF("superficie", 60, HorizontalAlignmentType.Centrato, false, false, 7, ColumnType.Testo, "superficie", "Superficie<br>Stimata") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1 });
|
||
// tablePDF.Columns.Add(new ColumnPDF("codTipologiaCatasto", 60, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "renditaCatastale", "Rendita<br>catastale*") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1 });
|
||
// tablePDF.Columns.Add(new ColumnPDF("ProQuota", 100, HorizontalAlignmentType.Centrato, false, false, 7, ColumnType.Testo, "ProQuota", "Valore stimato<br>pro quota (€)") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1 });
|
||
// tablePDF.Columns.Add(new ColumnPDF("valoreImmobileTotale", 100, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "valoreImmobileTotale", "Valore stimato<br>totale (€)") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1 });
|
||
|
||
|
||
|
||
// AddElement(tablePDF);
|
||
|
||
// }
|
||
//}
|
||
|
||
var dataset = GetDataSet();
|
||
FormattedTextAreaPDF testoPagina = null;
|
||
FormattedTextAreaPDF notaTabella = null;
|
||
DataTable table = dataset.Tables[0];
|
||
if (table != null && table.Rows.Count > 0)
|
||
{
|
||
testoPagina = new FormattedTextAreaPDF(getTesto1(), 35) { FontSize = 10, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, AutoIncrementYWritable = true, Width = 740 };
|
||
notaTabella = new FormattedTextAreaPDF("Nota(*): Il \"Reddito dominicale\" dei terreni è esposto nella colonna \"Rendita catastale\".<BR>", 60, 680) { AutoIncrementYWritable = false, Y = EnvironmentFacade.RendererFacade.YLowerLimit - 23, FontSize = 6, FontColor = ColorPDF.Nero, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify, DeltaX = 5, DeltaY = 5 };
|
||
var listaOggettiDaRipetere = new List<ObjectPDF> { new SpacePDF(30), testoPagina, new SpacePDF(25), notaTabella };
|
||
AddElement(listaOggettiDaRipetere);
|
||
AddElement(new RepeaterPDF(listaOggettiDaRipetere));
|
||
|
||
TablePDF tablePDF = new TablePDF(35, table)
|
||
{
|
||
Style = Style.Immobiliare,
|
||
AlternateRow = false,
|
||
HeaderHeight = 25,
|
||
Footer = false,
|
||
PageBreak = true,
|
||
ShowBorderLastLine = true,
|
||
DrawLineHeaderUP = false,
|
||
HeaderTextDrawJustOnce = false,
|
||
};
|
||
var lineaVerticaleSeparazione = new LinePDF(tablePDF.X, tablePDF.X + 720, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = false, DeltaY = -15 };
|
||
tablePDF.HeaderNoteObjects.Add(lineaVerticaleSeparazione);
|
||
tablePDF.HeaderNoteObjects.Add(new FormattedTextAreaPDF("Semestre precedente", tablePDF.X + 445, 105) { TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Center, FontBold = true, DeltaY = -10, AutoIncrementYWritable = false, });
|
||
tablePDF.HeaderNoteObjects.Add(new LinePDF(tablePDF.X + 445, tablePDF.X + 555) { DeltaY = 2, AutoIncrementYWritable = false, Color = new ColorPDF(0, 0, 0) });
|
||
|
||
tablePDF.HeaderNoteObjects.Add(new FormattedTextAreaPDF("Semestre attuale", tablePDF.X + 600, 120) { TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Center, FontBold = true, DeltaY = -10, AutoIncrementYWritable = false, });
|
||
tablePDF.HeaderNoteObjects.Add(new LinePDF(tablePDF.X + 600, tablePDF.X + 720) { DeltaY = 2, AutoIncrementYWritable = false, Color = new ColorPDF(0, 0, 0) });
|
||
|
||
|
||
|
||
tablePDF.Columns.Add(new ColumnPDF("descrizione", 300, HorizontalAlignmentType.Sinistra, false, false, 8, ColumnType.Testo, "colonnaImmobili", "Immobili") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 2 });
|
||
tablePDF.Columns.Add(new ColumnPDF("renditacatastale", 100, HorizontalAlignmentType.Destra, false, false, 8, ColumnType.Testo, "rendita", "Rendita catastale*") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 2 });
|
||
tablePDF.Columns.Add(new ColumnPDF("tipologiaprecedente", 100, HorizontalAlignmentType.Destra, false, false, 8, ColumnType.Testo, "Tipologiastorico", "Tipologia diritto") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 2 });
|
||
tablePDF.Columns.Add(new ColumnPDF("quotaprecedente", 60, HorizontalAlignmentType.Destra, false, false, 8, ColumnType.Testo, "quotaStorico", "Quota") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 2 });
|
||
tablePDF.Columns.Add(new ColumnPDF("tipologiaattuale", 100, HorizontalAlignmentType.Destra, false, false, 8, ColumnType.Testo, "tipologiaAttuale", "Tipologia diritto") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 2 });
|
||
tablePDF.Columns.Add(new ColumnPDF("quotaattuale", 60, HorizontalAlignmentType.Destra, false, false, 8, ColumnType.Testo, "quotaAttuale", "Quota") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 2 });
|
||
|
||
|
||
for (int k = 0; k < table.Rows.Count; k++)
|
||
{
|
||
|
||
//tablePDF.Cells[3, k].Value = Helper.FormatPercentage(Convert.ToDecimal(table.Rows[k].Field<string>("quotaStorico")) * 100, 1);
|
||
//tablePDF.Cells[5, k].Value = Helper.FormatPercentage(Convert.ToDecimal(table.Rows[k].Field<string>("quotaAttuale")) * 100, 1);
|
||
tablePDF.Cells[3, k].Value = Helper.FormatPercentage(Convert.ToDecimal(table.Rows[k].Field<string>("quotaStorico")), 1);
|
||
tablePDF.Cells[5, k].Value = Helper.FormatPercentage(Convert.ToDecimal(table.Rows[k].Field<string>("quotaAttuale")), 1);
|
||
|
||
if (table.Rows[k].Field<string>("rendita").Equals("") || Convert.ToDecimal(table.Rows[k].Field<string>("rendita")) == 0)
|
||
tablePDF.Cells[1, k].Value = "-";
|
||
else
|
||
tablePDF.Cells[1, k].Value = Helper.FormatCurrency(Convert.ToDecimal(table.Rows[k].Field<string>("rendita")).ToString());
|
||
|
||
|
||
}
|
||
|
||
DataTable header = new DataTable();
|
||
header.Columns.Add("space");
|
||
header.Columns.Add("semestrePrecedente");
|
||
header.Columns.Add("semestreAttuale");
|
||
|
||
|
||
header.Rows.Add("",
|
||
"Semestre precedente",
|
||
"Semestre attuale");
|
||
|
||
var tableHeader = new TablePDF(35, header)
|
||
{
|
||
Style = Style.Immobiliare,
|
||
AlternateRow = false,
|
||
Header = false,
|
||
Footer = false,
|
||
ShowBorderLastLine = false,
|
||
DrawLineHeaderUP = false,
|
||
HideFirstSeparationLine = true,
|
||
IndexesOfRowLinesToIgnoreSeparators = new List<int>() { 1 }
|
||
};
|
||
|
||
tableHeader.Columns.Add(new ColumnPDF("space", tablePDF.Columns[0].Width + tablePDF.Columns[1].Width + 20, HorizontalAlignmentType.Centrato, false, true, 8, ColumnType.Testo, "space", "") { DeltaYContent = 2 });
|
||
tableHeader.Columns.Add(new ColumnPDF("semestrePrecedente", tablePDF.Columns[2].Width + tablePDF.Columns[3].Width - 10, HorizontalAlignmentType.Centrato, false, true, 8, ColumnType.Testo, "semestrePrecedente", "") { DeltaYContent = 2, PaddingLeft = 10 });
|
||
tableHeader.Columns.Add(new ColumnPDF("semestreAttuale", tablePDF.Columns[4].Width + tablePDF.Columns[5].Width - 10, HorizontalAlignmentType.Centrato, false, true, 8, ColumnType.Testo, "semestreAttuale", "") { DeltaYContent = 2, PaddingLeft = 10 });
|
||
|
||
AddElement(tablePDF);
|
||
}
|
||
|
||
}
|
||
|
||
public string getTesto1()
|
||
{
|
||
return "Di seguito si rappresenta l'elenco degli immobili per i quali, rispetto al semestre precedente, sono intervenute " +
|
||
"variazioni nelle quote o nelle tipologie di diritto registrate all'Agenzia delle Entrate.";
|
||
}
|
||
|
||
/// <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()
|
||
{
|
||
// OLD CODE - ES 21.08.2017
|
||
// DataSet data = new DataSet();
|
||
// data.Tables.Add(new DataTable("1")); // U
|
||
// data.Tables.Add(new DataTable("2")); // S
|
||
// data.Tables.Add(new DataTable("3")); // I
|
||
// data.Tables.Add(new DataTable("4")); // NS
|
||
|
||
// #region Definizione dei parametri
|
||
|
||
// var parametri = new List<Parametro>
|
||
// {
|
||
// new Parametro
|
||
// {
|
||
// Direction = ParameterDirection.Input,
|
||
// DbType = DbType.Int64,
|
||
// ParameterName = "ChiaveNucleo",
|
||
// Value = EnvironmentFacade.ReportEnvironment.Cliente.Chiave
|
||
// }
|
||
// };
|
||
|
||
// #endregion
|
||
|
||
// var dsOriginal = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_ImmobiliareMonitoraggio_S_ImmobiliStoricoDirittoQuoteNucleo", parametri);
|
||
// if (dsOriginal.Tables[0].Rows.Count == 0)
|
||
// return null;
|
||
|
||
// List<string> indiciPagina = dsOriginal.Tables[0].AsEnumerable()
|
||
// .Select(z => z.Field<string>("NomeCliente") +"$"+z.Field<string>("CognomeCliente")).Distinct().ToList();
|
||
|
||
// DataTable copyDataTable = dsOriginal.Tables[0].AsEnumerable().Where(x => x.Field<int>("ordinamento") == 4).CopyToDataTable();
|
||
// var name = copyDataTable.Rows[0]["ordinamento"];
|
||
// data.Tables[name.ToString()].Merge(copyDataTable);
|
||
|
||
|
||
// return data;
|
||
|
||
DataSet data = new DataSet();
|
||
data.Tables.Add(new DataTable("quote")); // U
|
||
|
||
#region Definizione dei parametri
|
||
|
||
var parametri = new List<Parametro>
|
||
{
|
||
new Parametro
|
||
{
|
||
Direction = ParameterDirection.Input,
|
||
DbType = DbType.Int64,
|
||
ParameterName = "ChiaveNucleo",
|
||
Value = EnvironmentFacade.ReportEnvironment.NucleoImmobiliare.ChiaveNucleo
|
||
}
|
||
};
|
||
|
||
#endregion
|
||
|
||
var dsOriginal = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_ImmobiliareMonitoraggio_S_ImmobiliStoricoDirittoQuoteNucleo", parametri);
|
||
if (dsOriginal.Tables[0].Rows.Count == 0)
|
||
return null;
|
||
|
||
DataTable dtCloned = dsOriginal.Tables[0].Clone();
|
||
dtCloned.Columns[0].DataType = typeof(Int32);
|
||
for (int i = 0; i < dsOriginal.Tables[0].Columns.Count; i++)
|
||
dtCloned.Columns[i].DataType = typeof(string);
|
||
for (int row = 0; row < dsOriginal.Tables[0].Rows.Count; row++)
|
||
{
|
||
object[] array = new object[dsOriginal.Tables[0].Columns.Count];
|
||
for (int column = 0; column < dsOriginal.Tables[0].Columns.Count; column++)
|
||
array[column] = dsOriginal.Tables[0].Rows[row][column].ToString();
|
||
dtCloned.Rows.Add(array);
|
||
}
|
||
data.Tables["quote"].Merge(dtCloned);
|
||
|
||
return data;
|
||
|
||
}
|
||
}
|
||
}
|