185 lines
8.6 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 System.Collections.Generic;
using System.Linq;
using Consulenza.ExternalServices;
using Consulenza.ReportWriter.Business;
using Consulenza.ReportWriter.Business.Entity;
using Consulenza.ReportWriter.Business.OBJ_PDF;
using System.Data;
using Consulenza.ReportCommon;
namespace Consulenza.ReportWriter.Manager.Section.Immobiliare.MonitoraggioNucleo
{
/// <summary>
/// Patrimonio Immobiliare Stima delle imposte (id 43) Terreni
/// </summary>
//public class S11 : Monitoraggio.S11
//{
// public S11(EnvironmentFacade environmentFacade, int idSection)
// : base(environmentFacade, idSection)
// {
// }
//}
public class S11 : Entity.Section
{
public S11(EnvironmentFacade environmentFacade, int idSection)
: base(environmentFacade, idSection)
{
try
{
Draw();
}
catch (Exception ex)
{
SectionLogger.Write("S11", 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 width = 340;
string paragrafoSx, paragrafoDx, titolo;
int textCont = 0;
FormattedTextAreaPDF testoSx = null;
FormattedTextAreaPDF testoDx = null;
int x1Linea = 35;
int x2Linea;
var dataset = GetDataSet();
var _text = dataset.Tables[0];
var data = dataset.Tables[1];
for (int j = 0; j < _text.Rows.Count + 1; j++)
{
int switchVar = (j % 2 == 0 ? 0 : 1);
switch (switchVar)
{
case 0:
//TEXT
paragrafoSx = paragrafoDx = "";
titolo = _text.Rows[textCont].Field<string>("titolo") + "<br>";
for (int i = 1; i <= 15; i++)
paragrafoSx += _text.Rows[textCont].Field<string>("testo" + i) != null ?
"<p>" + _text.Rows[textCont].Field<string>("testo" + i) + "</p><br>" : "";
// SPLIT PARAGRAFO
if (paragrafoSx.Contains("SPLITPARAGRAPH"))
{
var listaSplit = StringExtensions.SplitAtOccurence(paragrafoSx, "SPLITPARAGRAPH", 1);
paragrafoSx = listaSplit[0] + "</p>";
paragrafoDx += "<p>";
listaSplit.RemoveRange(0, 1);
foreach (var stringa in listaSplit)
paragrafoDx += stringa;
x1Linea = 35;
x2Linea = 750;
var lineaVerticaleSeparazione = new LinePDF(x1Linea, x2Linea, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = true };
var _titolo = new FormattedTextAreaPDF(titolo, 35, width) { FontSize = 13, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left };
testoSx = new FormattedTextAreaPDF(paragrafoSx, 35, width) { AutoIncrementYWritable = false, FontSize = 10, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify };
testoDx = new FormattedTextAreaPDF(paragrafoDx, 410, width) { FontSize = 10, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify };
AddElement(new SpacePDF(45));
AddElement(_titolo);
AddElement(new SpacePDF(5));
AddElement(lineaVerticaleSeparazione);
AddElement(new SpacePDF(10));
AddElement(testoSx);
AddElement(new SpacePDF(-7));
AddElement(testoDx);
AddElement(new SpacePDF(10));
}
switchVar++;
textCont++;
break;
case 1:
if (data.AsEnumerable().Where(x => x.Field<string>("row1") != "").Count() > 0)
{
DataTable tabella = new DataTable();
for (int index = 1; index <= 5; index++)
tabella.Columns.Add("column" + index);
List<string> columnName = new List<string>();
for (int index = 1; index <= 5; index++)
columnName.Add(data.Rows[0].Field<string>("column" + index));
columnName.RemoveAll(item => item == null);
foreach (var _row in data.AsEnumerable())
{
if (_row["row1"] != null && _row["row1"].ToString() != "")
tabella.Rows.Add(_row["row1"], _row["row2"], _row["row3"], _row["row4"], _row["row5"]);
}
foreach (var column in tabella.Columns.Cast<DataColumn>().ToArray())
if (tabella.AsEnumerable().All(dr => dr.IsNull(column)))
tabella.Columns.Remove(column);
TablePDF table = new TablePDF(x1Linea, tabella)
{
Style = Style.Immobiliare,
AlternateRow = false,
Footer = false,
ShowBorderLastLine = true,
AdditionalSpaceBetweenHeadersAndTable = 5.0F
};
for (int idColumn = 1; idColumn <= tabella.Columns.Count; idColumn++)
table.Columns.Add(new ColumnPDF(tabella.Rows[0].Field<string>("column" + idColumn), idColumn == 2 ? 400 : 160, idColumn == 1 ? HorizontalAlignmentType.Sinistra : HorizontalAlignmentType.Centrato, false, false, 9, ColumnType.Testo, "column" + idColumn, columnName[idColumn - 1]) { HeaderFontColor = new ColorPDF(92, 89, 81), HeaderFontSize = 9, FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, HeaderGroupTextDeltaY = 10 });
for (int i = 0; i < tabella.Rows.Count; i++)
for (int k = 0; k < table.Columns.Count; k++)
{
table.Cells[k, i].YContentOffset = 2;
}
AddElement(new SpacePDF(22));
AddElement(table);
}
switchVar++;
break;
}
}
}
/// <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()
{
var parametri = new List<Parametro>
{
new Parametro
{
Direction = ParameterDirection.Input,
DbType = DbType.Int32,
ParameterName = "IdReport",
//Value = EnvironmentFacade.ReportEnvironment.ReportId
// Impostato a -1 per prendere quello dei Report Monitoraggio Immobiliare
Value = EnvironmentFacade.ReportEnvironment.ReportId - 1
},
new Parametro
{
Direction = ParameterDirection.Input,
DbType = DbType.Int32,
ParameterName = "IdSezione",
Value = IdSection
}
};
return DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerReportModeler, "REP_Monitoraggio_Immobiliare_S11_Scadenzario", parametri);
}
}
}