1585 lines
74 KiB
C#
1585 lines
74 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;
|
||
using System.Reflection;
|
||
using System.ComponentModel;
|
||
using System.Configuration;
|
||
|
||
namespace Consulenza.ReportWriter.Manager.Section.Immobiliare.Monitoraggio
|
||
{
|
||
/// <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()
|
||
{
|
||
var dataset = GetDataSet();
|
||
if (dataset == null)
|
||
return;
|
||
|
||
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(lineaVerticaleSeparazione);
|
||
|
||
//AddElement(tableHeader);
|
||
|
||
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. Sono esclusi dalla rappresentazione gli immobili con anomalie catastali.";
|
||
}
|
||
|
||
/// <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("quote")); // U
|
||
|
||
#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_S_ImmobiliStoricoDirittoQuote", parametri);
|
||
if (dsOriginal.Tables[0].Rows.Count == 0)
|
||
return null;
|
||
|
||
/************************* FIX Quote Variate - Pino *************************/
|
||
DataSet _data = GetQuoteVariate(dsOriginal);
|
||
if (_data.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);
|
||
|
||
data.Tables["quote"].Merge(_data.Tables[0]);
|
||
|
||
return data;
|
||
}
|
||
|
||
// Da qui comincia la fix per quote variate
|
||
#region Fix Quote Variate 16/07/2020 - Pino
|
||
private DataSet GetQuoteVariate(DataSet _ds)
|
||
{
|
||
DataSet data = new DataSet();
|
||
List<Quote> ListaQuote = new List<Quote>();
|
||
string oldImmobile = string.Empty;
|
||
|
||
try
|
||
{
|
||
/* Recupero tutti gli immobili per l'utente */
|
||
List<MasterQuote> _listaMaster = ConvertTo<MasterQuote>(_ds.Tables[0]);
|
||
//List<MasterQuote> _listaMaster = ConvertTo<MasterQuote>(_dtOrd);
|
||
|
||
// Recupero il Dettaglio per l'Attuale
|
||
var listaTotale = SetDetail(_listaMaster, "A");
|
||
|
||
/* Recupero tutti gli immobili per l'utente con riferimento all'ultima semestrale */
|
||
DataTable _dtST = GetDatiQuoteStorici(EnvironmentFacade.ReportEnvironment.Cliente.Chiave.ToString());
|
||
List<MasterQuote> _listaMasterST = ConvertTo<MasterQuote>(_dtST);
|
||
|
||
// Recupero il Dettaglio per la Precedente
|
||
var listaTotaleST = SetDetail(_listaMasterST, "P");
|
||
|
||
|
||
#region match tra le due liste
|
||
// Recupero gli elementi non presenti nel semestre precedente
|
||
var firstNotSecond = listaTotale.Where(f => f.dtStimaOMI == string.Empty || f.dtStimaOMI == null).ToList();
|
||
|
||
// Ciclo sulla lista del semestre precedente e verifico se vi sono differenze tra diritti/quote Precedenti e diritti/quote Attuali
|
||
foreach (var itemSemPrec in listaTotaleST)
|
||
{
|
||
Quote cls = null;
|
||
|
||
bool isEliminare = VerificaVariazioni(listaTotale, itemSemPrec);
|
||
|
||
foreach (var item in itemSemPrec._listaDetailQuote)
|
||
{
|
||
cls = new Quote();
|
||
|
||
if (itemSemPrec.colonnaImmobili != oldImmobile)
|
||
{
|
||
cls.idImmobileCatasto = itemSemPrec.IdImmobileCatasto;
|
||
cls.chiaveClientePB = Convert.ToString(itemSemPrec.chiaveClientePB);
|
||
cls.chiaveProdottiTerzi = Convert.ToString(itemSemPrec.chiaveProdottoTerzi);
|
||
cls.colonnaImmobili = itemSemPrec.colonnaImmobili;
|
||
cls.renditaCatastale = Convert.ToString(itemSemPrec.renditaCatastale);
|
||
cls.redditoAgrario = Convert.ToString(itemSemPrec.redditoAgrario);
|
||
cls.tipoImmobile = itemSemPrec.TipoImmobile;
|
||
cls.rendita = Convert.ToString((itemSemPrec.rendita == null ? string.Empty : itemSemPrec.rendita));
|
||
cls.descrizione = itemSemPrec.colonnaImmobili;
|
||
cls.comune = itemSemPrec.comune;
|
||
cls.valoreImmobileTotale = itemSemPrec.valoreImmobileTotale;
|
||
}
|
||
|
||
cls.Tipologiastorico = item.TipologiaDirittoST;
|
||
cls.QuotaStorico = Convert.ToString(item.QuoteDirittoST);
|
||
|
||
|
||
MasterQuote _semAtt = listaTotale.Where(f => f.chiaveProdottoTerzi == itemSemPrec.chiaveProdottoTerzi).Select(s => s).FirstOrDefault();
|
||
|
||
string _dirittiAtt = _semAtt._listaDetailQuote.Select(s => s.TipologiaDirittoATT).FirstOrDefault();
|
||
decimal _quoteAtt = _semAtt._listaDetailQuote.Select(s => s.QuoteDirittoATT).FirstOrDefault();
|
||
|
||
//string _dirittiAtt = _semAtt._listaDetailQuote.Where(f => f.TipologiaDirittoATT == item.TipologiaDirittoST).Select(s => s.TipologiaDirittoATT).FirstOrDefault();
|
||
//decimal _quoteAtt = _semAtt._listaDetailQuote.Where(f => f.QuoteDirittoATT == item.QuoteDirittoST).Select(s => s.QuoteDirittoATT).FirstOrDefault();
|
||
|
||
cls.tipologiaAttuale = _dirittiAtt;
|
||
cls.quotaAttuale = Convert.ToString(_quoteAtt);
|
||
|
||
cls.Elimina = (isEliminare ? "S" : "N");
|
||
|
||
ListaQuote.Add(cls);
|
||
|
||
cls = null;
|
||
oldImmobile = itemSemPrec.colonnaImmobili;
|
||
}
|
||
|
||
}
|
||
|
||
/* Aggiunge alla lista finale gli elementi presenti non presenti nel semestre precedente */
|
||
foreach (var itemNuovi in firstNotSecond)
|
||
{
|
||
Quote cls = null;
|
||
foreach (var item in itemNuovi._listaDetailQuote)
|
||
{
|
||
cls = new Quote();
|
||
|
||
if (itemNuovi.colonnaImmobili != oldImmobile)
|
||
{
|
||
cls.idImmobileCatasto = itemNuovi.IdImmobileCatasto;
|
||
cls.chiaveClientePB = Convert.ToString(itemNuovi.chiaveClientePB);
|
||
cls.chiaveProdottiTerzi = Convert.ToString(itemNuovi.chiaveProdottoTerzi);
|
||
cls.colonnaImmobili = itemNuovi.colonnaImmobili;
|
||
cls.renditaCatastale = Convert.ToString(itemNuovi.renditaCatastale);
|
||
cls.redditoAgrario = Convert.ToString(itemNuovi.redditoAgrario);
|
||
cls.tipoImmobile = itemNuovi.TipoImmobile;
|
||
cls.rendita = Convert.ToString((itemNuovi.rendita == null ? string.Empty : itemNuovi.rendita));
|
||
cls.descrizione = itemNuovi.colonnaImmobili;
|
||
cls.comune = itemNuovi.comune;
|
||
cls.valoreImmobileTotale = itemNuovi.valoreImmobileTotale;
|
||
}
|
||
|
||
cls.Tipologiastorico = item.TipologiaDirittoST;
|
||
cls.QuotaStorico = Convert.ToString(item.QuoteDirittoST);
|
||
|
||
cls.tipologiaAttuale = item.TipologiaDirittoATT;
|
||
cls.quotaAttuale = Convert.ToString(item.QuoteDirittoATT);
|
||
|
||
ListaQuote.Add(cls);
|
||
|
||
cls = null;
|
||
oldImmobile = itemNuovi.colonnaImmobili;
|
||
}
|
||
|
||
}
|
||
|
||
/* Ciclo sulla lista totale per recuperare gli altri immobili */
|
||
//foreach (var itemDiff in listaTotale)
|
||
//{
|
||
// int conta = ListaQuote.Where(f => f.idImmobileCatasto == itemDiff.IdImmobileCatasto).Count();
|
||
|
||
// if (conta == 0)
|
||
// {
|
||
// Quote cls = null;
|
||
// foreach (var item in itemDiff._listaDetailQuote)
|
||
// {
|
||
// cls = new Quote();
|
||
|
||
// if (itemDiff.colonnaImmobili != oldImmobile)
|
||
// {
|
||
// cls.idImmobileCatasto = itemDiff.IdImmobileCatasto;
|
||
// cls.chiaveClientePB = Convert.ToString(itemDiff.chiaveClientePB);
|
||
// cls.chiaveProdottiTerzi = Convert.ToString(itemDiff.chiaveProdottoTerzi);
|
||
// cls.colonnaImmobili = itemDiff.colonnaImmobili;
|
||
// cls.renditaCatastale = Convert.ToString(itemDiff.renditaCatastale);
|
||
// cls.redditoAgrario = Convert.ToString(itemDiff.redditoAgrario);
|
||
// cls.tipoImmobile = itemDiff.TipoImmobile;
|
||
// cls.rendita = Convert.ToString((itemDiff.rendita == null ? string.Empty : itemDiff.rendita));
|
||
// cls.descrizione = itemDiff.colonnaImmobili;
|
||
// cls.comune = itemDiff.comune;
|
||
// cls.valoreImmobileTotale = itemDiff.valoreImmobileTotale;
|
||
// }
|
||
|
||
// cls.Tipologiastorico = item.TipologiaDirittoST;
|
||
// cls.QuotaStorico = Convert.ToString(item.QuoteDirittoST);
|
||
|
||
// cls.tipologiaAttuale = item.TipologiaDirittoATT;
|
||
// cls.quotaAttuale = Convert.ToString(item.QuoteDirittoATT);
|
||
|
||
// ListaQuote.Add(cls);
|
||
|
||
// cls = null;
|
||
// oldImmobile = itemDiff.colonnaImmobili;
|
||
// }
|
||
// }
|
||
//}
|
||
|
||
|
||
ListaQuote.Where(f => f.rendita == null).ToList().ForEach(p => p.rendita = string.Empty);
|
||
|
||
ListaQuote.RemoveAll(rem => rem.Elimina == "S");
|
||
|
||
ListaQuote.Where(f => f.Tipologiastorico == null).ToList().ForEach(p => p.Tipologiastorico = "Nessuna");
|
||
|
||
#region Ordinamento
|
||
var newSort = (from row in ListaQuote
|
||
group row by row.comune into grp
|
||
select new
|
||
{
|
||
comune = grp.Key,
|
||
valoreImmobileTotale = grp.Sum(x => x.valoreImmobileTotale),
|
||
});
|
||
|
||
|
||
/* Dichiaro dei DataTable */
|
||
DataTable _dtFabbricati = new DataTable();
|
||
List<Quote> _listaTotaleOridnata = new List<Quote>();
|
||
|
||
foreach (var item in newSort)
|
||
{
|
||
var _listaFabbricati = ListaQuote.Where(f => f.comune == item.comune && f.tipoImmobile == "F").OrderByDescending(o => o.valoreImmobileTotale).Select(s => s).ToList();
|
||
|
||
|
||
if (_listaFabbricati.Count > 0)
|
||
_listaTotaleOridnata.AddRange(_listaFabbricati);
|
||
|
||
}
|
||
|
||
foreach (var itemTerreni in newSort)
|
||
{
|
||
var _listaTerreni = ListaQuote.Where(f => f.comune == itemTerreni.comune && f.tipoImmobile == "T").Select(s => s).ToList();
|
||
|
||
if (_listaTerreni.Count > 0)
|
||
_listaTotaleOridnata.AddRange(_listaTerreni);
|
||
}
|
||
#endregion
|
||
|
||
//DataTable _dt = ToDataTable<Quote>(ListaQuote.OrderBy(o=> o.tipoImmobile).ToList());
|
||
DataTable _dt = ToDataTable<Quote>(_listaTotaleOridnata.ToList());
|
||
|
||
data.Tables.Add(_dt);
|
||
|
||
|
||
#endregion
|
||
|
||
}
|
||
catch(Exception ex)
|
||
{
|
||
|
||
}
|
||
|
||
return data;
|
||
}
|
||
|
||
private DataTable GetDatiQuoteStorici(string _ccpb)
|
||
{
|
||
|
||
List<MasterQuote> _listaFiltrataStorica = new List<MasterQuote>();
|
||
DataTable _dt = null;
|
||
|
||
try
|
||
{
|
||
// Determino la data da utilizzare come filtro nella lista
|
||
string dataFineSemestreAttaule = ConfigurationManager.AppSettings["DataFineTrimestreCorrente_Copertina"].ToString();
|
||
|
||
DateTime dataSemestrePrecedente = Convert.ToDateTime(dataFineSemestreAttaule).AddMonths(-6).AddMonths(1);
|
||
|
||
string meseSemPrecedente = dataSemestrePrecedente.Month.ToString();
|
||
string annoSemPrecedente = dataSemestrePrecedente.Year.ToString();
|
||
string giornoSemPrecedente = "01"; //dataSemestrePrecedente.Day.ToString();
|
||
|
||
if (meseSemPrecedente.Length == 1)
|
||
meseSemPrecedente = string.Concat("0", meseSemPrecedente);
|
||
if (giornoSemPrecedente.Length == 1)
|
||
giornoSemPrecedente = string.Concat("0", giornoSemPrecedente);
|
||
|
||
string dataSemPrecedente = string.Concat(annoSemPrecedente, meseSemPrecedente, giornoSemPrecedente);
|
||
|
||
|
||
|
||
string meseSemAtt = Convert.ToDateTime(dataFineSemestreAttaule).Month.ToString();
|
||
string giornoSemAtt = Convert.ToDateTime(dataFineSemestreAttaule).Day.ToString();
|
||
string annoSemAtt = Convert.ToDateTime(dataFineSemestreAttaule).Year.ToString();
|
||
|
||
if (meseSemAtt.Length == 1)
|
||
meseSemAtt = string.Concat("0", meseSemAtt);
|
||
if (giornoSemAtt.Length == 1)
|
||
giornoSemAtt = string.Concat("0", giornoSemAtt);
|
||
|
||
string dataSemAttuale = string.Concat(annoSemAtt, meseSemAtt, giornoSemAtt);
|
||
|
||
#region Definizione dei parametri
|
||
|
||
var parametri = new List<Parametro>
|
||
{
|
||
new Parametro
|
||
{
|
||
Direction = ParameterDirection.Input,
|
||
DbType = DbType.Int64,
|
||
ParameterName = "@CCPB",
|
||
Value =_ccpb
|
||
},
|
||
new Parametro
|
||
{
|
||
Direction = ParameterDirection.Input,
|
||
DbType = DbType.Int64,
|
||
ParameterName = "@dataSemPrecedente",
|
||
Value =dataSemPrecedente
|
||
},
|
||
//new Parametro
|
||
//{
|
||
// Direction = ParameterDirection.Input,
|
||
// DbType = DbType.Int64,
|
||
// ParameterName = "@dataSemAttuale",
|
||
// Value =dataSemAttuale
|
||
//}
|
||
};
|
||
|
||
#endregion
|
||
|
||
string queryStatoAttuale = @"select pt.idImmobileCatasto,pt.chiaveClientePB,dett.chiaveProdottoTerzi,dett.descrizione as colonnaImmobili
|
||
,dett.renditaCatastale,dett.redditoAgrario,dett.tipoImmobile,Case when dett.tipoImmobile ='F' then dett.renditaCatastale
|
||
when dett.tipoImmobile ='T' then dett.redditoAgrario end rendita
|
||
,dett.tipologiaDiritto as tipologiaAttuale,dett.quotaProprieta as quotaAttuale,dett.descrizione,dett.quotaProprieta
|
||
,dett.valoreImmobileTotale,dett.tipologia,dett.dtStimaOMI,dett.dtUltimaModifica,dett.comune from ConsulenzaUnica..PatrimonioTerzi pt
|
||
inner join ConsulenzaUnica..DettImmobiliare dett on pt.chiaveProdottoTerzi = dett.chiaveProdottoTerzi
|
||
where pt.chiaveClientePB = @CCPB
|
||
and dett.tipoImmobile in ('F','T')
|
||
and pt.dtfinevalidita > GETDATE()
|
||
and convert(char(8),dett.dtStimaOMI,112) >= @dataSemPrecedente
|
||
--and convert(char(8),dett.dtStimaOMI,112) <= @dataSemAttuale
|
||
--and convert(char(8),pt.dtInizioValidita,112) >= @dataSemPrecedente
|
||
--and convert(char(8),pt.dtInizioValidita,112) <= @dataSemAttuale
|
||
order by dett.tipoImmobile,dett.descrizione";
|
||
|
||
|
||
var dsOriginal = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerConsulenzaUnica, queryStatoAttuale, parametri);
|
||
|
||
if (dsOriginal.Rows.Count > 0)
|
||
_dt = dsOriginal.AsEnumerable().CopyToDataTable();
|
||
|
||
return _dt;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw new Exception(ex.Message);
|
||
}
|
||
}
|
||
|
||
private List<MasterQuote> SetDetail(List<MasterQuote> _lista, string _Semestre)
|
||
{
|
||
try
|
||
{
|
||
// Ciclo sulla lista Master e per ogni CCPB e CTERZI
|
||
|
||
// 1. Ordino per CCPB
|
||
// 2. Faccio distinct
|
||
// 3. Per ogni CCPB trovo il dettaglio
|
||
|
||
_lista = _lista.OrderBy(o => o.chiaveClientePB).ToList();
|
||
|
||
//List<Int64> _listaCCPB = _lista.Select(s => s.chiaveClientePB).Distinct().ToList();
|
||
|
||
foreach (var item in _lista)
|
||
{
|
||
if (_Semestre == "A")
|
||
{
|
||
#region Dati Attuali
|
||
DataTable _dt = GetDetail(item.chiaveClientePB, item.chiaveProdottoTerzi);
|
||
|
||
var listaDettaglio = _dt.AsEnumerable().ToList();
|
||
|
||
if (listaDettaglio.Count() > 0)
|
||
{
|
||
Int64 max = listaDettaglio.Max(m => m.Field<Int64>("chiaveCointestatari"));
|
||
|
||
foreach (var itemDett in listaDettaglio.Where(f => f.Field<Int64>("chiaveCointestatari") == max))
|
||
{
|
||
item._listaDetailQuote.Add(new DetailQuote()
|
||
{
|
||
TipologiaDirittoATT = itemDett.Field<string>("tipologiaDiritto"),
|
||
QuoteDirittoATT = itemDett.Field<decimal>("quotaDiritto")
|
||
});
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
else
|
||
{
|
||
#region Storico Old
|
||
|
||
//DataTable _dtStorico = GetStorico(item.chiaveClientePB, item.chiaveProdottoTerzi);
|
||
|
||
//var listaStorico = _dtStorico.AsEnumerable().ToList();
|
||
|
||
//if (listaStorico.Count() > 0)
|
||
//{
|
||
// Int64 maxStorico = listaStorico.Max(m => m.Field<Int64>("chiaveCointestatari"));
|
||
// int pos = 0;
|
||
// foreach (var itemST in listaStorico.Where(f => f.Field<Int64>("chiaveCointestatari") == maxStorico))
|
||
// {
|
||
// if (pos <= item._listaDetailQuote.Count() - 1)
|
||
// {
|
||
// item._listaDetailQuote[pos].TipologiaDirittoST = itemST.Field<string>("tipologiaDiritto");
|
||
// item._listaDetailQuote[pos].QuoteDirittoST = itemST.Field<decimal>("quotaDiritto");
|
||
// item._listaDetailQuote[pos].AggiornatoAl = itemST.Field<DateTime>("dtImportazione").ToShortDateString();
|
||
// }
|
||
// else
|
||
// {
|
||
// item._listaDetailQuote.Add(new DetailQuote()
|
||
// {
|
||
// TipologiaDirittoST = itemST.Field<string>("tipologiaDiritto"),
|
||
// QuoteDirittoST = itemST.Field<decimal>("quotaDiritto"),
|
||
// AggiornatoAl = itemST.Field<DateTime>("dtImportazione").ToShortDateString()
|
||
// });
|
||
// }
|
||
|
||
// pos += 1;
|
||
// }
|
||
//}
|
||
#endregion
|
||
|
||
#region Storico New
|
||
//DataTable _dtST = GetDetail(item.chiaveClientePB, item.chiaveProdottoTerzi);
|
||
DataTable _dtST = GetStorico(item.chiaveClientePB, item.chiaveProdottoTerzi);
|
||
|
||
|
||
var listaDettaglioST = _dtST.AsEnumerable().ToList();
|
||
|
||
if (listaDettaglioST.Count() > 0)
|
||
{
|
||
Int64 max = listaDettaglioST.Max(m => m.Field<Int64>("chiaveCointestatari"));
|
||
//int pos = 0;
|
||
foreach (var itemDett in listaDettaglioST.Where(f => f.Field<Int64>("chiaveCointestatari") == max))
|
||
{
|
||
item._listaDetailQuote.Add(new DetailQuote()
|
||
{
|
||
TipologiaDirittoST = itemDett.Field<string>("TD_ST"),
|
||
QuoteDirittoST = itemDett.Field<decimal>("Q_ST")
|
||
});
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//MessageBox.Show("Errore: " + ex.Message);
|
||
}
|
||
|
||
return _lista;
|
||
}
|
||
|
||
private DataTable GetDetail(Int64 _ccpb, Int64 _cpt)
|
||
{
|
||
DataTable _dt = new DataTable();
|
||
|
||
try
|
||
{
|
||
#region Definizione dei parametri
|
||
|
||
var parametri = new List<Parametro>
|
||
{
|
||
new Parametro
|
||
{
|
||
Direction = ParameterDirection.Input,
|
||
DbType = DbType.Int64,
|
||
ParameterName = "@CCPB",
|
||
Value =_ccpb
|
||
},
|
||
new Parametro
|
||
{
|
||
Direction = ParameterDirection.Input,
|
||
DbType = DbType.Int64,
|
||
ParameterName = "CPT",
|
||
Value =_cpt
|
||
}
|
||
};
|
||
|
||
#endregion
|
||
|
||
string queryLogGenerale = @"Select coin.chiaveClientePB,coin.chiaveProdottoTerzi,coin.chiaveCointestatari,condett.tipologiaDiritto,condett.quotaDiritto from ConsulenzaUnica..cointestatari coin inner join ConsulenzaUnica..CointestatariDettaglioDiritto condett on coin.chiaveProdottoTerzi=condett.chiaveprodottoterzi and coin.chiaveCointestatari=condett.chiaveCointestatari where coin.chiaveClientePB = @CCPB and coin.chiaveClientePBProprietario = @CCPB and condett.chiaveprodottoterzi = @CPT";
|
||
var dsOriginal = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerConsulenzaUnica, queryLogGenerale, parametri);
|
||
|
||
_dt = dsOriginal.AsEnumerable().CopyToDataTable();
|
||
|
||
//#region Dettaglio
|
||
|
||
//DataSet ds = null;
|
||
//String connString = ConfigurationManager.ConnectionStrings["SqlServerConsulenzaUnicaCONG"].ToString();
|
||
|
||
//using (SqlConnection conn = new SqlConnection(connString))
|
||
//{
|
||
// string queryLogGenerale = @"Select coin.chiaveClientePB,coin.chiaveProdottoTerzi,coin.chiaveCointestatari,condett.tipologiaDiritto,condett.quotaDiritto from ConsulenzaUnica..cointestatari coin inner join ConsulenzaUnica..CointestatariDettaglioDiritto condett on coin.chiaveProdottoTerzi=condett.chiaveprodottoterzi and coin.chiaveCointestatari=condett.chiaveCointestatari where coin.chiaveClientePB = @CCPB and coin.chiaveClientePBProprietario = @CCPB and condett.chiaveprodottoterzi = @CPT";
|
||
|
||
// SqlCommand cmd = new SqlCommand(queryLogGenerale, conn);
|
||
|
||
// cmd.CommandType = CommandType.Text;
|
||
|
||
// cmd.Parameters.Add("@CCPB", SqlDbType.BigInt);
|
||
// cmd.Parameters["@CCPB"].Value = _ccpb; //6088; //6088; //1662180;
|
||
|
||
// cmd.Parameters.Add("@CPT", SqlDbType.BigInt);
|
||
// cmd.Parameters["@CPT"].Value = _cpt;
|
||
|
||
// try
|
||
// {
|
||
// conn.Open();
|
||
|
||
// ds = new DataSet();
|
||
// var da = new SqlDataAdapter(cmd);
|
||
// da.Fill(ds);
|
||
|
||
// _dt = ds.Tables[0].AsEnumerable().CopyToDataTable();//.AsEnumerable().GroupBy(x => x.Field<string>("idImmobileCatasto")).Select(x => x.First()).Where(x => x.Field<int>("ordinamento") == 4).CopyToDataTable();
|
||
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// Console.WriteLine(ex.Message);
|
||
// }
|
||
// finally
|
||
// {
|
||
// conn.Close();
|
||
// conn.Dispose();
|
||
// }
|
||
//}
|
||
//#endregion
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//MessageBox.Show("Errore: " + ex.Message);
|
||
}
|
||
|
||
return _dt;
|
||
}
|
||
|
||
private DataTable GetStorico(Int64 _ccpb, Int64 _cpt)
|
||
{
|
||
DataTable _dt = new DataTable();
|
||
|
||
try
|
||
{
|
||
|
||
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);
|
||
|
||
string dataannoUltSemRicCata = string.Concat(annoUltSemRicCata, meseUltSemRicCata, giornoUltSemRicCata);
|
||
|
||
|
||
#region Definizione dei parametri
|
||
|
||
var parametri = new List<Parametro>
|
||
{
|
||
new Parametro
|
||
{
|
||
Direction = ParameterDirection.Input,
|
||
DbType = DbType.Int64,
|
||
ParameterName = "@CCPB",
|
||
Value =_ccpb
|
||
},
|
||
new Parametro
|
||
{
|
||
Direction = ParameterDirection.Input,
|
||
DbType = DbType.Int64,
|
||
ParameterName = "@CPT",
|
||
Value =_cpt
|
||
},
|
||
new Parametro
|
||
{
|
||
Direction = ParameterDirection.Input,
|
||
DbType = DbType.String,
|
||
ParameterName = "@dataannoUltSemRicCata",
|
||
Value = dataannoUltSemRicCata
|
||
},
|
||
};
|
||
|
||
#endregion
|
||
|
||
var queryStorico = @"Select dettdir.chiaveClientePB,
|
||
dettdir.chiaveprodottoterzi,
|
||
dettdir.chiaveCointestatari,
|
||
dettimm.tipologiaDiritto as TD_Att,
|
||
dettimm.quotaProprieta as Q_ATT,
|
||
dettimm.dtStimaOMI,
|
||
dettdir.tipologiaDiritto as TD_ST,
|
||
dettdir.quotaDiritto as Q_ST,
|
||
dettdir.dtImportazione
|
||
from ConsulenzaUnica..PatrimonioTerzi pt
|
||
inner join ConsulenzaUnica..DettImmobiliare dettimm ON pt.chiaveProdottoTerzi = dettimm.chiaveProdottoTerzi
|
||
left join ConsulenzaUnica..DettImmobiliareStoricoVariazioni dettdir
|
||
on pt.chiaveProdottoTerzi = dettdir.chiaveProdottoTerzi
|
||
where dettdir.chiaveClientePB = @CCPB
|
||
and dettdir.chiaveprodottoterzi = @CPT
|
||
and chiaveclientepbProprietario = @CCPB
|
||
and dtfinevalidita > getdate()
|
||
and dettdir.dtImportazione > @dataannoUltSemRicCata";
|
||
|
||
|
||
var dsOriginal = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerConsulenzaUnica, queryStorico, parametri);
|
||
|
||
_dt = dsOriginal.AsEnumerable().CopyToDataTable();
|
||
|
||
//#region Dettaglio storico
|
||
//DataSet ds = null;
|
||
//String connString = ConfigurationManager.ConnectionStrings["SqlServerConsulenzaUnicaCONG"].ToString();
|
||
|
||
//using (SqlConnection conn = new SqlConnection(connString))
|
||
//{
|
||
// var queryStorico = @"Select dettdir.chiaveClientePB,
|
||
// dettdir.chiaveprodottoterzi,
|
||
// dettdir.chiaveCointestatari,
|
||
// dettimm.tipologiaDiritto as TD_Att,
|
||
// dettimm.quotaProprieta as Q_ATT,
|
||
// dettimm.dtStimaOMI,
|
||
// dettdir.tipologiaDiritto as TD_ST,
|
||
// dettdir.quotaDiritto as Q_ST,
|
||
// dettdir.dtImportazione
|
||
// from ConsulenzaUnica..PatrimonioTerzi pt
|
||
// inner join ConsulenzaUnica..DettImmobiliare dettimm ON pt.chiaveProdottoTerzi = dettimm.chiaveProdottoTerzi
|
||
// left join ConsulenzaUnica..DettImmobiliareStoricoVariazioni dettdir
|
||
// on pt.chiaveProdottoTerzi = dettdir.chiaveProdottoTerzi
|
||
// where dettdir.chiaveClientePB = @CCPB
|
||
// and dettdir.chiaveprodottoterzi = @CPT
|
||
// and chiaveclientepbProprietario = @CCPB
|
||
// and dtfinevalidita > getdate()";
|
||
|
||
// SqlCommand cmd = new SqlCommand(queryStorico, conn);
|
||
|
||
// cmd.CommandType = CommandType.Text;
|
||
|
||
// cmd.Parameters.Add("@CCPB", SqlDbType.BigInt);
|
||
// cmd.Parameters["@CCPB"].Value = _ccpb; //6088; //6088; //1662180;
|
||
|
||
// cmd.Parameters.Add("@CPT", SqlDbType.BigInt);
|
||
// cmd.Parameters["@CPT"].Value = _cpt;
|
||
|
||
// //cmd.Parameters.Add("@meseSemPrecedente", SqlDbType.VarChar);
|
||
// //cmd.Parameters["@meseSemPrecedente"].Value = meseSemPrecedente;
|
||
|
||
// //cmd.Parameters.Add("@annoSemPrecedente", SqlDbType.VarChar);
|
||
// //cmd.Parameters["@annoSemPrecedente"].Value = annoSemPrecedente;
|
||
|
||
// //cmd.Parameters.Add("@data", SqlDbType.VarChar);
|
||
// //cmd.Parameters["@data"].Value = dataSemestrePrecedente;
|
||
|
||
// try
|
||
// {
|
||
// conn.Open();
|
||
|
||
// ds = new DataSet();
|
||
// var da = new SqlDataAdapter(cmd);
|
||
// da.Fill(ds);
|
||
|
||
// _dt = ds.Tables[0].AsEnumerable().CopyToDataTable();//.AsEnumerable().GroupBy(x => x.Field<string>("idImmobileCatasto")).Select(x => x.First()).Where(x => x.Field<int>("ordinamento") == 4).CopyToDataTable();
|
||
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// Console.WriteLine(ex.Message);
|
||
// }
|
||
// finally
|
||
// {
|
||
// conn.Close();
|
||
// conn.Dispose();
|
||
// }
|
||
//}
|
||
//#endregion
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//MessageBox.Show("Errore: " + ex.Message);
|
||
}
|
||
|
||
return _dt;
|
||
}
|
||
|
||
private bool VerificaVariazioni(List<MasterQuote> listaAtt, MasterQuote _semPrec)
|
||
{
|
||
bool isEliminare = false;
|
||
bool isQuoteUguali = false;
|
||
bool isDirittiUguali = false;
|
||
|
||
Int64 cpt = _semPrec.chiaveProdottoTerzi;
|
||
|
||
// filtro la lista Att per quella cpt
|
||
MasterQuote _semAtt = listaAtt.Where(f => f.chiaveProdottoTerzi == cpt).Select(s => s).FirstOrDefault();
|
||
|
||
//foreach (var itemQuoteST in _semPrec._listaDetailQuote)
|
||
//{
|
||
// string _dirittiAtt = _semAtt._listaDetailQuote.Where(f => f.TipologiaDirittoATT == itemQuoteST.TipologiaDirittoST).Select(s => s.TipologiaDirittoATT).FirstOrDefault();
|
||
// decimal _quoteAtt = _semAtt._listaDetailQuote.Where(f => f.QuoteDirittoATT == itemQuoteST.QuoteDirittoST).Select(s => s.QuoteDirittoATT).FirstOrDefault();
|
||
|
||
// if (itemQuoteST.TipologiaDirittoST == _dirittiAtt)
|
||
// isDirittiUguali = true;
|
||
// else
|
||
// isDirittiUguali = false;
|
||
|
||
// if (itemQuoteST.QuoteDirittoST == _quoteAtt)
|
||
// isQuoteUguali = true;
|
||
// else
|
||
// isQuoteUguali = false;
|
||
//}
|
||
|
||
//if (isQuoteUguali && isDirittiUguali) isEliminare = true;
|
||
|
||
if (VerificaStoricoVariazione(_semPrec))
|
||
isEliminare = false;
|
||
else
|
||
{
|
||
if (isQuoteUguali && isDirittiUguali) isEliminare = true;
|
||
}
|
||
|
||
|
||
return isEliminare;
|
||
}
|
||
|
||
private bool VerificaStoricoVariazione(MasterQuote _semPrec)
|
||
{
|
||
bool isVariazioni = false;
|
||
|
||
// Verifico variazioni nelle quote
|
||
DataTable _dt = new DataTable();
|
||
|
||
try
|
||
{
|
||
#region Storico Variazioni
|
||
|
||
// Determino la data da utilizzare come filtro nella lista
|
||
string dataFineSemestreAttaule = ConfigurationManager.AppSettings["DataFineTrimestreCorrente_Copertina"].ToString();
|
||
|
||
DateTime dataSemestrePrecedente = Convert.ToDateTime(dataFineSemestreAttaule).AddMonths(-6).AddMonths(1);
|
||
|
||
string meseSemPrecedente = dataSemestrePrecedente.Month.ToString();
|
||
string annoSemPrecedente = dataSemestrePrecedente.Year.ToString();
|
||
string giornoSemPrecedente = "01"; //dataSemestrePrecedente.Day.ToString();
|
||
|
||
if (meseSemPrecedente.Length == 1)
|
||
meseSemPrecedente = string.Concat("0", meseSemPrecedente);
|
||
if (giornoSemPrecedente.Length == 1)
|
||
giornoSemPrecedente = string.Concat("0", giornoSemPrecedente);
|
||
|
||
string dataSemPrecedente = string.Concat(annoSemPrecedente, meseSemPrecedente, giornoSemPrecedente);
|
||
|
||
|
||
|
||
string meseSemAtt = Convert.ToDateTime(dataFineSemestreAttaule).Month.ToString();
|
||
string giornoSemAtt = Convert.ToDateTime(dataFineSemestreAttaule).Day.ToString();
|
||
string annoSemAtt = Convert.ToDateTime(dataFineSemestreAttaule).Year.ToString();
|
||
|
||
if (meseSemAtt.Length == 1)
|
||
meseSemAtt = string.Concat("0", meseSemAtt);
|
||
if (giornoSemAtt.Length == 1)
|
||
giornoSemAtt = string.Concat("0", giornoSemAtt);
|
||
|
||
string dataSemAttuale = string.Concat(annoSemAtt, meseSemAtt, giornoSemAtt);
|
||
|
||
|
||
#region Definizione dei parametri
|
||
|
||
var parametri = new List<Parametro>
|
||
{
|
||
new Parametro
|
||
{
|
||
Direction = ParameterDirection.Input,
|
||
DbType = DbType.Int64,
|
||
ParameterName = "@CCPB",
|
||
Value =_semPrec.chiaveClientePB
|
||
},
|
||
new Parametro
|
||
{
|
||
Direction = ParameterDirection.Input,
|
||
DbType = DbType.Int64,
|
||
ParameterName = "@CPT",
|
||
Value =_semPrec.chiaveProdottoTerzi
|
||
},
|
||
new Parametro
|
||
{
|
||
Direction = ParameterDirection.Input,
|
||
DbType = DbType.String,
|
||
ParameterName = "@dataSemPrecedente",
|
||
Value =dataSemPrecedente
|
||
},
|
||
new Parametro
|
||
{
|
||
Direction = ParameterDirection.Input,
|
||
DbType = DbType.String,
|
||
ParameterName = "@dataSemAttuale",
|
||
Value =dataSemAttuale
|
||
}
|
||
};
|
||
|
||
#endregion
|
||
|
||
string queryStoricoVariazioni = @"Select * from ConsulenzaUnica..DettImmobiliareStoricoVariazioni
|
||
where chiaveClientePB = @CCPB
|
||
and chiaveclientepbProprietario = @CCPB
|
||
and chiaveprodottoterzi = @CPT
|
||
and convert(char(8), dtimportazione, 112) >= @dataSemPrecedente
|
||
and convert(char(8), dtimportazione, 112) <= @dataSemAttuale";
|
||
|
||
|
||
var dsOriginal = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerConsulenzaUnica, queryStoricoVariazioni, parametri);
|
||
|
||
_dt = dsOriginal.AsEnumerable().CopyToDataTable();
|
||
|
||
if (_dt.Rows.Count > 0)
|
||
isVariazioni = true;
|
||
|
||
//DataSet ds = null;
|
||
//String connString = ConfigurationManager.ConnectionStrings["SqlServerConsulenzaUnicaCONG"].ToString();
|
||
|
||
//using (SqlConnection conn = new SqlConnection(connString))
|
||
//{
|
||
// string queryStoricoVariazioni = @"Select * from ConsulenzaUnica..DettImmobiliareStoricoVariazioni
|
||
// where chiaveClientePB = @CCPB
|
||
// and chiaveclientepbProprietario = @CCPB
|
||
// and chiaveprodottoterzi = @CPT
|
||
// and convert(char(8), dtimportazione, 112) >= @dataSemPrecedente
|
||
// and convert(char(8), dtimportazione, 112) <= @dataSemAttuale";
|
||
|
||
// SqlCommand cmd = new SqlCommand(queryStoricoVariazioni, conn);
|
||
|
||
// cmd.CommandType = CommandType.Text;
|
||
|
||
// cmd.Parameters.Add("@CCPB", SqlDbType.BigInt);
|
||
// cmd.Parameters["@CCPB"].Value = _semPrec.chiaveClientePB; //6088; //6088; //1662180;
|
||
|
||
// cmd.Parameters.Add("@CPT", SqlDbType.BigInt);
|
||
// cmd.Parameters["@CPT"].Value = _semPrec.chiaveProdottoTerzi;
|
||
|
||
// cmd.Parameters.Add("@dataSemPrecedente", SqlDbType.NVarChar);
|
||
// cmd.Parameters["@dataSemPrecedente"].Value = dataSemPrecedente;
|
||
|
||
// cmd.Parameters.Add("@dataSemAttuale", SqlDbType.NVarChar);
|
||
// cmd.Parameters["@dataSemAttuale"].Value = dataSemAttuale;
|
||
|
||
// try
|
||
// {
|
||
// conn.Open();
|
||
|
||
// ds = new DataSet();
|
||
// var da = new SqlDataAdapter(cmd);
|
||
// da.Fill(ds);
|
||
|
||
// _dt = ds.Tables[0].AsEnumerable().CopyToDataTable();//.AsEnumerable().GroupBy(x => x.Field<string>("idImmobileCatasto")).Select(x => x.First()).Where(x => x.Field<int>("ordinamento") == 4).CopyToDataTable();
|
||
|
||
// if (_dt.Rows.Count > 0)
|
||
// isVariazioni = true;
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// Console.WriteLine(ex.Message);
|
||
// }
|
||
// finally
|
||
// {
|
||
// conn.Close();
|
||
// conn.Dispose();
|
||
// }
|
||
//}
|
||
#endregion
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//MessageBox.Show("Errore: " + ex.Message);
|
||
}
|
||
|
||
return isVariazioni;
|
||
}
|
||
|
||
//private DataSet GetQuoteVariate(DataSet _ds)
|
||
//{
|
||
// DataSet data = new DataSet();
|
||
// List<Quote> ListaQuote = new List<Quote>();
|
||
// string oldImmobile = string.Empty;
|
||
|
||
// try
|
||
// {
|
||
// List<MasterQuote> _listaMaster = ConvertTo<MasterQuote>(_ds.Tables[0]);
|
||
|
||
// var listaTotale = SetDetail(_listaMaster);
|
||
|
||
|
||
// foreach (var item in listaTotale)
|
||
// {
|
||
// Quote cls = null;
|
||
|
||
// foreach (var itemST in item._listaDetailQuote)
|
||
// {
|
||
// cls = new Quote();
|
||
|
||
// bool isEliminare = VerificaNessunaVariazione(item._listaDetailQuote);
|
||
|
||
// if (item.colonnaImmobili != oldImmobile)
|
||
// {
|
||
// cls.idImmobileCatasto = item.IdImmobileCatasto;
|
||
// cls.chiaveClientePB = Convert.ToString(item.chiaveClientePB);
|
||
// cls.chiaveProdottiTerzi = Convert.ToString(item.chiaveProdottoTerzi);
|
||
// cls.colonnaImmobili = item.colonnaImmobili;
|
||
// cls.renditaCatastale = Convert.ToString(item.renditaCatastale);
|
||
// cls.redditoAgrario = Convert.ToString(item.redditoAgrario);
|
||
// cls.tipoImmobile = item.TipoImmobile;
|
||
// cls.rendita = Convert.ToString((item.rendita != null ? item.rendita : "0"));
|
||
// cls.descrizione = item.colonnaImmobili;
|
||
// }
|
||
|
||
// cls.Tipologiastorico = itemST.TipologiaDirittoST;
|
||
// cls.QuotaStorico = Convert.ToString(itemST.QuoteDirittoST);
|
||
// cls.tipologiaAttuale = itemST.TipologiaDirittoATT;
|
||
// cls.quotaAttuale = Convert.ToString(itemST.QuoteDirittoATT);
|
||
|
||
// cls.Elimina = (isEliminare ? "S" : "N");
|
||
|
||
// ListaQuote.Add(cls);
|
||
|
||
// cls = null;
|
||
// oldImmobile = item.colonnaImmobili;
|
||
// }
|
||
|
||
// }
|
||
// }
|
||
// catch(Exception ex)
|
||
// {
|
||
|
||
// }
|
||
|
||
// ListaQuote.Where(f => f.rendita == null).ToList().ForEach(p => p.rendita = string.Empty);
|
||
|
||
// ListaQuote.RemoveAll(rem => rem.Elimina == "S");
|
||
// //ListaQuote.RemoveAll(rem => rem.tipologiaAttuale == rem.Tipologiastorico && rem.quotaAttuale == rem.QuotaStorico);
|
||
|
||
// ListaQuote.Where(f => f.Tipologiastorico == null).ToList().ForEach(p => p.Tipologiastorico = "Nessuna");
|
||
|
||
// DataTable _dt = ToDataTable<Quote>(ListaQuote);
|
||
|
||
// data.Tables.Add(_dt);
|
||
|
||
// return data;
|
||
//}
|
||
|
||
//private List<MasterQuote> SetDetail(List<MasterQuote> _lista)
|
||
//{
|
||
// try
|
||
// {
|
||
// // Ciclo sulla lista Master e per ogni CCPB e CTERZI
|
||
|
||
// // 1. Ordino per CCPB
|
||
// // 2. Faccio distinct
|
||
// // 3. Per ogni CCPB trovo il dettaglio
|
||
|
||
// _lista = _lista.OrderBy(o => o.chiaveClientePB).ToList();
|
||
|
||
// //List<Int64> _listaCCPB = _lista.Select(s => s.chiaveClientePB).Distinct().ToList();
|
||
|
||
// foreach (var item in _lista)
|
||
// {
|
||
// DataTable _dt = GetDetail(item.chiaveClientePB, item.chiaveProdottoTerzi);
|
||
|
||
// var listaDettaglio = _dt.AsEnumerable().ToList();
|
||
|
||
// if (listaDettaglio.Count() > 0)
|
||
// {
|
||
// Int64 max = listaDettaglio.Max(m => m.Field<Int64>("chiaveCointestatari"));
|
||
|
||
// foreach (var itemDett in listaDettaglio.Where(f => f.Field<Int64>("chiaveCointestatari") == max))
|
||
// {
|
||
// item._listaDetailQuote.Add(new DetailQuote()
|
||
// {
|
||
// TipologiaDirittoATT = itemDett.Field<string>("tipologiaDiritto"),
|
||
// QuoteDirittoATT = itemDett.Field<decimal>("quotaDiritto")
|
||
// });
|
||
// }
|
||
// }
|
||
|
||
|
||
// #region Storico
|
||
|
||
// DataTable _dtStorico = GetStorico(item.chiaveClientePB, item.chiaveProdottoTerzi);
|
||
|
||
// var listaStorico = _dtStorico.AsEnumerable().ToList();
|
||
|
||
// if (listaStorico.Count() > 0)
|
||
// {
|
||
// Int64 maxStorico = listaStorico.Max(m => m.Field<Int64>("chiaveCointestatari"));
|
||
// int pos = 0;
|
||
// foreach (var itemST in listaStorico.Where(f => f.Field<Int64>("chiaveCointestatari") == maxStorico))
|
||
// {
|
||
// if (pos <= item._listaDetailQuote.Count() - 1)
|
||
// {
|
||
// item._listaDetailQuote[pos].TipologiaDirittoST = itemST.Field<string>("tipologiaDiritto");
|
||
// item._listaDetailQuote[pos].QuoteDirittoST = itemST.Field<decimal>("quotaDiritto");
|
||
// }
|
||
// else
|
||
// {
|
||
// item._listaDetailQuote.Add(new DetailQuote()
|
||
// {
|
||
// TipologiaDirittoST = itemST.Field<string>("tipologiaDiritto"),
|
||
// QuoteDirittoST = itemST.Field<decimal>("quotaDiritto")
|
||
// });
|
||
// }
|
||
|
||
// pos += 1;
|
||
// }
|
||
// }
|
||
// #endregion
|
||
// }
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// //MessageBox.Show("Errore: " + ex.Message);
|
||
// }
|
||
|
||
// return _lista;
|
||
//}
|
||
|
||
//private DataTable GetDetail(Int64 _ccpb, Int64 _cpt)
|
||
//{
|
||
// DataTable _dt = new DataTable();
|
||
|
||
// try
|
||
// {
|
||
// #region Definizione dei parametri
|
||
|
||
// var parametri = new List<Parametro>
|
||
// {
|
||
// new Parametro
|
||
// {
|
||
// Direction = ParameterDirection.Input,
|
||
// DbType = DbType.Int64,
|
||
// ParameterName = "@CCPB",
|
||
// Value =_ccpb
|
||
// },
|
||
// new Parametro
|
||
// {
|
||
// Direction = ParameterDirection.Input,
|
||
// DbType = DbType.Int64,
|
||
// ParameterName = "CPT",
|
||
// Value =_cpt
|
||
// }
|
||
// };
|
||
|
||
// #endregion
|
||
|
||
// string queryLogGenerale = @"Select coin.chiaveClientePB,coin.chiaveProdottoTerzi,coin.chiaveCointestatari,condett.tipologiaDiritto,condett.quotaDiritto from ConsulenzaUnica..cointestatari coin inner join ConsulenzaUnica..CointestatariDettaglioDiritto condett on coin.chiaveProdottoTerzi=condett.chiaveprodottoterzi and coin.chiaveCointestatari=condett.chiaveCointestatari where coin.chiaveClientePB = @CCPB and coin.chiaveClientePBProprietario = @CCPB and condett.chiaveprodottoterzi = @CPT";
|
||
// var dsOriginal = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerConsulenzaUnica, queryLogGenerale, parametri);
|
||
|
||
// _dt = dsOriginal.AsEnumerable().CopyToDataTable();
|
||
|
||
// //#region Dettaglio
|
||
|
||
// //DataSet ds = null;
|
||
// //String connString = ConfigurationManager.ConnectionStrings["SqlServerConsulenzaUnicaCONG"].ToString();
|
||
|
||
// //using (SqlConnection conn = new SqlConnection(connString))
|
||
// //{
|
||
// // string queryLogGenerale = @"Select coin.chiaveClientePB,coin.chiaveProdottoTerzi,coin.chiaveCointestatari,condett.tipologiaDiritto,condett.quotaDiritto from ConsulenzaUnica..cointestatari coin inner join ConsulenzaUnica..CointestatariDettaglioDiritto condett on coin.chiaveProdottoTerzi=condett.chiaveprodottoterzi and coin.chiaveCointestatari=condett.chiaveCointestatari where coin.chiaveClientePB = @CCPB and coin.chiaveClientePBProprietario = @CCPB and condett.chiaveprodottoterzi = @CPT";
|
||
|
||
// // SqlCommand cmd = new SqlCommand(queryLogGenerale, conn);
|
||
|
||
// // cmd.CommandType = CommandType.Text;
|
||
|
||
// // cmd.Parameters.Add("@CCPB", SqlDbType.BigInt);
|
||
// // cmd.Parameters["@CCPB"].Value = _ccpb; //6088; //6088; //1662180;
|
||
|
||
// // cmd.Parameters.Add("@CPT", SqlDbType.BigInt);
|
||
// // cmd.Parameters["@CPT"].Value = _cpt;
|
||
|
||
// // try
|
||
// // {
|
||
// // conn.Open();
|
||
|
||
// // ds = new DataSet();
|
||
// // var da = new SqlDataAdapter(cmd);
|
||
// // da.Fill(ds);
|
||
|
||
// // _dt = ds.Tables[0].AsEnumerable().CopyToDataTable();//.AsEnumerable().GroupBy(x => x.Field<string>("idImmobileCatasto")).Select(x => x.First()).Where(x => x.Field<int>("ordinamento") == 4).CopyToDataTable();
|
||
|
||
// // }
|
||
// // catch (Exception ex)
|
||
// // {
|
||
// // Console.WriteLine(ex.Message);
|
||
// // }
|
||
// // finally
|
||
// // {
|
||
// // conn.Close();
|
||
// // conn.Dispose();
|
||
// // }
|
||
// //}
|
||
// //#endregion
|
||
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// //MessageBox.Show("Errore: " + ex.Message);
|
||
// }
|
||
|
||
// return _dt;
|
||
//}
|
||
|
||
//private DataTable GetStorico(Int64 _ccpb, Int64 _cpt)
|
||
//{
|
||
// DataTable _dt = new DataTable();
|
||
|
||
// try
|
||
// {
|
||
|
||
// string dataFineSemestreAttaule = ConfigurationManager.AppSettings["DataFineTrimestreCorrente_Copertina"].ToString();
|
||
|
||
// DateTime dataSemestrePrecedente = Convert.ToDateTime(dataFineSemestreAttaule).AddMonths(-6);
|
||
// string meseSemPrecedente = ((dataSemestrePrecedente.Month) + 1).ToString();
|
||
// string annoSemPrecedente = dataSemestrePrecedente.Year.ToString();
|
||
|
||
// #region Definizione dei parametri
|
||
|
||
// var parametri = new List<Parametro>
|
||
// {
|
||
// new Parametro
|
||
// {
|
||
// Direction = ParameterDirection.Input,
|
||
// DbType = DbType.Int64,
|
||
// ParameterName = "@CCPB",
|
||
// Value =_ccpb
|
||
// },
|
||
// new Parametro
|
||
// {
|
||
// Direction = ParameterDirection.Input,
|
||
// DbType = DbType.Int64,
|
||
// ParameterName = "@CPT",
|
||
// Value =_cpt
|
||
// },
|
||
// new Parametro
|
||
// {
|
||
// Direction = ParameterDirection.Input,
|
||
// DbType = DbType.String,
|
||
// ParameterName = "@meseSemPrecedente",
|
||
// Value = meseSemPrecedente
|
||
// },
|
||
// new Parametro
|
||
// {
|
||
// Direction = ParameterDirection.Input,
|
||
// DbType = DbType.String,
|
||
// ParameterName = "@annoSemPrecedente",
|
||
// Value = annoSemPrecedente
|
||
// }
|
||
// };
|
||
// #endregion
|
||
|
||
// //string queryLogGenerale = @"Select dettImmSTDD.tipologiaDiritto,dettImmSTDD.quotaDiritto,dettImmST.chiaveCointestatari from (Select * from ConsulenzaUnica..DettImmobiliareStoricoVariazioni where convert(char(8),dtimportazione,112) >= '20200331') as dettImmST
|
||
// // inner join (Select distinct chiaveprodottoterzi, tipologiaDiritto,quotaDiritto from ConsulenzaUnica..DettImmobiliareStoricoVariazioniDettaglioDiritto) as dettImmSTDD
|
||
// // on dettImmST.chiaveprodottoterzi = dettImmSTDD.chiaveprodottoterzi
|
||
// // where dettImmST.chiaveClientePB = @CCPB
|
||
// // and dettImmST.chiaveprodottoterzi = @CPT";
|
||
|
||
// //string queryLogGenerale = @"Select condett.tipologiaDiritto,condett.quotaDiritto,condett.chiaveCointestatari from ConsulenzaUnica..cointestatari coin
|
||
// // inner join ConsulenzaUnica..CointestatariDettaglioDiritto_1706 condett on coin.chiaveProdottoTerzi=condett.chiaveprodottoterzi and coin.chiaveCointestatari=condett.chiaveCointestatari
|
||
// // where coin.chiaveClientePB = @CCPB
|
||
// // and condett.chiaveprodottoterzi = @CPT";
|
||
|
||
|
||
// string queryLogGenerale = @"select DISTINCT
|
||
// CASE WHEN isnull(stor.tipologiaDiritto, '') = '' THEN dettimmST.tipologiaDiritto ELSE stor.tipologiaDiritto END AS tipologiaDiritto,
|
||
// CASE WHEN isnull(stor.quotaDiritto, 0) = 0 THEN dettimmST.quotaDiritto ELSE stor.quotaDiritto END AS quotaDiritto,
|
||
// --CAST(pt.chiaveClientePB AS bigint) AS chiaveClientePB,
|
||
// dettimmST.chiaveCointestatari
|
||
// --pt.chiaveProdottoTerzi,
|
||
// --dettimmST.dtImportazione
|
||
// from ConsulenzaUnica..PatrimonioTerzi pt
|
||
// inner join ConsulenzaUnica..DettImmobiliare dettimm on pt.chiaveProdottoTerzi = dettimm.chiaveProdottoTerzi AND pt.dtfinevalidita > GETDATE()
|
||
// inner join ConsulenzaUnica..DettImmobiliareStoricoVariazioni dettimmST on pt.chiaveClientePB = dettimmST.chiaveClientePB and pt.chiaveProdottoTerzi=dettimmST.chiaveprodottoterzi
|
||
// inner join dbo.DettImmobiliareStoricoVariazioniDettaglioDiritto AS stor ON stor.chiaveCointestatari = dettimmST.chiaveCointestatari
|
||
// where dettimmST.chiaveClientePB=@CCPB
|
||
// and dettimmST.chiaveProdottoTerzi = @CPT
|
||
// and dettImmST.chiaveclientepbProprietario = @CCPB
|
||
// and MONTH(dettimmST.dtimportazione) = @meseSemPrecedente
|
||
// and Year(dettimmST.dtimportazione) = @annoSemPrecedente";
|
||
// //and convert(char(8),dettimmST.dtimportazione,112) >= '20200331'";
|
||
|
||
// var dsOriginal = DataAccess.ExecuteDataTableSqlStatement(DBProvider.SqlServerConsulenzaUnica, queryLogGenerale, parametri);
|
||
|
||
// _dt = dsOriginal.AsEnumerable().CopyToDataTable();
|
||
|
||
|
||
// //#region Dettaglio
|
||
|
||
// //DataSet ds = null;
|
||
// //String connString = ConfigurationManager.ConnectionStrings["SqlServerConsulenzaUnicaCONG"].ToString();
|
||
|
||
// //using (SqlConnection conn = new SqlConnection(connString))
|
||
// //{
|
||
// // string queryLogGenerale = @"Select dettImmSTDD.tipologiaDiritto,dettImmSTDD.quotaDiritto,dettImmST.chiaveCointestatari from (Select * from ConsulenzaUnica..DettImmobiliareStoricoVariazioni where convert(char(8),dtimportazione,112) >= '20200331') as dettImmST
|
||
// // inner join (Select distinct chiaveprodottoterzi, tipologiaDiritto,quotaDiritto from ConsulenzaUnica..DettImmobiliareStoricoVariazioniDettaglioDiritto) as dettImmSTDD
|
||
// // on dettImmST.chiaveprodottoterzi = dettImmSTDD.chiaveprodottoterzi
|
||
// // where dettImmST.chiaveClientePB = @CCPB
|
||
// // and dettImmST.chiaveprodottoterzi = @CPT";
|
||
// // //and dettImmST.chiaveCointestatari = @CC";
|
||
|
||
// // SqlCommand cmd = new SqlCommand(queryLogGenerale, conn);
|
||
|
||
// // cmd.CommandType = CommandType.Text;
|
||
|
||
// // cmd.Parameters.Add("@CCPB", SqlDbType.BigInt);
|
||
// // cmd.Parameters["@CCPB"].Value = _ccpb; //6088; //6088; //1662180;
|
||
|
||
// // cmd.Parameters.Add("@CPT", SqlDbType.BigInt);
|
||
// // cmd.Parameters["@CPT"].Value = _cpt;
|
||
|
||
// // //cmd.Parameters.Add("@CC", SqlDbType.BigInt);
|
||
// // //cmd.Parameters["@CC"].Value = _cc;
|
||
|
||
// // try
|
||
// // {
|
||
// // conn.Open();
|
||
|
||
// // ds = new DataSet();
|
||
// // var da = new SqlDataAdapter(cmd);
|
||
// // da.Fill(ds);
|
||
|
||
// // _dt = ds.Tables[0].AsEnumerable().CopyToDataTable();//.AsEnumerable().GroupBy(x => x.Field<string>("idImmobileCatasto")).Select(x => x.First()).Where(x => x.Field<int>("ordinamento") == 4).CopyToDataTable();
|
||
|
||
// // }
|
||
// // catch (Exception ex)
|
||
// // {
|
||
// // Console.WriteLine(ex.Message);
|
||
// // }
|
||
// // finally
|
||
// // {
|
||
// // conn.Close();
|
||
// // conn.Dispose();
|
||
// // }
|
||
// //}
|
||
// //#endregion
|
||
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// //MessageBox.Show("Errore: " + ex.Message);
|
||
// }
|
||
|
||
// return _dt;
|
||
//}
|
||
|
||
//private bool VerificaNessunaVariazione(List<DetailQuote> quote)
|
||
//{
|
||
// bool isEliminare = false;
|
||
// bool isQuoteUguali = false;
|
||
// bool isDirittiUguali = false;
|
||
|
||
// // Verifico variazini nelle quote
|
||
// foreach (var item in quote)
|
||
// {
|
||
// if (item.QuoteDirittoST == item.QuoteDirittoATT)
|
||
// isQuoteUguali = true;
|
||
// else
|
||
// isQuoteUguali = false;
|
||
|
||
// if (item.TipologiaDirittoST == item.TipologiaDirittoATT)
|
||
// isDirittiUguali = true;
|
||
// else
|
||
// isDirittiUguali = false;
|
||
// }
|
||
|
||
// if (isQuoteUguali && isDirittiUguali) isEliminare = true;
|
||
|
||
|
||
// return isEliminare;
|
||
//}
|
||
|
||
|
||
#region "getobject filled object with property reconized"
|
||
|
||
public List<T> ConvertTo<T>(DataTable datatable) where T : new()
|
||
{
|
||
List<T> Temp = new List<T>();
|
||
try
|
||
{
|
||
List<string> columnsNames = new List<string>();
|
||
foreach (DataColumn DataColumn in datatable.Columns)
|
||
columnsNames.Add(DataColumn.ColumnName);
|
||
Temp = datatable.AsEnumerable().ToList().ConvertAll<T>(row => getObject<T>(row, columnsNames));
|
||
return Temp;
|
||
}
|
||
catch
|
||
{
|
||
return Temp;
|
||
}
|
||
|
||
}
|
||
|
||
public T getObject<T>(DataRow row, List<string> columnsName) where T : new()
|
||
{
|
||
T obj = new T();
|
||
try
|
||
{
|
||
string columnname = "";
|
||
string value = "";
|
||
PropertyInfo[] Properties;
|
||
Properties = typeof(T).GetProperties();
|
||
foreach (PropertyInfo objProperty in Properties)
|
||
{
|
||
columnname = columnsName.Find(name => name.ToLower() == objProperty.Name.ToLower());
|
||
if (!string.IsNullOrEmpty(columnname))
|
||
{
|
||
value = row[columnname].ToString();
|
||
if (!string.IsNullOrEmpty(value))
|
||
{
|
||
if (Nullable.GetUnderlyingType(objProperty.PropertyType) != null)
|
||
{
|
||
value = row[columnname].ToString().Replace("$", "").Replace(",", "");
|
||
objProperty.SetValue(obj, Convert.ChangeType(value, Type.GetType(Nullable.GetUnderlyingType(objProperty.PropertyType).ToString())), null);
|
||
}
|
||
else
|
||
{
|
||
value = row[columnname].ToString().Replace("%", "");
|
||
objProperty.SetValue(obj, Convert.ChangeType(value, Type.GetType(objProperty.PropertyType.ToString())), null);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return obj;
|
||
}
|
||
catch
|
||
{
|
||
return obj;
|
||
}
|
||
}
|
||
|
||
private DataTable ToDataTable<T>(IList<T> data)
|
||
{
|
||
PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(T));
|
||
DataTable table = new DataTable();
|
||
for (int i = 0; i < props.Count; i++)
|
||
{
|
||
PropertyDescriptor prop = props[i];
|
||
table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
|
||
}
|
||
object[] values = new object[props.Count];
|
||
foreach (T item in data)
|
||
{
|
||
for (int i = 0; i < values.Length; i++)
|
||
values[i] = props[i].GetValue(item) ?? DBNull.Value;
|
||
table.Rows.Add(values);
|
||
}
|
||
return table;
|
||
}
|
||
#endregion
|
||
#endregion
|
||
|
||
}
|
||
|
||
public class MasterQuote
|
||
{
|
||
public MasterQuote()
|
||
{
|
||
_listaDetailQuote = new List<DetailQuote>();
|
||
}
|
||
|
||
public int Id { get; set; }
|
||
public string IdImmobileCatasto { get; set; }
|
||
public Int64 chiaveClientePB { get; set; }
|
||
public Int64 chiaveProdottoTerzi { get; set; }
|
||
public string colonnaImmobili { get; set; }
|
||
public decimal renditaCatastale { get; set; }
|
||
public decimal redditoAgrario { get; set; }
|
||
public string TipoImmobile { get; set; }
|
||
public string rendita { get; set; }
|
||
public string dtStimaOMI { get; set; }
|
||
public string comune { get; set; }
|
||
public decimal valoreImmobileTotale { get; set; }
|
||
|
||
public List<DetailQuote> _listaDetailQuote { get; set; }
|
||
}
|
||
|
||
public class DetailQuote
|
||
{
|
||
public int Id { get; set; }
|
||
public string TipologiaDirittoATT { get; set; }
|
||
public decimal QuoteDirittoATT { get; set; }
|
||
|
||
public string TipologiaDirittoST { get; set; }
|
||
public decimal QuoteDirittoST { get; set; }
|
||
|
||
}
|
||
|
||
public class Quote
|
||
{
|
||
public string idImmobileCatasto { get; set; }
|
||
public string chiaveClientePB { get; set; }
|
||
public string chiaveProdottiTerzi { get; set; }
|
||
public string colonnaImmobili { get; set; }
|
||
public string renditaCatastale { get; set; }
|
||
public string redditoAgrario { get; set; }
|
||
public string tipoImmobile { get; set; }
|
||
public string rendita { get; set; }
|
||
public string tipologiaAttuale { get; set; }
|
||
public string quotaAttuale { get; set; }
|
||
public string descrizione { get; set; }
|
||
public string quotaProprieta { get; set; }
|
||
public decimal valoreImmobileTotale { get; set; }
|
||
public string Tipologiastorico { get; set; }
|
||
public string QuotaStorico { get; set; }
|
||
public string Elimina { get; set; }
|
||
public string comune { get; set; }
|
||
|
||
}
|
||
}
|