635 lines
36 KiB
C#
635 lines
36 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 System.Configuration;
|
||
|
||
namespace Consulenza.ReportWriter.Manager.Section.Immobiliare.Monitoraggio
|
||
{
|
||
/// <summary>
|
||
/// Scheda 19
|
||
/// </summary>
|
||
public class S19 : Entity.Section
|
||
{
|
||
|
||
public S19(EnvironmentFacade environmentFacade, int idSection)
|
||
: base(environmentFacade, idSection)
|
||
{
|
||
try
|
||
{
|
||
Draw();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SectionLogger.Write("S19", 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 dataset = GetDataSet();
|
||
FormattedTextAreaPDF testoPagina = null;
|
||
FormattedTextAreaPDF notaTabella = null;
|
||
|
||
foreach (DataTable table in dataset.Tables)
|
||
{
|
||
if (table != null && table.Rows.Count > 0)
|
||
{
|
||
testoPagina = new FormattedTextAreaPDF("Di seguito si rappresenta l'elenco degli immobili con finalità d'investimento.", 35) { FontSize = 10, FontColor = ColorPDF.Immobiliare_Grigio_TitoloPiccolo, AutoIncrementYWritable = true, Width = 740, FixedHeight = 20 };
|
||
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(10), notaTabella };
|
||
AddElement(listaOggettiDaRipetere);
|
||
|
||
AddElement(new RepeaterPDF(listaOggettiDaRipetere));
|
||
|
||
TablePDF tablePDF = new TablePDF(35, table)
|
||
{
|
||
Style = Style.Immobiliare,
|
||
AlternateRow = false,
|
||
HeaderHeight = 25,
|
||
// Inserito il 24/04/2018 per spazio su prima riga
|
||
AdditionalSpaceBetweenHeadersAndTable = 7,
|
||
//
|
||
RowHeight = 15,
|
||
Footer = false,
|
||
PageBreak = true,
|
||
ShowBorderLastLine = true
|
||
};
|
||
|
||
tablePDF.Columns.Add(new ColumnPDF("codAnomalia", 16, HorizontalAlignmentType.Sinistra, false, false, 8, ColumnType.Immagine, "codAnomalia", "") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, ScaleColumnTypeImage = 0.1F, DeltaYContent = 2, PaddingLeft = -10 });
|
||
tablePDF.Columns.Add(new ColumnPDF("codAnomalia1", 16, HorizontalAlignmentType.Sinistra, false, false, 8, ColumnType.Immagine, "codAnomalia1", "") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, ScaleColumnTypeImage = 0.1F, DeltaYContent = 4 });
|
||
tablePDF.Columns.Add(new ColumnPDF("descrizione", 310, HorizontalAlignmentType.Sinistra, false, false, 8, ColumnType.Testo, "descrizione", "Immobili d'investimento") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1 });
|
||
tablePDF.Columns.Add(new ColumnPDF("codTipologiaCatasto", 60, HorizontalAlignmentType.Centrato, false, false, 8, 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, 8, ColumnType.Testo, "superficie", "Superficie<br>stimata") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1 });
|
||
tablePDF.Columns.Add(new ColumnPDF("renditaCatastale", 60, HorizontalAlignmentType.Destra, false, false, 8, ColumnType.Testo, "renditaCatastale", "Rendita<br>catastale*") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1 });
|
||
tablePDF.Columns.Add(new ColumnPDF("ProQuota", 100, HorizontalAlignmentType.Destra, false, false, 8, 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, 8, ColumnType.Testo, "valoreImmobileTotale", "Valore stimato<br>totale (€)") { FontBold = false, HeaderFontBold = true, HeaderFontSize = 7, DeltaYContent = 1 });
|
||
for (int k = 0; k < table.Rows.Count; k++)
|
||
{
|
||
|
||
if (table.Rows[k].Field<string>("codTipologiaCatasto").All(Char.IsDigit))
|
||
{
|
||
int column = table.Rows[k].Table.Columns["codTipologiaCatasto"].Ordinal;
|
||
tablePDF.Cells[column+1, k].Value = "-";
|
||
}
|
||
else if (table.Rows[k].Field<string>("codTipologiaCatasto").Equals("F/5"))
|
||
{
|
||
tablePDF.Cells[4, k].Value = "n.d.";
|
||
tablePDF.Cells[5, k].Value = "n.d.";
|
||
}
|
||
|
||
if (table.Rows[k].Field<string>("codTipologiaCatasto").Substring(0, 1) == "M")
|
||
tablePDF.Cells[3, k].Value = "-";
|
||
else
|
||
tablePDF.Cells[3, k].Value = table.Rows[k].Field<string>("codTipologiaCatasto");
|
||
|
||
if (table.Rows[k].Field<string>("renditaCatastale").Equals("") || Convert.ToDecimal(table.Rows[k].Field<string>("renditaCatastale")) == 0)
|
||
tablePDF.Cells[5, k].Value = "-";
|
||
else
|
||
tablePDF.Cells[5, k].Value = Helper.FormatCurrency(Convert.ToDecimal(table.Rows[k].Field<string>("renditaCatastale")).ToString());
|
||
|
||
if (Convert.ToDecimal(table.Rows[k].Field<string>("ProQuota")) <= 0)
|
||
tablePDF.Cells[6, k].Value = "-";
|
||
else
|
||
tablePDF.Cells[6, k].Value = Helper.FormatCurrency(Convert.ToDecimal(table.Rows[k].Field<string>("ProQuota")).ToString());
|
||
|
||
if (Convert.ToDecimal(table.Rows[k].Field<string>("valoreImmobileTotale")) == 0)
|
||
tablePDF.Cells[7, k].Value = "-";
|
||
else
|
||
tablePDF.Cells[7, k].Value = Helper.FormatCurrency(Convert.ToDecimal(table.Rows[k].Field<string>("valoreImmobileTotale")).ToString());
|
||
|
||
//if (table.Rows[k].Field<string>("tipoImmobile").Equals("F"))
|
||
// tablePDF.Cells[4, k].Value = Helper.FormatDecimal(table.Rows[k].Field<string>("superficie"), 0) + " mq";
|
||
|
||
//if (table.Rows[k].Field<string>("tipoImmobile").Equals("T"))
|
||
//{
|
||
// if (table.Rows[k].Field<string>("superficie").Equals(""))
|
||
// tablePDF.Cells[4, k].Value = "n.d.";
|
||
// else
|
||
// tablePDF.Cells[4, k].Value = Helper.FormatDecimal(table.Rows[k].Field<string>("superficie"), 3) + " ha";
|
||
//}
|
||
|
||
if (table.Rows[k].Field<string>("superficie") == null || table.Rows[k].Field<string>("superficie") == "0,000")
|
||
tablePDF.Cells[4, k].Value = "-";
|
||
else
|
||
{
|
||
if (table.Rows[k].Field<string>("superficie").Equals(""))
|
||
tablePDF.Cells[4, k].Value = "n.d.";
|
||
else
|
||
{
|
||
if (table.Rows[k].Field<string>("tipoImmobile").Equals("F"))
|
||
tablePDF.Cells[4, k].Value = Helper.FormatInteger(Helper.FormatDecimal(table.Rows[k].Field<string>("superficie"), 0)) + " mq";
|
||
else
|
||
tablePDF.Cells[4, k].Value = Helper.FormatDecimal(table.Rows[k].Field<string>("superficie"), 3) + " ha";
|
||
}
|
||
}
|
||
|
||
if (table.Rows[k].Field<string>("tipoImmobile").Equals("T"))
|
||
tablePDF.Cells[3, k].Value = "-";
|
||
|
||
if (!table.Rows[k].Field<string>("redditoDominicale").Equals(""))
|
||
tablePDF.Cells[5, k].Value = Helper.FormatCurrency(Convert.ToDecimal(table.Rows[k].Field<string>("redditoDominicale")).ToString());
|
||
|
||
tablePDF.Cells[2, k].Value = table.Rows[k].Field<string>("descrizione");
|
||
}
|
||
|
||
AddElement(tablePDF);
|
||
|
||
// Commentato ES 04.08.2017 per modifica Legenda
|
||
//List<string> legenda = table.AsEnumerable()
|
||
// .Select(z => z.Field<string>("codAnomalia")).Distinct() != null ?
|
||
// table.AsEnumerable()
|
||
// .Select(z => z.Field<string>("codAnomalia")).Distinct().ToList() : null;
|
||
//if (legenda != null && legenda.Count > 0)
|
||
// AddLegend(legenda);
|
||
|
||
List<string> legenda = table.AsEnumerable()
|
||
.Select(z => z.Field<string>("codAnomalia")).Distinct() != null ?
|
||
table.AsEnumerable()
|
||
.Select(z => z.Field<string>("codAnomalia")).Distinct().ToList() : null;
|
||
|
||
|
||
|
||
/********************** Modifiche per non visualizzare l'icona per le variazioni di quote per la semestrale 10/2020 - Pino ***********/
|
||
//List<string> legenda1 = new List<string>();
|
||
|
||
//if (VerificaPresenzaIconaQuoteVariate(table,"0"))
|
||
//{
|
||
// legenda1 = table.AsEnumerable().Select(z => z.Field<string>("codAnomalia1")).Distinct() != null ?
|
||
// table.AsEnumerable().Select(z => z.Field<string>("codAnomalia1")).Distinct().ToList() : null;
|
||
//}
|
||
//else
|
||
// legenda1 = null;
|
||
|
||
List<string> legenda1 = table.AsEnumerable()
|
||
.Select(z => z.Field<string>("codAnomalia1")).Distinct() != null ?
|
||
table.AsEnumerable()
|
||
.Select(z => z.Field<string>("codAnomalia1")).Distinct().ToList() : null;
|
||
|
||
if (legenda1 != null && legenda1.Count > 0)
|
||
legenda.Add(legenda1.First());
|
||
/*************************************************************************************************************************************/
|
||
|
||
if (legenda != null && legenda.Count > 0)
|
||
AddLegend(legenda);
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
public void AddLegend(List<string> legenda)
|
||
{
|
||
AddElement(new SpacePDF(2));
|
||
|
||
var xSx = 35;
|
||
foreach (string valore in legenda)
|
||
{
|
||
var listaLegend = new List<ObjectPDF>();
|
||
ImagePDF image = null;
|
||
FormattedTextAreaPDF testo = null;
|
||
switch (valore)
|
||
{
|
||
case "Warning.png":
|
||
image = new ImagePDF(xSx, 0.1F, valore) { AutoIncrementYWritable = false };
|
||
testo = new FormattedTextAreaPDF("Immobile con anomalie catastali. Vedi Dettaglio immobili - Anomalie catastali.", xSx + 15) { DeltaY = 1, AutoIncrementYWritable = true };
|
||
listaLegend.Add(image);
|
||
listaLegend.Add(testo);
|
||
break;
|
||
case "detagglio2.png":
|
||
image = new ImagePDF(xSx, 0.15F, valore) { AutoIncrementYWritable = false };
|
||
/**************** Fix 13-05-2020 Quote Variate, non da mostrare per tutti, per futura revisione del processo - Pino **************/
|
||
testo = new FormattedTextAreaPDF("Immobile con diritti e/o quote variate. Vedi Dettaglio immobili – Immobili con diritti e/o quote di diritto variate.", xSx + 15) { DeltaY = 3, AutoIncrementYWritable = true };
|
||
//testo = new FormattedTextAreaPDF("Immobile con diritti e/o quote variate.", xSx + 15) { DeltaY = 3, AutoIncrementYWritable = true };
|
||
/*********************************************************************************************************************************/
|
||
listaLegend.Add(image);
|
||
listaLegend.Add(testo);
|
||
break;
|
||
case "New.png":
|
||
image = new ImagePDF(xSx, 0.1F, valore) { AutoIncrementYWritable = false };
|
||
testo = new FormattedTextAreaPDF("Immobile di nuova acquisizione.", xSx + 15) { DeltaY = 1, AutoIncrementYWritable = true };
|
||
listaLegend.Add(image);
|
||
listaLegend.Add(testo);
|
||
break;
|
||
}
|
||
AddElement(listaLegend);
|
||
AddElement(new SpacePDF(5));
|
||
}
|
||
}
|
||
|
||
/// <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()
|
||
{
|
||
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 = "ChiaveClientePB",
|
||
Value = EnvironmentFacade.ReportEnvironment.Cliente.Chiave
|
||
}
|
||
};
|
||
|
||
#endregion
|
||
|
||
var dsOriginal = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_ImmobiliareMonitoraggio_S18_DettaglioFabbricati", parametri);
|
||
if (dsOriginal.Tables[0].Rows.Count == 0)
|
||
return null;
|
||
if (dsOriginal.Tables[0].AsEnumerable().Where(x => x.Field<int>("ordinamento") == 3).Count() > 0)
|
||
{
|
||
|
||
|
||
//********** Evol. 15-04-2020 Pino *****************//
|
||
//DataTable copyDataTable = dsOriginal.Tables[0].AsEnumerable().GroupBy(x => x.Field<string>("idImmobileCatasto")).Select(x => x.First()).Where(x => x.Field<int>("ordinamento") == 3).OrderBy(x => x.Field<int>("Tipo")).CopyToDataTable();
|
||
DataTable _dt = dsOriginal.Tables[0].AsEnumerable().GroupBy(x => x.Field<string>("idImmobileCatasto")).Select(x => x.First()).Where(x => x.Field<int>("ordinamento") == 3).OrderBy(x => x.Field<int>("Tipo")).CopyToDataTable();
|
||
DataTable copyDataTable = NuovoOrdinamento(_dt);
|
||
//********** Fine Evol. ****************************//
|
||
|
||
for (int i = 0; i < copyDataTable.Rows.Count; i++)
|
||
{
|
||
//copyDataTable.Rows[i]["codAnomalia"] = copyDataTable.Rows[i]["codAnomalia"] != DBNull.Value &&
|
||
// copyDataTable.Rows[i]["codAnomalia"] != null ?
|
||
// "Warning.png" : "";
|
||
//copyDataTable.Rows[i]["codAnomalia"] = copyDataTable.Rows[i]["quotaDiritto"] != DBNull.Value &&
|
||
// copyDataTable.Rows[i]["quotaDiritto"] != null ?
|
||
// "detagglio2.png" : copyDataTable.Rows[i]["codAnomalia"];
|
||
//copyDataTable.Rows[i]["ProQuota"] = Helper.FormatCurrency(copyDataTable.Rows[i]["ProQuota"].ToString());
|
||
//copyDataTable.Rows[i]["valoreImmobileTotale"] = Helper.FormatCurrency(copyDataTable.Rows[i]["valoreImmobileTotale"].ToString());
|
||
|
||
if (copyDataTable.Rows[i]["codAnomalia"] != DBNull.Value)
|
||
copyDataTable.Rows[i]["codAnomalia"] = "Warning.png";
|
||
else
|
||
copyDataTable.Rows[i]["codAnomalia"] = "";
|
||
|
||
/********************** Modifiche per non visualizzare l'icona per le variazioni di quote per la semestrale 10/2020 - Pino ***********/
|
||
if (copyDataTable.Rows[i]["quotaDiritto"] != DBNull.Value)
|
||
{
|
||
if (VerificaPresenzaIconaQuoteVariate(copyDataTable.Rows[i]["dtImportazione"].ToString()))
|
||
copyDataTable.Rows[i]["codAnomalia1"] = "detagglio2.png";
|
||
else
|
||
copyDataTable.Rows[i]["codAnomalia1"] = "";
|
||
}
|
||
else
|
||
copyDataTable.Rows[i]["codAnomalia1"] = "";
|
||
|
||
//if (copyDataTable.Rows[i]["quotaDiritto"] != DBNull.Value)
|
||
// copyDataTable.Rows[i]["codAnomalia1"] = "detagglio2.png";
|
||
//else
|
||
// copyDataTable.Rows[i]["codAnomalia1"] = "";
|
||
/*************************************************************************************************************************************/
|
||
|
||
|
||
if (copyDataTable.Rows[i]["ProQuota"] != DBNull.Value)
|
||
copyDataTable.Rows[i]["ProQuota"] = Helper.FormatCurrency(copyDataTable.Rows[i]["ProQuota"].ToString());
|
||
else
|
||
copyDataTable.Rows[i]["ProQuota"] = "0";
|
||
if (copyDataTable.Rows[i]["valoreImmobileTotale"] != DBNull.Value)
|
||
copyDataTable.Rows[i]["valoreImmobileTotale"] = Helper.FormatCurrency(copyDataTable.Rows[i]["valoreImmobileTotale"].ToString());
|
||
else
|
||
copyDataTable.Rows[i]["valoreImmobileTotale"] = "0";
|
||
|
||
//copyDataTable.Rows[i]["ProQuota"] = Helper.FormatCurrency(copyDataTable.Rows[i]["ProQuota"].ToString());
|
||
//copyDataTable.Rows[i]["valoreImmobileTotale"] = Helper.FormatCurrency(copyDataTable.Rows[i]["valoreImmobileTotale"].ToString());
|
||
|
||
}
|
||
//copyDataTable.Rows[0]["codAnomalia"] = "Warning.png";
|
||
var name = copyDataTable.Rows[0]["ordinamento"];
|
||
DataTable dtCloned = copyDataTable.Clone();
|
||
dtCloned.Columns[0].DataType = typeof(Int32);
|
||
for (int i = 0; i < copyDataTable.Columns.Count; i++)
|
||
dtCloned.Columns[i].DataType = typeof(string);
|
||
|
||
for (int row = 0; row < copyDataTable.Rows.Count; row++)
|
||
{
|
||
object[] array = new object[copyDataTable.Columns.Count];
|
||
for (int column = 0; column < copyDataTable.Columns.Count; column++)
|
||
array[column] = copyDataTable.Rows[row][column].ToString();
|
||
dtCloned.Rows.Add(array);
|
||
}
|
||
data.Tables[name.ToString()].Merge(dtCloned);
|
||
|
||
}
|
||
return data;
|
||
}
|
||
|
||
/// <summary>
|
||
/// Funzione che effettua l'ordinamento come da specifiche:
|
||
/// • Immobile di residenza (se indicato)
|
||
// • Pertinenza dell’immobile di residenza( )
|
||
// • Fabbricati del comune di residenza:
|
||
// - Abitazioni(per valore decrescente);
|
||
// - Box/posti auto(per valore decrescente);
|
||
// - Altre categorie fabbricati(per valore decrescente).
|
||
// • Fabbricati di altri comuni(per valore aggregato complessivo decrescente):
|
||
// - Abitazioni(per valore decrescente);
|
||
// - Box/posti auto(per valore decrescente);
|
||
// - Altre categorie fabbricati(per valore decrescente).
|
||
// • Terreni per qualità e valore decrescente
|
||
/// </summary>
|
||
/// <param name="dt">DataTable da ordinare</param>
|
||
/// <returns>DataTable ordinato</returns>
|
||
private DataTable NuovoOrdinamento(DataTable dt)
|
||
{
|
||
DataTable TabellaOrdinataFabbricati = new DataTable();
|
||
DataTable TabellaOrdinataTerreni = new DataTable();
|
||
DataTable TabellaOrdinataFabbricatiManuali = new DataTable();
|
||
DataTable copyDataTable = new DataTable();
|
||
|
||
copyDataTable = dt;
|
||
|
||
var newSort = (from row in copyDataTable.AsEnumerable()
|
||
group row by new
|
||
{
|
||
comune = row.Field<string>("comune"),
|
||
} into grp
|
||
select new
|
||
{
|
||
//descrizione = copyDataTable.AsEnumerable().Where(f => f.Field<string>("comune") == grp.Key.comune).Select(s => s.Field<string>("descrizione")).FirstOrDefault(),
|
||
valoreImmobileTotale = grp.Sum(s => s.Field<decimal>("valoreImmobileTotale")),
|
||
comune = grp.Key.comune
|
||
}).OrderBy(oo => oo.comune).OrderByDescending(o => o.valoreImmobileTotale).ToList();
|
||
|
||
DataTable tabellaFabbricati = copyDataTable.Clone();
|
||
DataTable tabellaFabbricatiManuali = copyDataTable.Clone();
|
||
DataTable tabellaTerreni = copyDataTable.Clone();
|
||
tabellaFabbricati.Clear();
|
||
tabellaFabbricatiManuali.Clear();
|
||
tabellaTerreni.Clear();
|
||
|
||
foreach (var item in newSort)
|
||
{
|
||
if (copyDataTable.AsEnumerable().Where(f => f.Field<string>("comune") == item.comune).Where(ff => ff.Field<string>("tipoImmobile") == "F").Count() > 0)
|
||
{
|
||
if (copyDataTable.AsEnumerable().Where(f => f.Field<string>("comune") == item.comune).Where(ff => ff.Field<string>("tipoImmobile") == "F").Where(f => f.Field<string>("codTipologiaCatasto").StartsWith("M")).Count() > 0)
|
||
{
|
||
//TabellaOrdinataFabbricatiManuali = copyDataTable.AsEnumerable().Where(f => f.Field<string>("comune") == item.comune).Where(ff => ff.Field<string>("tipoImmobile") == "F").Where(f => f.Field<string>("codTipologiaCatasto").StartsWith("M")).OrderBy(oo => oo.Field<string>("codTipologiaCatasto")).OrderBy(o => o.Field<string>("descrizione")).ThenByDescending(o1 => o1.Field<decimal>("valoreImmobileTotale")).CopyToDataTable();
|
||
TabellaOrdinataFabbricatiManuali = copyDataTable.AsEnumerable().Where(f => f.Field<string>("comune") == item.comune).Where(ff => ff.Field<string>("tipoImmobile") == "F").Where(f => f.Field<string>("codTipologiaCatasto").StartsWith("M")).CopyToDataTable();
|
||
|
||
foreach (DataRow itemRow in TabellaOrdinataFabbricatiManuali.Select())
|
||
tabellaFabbricatiManuali.ImportRow(itemRow);
|
||
}
|
||
|
||
if (copyDataTable.AsEnumerable().Where(f => f.Field<string>("comune") == item.comune).Where(ff => ff.Field<string>("tipoImmobile") == "F").Where(f => !f.Field<string>("codTipologiaCatasto").StartsWith("M")).Count() > 0)
|
||
{
|
||
//TabellaOrdinataFabbricati = copyDataTable.AsEnumerable().Where(f => f.Field<string>("comune") == item.comune).Where(ff => ff.Field<string>("tipoImmobile") == "F").OrderBy(o => o.Field<string>("codTipologiaCatasto")).OrderBy(o => o.Field<string>("descrizione")).CopyToDataTable();
|
||
TabellaOrdinataFabbricati = copyDataTable.AsEnumerable().Where(f => f.Field<string>("comune") == item.comune).Where(ff => ff.Field<string>("tipoImmobile") == "F").OrderBy(oo => oo.Field<string>("descrizione")).OrderBy(o => o.Field<string>("codTipologiaCatasto")).CopyToDataTable();
|
||
|
||
TabellaOrdinataFabbricati.Columns.Add(new DataColumn("CatastoCodice", typeof(System.String)));
|
||
TabellaOrdinataFabbricati.Columns.Add(new DataColumn("CatastoNumero", typeof(System.Int16)));
|
||
|
||
foreach (DataRow itemRow in TabellaOrdinataFabbricati.Select())
|
||
{
|
||
if (itemRow["codTipologiaCatasto"].ToString().IndexOf("/") > 0)
|
||
{
|
||
string[] codiceCatasto = itemRow["codTipologiaCatasto"].ToString().Split('/');
|
||
|
||
if (codiceCatasto.Length > 1)
|
||
{
|
||
/* Caso di categoria catastale censita all'agenzia delle entrate */
|
||
itemRow["CatastoCodice"] = codiceCatasto[0];
|
||
itemRow["CatastoNumero"] = Convert.ToInt16(codiceCatasto[1]);
|
||
}
|
||
//else
|
||
//{
|
||
// /* Caso di categoria catastale non censita all'agenzia delle entrete */
|
||
// itemRow["CatastoCodice"] = codiceCatasto[0].Substring(1, 1);
|
||
// itemRow["CatastoNumero"] = Convert.ToInt16(codiceCatasto[0].Substring(0, 1));
|
||
//}
|
||
}
|
||
else
|
||
{
|
||
/***** Caso in cui il codice catasto non è normalizzato con X/xx ******/
|
||
char[] c = (itemRow["codTipologiaCatasto"].ToString().ToCharArray(0, 1));
|
||
char a = c[0];
|
||
|
||
string[] codiceCatasto = itemRow["codTipologiaCatasto"].ToString().Split('/');
|
||
|
||
if ((Char.IsLetter(a)))
|
||
{
|
||
/* Caso di categoria catastale con il primo carattere di tipo lettera */
|
||
itemRow["CatastoCodice"] = itemRow["codTipologiaCatasto"].ToString().Substring(0, 1);
|
||
itemRow["CatastoNumero"] = Convert.ToInt16(itemRow["codTipologiaCatasto"].ToString().Substring(1, itemRow["codTipologiaCatasto"].ToString().Length - 1));
|
||
}
|
||
else
|
||
{
|
||
if ((char.IsNumber(a)))
|
||
{
|
||
/* Caso di categoria catastale non censita all'agenzia delle entrete */
|
||
itemRow["CatastoCodice"] = codiceCatasto[0].Substring(1, 1);
|
||
itemRow["CatastoNumero"] = Convert.ToInt16(codiceCatasto[0].Substring(0, 1));
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
//tabellaFabbricati.ImportRow(itemRow);
|
||
}
|
||
|
||
TabellaOrdinataFabbricati = TabellaOrdinataFabbricati.AsEnumerable().OrderBy(o => o.Field<string>("CatastoCodice")).ThenBy(o => o.Field<Int16>("CatastoNumero")).ThenByDescending(o => o.Field<decimal>("valoreImmobileTotale")).CopyToDataTable();
|
||
|
||
|
||
foreach (DataRow itemRow in TabellaOrdinataFabbricati.Select())
|
||
tabellaFabbricati.ImportRow(itemRow);
|
||
}
|
||
}
|
||
|
||
if (copyDataTable.AsEnumerable().Where(f => f.Field<string>("comune") == item.comune).Where(ff => ff.Field<string>("tipoImmobile") == "T").Count() > 0)
|
||
{
|
||
TabellaOrdinataTerreni = copyDataTable.AsEnumerable().Where(f => f.Field<string>("comune") == item.comune).Where(ff => ff.Field<string>("tipoImmobile") == "T").CopyToDataTable();
|
||
|
||
foreach (DataRow itemRowTerreni in TabellaOrdinataTerreni.Select())
|
||
tabellaTerreni.ImportRow(itemRowTerreni);
|
||
}
|
||
}
|
||
|
||
copyDataTable.Clear();
|
||
|
||
if (tabellaFabbricati.Rows.Count > 0)
|
||
copyDataTable = tabellaFabbricati.AsEnumerable().CopyToDataTable();
|
||
|
||
if (tabellaFabbricatiManuali.Rows.Count > 0)
|
||
{
|
||
string find = "comune='Estero'";
|
||
// Sfilo gli immobili all'estero
|
||
DataRow[] _rowElab = tabellaFabbricatiManuali.Select(find);
|
||
|
||
foreach (var itemFabbManuali in tabellaFabbricatiManuali.Select())
|
||
{
|
||
if (itemFabbManuali.Field<string>("comune") != "Estero")
|
||
copyDataTable.ImportRow(itemFabbManuali);
|
||
}
|
||
|
||
// Ordino il datatable degli immobili manuali
|
||
if (copyDataTable.Rows.Count > 0)
|
||
copyDataTable = copyDataTable.AsEnumerable().OrderByDescending(o => o.Field<decimal>("valoreImmobileTotale")).CopyToDataTable();
|
||
|
||
// Inserisco gli immobili all'estero
|
||
foreach (var item in _rowElab)
|
||
{
|
||
DataRow newRow = copyDataTable.NewRow();
|
||
|
||
newRow.ItemArray = item.ItemArray;
|
||
|
||
copyDataTable.Rows.Add(newRow);
|
||
}
|
||
}
|
||
|
||
|
||
//if (TabellaOrdinataFabbricatiManuali.Rows.Count > 0)
|
||
//{
|
||
// foreach (var itemFabbManuali in TabellaOrdinataFabbricatiManuali.Select())
|
||
// copyDataTable.ImportRow(itemFabbManuali);
|
||
//}
|
||
|
||
foreach (var itemTerreni in tabellaTerreni.Select())
|
||
copyDataTable.ImportRow(itemTerreni);
|
||
|
||
return copyDataTable;
|
||
}
|
||
|
||
private bool VerificaPresenzaIconaQuoteVariate(string dtImportazione)
|
||
{
|
||
bool verifica = true;
|
||
|
||
#region Data Ultima ricezione Catasto
|
||
string DataRicCatastoPenSem = ConfigurationManager.AppSettings["DataRicCatastoUltimaSemestrale"].ToString();
|
||
|
||
string meseUltSemRicCata = Convert.ToDateTime(DataRicCatastoPenSem).Month.ToString();
|
||
string giornoUltSemRicCata = Convert.ToDateTime(DataRicCatastoPenSem).Day.ToString();
|
||
string annoUltSemRicCata = Convert.ToDateTime(DataRicCatastoPenSem).Year.ToString();
|
||
|
||
if (meseUltSemRicCata.Length == 1)
|
||
meseUltSemRicCata = string.Concat("0", meseUltSemRicCata);
|
||
if (giornoUltSemRicCata.Length == 1)
|
||
giornoUltSemRicCata = string.Concat("0", giornoUltSemRicCata);
|
||
|
||
int dataannoUltSemRicCata = Convert.ToInt32(string.Concat(annoUltSemRicCata, meseUltSemRicCata, giornoUltSemRicCata));
|
||
#endregion
|
||
|
||
#region Data Importazione Attuale
|
||
string mesedtImportazione = Convert.ToDateTime(dtImportazione).Month.ToString();
|
||
string giornodtImportazione = Convert.ToDateTime(dtImportazione).Day.ToString();
|
||
string annodtImportazione = Convert.ToDateTime(dtImportazione).Year.ToString();
|
||
|
||
if (mesedtImportazione.Length == 1)
|
||
mesedtImportazione = string.Concat("0", mesedtImportazione);
|
||
if (giornodtImportazione.Length == 1)
|
||
giornodtImportazione = string.Concat("0", giornodtImportazione);
|
||
|
||
int dataUltimaImportazione = Convert.ToInt32(string.Concat(annodtImportazione, mesedtImportazione, giornodtImportazione));
|
||
#endregion
|
||
|
||
if (dataUltimaImportazione > dataannoUltSemRicCata)
|
||
verifica = true;
|
||
else
|
||
verifica = false;
|
||
|
||
return verifica;
|
||
}
|
||
|
||
|
||
private bool VerificaPresenzaIconaQuoteVariate(DataTable _dt,string idCatasto)
|
||
{
|
||
bool verifica = true;
|
||
string dataImportazione = string.Empty;
|
||
|
||
//try
|
||
//{
|
||
// var _ListDistinct = _dt.AsEnumerable().Select(zz => new
|
||
// {
|
||
// idImmobile = zz.Field<string>("idImmobileCatasto"),
|
||
// dtImportazione = zz.Field<string>("dtImportazione")
|
||
// }).Distinct().ToList();
|
||
//}
|
||
//catch(Exception ex)
|
||
//{
|
||
// var _ListDistinct = _dt.AsEnumerable().Select(zz => new
|
||
// {
|
||
// idImmobile = zz.Field<string>("idImmobileCatasto"),
|
||
// dtImportazione = zz.Field<DateTime>("dtImportazione")
|
||
// }).Distinct().ToList();
|
||
//}
|
||
|
||
if (_dt.AsEnumerable().Select(z => z.Field<string>("codAnomalia1")).Distinct() != null)
|
||
{
|
||
string DataRicCatastoPenSem = ConfigurationManager.AppSettings["DataRicCatastoUltimaSemestrale"].ToString();
|
||
|
||
string meseUltSemRicCata = Convert.ToDateTime(DataRicCatastoPenSem).Month.ToString();
|
||
string giornoUltSemRicCata = Convert.ToDateTime(DataRicCatastoPenSem).Day.ToString();
|
||
string annoUltSemRicCata = Convert.ToDateTime(DataRicCatastoPenSem).Year.ToString();
|
||
|
||
if (meseUltSemRicCata.Length == 1)
|
||
meseUltSemRicCata = string.Concat("0", meseUltSemRicCata);
|
||
if (giornoUltSemRicCata.Length == 1)
|
||
giornoUltSemRicCata = string.Concat("0", giornoUltSemRicCata);
|
||
|
||
int dataannoUltSemRicCata = Convert.ToInt32(string.Concat(annoUltSemRicCata, meseUltSemRicCata, giornoUltSemRicCata));
|
||
|
||
try
|
||
{
|
||
dataImportazione = _dt.AsEnumerable().Where(f => f.Field<string>("idImmobileCatasto") == idCatasto).Select(s => s.Field<DateTime>("dtImportazione").ToString()).First();
|
||
//dataImportazione = _dt.AsEnumerable().Select(s => s.Field<DateTime>("dtImportazione").ToString()).FirstOrDefault();
|
||
}
|
||
catch
|
||
{
|
||
dataImportazione = _dt.AsEnumerable().Where(f => f.Field<string>("idImmobileCatasto") == idCatasto).Select(s => s.Field<string>("dtImportazione").ToString()).First();
|
||
//dataImportazione = _dt.AsEnumerable().Select(s => s.Field<string>("dtImportazione").ToString()).FirstOrDefault();
|
||
}
|
||
|
||
string mesedtImportazione = Convert.ToDateTime(dataImportazione).Month.ToString();
|
||
string giornodtImportazione = Convert.ToDateTime(dataImportazione).Day.ToString();
|
||
string annodtImportazione = Convert.ToDateTime(dataImportazione).Year.ToString();
|
||
|
||
if (mesedtImportazione.Length == 1)
|
||
mesedtImportazione = string.Concat("0", mesedtImportazione);
|
||
if (giornodtImportazione.Length == 1)
|
||
giornodtImportazione = string.Concat("0", giornodtImportazione);
|
||
|
||
int dataUltimaImportazione = Convert.ToInt32(string.Concat(annodtImportazione, mesedtImportazione, giornodtImportazione));
|
||
|
||
|
||
|
||
if (dataUltimaImportazione > dataannoUltSemRicCata)
|
||
verifica = true;
|
||
else
|
||
verifica = false;
|
||
|
||
}
|
||
else
|
||
verifica = false;
|
||
|
||
return verifica;
|
||
}
|
||
}
|
||
}
|