using System; using System.Collections.Generic; using System.Linq; using Consulenza.ExternalServices; using Consulenza.ReportWriter.Business; using Consulenza.ReportWriter.Business.OBJ_PDF; using System.Data; using Consulenza.ReportWriter.Business.CHART_PDF; using Consulenza.ReportCommon; using Consulenza.ReportWriter.Business.Entity; using System.Text; using Consulenza.ReportWriter.Business.Headers; namespace Consulenza.ReportWriter.Manager.Section.Immobiliare.MonitoraggioNucleo { /// /// Scheda 13 /// public class S13 : Entity.Section { public S13(EnvironmentFacade environmentFacade, int idSection) : base(environmentFacade, idSection) { try { Draw(); } catch (Exception ex) { SectionLogger.Write("S13", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment); } } /// /// Scheda2. Patrimonio immobiliare –Sintesi (distribuzione del patrimonio complessivo del cliente diviso per tipologia e cointestatari) /// protected override void Draw() { var ds = GetDataSet(); #region Grafico torta #region Valorizzazione Serie var serieTorta = new List(); foreach (var row in ds.Tables["sintesiTorta"].AsEnumerable()) { serieTorta.Add(new Serie { Name = row["tipologia"].ToString() }); serieTorta[0].Points.Add(new Point { LabelAxisX = row["tipologia"].ToString(), Value = Convert.ToDouble(row["peso"]), Color = getColor(row["tipologia"].ToString()), ShowLabelAxisX = false, ShowLabelAxisY = false, FontSizeLabelAxisX = 10, FontSizeLabelAxisY = 10, }); } AddElement(new SpacePDF(90)); //var torta = new PiePDF(20 + 395, 0.8F) //{ // Width = 340, // Height = 340, // SeriesCollection = serieTorta, // StartAngle = 270, // ShowLabelPoints = true, // Style3DEnabled = false, // AutoIncrementYWritable = true, // LabelDecimalDigitsCount = 1, // FontLabelSize = 4.5f, // CustomPlottingHeight = 50, // CustomPlottingWidth = 50, // CustomPlottingX = 25, // CustomPlottingY = 7, // UseCustomPlotting = true //}; //var torta = new PiePDF(48 + 395, 0.2F) //var torta = new PiePDF(40 + 400, 0.2F) var torta = new PiePDF(40 + 380, 0.2F) { Width = 340, Height = 340, SeriesCollection = serieTorta, StartAngle = 270, ShowLabelPoints = true, Style3DEnabled = false, AutoIncrementYWritable = true, LabelDecimalDigitsCount = 1, FontLabelSize = 5f, CustomPlottingHeight = 50, CustomPlottingWidth = 50, CustomPlottingX = 25, CustomPlottingY = 7, UseCustomPlotting = true }; //AddElement(new SpacePDF(5)); AddElement(torta); #endregion var tortaTitolo = new FormattedTextAreaPDF(string.Format("{0}", "Patrimonio immobiliare complessivo"), 85 + 405) { FontColor = new ColorPDF(91, 88, 79), FontSize = 10, FontBold = true, AutoIncrementYWritable = true }; AddElement(new SpacePDF(-7)); AddElement(tortaTitolo); #endregion var xLegenda = 135 + 395; ColorPDF coloriUsoAbitativo = new ColorPDF(207, 220, 210); ColorPDF coloriStrumentale = new ColorPDF(167, 192, 168); ColorPDF coloriInvestimento = new ColorPDF(115, 152, 109); ColorPDF coloriNonSpecificata = new ColorPDF(245, 245, 220); AddElement(new SpacePDF(235)); foreach (var row in ds.Tables["sintesiTorta"].AsEnumerable()) { switch (row["indice"].ToString()) { case "U": var legendaUsoAbitativoRettangolo = new RectanglePDF(xLegenda, 12, 17, coloriUsoAbitativo) { AutoIncrementYWritable = false }; var legendaUsoAbitativoTesto = new FormattedTextAreaPDF(string.Format("{0}", "Immobili d'uso abitativo"), xLegenda + 25) { FontSize = 7, AutoIncrementYWritable = true }; AddElement(legendaUsoAbitativoRettangolo); AddElement(legendaUsoAbitativoTesto); AddElement(new SpacePDF(10)); break; case "S": var legendaStrumentaleRettangolo = new RectanglePDF(xLegenda, 12, 17, coloriStrumentale) { AutoIncrementYWritable = false }; var legendaStrumentaleTesto = new FormattedTextAreaPDF(string.Format("{0}", "Immobili strumentali"), xLegenda + 25) { FontSize = 7, AutoIncrementYWritable = true }; AddElement(legendaStrumentaleRettangolo); AddElement(legendaStrumentaleTesto); AddElement(new SpacePDF(10)); break; case "I": var legendaInvestimentoRettangolo = new RectanglePDF(xLegenda, 12, 17, coloriInvestimento) { AutoIncrementYWritable = false }; var legendaInvestimentoTesto = new FormattedTextAreaPDF(string.Format("{0}", "Immobili d'investimento"), xLegenda + 25) { FontSize = 7, AutoIncrementYWritable = true }; AddElement(legendaInvestimentoRettangolo); AddElement(legendaInvestimentoTesto); AddElement(new SpacePDF(10)); break; case "NS": var legendaNonSpecificataRettangolo = new RectanglePDF(xLegenda, 12, 17, coloriNonSpecificata) { AutoIncrementYWritable = false }; var legendaNonSpecificataTesto = new FormattedTextAreaPDF(string.Format("{0}", "Finalità non specificata"), xLegenda + 25) { FontSize = 7, AutoIncrementYWritable = true }; AddElement(legendaNonSpecificataRettangolo); AddElement(legendaNonSpecificataTesto); break; default: break; } } AddElement(new ResetterYPDF()); var table = new TablePDF(35, ds.Tables["sintesi"], ds.Tables["sintesiTotale"]) { Style = Style.Immobiliare, AlternateRow = false, HeaderHeight = 25, RowHeight = 10, ShowBorderLastLine = false, ShowBorderLastLineInPageBreak = false, ShowBorderHeader = false, //AdditionalSpaceBetweenHeadersAndTable = 5.0F, HeaderTextVerticalAlign = VerticalAlignmentType.Basso, AutoIncrementYWritable = false }; table.Columns.Add(new ColumnPDF("tipologia", 105, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "tipologia", "Finalità/Tipologia") { HeaderFontSize = 7 }); table.Columns.Add(new ColumnPDF("numero", 40, HorizontalAlignmentType.Centrato, false, false, 7, ColumnType.Testo, "numero", "Numero
immobili") { HeaderFontSize = 7 }); table.Columns.Add(new ColumnPDF("proquota", 100, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "proquota", "Valore stimato
nucleo (€)") { HeaderFontSize = 7 }); table.Columns.Add(new ColumnPDF("stimato", 100, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "stimato", "Valore stimato
totale (€)") { HeaderFontSize = 7 }); table.Columns.Add(new ColumnPDF("peso", 55, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Testo, "peso", "Peso (%)") { HeaderFontSize = 7 }); table.FooterColumns.Add(new ColumnPDF("tipologiaTotale", 105, HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo)); table.FooterColumns.Add(new ColumnPDF("numeroTotale", 40, HorizontalAlignmentType.Centrato, false, true, 7, ColumnType.Testo)); table.FooterColumns.Add(new ColumnPDF("proquotaTotale", 100, HorizontalAlignmentType.Destra, false, true, 7, ColumnType.Testo)); table.FooterColumns.Add(new ColumnPDF("stimatoTotale", 100, HorizontalAlignmentType.Destra, false, true, 7, ColumnType.Testo)); table.FooterColumns.Add(new ColumnPDF("pesoTotale", 55, HorizontalAlignmentType.Destra, false, true, 7, ColumnType.Testo)); float startFrameX = table.X + table.Width + 10; float startFrameY = 94; //addFrame(startFrameX, startFrameX + 286, startFrameY, startFrameY + 350); addFrame(startFrameX, startFrameX + 300, startFrameY, startFrameY + 340); AddElement(new SpacePDF(50)); AddElement(new RepeaterPDF(new List() { new SpacePDF(50) })); AddElement(new FormattedTextAreaPDF(getTesto1(), 45, 700) { FontColor = ColorPDF.Immobiliare_Grigio_TestoStandard, FontSize = 10, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left }); AddElement(new SpacePDF(15)); AddElement(table); } protected override DataSet GetDataSet() { #region Definizione dei parametri var parametri = new List { new Parametro { Direction = ParameterDirection.Input, DbType = DbType.Int64, ParameterName = "chiaveNucleo", Value = EnvironmentFacade.ReportEnvironment.Cliente.Chiave } }; #endregion var dt = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_ImmobiliareMonitoraggio_S13_MappaturaSintesi", parametri); DataTable table = new DataTable(); table.Columns.Add("tipologia", typeof(string)); table.Columns.Add("numero", typeof(string)); table.Columns.Add("proquota", typeof(string)); table.Columns.Add("stimato", typeof(string)); table.Columns.Add("peso", typeof(string)); DataTable tableTotale = new DataTable(); tableTotale.Columns.Add("tipologiaTotale", typeof(string)); tableTotale.Columns.Add("numeroTotale", typeof(string)); tableTotale.Columns.Add("proquotaTotale", typeof(string)); tableTotale.Columns.Add("stimatoTotale", typeof(string)); tableTotale.Columns.Add("pesoTotale", typeof(string)); DataTable tableTorta = new DataTable(); tableTorta.Columns.Add("indice", typeof(string)); tableTorta.Columns.Add("tipologia", typeof(string)); tableTorta.Columns.Add("peso", typeof(decimal)); tableTorta.Columns.Add("ord1", typeof(int)); List indiciPagina = dt.Tables[0].AsEnumerable() .Select(z => z.Field("usoTipologia")).Distinct().ToList(); #region Commento per TEST da copia Monitoraggio #region Controllo Totale e Singoli decimal nTipologiaGlobale = 0; decimal nPesoGlobale = 0; #region // Ciclo per riadattare Tabella decimal nTipologia = 0; decimal nPeso = 0; #region // Primo Ciclo Calcolo Pesi Singoli foreach (var indice in indiciPagina) { var tabellaIndice = dt.Tables[0].AsEnumerable().Where(z => z.Field("usoTipologia").Equals(indice)); if (tabellaIndice != null) { foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { nPeso = nPeso + ((decimal)row["peso"] * 100); } } } string sUpdate = ""; if (nPeso != 100) { var tabellaIndice = dt.Tables[0].AsEnumerable().Where(z => z.Field("usoTipologia").Equals("NS")); if (tabellaIndice.Count() > 0) sUpdate = "NS"; else { tabellaIndice = dt.Tables[0].AsEnumerable().Where(z => z.Field("usoTipologia").Equals("I")); if (tabellaIndice.Count() > 0) sUpdate = "I"; else { tabellaIndice = dt.Tables[0].AsEnumerable().Where(z => z.Field("usoTipologia").Equals("S")); if (tabellaIndice.Count() > 0) sUpdate = "S"; else sUpdate = "U"; } } tabellaIndice = dt.Tables[0].AsEnumerable().Where(z => z.Field("usoTipologia").Equals(sUpdate)); if (nPeso < 100) { foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { row["peso"] = (decimal)row["peso"] + ((100 - nPeso) / 100); break; } } else { foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { row["peso"] = (decimal)row["peso"] - ((nPeso - 100) / 100); break; } } } #endregion foreach (var indice in indiciPagina) { nTipologia = 0; nPeso = 0; var tabellaIndice = dt.Tables[0].AsEnumerable().Where(z => z.Field("usoTipologia").Equals(indice)); if (tabellaIndice != null) { nTipologia = (decimal)tabellaIndice.ToList()[0]["pesoTipologia"] * 100; foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { nPeso = nPeso + ((decimal)row["peso"] * 100); } if (nTipologia != nPeso) { foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { row["pesoTipologia"] = nPeso / 100; } } } } // Fine Ciclo #endregion foreach (var row in dt.Tables[0].AsEnumerable()) { nPesoGlobale = nPesoGlobale + (Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100); } foreach (var idx in indiciPagina) { var tabellaGlobale = dt.Tables[0].AsEnumerable().Where(z => z.Field("usoTipologia").Equals(idx)); nTipologiaGlobale = nTipologiaGlobale + Convert.ToDecimal(Helper.FormatDecimal(((decimal)tabellaGlobale.ToList()[0]["pesoTipologia"] * 100).ToString(), 1)); } bool bTipologia = false; bool bPeso = false; //if (nPesoGlobale != 100) // bPeso = true; //else //{ // if (nTipologiaGlobale != 100) // bTipologia = true; //} if (nPesoGlobale != 100) bPeso = true; if (nTipologiaGlobale != 100) bTipologia = true; #endregion #region Ciclo Totali = 100 e Singoli = 100 if (!bTipologia && !bPeso) { foreach (var indice in indiciPagina) { var tabellaIndice = dt.Tables[0].AsEnumerable().Where(z => z.Field("usoTipologia").Equals(indice)); if (tabellaIndice != null) { table.Rows.Add(getTipologia(indice), "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valProQuotaTipologia"].ToString()) + "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valTotaleTipologia"].ToString()) + "", "" + Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(tabellaIndice.ToList()[0]["pesoTipologia"].ToString(), 4)) * 100, 1) + ""); tableTorta.Rows.Add(indice, getTipologia(indice), Convert.ToDecimal(Helper.FormatDecimal(((decimal)tabellaIndice.ToList()[0]["pesoTipologia"] * 100).ToString(), 1)), tabellaIndice.ToList()[0]["ord1"]); foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { table.Rows.Add(row["FinalitaTipologia"], row["numImmobili"], Helper.FormatCurrency(row["valProQuota"].ToString()), Helper.FormatCurrency(row["valTotale"].ToString()), Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100, 1)); } } } } #endregion #region Ciclo Totali <> 100 e Singoli = 100 if (bTipologia && !bPeso) { foreach (var indice in indiciPagina) { var tabellaIndice = dt.Tables[0].AsEnumerable().Where(z => z.Field("usoTipologia").Equals(indice)); if (tabellaIndice != null) { // Check su Totali decimal nPesoTotal = Convert.ToDecimal(Helper.FormatDecimal(((decimal)tabellaIndice.ToList()[0]["pesoTipologia"] * 100).ToString(), 1)); decimal nPesoSingle = 0; foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { nPesoSingle = nPesoSingle + (Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100); } // Fine Check if (nPesoTotal == nPesoSingle) { table.Rows.Add(getTipologia(indice), "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valProQuotaTipologia"].ToString()) + "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valTotaleTipologia"].ToString()) + "", "" + Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(tabellaIndice.ToList()[0]["pesoTipologia"].ToString(), 4)) * 100, 1) + ""); tableTorta.Rows.Add(indice, getTipologia(indice), Convert.ToDecimal(Helper.FormatDecimal(((decimal)tabellaIndice.ToList()[0]["pesoTipologia"] * 100).ToString(), 1)), tabellaIndice.ToList()[0]["ord1"]); foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { table.Rows.Add(row["FinalitaTipologia"], row["numImmobili"], Helper.FormatCurrency(row["valProQuota"].ToString()), Helper.FormatCurrency(row["valTotale"].ToString()), Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100, 1)); } } else { if (nPesoTotal < nPesoSingle) { table.Rows.Add(getTipologia(indice), "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valProQuotaTipologia"].ToString()) + "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valTotaleTipologia"].ToString()) + "", "" + Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal((Convert.ToDecimal(tabellaIndice.ToList()[0]["pesoTipologia"]) + Convert.ToDecimal("0,001")).ToString(), 4)) * 100, 1) + ""); tableTorta.Rows.Add(indice, getTipologia(indice), Convert.ToDecimal(Helper.FormatDecimal((((decimal)tabellaIndice.ToList()[0]["pesoTipologia"] + Convert.ToDecimal("0,001")) * 100).ToString(), 1))); foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { table.Rows.Add(row["FinalitaTipologia"], row["numImmobili"], Helper.FormatCurrency(row["valProQuota"].ToString()), Helper.FormatCurrency(row["valTotale"].ToString()), Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100, 1)); } } else { table.Rows.Add(getTipologia(indice), "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valProQuotaTipologia"].ToString()) + "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valTotaleTipologia"].ToString()) + "", "" + Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal((Convert.ToDecimal(tabellaIndice.ToList()[0]["pesoTipologia"]) - Convert.ToDecimal("0,001")).ToString(), 4)) * 100, 1) + ""); tableTorta.Rows.Add(indice, getTipologia(indice), Convert.ToDecimal(Helper.FormatDecimal((((decimal)tabellaIndice.ToList()[0]["pesoTipologia"] - Convert.ToDecimal("0,001")) * 100).ToString(), 1))); foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { table.Rows.Add(row["FinalitaTipologia"], row["numImmobili"], Helper.FormatCurrency(row["valProQuota"].ToString()), Helper.FormatCurrency(row["valTotale"].ToString()), Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100, 1)); } } } } } } #endregion #region Ciclo Totali = 100 e Singoli <> 100 if (!bTipologia && bPeso) { foreach (var indice in indiciPagina) { var tabellaIndice = dt.Tables[0].AsEnumerable().Where(z => z.Field("usoTipologia").Equals(indice)); if (tabellaIndice != null) { // Check su Totali decimal nPesoTotal = Convert.ToDecimal(Helper.FormatDecimal(((decimal)tabellaIndice.ToList()[0]["pesoTipologia"] * 100).ToString(), 1)); decimal nPesoSingle = 0; foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { nPesoSingle = nPesoSingle + (Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100); } // Fine Check if (nPesoTotal == nPesoSingle) { table.Rows.Add(getTipologia(indice), "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valProQuotaTipologia"].ToString()) + "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valTotaleTipologia"].ToString()) + "", "" + Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(tabellaIndice.ToList()[0]["pesoTipologia"].ToString(), 4)) * 100, 1) + ""); tableTorta.Rows.Add(indice, getTipologia(indice), Convert.ToDecimal(Helper.FormatDecimal(((decimal)tabellaIndice.ToList()[0]["pesoTipologia"] * 100).ToString(), 1)), tabellaIndice.ToList()[0]["ord1"]); foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { table.Rows.Add(row["FinalitaTipologia"], row["numImmobili"], Helper.FormatCurrency(row["valProQuota"].ToString()), Helper.FormatCurrency(row["valTotale"].ToString()), Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100, 1)); } } else { if (nPesoTotal < nPesoSingle) { table.Rows.Add(getTipologia(indice), "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valProQuotaTipologia"].ToString()) + "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valTotaleTipologia"].ToString()) + "", "" + Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(tabellaIndice.ToList()[0]["pesoTipologia"].ToString(), 4)) * 100, 1) + ""); tableTorta.Rows.Add(indice, getTipologia(indice), Convert.ToDecimal(Helper.FormatDecimal(((decimal)tabellaIndice.ToList()[0]["pesoTipologia"] * 100).ToString(), 1)), tabellaIndice.ToList()[0]["ord1"]); Boolean bPass = false; foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { if (bPass) table.Rows.Add(row["FinalitaTipologia"], row["numImmobili"], Helper.FormatCurrency(row["valProQuota"].ToString()), Helper.FormatCurrency(row["valTotale"].ToString()), Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100, 1)); else { table.Rows.Add(row["FinalitaTipologia"], row["numImmobili"], Helper.FormatCurrency(row["valProQuota"].ToString()), Helper.FormatCurrency(row["valTotale"].ToString()), Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal((Convert.ToDecimal(row["peso"]) - Convert.ToDecimal("0,001")).ToString(), 4)) * 100, 1)); bPass = true; } } } else { table.Rows.Add(getTipologia(indice), "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valProQuotaTipologia"].ToString()) + "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valTotaleTipologia"].ToString()) + "", "" + Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal((Convert.ToDecimal(tabellaIndice.ToList()[0]["pesoTipologia"])).ToString(), 4)) * 100, 1) + ""); tableTorta.Rows.Add(indice, getTipologia(indice), Convert.ToDecimal(Helper.FormatDecimal((((decimal)tabellaIndice.ToList()[0]["pesoTipologia"]) * 100).ToString(), 1)), tabellaIndice.ToList()[0]["ord1"]); Boolean bPass = false; foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { if (bPass) { table.Rows.Add(row["FinalitaTipologia"], row["numImmobili"], Helper.FormatCurrency(row["valProQuota"].ToString()), Helper.FormatCurrency(row["valTotale"].ToString()), Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100, 1)); } else { table.Rows.Add(row["FinalitaTipologia"], row["numImmobili"], Helper.FormatCurrency(row["valProQuota"].ToString()), Helper.FormatCurrency(row["valTotale"].ToString()), Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal((Convert.ToDecimal(row["peso"]) + Convert.ToDecimal("0,001")).ToString(), 4)) * 100, 1)); bPass = true; } } } } } } } #endregion #region Ciclo Totali <> 100 e Singoli <> 100 if (bTipologia && bPeso) { foreach (var indice in indiciPagina) { var tabellaIndice = dt.Tables[0].AsEnumerable().Where(z => z.Field("usoTipologia").Equals(indice)); if (tabellaIndice != null) { // Check su Totali decimal nPesoTotal = Convert.ToDecimal(Helper.FormatDecimal(((decimal)tabellaIndice.ToList()[0]["pesoTipologia"] * 100).ToString(), 1)); decimal nPesoSingle = 0; foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { nPesoSingle = nPesoSingle + (Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100); } // Fine Check if (nPesoTotal == nPesoSingle) { table.Rows.Add(getTipologia(indice), "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valProQuotaTipologia"].ToString()) + "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valTotaleTipologia"].ToString()) + "", "" + Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(tabellaIndice.ToList()[0]["pesoTipologia"].ToString(), 4)) * 100, 1) + ""); tableTorta.Rows.Add(indice, getTipologia(indice), Convert.ToDecimal(Helper.FormatDecimal(((decimal)tabellaIndice.ToList()[0]["pesoTipologia"] * 100).ToString(), 1)), tabellaIndice.ToList()[0]["ord1"]); foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { table.Rows.Add(row["FinalitaTipologia"], row["numImmobili"], Helper.FormatCurrency(row["valProQuota"].ToString()), Helper.FormatCurrency(row["valTotale"].ToString()), Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100, 1)); } } else { if (nPesoTotal < nPesoSingle) { table.Rows.Add(getTipologia(indice), "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valProQuotaTipologia"].ToString()) + "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valTotaleTipologia"].ToString()) + "", "" + Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(tabellaIndice.ToList()[0]["pesoTipologia"].ToString(), 4)) * 100, 1) + ""); tableTorta.Rows.Add(indice, getTipologia(indice), Convert.ToDecimal(Helper.FormatDecimal(((decimal)tabellaIndice.ToList()[0]["pesoTipologia"] * 100).ToString(), 1)), tabellaIndice.ToList()[0]["ord1"]); Boolean bPass = false; foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { if (bPass) table.Rows.Add(row["FinalitaTipologia"], row["numImmobili"], Helper.FormatCurrency(row["valProQuota"].ToString()), Helper.FormatCurrency(row["valTotale"].ToString()), Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100, 1)); else { table.Rows.Add(row["FinalitaTipologia"], row["numImmobili"], Helper.FormatCurrency(row["valProQuota"].ToString()), Helper.FormatCurrency(row["valTotale"].ToString()), Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal((Convert.ToDecimal(row["peso"]) - Convert.ToDecimal("0,001")).ToString(), 4)) * 100, 1)); bPass = true; } } } else { table.Rows.Add(getTipologia(indice), "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valProQuotaTipologia"].ToString()) + "", "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valTotaleTipologia"].ToString()) + "", "" + Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal((Convert.ToDecimal(tabellaIndice.ToList()[0]["pesoTipologia"])).ToString(), 4)) * 100, 1) + ""); tableTorta.Rows.Add(indice, getTipologia(indice), Convert.ToDecimal(Helper.FormatDecimal((((decimal)tabellaIndice.ToList()[0]["pesoTipologia"]) * 100).ToString(), 1)), tabellaIndice.ToList()[0]["ord1"]); Boolean bPass = false; foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) { if (bPass) { table.Rows.Add(row["FinalitaTipologia"], row["numImmobili"], Helper.FormatCurrency(row["valProQuota"].ToString()), Helper.FormatCurrency(row["valTotale"].ToString()), Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100, 1)); } else { table.Rows.Add(row["FinalitaTipologia"], row["numImmobili"], Helper.FormatCurrency(row["valProQuota"].ToString()), Helper.FormatCurrency(row["valTotale"].ToString()), Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal((Convert.ToDecimal(row["peso"]) + Convert.ToDecimal("0,001")).ToString(), 4)) * 100, 1)); bPass = true; } } } } } } } #endregion #endregion #region Aggiunta da Monitoraggio //foreach (var indice in indiciPagina) //{ // var tabellaIndice = dt.Tables[0].AsEnumerable().Where(z => z.Field("usoTipologia").Equals(indice)); // if (tabellaIndice != null) // { // // Check su Totali // //decimal nPesoTotal = Convert.ToDecimal(Helper.FormatDecimal(((decimal)tabellaIndice.ToList()[0]["pesoTipologia"] * 100).ToString(), 1)); // decimal nPesoTotal = Convert.ToDecimal(Helper.FormatDecimal(tabellaIndice.ToList()[0]["pesoTipologia"].ToString(), 4)) * 100; // decimal nPesoSingle = 0; // foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) // { // nPesoSingle = nPesoSingle + (Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100); // } // // Fine Check // if (nPesoTotal == nPesoSingle) // { // table.Rows.Add(getTipologia(indice), "", // "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valProQuotaTipologia"].ToString()) + "", // "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valTotaleTipologia"].ToString()) + "", // "" + Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(tabellaIndice.ToList()[0]["pesoTipologia"].ToString(), 4)) * 100, 1) + ""); // tableTorta.Rows.Add(indice, getTipologia(indice), Convert.ToDecimal(Helper.FormatDecimal(((decimal)tabellaIndice.ToList()[0]["pesoTipologia"] * 100).ToString(), 1)), tabellaIndice.ToList()[0]["ord1"]); // foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) // { // table.Rows.Add(row["FinalitaTipologia"], // row["numImmobili"], // Helper.FormatCurrency(row["valProQuota"].ToString()), // Helper.FormatCurrency(row["valTotale"].ToString()), // Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100, 1)); // } // } // else // { // if (nPesoTotal < nPesoSingle) // { // table.Rows.Add(getTipologia(indice), "", // "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valProQuotaTipologia"].ToString()) + "", // "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valTotaleTipologia"].ToString()) + "", // "" + Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(tabellaIndice.ToList()[0]["pesoTipologia"].ToString(), 4)) * 100, 1) + ""); // tableTorta.Rows.Add(indice, getTipologia(indice), Convert.ToDecimal(Helper.FormatDecimal(((decimal)tabellaIndice.ToList()[0]["pesoTipologia"] * 100).ToString(), 1)), tabellaIndice.ToList()[0]["ord1"]); // Boolean bPass = false; // foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) // { // if (bPass) // table.Rows.Add(row["FinalitaTipologia"], // row["numImmobili"], // Helper.FormatCurrency(row["valProQuota"].ToString()), // Helper.FormatCurrency(row["valTotale"].ToString()), // Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100, 1)); // else // { // table.Rows.Add(row["FinalitaTipologia"], // row["numImmobili"], // Helper.FormatCurrency(row["valProQuota"].ToString()), // Helper.FormatCurrency(row["valTotale"].ToString()), // Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal((Convert.ToDecimal(row["peso"]) - Convert.ToDecimal("0,001")).ToString(), 4)) * 100, 1)); // bPass = true; // } // } // } // else // { // // CODICE ES del 13.09.2017 // table.Rows.Add(getTipologia(indice), "", // "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valProQuotaTipologia"].ToString()) + "", // "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valTotaleTipologia"].ToString()) + "", // "" + Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal((Convert.ToDecimal(tabellaIndice.ToList()[0]["pesoTipologia"])).ToString(), 4)) * 100, 1) + ""); // tableTorta.Rows.Add(indice, getTipologia(indice), Convert.ToDecimal(Helper.FormatDecimal((((decimal)tabellaIndice.ToList()[0]["pesoTipologia"]) * 100).ToString(), 1)), tabellaIndice.ToList()[0]["ord1"]); // Boolean bPass = false; // foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) // { // if (bPass) // { // table.Rows.Add(row["FinalitaTipologia"], // row["numImmobili"], // Helper.FormatCurrency(row["valProQuota"].ToString()), // Helper.FormatCurrency(row["valTotale"].ToString()), // Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100, 1)); // } // else // { // table.Rows.Add(row["FinalitaTipologia"], // row["numImmobili"], // Helper.FormatCurrency(row["valProQuota"].ToString()), // Helper.FormatCurrency(row["valTotale"].ToString()), // Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal((Convert.ToDecimal(row["peso"]) + Convert.ToDecimal("0,001")).ToString(), 4)) * 100, 1)); // bPass = true; // } // } // } // } // } //} #endregion DataRow rowTotale = dt.Tables[0].Rows[0]; tableTotale.Rows.Add("Totale", rowTotale["numImmobiliTotale"], Helper.FormatCurrency(rowTotale["valProQuotaTotale"].ToString()), Helper.FormatCurrency(rowTotale["valTotaleTotale"].ToString()), Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(rowTotale["pesoTotale"].ToString(), 4)) * 100, 1)); DataSet ds = new DataSet(); table.TableName = "sintesi"; tableTotale.TableName = "sintesiTotale"; tableTorta.TableName = "sintesiTorta"; ds.Tables.Add(table); ds.Tables.Add(tableTotale); ds.Tables.Add(tableTorta); return ds; } //protected override DataSet GetDataSet() //{ // #region Definizione dei parametri // var parametri = new List // { // new Parametro // { // Direction = ParameterDirection.Input, // DbType = DbType.Int64, // ParameterName = "chiaveNucleo", // Value = EnvironmentFacade.ReportEnvironment.Cliente.Chiave // } // }; // #endregion // var dt = DataAccess.ExecuteDataSetStoredProcedure(DBProvider.SqlServerConsulenzaUnica, "REP_ImmobiliareMonitoraggio_S13_MappaturaSintesi", parametri); // DataTable table = new DataTable(); // table.Columns.Add("tipologia", typeof(string)); // table.Columns.Add("numero", typeof(string)); // table.Columns.Add("proquota", typeof(string)); // table.Columns.Add("stimato", typeof(string)); // table.Columns.Add("peso", typeof(string)); // DataTable tableTotale = new DataTable(); // tableTotale.Columns.Add("tipologiaTotale", typeof(string)); // tableTotale.Columns.Add("numeroTotale", typeof(string)); // tableTotale.Columns.Add("proquotaTotale", typeof(string)); // tableTotale.Columns.Add("stimatoTotale", typeof(string)); // tableTotale.Columns.Add("pesoTotale", typeof(string)); // DataTable tableTorta = new DataTable(); // tableTorta.Columns.Add("indice", typeof(string)); // tableTorta.Columns.Add("tipologia", typeof(string)); // tableTorta.Columns.Add("peso", typeof(decimal)); // List indiciPagina = dt.Tables[0].AsEnumerable() // .Select(z => z.Field("usoTipologia")).Distinct().ToList(); // foreach (var indice in indiciPagina) // { // var tabellaIndice = dt.Tables[0].AsEnumerable().Where(z => z.Field("usoTipologia").Equals(indice)); // if (tabellaIndice != null) // { // table.Rows.Add(getTipologia(indice), "", // "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valProQuotaTipologia"].ToString()) + "", // "" + Helper.FormatCurrency(tabellaIndice.ToList()[0]["valTotaleTipologia"].ToString()) + "", // "" + Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(tabellaIndice.ToList()[0]["pesoTipologia"].ToString(), 4)) * 100, 1) + ""); // tableTorta.Rows.Add(indice, getTipologia(indice), Convert.ToDecimal(Helper.FormatDecimal(((decimal)tabellaIndice.ToList()[0]["pesoTipologia"] * 100).ToString(), 1))); // foreach (var row in tabellaIndice.OrderBy(z => z.Field("ord2"))) // { // table.Rows.Add(row["FinalitaTipologia"], // row["numImmobili"], // Helper.FormatCurrency(row["valProQuota"].ToString()), // Helper.FormatCurrency(row["valTotale"].ToString()), // Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(row["peso"].ToString(), 4)) * 100, 1)); // } // } // } // DataRow rowTotale = dt.Tables[0].Rows[0]; // tableTotale.Rows.Add("Totale", // rowTotale["numImmobiliTotale"], // Helper.FormatCurrency(rowTotale["valProQuotaTotale"].ToString()), // Helper.FormatCurrency(rowTotale["valTotaleTotale"].ToString()), // Helper.FormatPercentage(Convert.ToDecimal(Helper.FormatDecimal(rowTotale["pesoTotale"].ToString(), 4)) * 100, 1)); // DataSet ds = new DataSet(); // table.TableName = "sintesi"; // tableTotale.TableName = "sintesiTotale"; // tableTorta.TableName = "sintesiTorta"; // ds.Tables.Add(table); // ds.Tables.Add(tableTotale); // ds.Tables.Add(tableTorta); // return ds; //} public void addFrame(float XupSx, float XupDx, float Yup, float Ydown) { var horizontalTopLine = new LinePDF(XupSx, Yup, XupDx, Yup, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = false }; AddElement(horizontalTopLine); var horizontalBottomLine = new LinePDF(XupSx, Ydown, XupDx, Ydown, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = false }; AddElement(horizontalBottomLine); var verticalLeftLine = new LinePDF(XupSx, Yup, XupSx, Ydown, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = false }; AddElement(verticalLeftLine); var verticalRightLine = new LinePDF(XupDx, Yup, XupDx, Ydown, 0.5F, ColorPDF.Immobiliare_Grigio_TitoloPiccolo) { AutoIncrementYWritable = false }; AddElement(verticalRightLine); } /// /// Recupera i dati necessari alla Section restituendo un DataTable. /// /// protected override DataTable GetDataTable() { return null; } public string getTipologia(string tipologia) { switch (tipologia) { case "U": return "Uso abitativo"; case "I": return "Investimento"; case "S": return "Strumentale"; case "NS": return "Non specificata"; default: return ""; } } public string getTesto1() { return "Di seguito si rappresenta la distribuzione del patrimonio immobiliare in base alla finalità con cui l'immobile è detenuto."; } public ColorPDF getColor(string tipologia) { switch (tipologia) { case "Uso abitativo": return new ColorPDF(207, 220, 210); case "Investimento": return new ColorPDF(115, 152, 109); case "Strumentale": return new ColorPDF(167, 192, 168); case "Non specificata": return new ColorPDF(245, 245, 220); default: return null; } } } }