using System; using Consulenza.ReportWriter.Business; using Consulenza.ReportWriter.Business.OBJ_PDF; using System.Data; using Consulenza.ReportCommon; using Consulenza.ReportWriter.Business.Entity; using Consulenza.ReportWriter.Business.CHART_PDF; using System.Collections.Generic; using System.Linq; using Consulenza.ReportWriter.Business.CUSTOM_PDF.ConsulenzaUnica; namespace Consulenza.ReportWriter.Manager.Section.Unica { public class S57 : Entity.Section { /// ///S57.PropostaRappresentazioneMacroAssetclass idSezione = 100 /// public S57(EnvironmentFacade environmentFacade, int idSection) : base(environmentFacade, idSection) { try { if (!datiSeiUnico.isVincolo("prodottiCasa_rappassetPro")) Draw(); } catch (Exception ex) { SectionLogger.Write("S57", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment); } } protected override sealed void Draw() { var dati = GetDataSet(); string signValue = isControvalore() ? "(€)" : "(%)"; bool isAdeguata = datiSeiUnico.flagAdeguatezzaPro(); AddElement(new PagePDF(PagePDF.PagePDFType.Generic)); var intestazione = new SectionHeadingPDF( (isAdeguata ? "Proposta" : "Operazioni richieste") + ": rappresentazione per macro asset class", EnvironmentFacade.RendererFacade.XLeftLimit, EnvironmentFacade.RendererFacade.YUpperLimit, EnvironmentFacade.ReportEnvironment.FontFamily); AddElement(intestazione.ToElement()); #region Sintesi portafoglio AddElement(new SpacePDF(20)); if (dati.Tables["macroAssetClass"].Rows.Count > 0 && presenzaGrafico()) { if (getTesto1().Length > 0) { AddElement(new FormattedTextAreaPDF(getTesto1(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }); AddElement(new SpacePDF(20)); } FormattedTextAreaPDF captionAttuale = new FormattedTextAreaPDF("Controvalore attuale (€)", EnvironmentFacade.RendererFacade.XLeftLimit, 135) { FontSize = 7, BackGroundMarginLeft = 5, BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontColor = ColorPDF.Nero, FontBold = true, AutoIncrementYWritable = false }; AddElement(captionAttuale); FormattedTextAreaPDF ctvAttuale = new FormattedTextAreaPDF(Helper.FormatCurrency(dati.Tables["labelControvalore"].Rows[0]["ctvAttuale"].ToString()), EnvironmentFacade.RendererFacade.XLeftLimit + 145/*230*/) { FontSize = 7, BackGroundColor = ColorPDF.Bianco, AutoIncrementYWritable = false }; AddElement(ctvAttuale); FormattedTextAreaPDF captionProposto = new FormattedTextAreaPDF("Controvalore " + (isAdeguata ? "proposto (€)" : "prospettico (€)"), EnvironmentFacade.RendererFacade.XLeftLimit + 280, 140) { FontSize = 7, BackGroundMarginLeft = 5, BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontColor = ColorPDF.Nero, FontBold = true, AutoIncrementYWritable = false }; AddElement(captionProposto); FormattedTextAreaPDF ctvProposto = new FormattedTextAreaPDF(Helper.FormatCurrency(dati.Tables["labelControvalore"].Rows[0]["ctvProposto"].ToString()), EnvironmentFacade.RendererFacade.XLeftLimit + 430/*490*/) { FontSize = 7, BackGroundColor = ColorPDF.Bianco, AutoIncrementYWritable = true }; AddElement(ctvProposto); AddElement(new SpacePDF(20)); AddElement(new FormattedTextAreaPDF("Macro asset class", EnvironmentFacade.RendererFacade.XLeftLimit, 130) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, AutoIncrementYWritable = false, BackGroundMarginLeft = 5 }); AddElement(new FormattedTextAreaPDF("Portafoglio attuale " + signValue, EnvironmentFacade.RendererFacade.XLeftLimit + 133.5f, 190) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, AutoIncrementYWritable = false, BackGroundMarginLeft = 5 }); AddElement(new FormattedTextAreaPDF("Portafoglio " + (isAdeguata ? "proposto " : "prospettico ") + signValue, EnvironmentFacade.RendererFacade.XLeftLimit + 327.5f, 190) { BackGroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella, FontBold = true, FontSize = 7, FontColor = ColorPDF.ConsulenzaUnica_Rosso, BackGroundMarginLeft = 5 }); //340 = + 145 + 195 #region ASSET ASSET var tabellaAsset = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["macroAssetClass"]) { Style = Style.ConsulenzaUnica, Header = false, Footer = false, AlternateRow = false, RowHeight = 28, ShowSeparationLines = false }; //tabellaAsset.Columns.Add(new ColumnPDF("oggetto", 17, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Objectpdf, "", string.Empty) { PaddingLeft = 3, DeltaYContent = 7 }); tabellaAsset.Columns.Add(new ColumnPDF("descrizione", 145, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Testo, "Descrizione", "") { HeaderFontSize = 7, FontSize = 7 }); tabellaAsset.Columns.Add(new ColumnPDF("portafogliomodello", 179, HorizontalAlignmentType.Destra, false, false, 7, ColumnType.Objectpdf, "PercentualeControvaloreModello", "") { HeaderPaddingLeft = 5, HeaderFontSize = 7, DeltaYContent = 2, FontSize = 7 }); tabellaAsset.Columns.Add(new ColumnPDF("portafoglioproposto", 180, HorizontalAlignmentType.Sinistra, false, false, 7, ColumnType.Objectpdf, "PercentualeControvaloreProposto", "") { HeaderPaddingLeft = 5, HeaderFontSize = 7, PaddingLeft = 3.5f, DeltaYContent = 2, FontSize = 7 }); int o = 0; var list = new List(); list.Add(Convert.ToDouble(dati.Tables["macroAssetClass"].AsEnumerable().Max(x => x["ValoreAttuale"]))); list.Add(Convert.ToDouble(dati.Tables["macroAssetClass"].AsEnumerable().Max(x => x["ValoreProposto"]))); var max = (float)Helper.Round(list.Max()); float larghezzaBarra = 0; float deltaXBarra = 0; var width = 0; foreach (DataRow row in dati.Tables["macroAssetClass"].Rows) { var colore = new ColorPDF(Convert.ToInt32(row["Red"]), Convert.ToInt32(row["Green"]), Convert.ToInt32(row["Blue"])); int indexportafoglioattuale = 1; int indexportafoglioproposto = 2; width = tabellaAsset.Columns[indexportafoglioattuale].Width - (isControvalore() ? 50 : 20); //tabellaAsset.Cells[indexOggetto, o].ValueObject = new CirclePDF(13, 13, colore); #region barra colonna attuale larghezzaBarra = Helper.GetWidthProportional(Convert.ToDouble(row["ValoreAttuale"]) == 0 ? (float)0.01 : (float)Convert.ToDouble(row["ValoreAttuale"]), max, width); /**************************** Modifica aladdin 16062021 - Pino *************************************************************************/ //deltaXBarra = Convert.ToDouble(row["ValoreAttuale"]) == 0 ? -larghezzaBarra + 10 : -larghezzaBarra + (isControvalore() ? 0 : 7); deltaXBarra = Convert.ToDouble(row["ValoreAttuale"]) == 0 ? larghezzaBarra + 5 : larghezzaBarra + (isControvalore() ? 0 : 7); /**************************************************************************************************************************************/ //deltaXBarra = -larghezzaBarra + (isControvalore() ? 0 : 7); /**************************** Modifica aladdin 16062021 - Pino *************************************************************************/ tabellaAsset.Columns[1].HorizontalAlignment = HorizontalAlignmentType.Sinistra; /**************************************************************************************************************************************/ if (Convert.ToDouble(row["ValoreAttuale"]) == 0) { tabellaAsset.Cells[indexportafoglioattuale, o].ValueObjectList = new List() { new FormattedTextAreaPDF(isControvalore() ? Helper.FormatCurrency(row["ValoreAttuale"].ToString()) : Helper.FormatDecimal(row["ValoreAttuale"].ToString(), 2), deltaXBarra-10, isControvalore()? 50 : 35) { DeltaY = 3, /**************************** Modifica aladdin 16062021 - Pino *************************************************************************/ //TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right, /**************************************************************************************************************************************/ DeltaX =isControvalore()? deltaXBarra+20 : deltaXBarra, FontSize = 7 }, new RectanglePDF(12, 1 , ColorPDF.Bianco){DeltaY = 3} }; } else { tabellaAsset.Cells[indexportafoglioattuale, o].ValueObjectList = new List() { new FormattedTextAreaPDF(isControvalore() ? Helper.FormatCurrency(row["ValoreAttuale"].ToString()) : Helper.FormatDecimal(row["ValoreAttuale"].ToString(), 2),deltaXBarra, isControvalore()? 50 : 35) { DeltaY = 3, /**************************** Modifica aladdin 16062021 - Pino *************************************************************************/ //TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right, /**************************************************************************************************************************************/ DeltaX = deltaXBarra, FontSize = 7 }, new RectanglePDF(12, larghezzaBarra , colore){DeltaY = 5}, }; } #endregion #region barra colonna proposto width = tabellaAsset.Columns[indexportafoglioproposto].Width - (isControvalore() ? 50 : 20); larghezzaBarra = Helper.GetWidthProportional(Convert.ToDouble(row["ValoreProposto"]) == 0 ? (float)0.01 : (float)Convert.ToDouble(row["ValoreProposto"]), max, width); deltaXBarra = Convert.ToDouble(row["ValoreProposto"]) == 0 ? isControvalore() ? larghezzaBarra - 20 : larghezzaBarra - 10 : isControvalore() ? larghezzaBarra + 3 : larghezzaBarra - 5; // deltaXBarra = isControvalore() ? larghezzaBarra : larghezzaBarra - 5; if (Convert.ToDouble(row["ValoreProposto"]) == 0) { tabellaAsset.Cells[indexportafoglioproposto, o].ValueObjectList = new List() { new RectanglePDF(12, 1 , ColorPDF.Bianco){DeltaY = 3}, new FormattedTextAreaPDF(isControvalore() ? Helper.FormatCurrency(row["ValoreProposto"].ToString()) :Helper.FormatDecimal(row["ValoreProposto"].ToString(), 2), deltaXBarra-10, isControvalore()? 50 : 35) { DeltaY = 3, /**************************** Modifica aladdin 16062021 - Pino *************************************************************************/ //TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right, /**************************************************************************************************************************************/ DeltaX = deltaXBarra-10, FontSize = 7 } }; } else { tabellaAsset.Cells[indexportafoglioproposto, o].ValueObjectList = new List() { new RectanglePDF(12, larghezzaBarra , colore){DeltaY = 5}, new FormattedTextAreaPDF(isControvalore() ? Helper.FormatCurrency(row["ValoreProposto"].ToString()) :Helper.FormatDecimal(row["ValoreProposto"].ToString(), 2),deltaXBarra, isControvalore()? 50 : 35) { DeltaY = 3, /**************************** Modifica aladdin 16062021 - Pino *************************************************************************/ //TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Left, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Right, /**************************************************************************************************************************************/ DeltaX = deltaXBarra, FontSize = 7 } }; } #endregion o++; } AddElement(tabellaAsset); string note = "*"; if (GetNota1().Length > 0) { AddElement(new SpacePDF(10)); tabellaAsset.Notes.Add( new TableNotePDF(TableNotePDF.TableNotePositionType.PièDiTabella, GetNota1(), new[] { "" }, string.Empty, TableNotePDF.TableNoteAsteriskPositionType.CorpoTabella) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify } ); captionAttuale.Text += note; note += "*"; } if (GetNota2().Length > 0) { AddElement(new SpacePDF(15)); tabellaAsset.Notes.Add( new TableNotePDF(TableNotePDF.TableNotePositionType.PièDiTabella, GetNota2(), new[] { "" }, string.Empty, TableNotePDF .TableNoteAsteriskPositionType.CorpoTabella) { FontSize = 6, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify } ); captionProposto.Text += note; note += "*"; } #endregion } #endregion #region prodotti if (dati.Tables["prodottiPerArea"].Rows.Count > 0) { if (getTesto2().Length > 0) { AddElement(new FormattedTextAreaPDF(getTesto2(), EnvironmentFacade.RendererFacade.XLeftLimit) { FontSize = 7, TextHorizontalAlign = ceTe.DynamicPDF.TextAlign.Justify }); AddElement(new SpacePDF(15)); } #region largezza e visibilità colonne ColorPDF _coloreAzionario = new ColorPDF(0, 0, 0); ColorPDF _coloreObbligazionario = new ColorPDF(0, 0, 0); ColorPDF _coloreMonetario = new ColorPDF(0, 0, 0); ColorPDF _coloreFlessibili = new ColorPDF(0, 0, 0); ColorPDF _coloreAlternative = new ColorPDF(0, 0, 0); ColorPDF _coloreMonetarioValuteEstere = new ColorPDF(0, 0, 0); ColorPDF _coloreAltro = new ColorPDF(0, 0, 0); foreach (DataRow dr in dati.Tables["macroAssetDisplayInfos"].Rows) { ColorPDF _colore = new ColorPDF(int.Parse(dr["Red"].ToString()), int.Parse(dr["Green"].ToString()), int.Parse(dr["Blue"].ToString())); switch (dr["codice"].ToString()) { case "AZ": _coloreAzionario = _colore; break; case "OB": _coloreObbligazionario = _colore; break; case "MN": _coloreMonetario = _colore; break; case "FL": _coloreFlessibili = _colore; break; case "AT": _coloreAlternative = _colore; break; case "FX": _coloreMonetarioValuteEstere = _colore; break; case "AL": _coloreAltro = _colore; break; } } bool presenzaAzionario = (bool)dati.Tables["prodottimacroAsset"].Rows[0]["presenzaAzionario"]; bool presenzaObbligazionario = (bool)dati.Tables["prodottimacroAsset"].Rows[0]["presenzaObbligazionario"]; bool presenzaMonetario = (bool)dati.Tables["prodottimacroAsset"].Rows[0]["presenzaMonetario"]; bool presenzaFlessibili = (bool)dati.Tables["prodottimacroAsset"].Rows[0]["presenzaFlessibili"]; bool presenzaAlternative = (bool)dati.Tables["prodottimacroAsset"].Rows[0]["presenzaAlternative"]; bool presenzaMonetarioValuteEstere = (bool)dati.Tables["prodottimacroAsset"].Rows[0]["presenzaMonetarioValuteEstere"]; bool presenzaAltro = (bool)dati.Tables["prodottimacroAsset"].Rows[0]["presenzaAltro"]; var numeroColonneVisibili = 0; if (presenzaAzionario) numeroColonneVisibili++; if (presenzaObbligazionario) numeroColonneVisibili++; if (presenzaMonetario) numeroColonneVisibili++; if (presenzaFlessibili) numeroColonneVisibili++; if (presenzaAlternative) numeroColonneVisibili++; if (presenzaMonetarioValuteEstere) numeroColonneVisibili++; if (presenzaAltro) numeroColonneVisibili++; bool presenzaControvalore = numeroColonneVisibili <= 5; const int larghezzaColonnaImmagine = 15; var larghezzaColonnaControvalore = presenzaControvalore ? 80 : 0; var larghezzaColonnaAzionario = presenzaAzionario ? 55 : 0; var larghezzaColonnaObbligazionario = presenzaObbligazionario ? 65 : 0; var larghezzaColonnaMonetario = presenzaMonetario ? 55 : 0; var larghezzaColonnaFlessibili = presenzaFlessibili ? 55 : 0; var larghezzaColonnaAlternative = presenzaAlternative ? 55 : 0; var larghezzaColonnaMonetarioValuteEstere = presenzaMonetarioValuteEstere ? 55 : 0; var larghezzaColonnaAltro = presenzaAltro ? 55 : 0; var larghezzaColonnaDescrizione = 520 - (larghezzaColonnaImmagine + larghezzaColonnaControvalore + larghezzaColonnaAzionario + larghezzaColonnaObbligazionario + larghezzaColonnaMonetario + larghezzaColonnaFlessibili + larghezzaColonnaAlternative + larghezzaColonnaMonetarioValuteEstere + larghezzaColonnaAltro); #endregion var tabellaProdottiPerArea = new TablePDF(EnvironmentFacade.RendererFacade.XLeftLimit, dati.Tables["prodottiPerArea"]) { Style = Style.ConsulenzaUnica, Header = true, Footer = false, AlternateRow = false, RowHeight = 25, HeaderMargin = 2, ShowSeparationLines = false, ShowBorderContent = false, RowsHeightOffset = -2 }; #region Columns e FooterColumns // Modifica per Saving Map tabellaProdottiPerArea.Columns.Add(new ColumnPDF("SavingMap", 10, HorizontalAlignmentType.Sinistra, false, false, 6, ColumnType.Immagine, "SavingMap", string.Empty) { DeltaYContent = 11, ScaleColumnTypeImage = 0.50F, HeaderBackgroundColor = ColorPDF.Bianco }); // Fine Modifica tabellaProdottiPerArea.Columns.Add(new ColumnPDF("Immagine", larghezzaColonnaImmagine + larghezzaColonnaDescrizione - 10, HorizontalAlignmentType.Sinistra, false, false, 6, ColumnType.Objectpdf, string.Empty, string.Empty) { DeltaYContent = 4, PaddingLeft = 2, HeaderBackgroundColor = ColorPDF.Bianco }); //tabellaProdottiPerArea.Columns.Add(new ColumnPDF("DescrizioneAreaProdotto", larghezzaColonnaDescrizione, HorizontalAlignmentType.Sinistra, false, true, 6, ColumnType.Testo, "DescrizioneProdotto", string.Empty) { HeaderBackgroundColor = ColorPDF.Bianco, HeaderFontColor = ColorPDF.Nero, HeaderFontSize = 7}); //tabellaProdottiPerArea.FooterColumns.Add(new ColumnPDF("TotalePatrimonio", tabellaProdottiPerArea.Columns.Sum(o => o.Width), HorizontalAlignmentType.Sinistra, false, true, 7, ColumnType.Testo)); //tabellaProdottiPerArea.FooterCells[0, 0].Value = "Portafoglio Proposto"; if (presenzaControvalore) { tabellaProdottiPerArea.Columns.Add(new ColumnPDF("ValoreProdotto", larghezzaColonnaControvalore, HorizontalAlignmentType.Centrato, false, true, 6, ColumnType.Testo, "ValoreProdottoString", "Controvalore
" + (isAdeguata ? "proposto (€)" : "prospettico (€)")) { HeaderBackgroundColor = ColorPDF.Bianco, HeaderFontColor = ColorPDF.Nero, HeaderFontSize = 7, PaddingRight = 10 }); } if (presenzaMonetario) { tabellaProdottiPerArea.Columns.Add(new ColumnPDF("Monetario", larghezzaColonnaMonetario, HorizontalAlignmentType.Centrato, false, true, 6, ColumnType.Testo, "MNString", "Monetario
" + signValue) { HeaderBackgroundColor = _coloreMonetario, BackgroundColor = _coloreMonetario, HeaderFontSize = 7, HeaderFontColor = ColorPDF.Nero, PaddingRight = 4 }); } if (presenzaObbligazionario) { tabellaProdottiPerArea.Columns.Add(new ColumnPDF("Obbligazionario", larghezzaColonnaObbligazionario, HorizontalAlignmentType.Centrato, false, true, 6, ColumnType.Testo, "OBString", "Obbligazionario
" + signValue) { HeaderBackgroundColor = _coloreObbligazionario, BackgroundColor = _coloreObbligazionario, HeaderFontSize = 7, HeaderFontColor = ColorPDF.Bianco, FontColor = ColorPDF.Bianco, PaddingRight = 4 }); } if (presenzaAzionario) { tabellaProdottiPerArea.Columns.Add(new ColumnPDF("Azionario", larghezzaColonnaAzionario, HorizontalAlignmentType.Centrato, false, true, 6, ColumnType.Testo, "AZString", "Azionario
" + signValue) { HeaderBackgroundColor = _coloreAzionario, BackgroundColor = _coloreAzionario, HeaderFontSize = 7, HeaderFontColor = ColorPDF.Bianco, FontColor = ColorPDF.Bianco, PaddingRight = 4 }); } if (presenzaMonetarioValuteEstere) { tabellaProdottiPerArea.Columns.Add(new ColumnPDF("MonetarioValuteEstere", larghezzaColonnaMonetarioValuteEstere, HorizontalAlignmentType.Centrato, false, true, 6, ColumnType.Testo, "FXString", "Mon. Val. Est.
" + signValue) { HeaderBackgroundColor = _coloreMonetarioValuteEstere, BackgroundColor = _coloreMonetarioValuteEstere, HeaderFontSize = 7, HeaderFontColor = ColorPDF.Bianco, FontColor = ColorPDF.Bianco, PaddingRight = 4 }); } if (presenzaFlessibili) { tabellaProdottiPerArea.Columns.Add(new ColumnPDF("Flessibili", larghezzaColonnaFlessibili, HorizontalAlignmentType.Centrato, false, true, 6, ColumnType.Testo, "FLString", "Flessibili
" + signValue) { HeaderBackgroundColor = _coloreFlessibili, BackgroundColor = _coloreFlessibili, HeaderFontSize = 7, HeaderFontColor = ColorPDF.Nero, PaddingRight = 4 }); } if (presenzaAlternative) { tabellaProdottiPerArea.Columns.Add(new ColumnPDF("Alternative", larghezzaColonnaAlternative, HorizontalAlignmentType.Centrato, false, true, 6, ColumnType.Testo, "ATString", "Alternative
" + signValue) { HeaderBackgroundColor = _coloreAlternative, BackgroundColor = _coloreAlternative, HeaderFontSize = 7, HeaderFontColor = ColorPDF.Nero, PaddingRight = 4 }); } if (presenzaAltro) { tabellaProdottiPerArea.Columns.Add(new ColumnPDF("Altro", larghezzaColonnaAltro, HorizontalAlignmentType.Centrato, false, true, 6, ColumnType.Testo, "ALString", "Altro
" + signValue) { HeaderBackgroundColor = _coloreAltro, BackgroundColor = _coloreAltro, HeaderFontSize = 7, HeaderFontColor = ColorPDF.Nero }); } #endregion #region Cells int d = 0; foreach (DataRow rw in dati.Tables["prodottiPerArea"].Rows) { var isTotal = Convert.ToBoolean(rw["IsTotal"]); var isSubTotal = Convert.ToBoolean(rw["IsSubTotal"]); var isFontBold = Convert.ToBoolean(rw["FontBold"]); if (isTotal || isSubTotal) { for (int c = 0; c < tabellaProdottiPerArea.Columns.Count; c++) { tabellaProdottiPerArea.Cells[c, d].BackgroundColor = ColorPDF.Standard_Grigio_SfondoColonnaTabella; tabellaProdottiPerArea.Cells[c, d].FontBold = true; tabellaProdottiPerArea.Cells[c, d].FontColor = ColorPDF.Nero; } if (isTotal) { // Simboli dell'area di bisogno var listaOggetti = new List { new RectanglePDF(8, 8, ColorPDF.GetBy_AreaBisogno(rw["CodiceAreaBisogno"].ToString())){DeltaY = 4}, new FormattedTextAreaPDF { Text = new AreaBisogno(rw["CodiceAreaBisogno"].ToString()).Abbreviazione, FontBold = true, FontColor = ColorPDF.Bianco, DeltaX = 2, FontSize=7, DeltaY = 2 }, new FormattedTextAreaPDF { Text = new AreaBisogno(rw["CodiceAreaBisogno"].ToString()).Nome, FontBold = true, FontColor = ColorPDF.Nero, DeltaX = 12F, FontSize=6, DeltaY = 2 } }; tabellaProdottiPerArea.Cells[1, d].ValueObjectList.AddRange(listaOggetti); } if (isSubTotal) { var stringa = rw["DescrizioneProdotto"].ToString(); tabellaProdottiPerArea.Cells[1, d].ValueObject = new FormattedTextAreaPDF { Text = stringa, FontBold = true, FontColor = ColorPDF.Nero, DeltaX = 2F, FontSize = 6, Width = larghezzaColonnaImmagine + larghezzaColonnaDescrizione + 5, DeltaY = 2, }; } tabellaProdottiPerArea.RowsIndexesThatIgnoreColumnBackgroundColor.Add(d); } else if (isFontBold && !isSubTotal && !isTotal) { for (int c = 0; c < tabellaProdottiPerArea.Columns.Count; c++) { tabellaProdottiPerArea.Cells[c, d].BackgroundColor = ColorPDF.Bianco; tabellaProdottiPerArea.Cells[c, d].FontBold = true; tabellaProdottiPerArea.Cells[c, d].FontColor = ColorPDF.Nero; } var stringa = rw["DescrizioneProdotto"].ToString(); tabellaProdottiPerArea.Cells[1, d].ValueObject = new FormattedTextAreaPDF { Text = stringa, FontBold = isFontBold, FontColor = ColorPDF.Nero, DeltaX = 2F, FontSize = 6, DeltaY = 3, Width = larghezzaColonnaImmagine + larghezzaColonnaDescrizione + 5 }; } else { var stringa = rw["DescrizioneProdotto"].ToString(); tabellaProdottiPerArea.Cells[1, d].ValueObject = new FormattedTextAreaPDF { Text = stringa, FontBold = false, FontColor = ColorPDF.Nero, DeltaX = 2F, FontSize = 6, DeltaY = 3, Width = larghezzaColonnaImmagine + larghezzaColonnaDescrizione + 5 }; } d++; } int a = 0; foreach (var item in dati.Tables["prodottiPerArea"].Rows) { for (int b = 1; b < tabellaProdottiPerArea.Columns.Count; b++) { //if (a == dati.Tables["prodottiPerArea"].Rows.Count-1) // tabellaProdottiPerArea.Cells[b, a].BackgroundColor = ColorPDF.Bianco; tabellaProdottiPerArea.Cells[b, a].HorizontalAlignment = HorizontalAlignmentType.Destra; } a++; } #endregion AddElement(tabellaProdottiPerArea); } #endregion } protected sealed override DataTable GetDataTable() { return null; } protected sealed override DataSet GetDataSet() { #region Definizione Dataset + Unit var dataDettaglioProdotti = datiSeiUnico.propostaUnit().dettaglioProdotti; var dataDettaglioProdottiExtraRisorseFinanziarie = datiSeiUnico.GetListaProdottiPatrimonioAltro(); var displayInfos = datiSeiUnico.displayInfos(); var dataPatrimonioCasa = datiSeiUnico.propostaUnit().stDettaglioProposta; bool Adeguata = datiSeiUnico.propostaUnit().stAdequatezza.flagAdeguatezzaPro; var MacroAssetAttuale = datiSeiUnico.patrimonioUnit().patrimonioCasa.macroAssetClass; var MacroAssetProposto = datiSeiUnico.propostaUnit().macroAssetClass; var ds = new DataSet(); ds.Tables.Add(new DataTable("labelControvalore")); ds.Tables.Add(new DataTable("macroAssetClass")); ds.Tables.Add(new DataTable("macroAssetDisplayInfos")); ds.Tables.Add(new DataTable("prodottimacroAsset")); ds.Tables.Add(new DataTable("prodotti")); ds.Tables["labelControvalore"].Columns.Add("ctvAttuale", typeof(decimal)); ds.Tables["labelControvalore"].Columns.Add("ctvProposto", typeof(decimal)); ds.Tables["macroAssetClass"].Columns.Add(new DataColumn("Descrizione", typeof(string))); ds.Tables["macroAssetClass"].Columns.Add(new DataColumn("Red", typeof(int))); ds.Tables["macroAssetClass"].Columns.Add(new DataColumn("Green", typeof(int))); ds.Tables["macroAssetClass"].Columns.Add(new DataColumn("Blue", typeof(int))); ds.Tables["macroAssetClass"].Columns.Add(new DataColumn("ValoreAttuale", typeof(decimal))); ds.Tables["macroAssetClass"].Columns.Add(new DataColumn("ValoreProposto", typeof(decimal))); ds.Tables["macroAssetDisplayInfos"].Columns.Add(new DataColumn("codice", typeof(string))); ds.Tables["macroAssetDisplayInfos"].Columns.Add(new DataColumn("ordine", typeof(int))); ds.Tables["macroAssetDisplayInfos"].Columns.Add(new DataColumn("Red", typeof(int))); ds.Tables["macroAssetDisplayInfos"].Columns.Add(new DataColumn("Green", typeof(int))); ds.Tables["macroAssetDisplayInfos"].Columns.Add(new DataColumn("Blue", typeof(int))); ds.Tables["prodottimacroAsset"].Columns.Add(new DataColumn("presenzaAzionario", typeof(bool))); ds.Tables["prodottimacroAsset"].Columns.Add(new DataColumn("presenzaObbligazionario", typeof(bool))); ds.Tables["prodottimacroAsset"].Columns.Add(new DataColumn("presenzaMonetario", typeof(bool))); ds.Tables["prodottimacroAsset"].Columns.Add(new DataColumn("presenzaFlessibili", typeof(bool))); ds.Tables["prodottimacroAsset"].Columns.Add(new DataColumn("presenzaAlternative", typeof(bool))); ds.Tables["prodottimacroAsset"].Columns.Add(new DataColumn("presenzaMonetarioValuteEstere", typeof(bool))); ds.Tables["prodottimacroAsset"].Columns.Add(new DataColumn("presenzaAltro", typeof(bool))); ds.Tables["prodotti"].Columns.Add(new DataColumn("SavingMap", typeof(string))); ds.Tables["prodotti"].Columns.Add(new DataColumn("CodiceAreaBisogno", typeof(string))); ds.Tables["prodotti"].Columns.Add(new DataColumn("DescrizioneAreaBisogno", typeof(string))); ds.Tables["prodotti"].Columns.Add(new DataColumn("DescrizioneProgetto", typeof(string))); ds.Tables["prodotti"].Columns.Add(new DataColumn("DescrizioneProdotto", typeof(string))); ds.Tables["prodotti"].Columns.Add(new DataColumn("ValoreProdotto", typeof(decimal))); ds.Tables["prodotti"].Columns.Add(new DataColumn("ValoreProdottoString", typeof(string))); //foreach (var item in MacroAssetAttuale.distribuzione.elencoSlice) BugFix #4450 foreach (var item in MacroAssetProposto.distribuzione.elencoSlice) { if (item.sliceRappresentabile) { ds.Tables["prodotti"].Columns.Add(new DataColumn(item.codice, typeof(string))); ds.Tables["prodotti"].Columns.Add(new DataColumn(item.codice + "String", typeof(string))); } } ds.Tables["prodotti"].Columns.Add(new DataColumn("OrdinamentoAreaBisogno", typeof(int))); ds.Tables["prodotti"].Columns.Add(new DataColumn("FontBold", typeof(bool))); ds.Tables["prodotti"].Columns.Add(new DataColumn("ReplaceIfZero", typeof(string))); ds.Tables["prodotti"].Columns.Add(new DataColumn("CanLastRow", typeof(bool))); ds.Tables["prodotti"].Columns.Add(new DataColumn("IsTotal", typeof(bool))); ds.Tables["prodotti"].Columns.Add(new DataColumn("IsSubTotal", typeof(bool))); ds.Tables["prodotti"].Columns.Add(new DataColumn("CodiceProgetto", typeof(string))); #endregion #region GraficoSintesi ds.Tables["labelControvalore"].Rows.Add( Helper.FormatCurrency(datiSeiUnico.ATTUTALE_TOTALEPOSITIVO.ToString()), Helper.FormatCurrency(datiSeiUnico.PROPOSTO_TOTALEPOSITIVO.ToString().ToString()) ); foreach (var displayInfo in from o in displayInfos.macroAssetDisplayInfos /*where presenzaGrafico() */orderby o.value.order select o) { var attuale = (from o in MacroAssetAttuale.distribuzione.elencoSlice where o.codice == displayInfo.key && o.sliceRappresentabile select o).LastOrDefault(); var proposto = (from o in MacroAssetProposto.distribuzione.elencoSlice where o.codice == displayInfo.key && o.sliceRappresentabile select o).LastOrDefault(); bool attualeExist = false; bool propostoExist = false; if (attuale != null) if (presenzaContocorrenteInMonterio() ? attuale.ctvCC != 0 : attuale.ctv != 0) attualeExist = true; if (proposto != null) if (presenzaContocorrenteInMonterio() ? proposto.ctvCC != 0 : proposto.ctv != 0) attualeExist = true; if (attuale != null || proposto != null) { if (attualeExist || propostoExist) { DataRow dr = ds.Tables["macroAssetClass"].NewRow(); dr["Red"] = new ColorPDF(displayInfo.value.fill).Red; dr["Green"] = new ColorPDF(displayInfo.value.fill).Green; dr["Blue"] = new ColorPDF(displayInfo.value.fill).Blue; dr["ValoreProposto"] = 0; dr["ValoreAttuale"] = 0; ds.Tables["macroAssetClass"].Rows.Add(dr); if (attuale != null) { dr["Descrizione"] = attuale.descrizione; dr["ValoreAttuale"] = presenzaContocorrenteInMonterio() ? isControvalore() ? attuale.ctvCC : attuale.pesoCC * 100 : isControvalore() ? attuale.ctv : attuale.peso * 100; } if (proposto != null) { dr["Descrizione"] = proposto.descrizione; dr["ValoreProposto"] = presenzaContocorrenteInMonterio() ? isControvalore() ? proposto.ctvCC : proposto.pesoCC * 100 : isControvalore() ? proposto.ctv : proposto.peso * 100; } } } } #endregion #region Prodotti foreach (var displayInfo in displayInfos.macroAssetDisplayInfos) { ds.Tables["macroAssetDisplayInfos"].Rows.Add( displayInfo.key, displayInfo.value.order, new ColorPDF(displayInfo.value.fill).Red, new ColorPDF(displayInfo.value.fill).Green, new ColorPDF(displayInfo.value.fill).Blue ); } bool presenzaAzionario = false; bool presenzaObbligazionario = false; bool presenzaMonetario = false; bool presenzaFlessibili = false; bool presenzaAlternative = false; bool presenzaMonetarioValuteEstere = false; bool presenzaAltro = false; const string labelProdottiNonRappresentabili = "n.d."; const string stringReplaceIfZero = " "; presenzaAzionario = MacroAssetProposto.distribuzionePerProdotti.listaProdotti.ToList().Any(o => o.listaSlice.Any(l => l.codice.Equals("AZ"))) ? true : presenzaAzionario; presenzaObbligazionario = MacroAssetProposto.distribuzionePerProdotti.listaProdotti.ToList().Any(o => o.listaSlice.Any(l => l.codice.Equals("OB"))) ? true : presenzaObbligazionario; presenzaMonetario = MacroAssetProposto.distribuzionePerProdotti.listaProdotti.ToList().Any(o => o.listaSlice.Any(l =>l.codice.Equals("MN"))) ? true : presenzaMonetario; presenzaFlessibili = MacroAssetProposto.distribuzionePerProdotti.listaProdotti.ToList().Any(o => o.listaSlice.Any(l => l.codice.Equals("FL"))) ? true : presenzaFlessibili; presenzaAlternative = MacroAssetProposto.distribuzionePerProdotti.listaProdotti.ToList().Any(o => o.listaSlice.Any(l => l.codice.Equals("AT"))) ? true : presenzaAlternative; presenzaMonetarioValuteEstere = MacroAssetProposto.distribuzionePerProdotti.listaProdotti.ToList().Any(o => o.listaSlice.Any(l => l.codice.Equals("FX"))) ? true : presenzaMonetarioValuteEstere; presenzaAltro = MacroAssetProposto.distribuzionePerProdotti.listaProdotti.ToList().Any(o => o.listaSlice.Any(l => l.codice.Equals("AL"))) ? true : presenzaAltro; if (ds.Tables["macroAssetClass"].AsEnumerable().FirstOrDefault(x => x.Field("Descrizione").ToLower().Equals("monetario")) == null) presenzaMonetario = false; foreach (var itemMacroAsset in from o in MacroAssetProposto.distribuzionePerProdotti.listaProdotti where presenzaDettaglioProdotti() select o) { //presenzaAzionario = itemMacroAsset.listaSlice.Any(o => o.codice.Equals("AZ")) ? true : presenzaAzionario; //presenzaObbligazionario =itemMacroAsset.listaSlice.Any(o => o.codice.Equals("OB"))?true:presenzaObbligazionario; //presenzaMonetario =itemMacroAsset.listaSlice.Any(o => o.codice.Equals("MN"))?true:presenzaMonetario; //presenzaFlessibili =itemMacroAsset.listaSlice.Any(o => o.codice.Equals("FL"))?true:presenzaFlessibili; //presenzaAlternative = itemMacroAsset.listaSlice.Any(o => o.codice.Equals("AT"))?true:presenzaAlternative; //presenzaMonetarioValuteEstere =itemMacroAsset.listaSlice.Any(o => o.codice.Equals("FX"))?true:presenzaMonetarioValuteEstere; //presenzaAltro = itemMacroAsset.listaSlice.Any(o => o.codice.Equals("AL"))?true:presenzaAltro; var itemPosizione = dataDettaglioProdotti.dettaglioProdotti.FirstOrDefault(o => o.chiaveAggregazione.Equals(itemMacroAsset.chiaveAggregazione)); var flagProdottoRappresentabile = itemMacroAsset.rappresentabile; if (itemPosizione.ctvPro != 0) { var rowProdotti = ds.Tables["prodotti"].NewRow(); rowProdotti["CodiceAreaBisogno"] = itemPosizione.area; rowProdotti["CodiceProgetto"] = itemPosizione.codProgetto; rowProdotti["OrdinamentoAreaBisogno"] = /*flagProdottoRappresentabile ? */displayInfos.areeDisplayInfos.Where(o => o.key.ToUpper() == itemPosizione.area.ToUpper()).LastOrDefault().value.order; //0;//FARE rowProdotti["DescrizioneAreaBisogno"] = new AreaBisogno(itemPosizione.area).Nome; rowProdotti["DescrizioneProgetto"] = itemPosizione.nomeProgetto; if (itemPosizione.savingMap) //if (itemPosizione.prodotto.nomeProdotto.Substring(0, 2) == "FV") rowProdotti["SavingMap"] = "SavingMap.png"; else rowProdotti["SavingMap"] = ""; rowProdotti["DescrizioneProdotto"] = itemPosizione.prodotto.nomeProdotto; rowProdotti["ValoreProdotto"] = Math.Round(Convert.ToDecimal(itemPosizione.ctvPro), 2); rowProdotti["ValoreProdottoString"] = Helper.FormatCurrency(rowProdotti["ValoreProdotto"].ToString()); foreach (var item in MacroAssetProposto.distribuzione.elencoSlice) { if (item.sliceRappresentabile) { bool ccNA = itemPosizione.prodotto.tipoProdotto.ToUpper() == "CC" && !presenzaContocorrenteInMonterio(); if (!ccNA) { rowProdotti[item.codice] = flagProdottoRappresentabile ? itemMacroAsset.listaSlice.Any(o => o.codice.Equals(item.codice)) ? isControvalore() ? Convert.ToDecimal(itemMacroAsset.listaSlice.FirstOrDefault(o => o.codice.Equals(item.codice)).ctv) : Convert.ToDecimal(itemMacroAsset.listaSlice.FirstOrDefault(o => o.codice.Equals(item.codice)).pesoSuPosizione * 100) : 0 : 0; } else { rowProdotti[item.codice] = flagProdottoRappresentabile ? itemMacroAsset.listaSlice.Any(o => o.codice.Equals(item.codice)) ? isControvalore() ? "n.a." : "n.a." : "n.a." : "n.a."; } rowProdotti[item.codice + "String"] = flagProdottoRappresentabile ? Helper.FormatCurrency(rowProdotti[item.codice].ToString()) : labelProdottiNonRappresentabili; } } rowProdotti["FontBold"] = false; rowProdotti["ReplaceIfZero"] = " "; rowProdotti["CanLastRow"] = true; rowProdotti["IsTotal"] = false; rowProdotti["IsSubTotal"] = false; ds.Tables["prodotti"].Rows.Add(rowProdotti); } } DataRow prodottimacroAsset = ds.Tables["prodottimacroAsset"].NewRow(); prodottimacroAsset["presenzaAzionario"] = presenzaAzionario; prodottimacroAsset["presenzaObbligazionario"] = presenzaObbligazionario; prodottimacroAsset["presenzaMonetario"] = presenzaMonetario; prodottimacroAsset["presenzaFlessibili"] = presenzaFlessibili; prodottimacroAsset["presenzaAlternative"] = presenzaAlternative; prodottimacroAsset["presenzaMonetarioValuteEstere"] = presenzaMonetarioValuteEstere; prodottimacroAsset["presenzaAltro"] = presenzaAltro; ds.Tables["prodottimacroAsset"].Rows.Add(prodottimacroAsset); #endregion #region Prodotti raggruppati per area DataTable dtProdottiPerArea = ds.Tables["prodotti"].Clone(); dtProdottiPerArea.TableName = "prodottiPerArea"; ds.Tables.Add(dtProdottiPerArea); if (ds.Tables["prodotti"].Rows.Count > 0) { var viewAree = new DataView(ds.Tables["prodotti"]) { Sort = "OrdinamentoAreaBisogno" }; var dtAree = viewAree.ToTable(true, "CodiceAreaBisogno", "DescrizioneAreaBisogno", "OrdinamentoAreaBisogno"); var area = string.Empty; var progetto = string.Empty; var codiceprogetto = string.Empty; #region Prodotti delle Risorse Finanziarie foreach (DataRow rowAreaProgetto in dtAree.Rows) { area = rowAreaProgetto["CodiceAreaBisogno"].ToString(); if (new AreaBisogno(area).Visibile) { //Progetti var viewProgetti = new DataView(ds.Tables["prodotti"].Select("CodiceAreaBisogno='" + area + "'").OrderByDescending(o => o.Field("ValoreProdotto")).CopyToDataTable()); var dtProgetti = viewProgetti.ToTable(true, "DescrizioneProgetto", "CodiceProgetto"); var bIntestazioneArea = true; // la riga di intestazione dell'area va stampata una sola volta. var bItestazioneProgetto = area == "Inv" || area == "Pre"; // la riga di intestazione del progetto va stampata solo per area Inv e Pre. DataRow rowProdottiPerArea; foreach (DataRow itemProgetto in dtProgetti.Rows) { progetto = itemProgetto["DescrizioneProgetto"].ToString(); codiceprogetto = itemProgetto["CodiceProgetto"].ToString(); ; // Subset di prodotti filtrati per Area/Progetto var dtArea = ds.Tables["prodotti"].Select("CodiceAreaBisogno='" + area + "'").CopyToDataTable(); var dtAreaProgetto = ds.Tables["prodotti"].Select("CodiceAreaBisogno='" + area + "' AND " + string.Format("DescrizioneProgetto ='{0}'", itemProgetto["DescrizioneProgetto"].ToString().Replace("'", "''"))).OrderByDescending(o => o.Field("ValoreProdotto")).CopyToDataTable(); if (bIntestazioneArea) { #region Riga con background grigio di intestazione per ogni Area rowProdottiPerArea = dtProdottiPerArea.NewRow(); rowProdottiPerArea["CodiceAreaBisogno"] = rowAreaProgetto["CodiceAreaBisogno"]; rowProdottiPerArea["DescrizioneProdotto"] = rowAreaProgetto["DescrizioneAreaBisogno"]; rowProdottiPerArea["ValoreProdotto"] = /*presenzaContocorrenteInMonterio() ? MacroAssetProposto.distribuzioneAree.FirstOrDefault(o => o.area.Equals(area)).distribuzione.totaleRapprCC : */MacroAssetProposto.distribuzioneAree.FirstOrDefault(o => o.area.Equals(area)).distribuzione.totaleCtv; rowProdottiPerArea["ValoreProdottoString"] = Helper.FormatCurrency(rowProdottiPerArea["ValoreProdotto"].ToString()); var pippo = MacroAssetProposto.distribuzioneAree.FirstOrDefault(o => o.area.Equals(rowAreaProgetto["CodiceAreaBisogno"]) && o.chiaveProgetto == null); if (pippo != null) { foreach (var item in pippo.distribuzione.elencoSlice) { if (item.sliceRappresentabile) { var controvalore = (presenzaContocorrenteInMonterio() ? item.ctvCC : item.ctv); var perc = (presenzaContocorrenteInMonterio() ? item.pesoCC : item.peso) * 100; rowProdottiPerArea[item.codice] = isControvalore() ? controvalore : perc; // dtArea.AsEnumerable().Sum(x => x.Field(item.codice)); rowProdottiPerArea[item.codice + "String"] = Helper.FormatCurrency(rowProdottiPerArea[item.codice].ToString()); } } } rowProdottiPerArea["FontBold"] = true; rowProdottiPerArea["ReplaceIfZero"] = stringReplaceIfZero; rowProdottiPerArea["CanLastRow"] = false; rowProdottiPerArea["IsTotal"] = true; rowProdottiPerArea["IsSubTotal"] = false; dtProdottiPerArea.Rows.Add(rowProdottiPerArea); bIntestazioneArea = false; #endregion } if (bItestazioneProgetto) { #region Riga con background grigio di intestazione per ogni Progetto rowProdottiPerArea = dtProdottiPerArea.NewRow(); rowProdottiPerArea["CodiceAreaBisogno"] = rowAreaProgetto["CodiceAreaBisogno"]; rowProdottiPerArea["DescrizioneProdotto"] = progetto; rowProdottiPerArea["ValoreProdotto"] = dtAreaProgetto.AsEnumerable().Sum(x => x.Field("ValoreProdotto")); rowProdottiPerArea["ValoreProdottoString"] = Helper.FormatCurrency(rowProdottiPerArea["ValoreProdotto"].ToString()); var valoreprogetto = MacroAssetProposto.distribuzioneAree.Where(o => o.area.Equals(area) && codiceprogetto == o.chiaveProgetto).FirstOrDefault(); if (valoreprogetto != null) { foreach (var item in valoreprogetto.distribuzione.elencoSlice) { if (item.sliceRappresentabile) { var controvalore = (presenzaContocorrenteInMonterio() ? item.ctvCC : item.ctv); var perc = (presenzaContocorrenteInMonterio() ? item.pesoCC : item.peso) * 100; rowProdottiPerArea[item.codice] = isControvalore() ? controvalore : perc; // dtArea.AsEnumerable().Sum(x => x.Field(item.codice)); rowProdottiPerArea[item.codice + "String"] = Helper.FormatCurrency(rowProdottiPerArea[item.codice].ToString()); } } } rowProdottiPerArea["FontBold"] = true; rowProdottiPerArea["ReplaceIfZero"] = stringReplaceIfZero; if (rowAreaProgetto["CodiceAreaBisogno"].ToString() == "Inv" || rowAreaProgetto["CodiceAreaBisogno"].ToString().Equals("Pre")) rowProdottiPerArea["CanLastRow"] = true; else rowProdottiPerArea["CanLastRow"] = false; rowProdottiPerArea["IsTotal"] = false; rowProdottiPerArea["IsSubTotal"] = true; dtProdottiPerArea.Rows.Add(rowProdottiPerArea); #endregion } // I prodotti della dtProdotti vengono mergiati sulla dtProdottiPerArea dtProdottiPerArea.Merge(dtAreaProgetto); } } } #endregion var PROPOSTO_OC = datiSeiUnico.PROPOSTO_OC; var PROPOSTO_CCN = from o in dataDettaglioProdotti.dettaglioProdotti where o.area.ToLower().Equals("cc") && o.ctvPro < 0 orderby o.ctvPro descending select o; var PROPOSTO_EF = from o in dataDettaglioProdotti.dettaglioProdotti where o.area.ToLower().Equals("self") && o.ctvPro < 0 && o.prodotto.codSottoprodotto.Equals("L191") orderby o.ctvPro descending select o; var PROPOSTO_ET = from o in dataDettaglioProdotti.dettaglioProdotti where o.area.ToLower().Equals("self") && o.ctvPro < 0 && o.prodotto.codSottoprodotto.Equals("L192") orderby o.ctvPro descending select o; //AC var PROPOSTO_FO = from o in dataDettaglioProdotti.dettaglioProdotti where o.area.ToLower().Equals("self") && o.ctvPro < 0 && o.prodotto.codSottoprodotto.Equals("V301") orderby o.ctvPro descending select o; //AC bool totaleRisorse = PROPOSTO_CCN.Count() > 0 || PROPOSTO_OC != 0 || PROPOSTO_EF.Count() > 0 || PROPOSTO_ET.Count() > 0 || PROPOSTO_FO.Count() > 0; if (totaleRisorse) { #region Totale risorse finanziarie DataRow rowProdottiPerArea = ds.Tables["prodottiPerArea"].NewRow(); rowProdottiPerArea["CodiceAreaBisogno"] = "RF"; rowProdottiPerArea["DescrizioneProdotto"] = "Totale risorse allocate"; rowProdottiPerArea["ValoreProdotto"] = datiSeiUnico.PROPOSTO_SUBTOTALE; rowProdottiPerArea["ValoreProdottoString"] = Helper.FormatCurrency(datiSeiUnico.PROPOSTO_SUBTOTALE.ToString()); foreach (var displayInfo in from o in displayInfos.macroAssetDisplayInfos orderby o.value.order select o) { var proposto = (from o in MacroAssetProposto.distribuzione.elencoSlice where o.codice == displayInfo.key && o.sliceRappresentabile select o).LastOrDefault(); if (proposto != null) { rowProdottiPerArea[proposto.codice] = presenzaContocorrenteInMonterio() ? isControvalore() ? proposto.ctvCC : proposto.pesoCC * 100 : isControvalore() ? proposto.ctv : proposto.peso * 100; rowProdottiPerArea[proposto.codice + "String"] = presenzaContocorrenteInMonterio() ? isControvalore() ? Helper.FormatCurrency(proposto.ctvCC.ToString()) : Helper.FormatDecimal((proposto.pesoCC * 100).ToString(), 2) : isControvalore() ? Helper.FormatCurrency(proposto.ctv.ToString()) : Helper.FormatDecimal((proposto.peso * 100).ToString(), 2); } } rowProdottiPerArea["FontBold"] = true; rowProdottiPerArea["ReplaceIfZero"] = "n.d."; rowProdottiPerArea["CanLastRow"] = false; rowProdottiPerArea["IsTotal"] = false; rowProdottiPerArea["IsSubTotal"] = true; ds.Tables["prodottiPerArea"].Rows.Add(rowProdottiPerArea); #endregion #region Operazioni in corso if (PROPOSTO_OC != 0) { rowProdottiPerArea = ds.Tables["prodottiPerArea"].NewRow(); rowProdottiPerArea["CodiceAreaBisogno"] = ""; rowProdottiPerArea["DescrizioneProdotto"] = "Operazioni in corso"; rowProdottiPerArea["ValoreProdotto"] = Helper.FormatCurrency(PROPOSTO_OC.ToString()); ; rowProdottiPerArea["ValoreProdottoString"] = Helper.FormatCurrency(PROPOSTO_OC.ToString()); foreach (var displayInfo in from o in displayInfos.macroAssetDisplayInfos orderby o.value.order select o) { var proposto = (from o in MacroAssetProposto.distribuzione.elencoSlice where o.codice == displayInfo.key && o.sliceRappresentabile select o).LastOrDefault(); if (proposto != null) { rowProdottiPerArea[proposto.codice] = 0; rowProdottiPerArea[proposto.codice + "String"] = Helper.FormatCurrency(rowProdottiPerArea[proposto.codice].ToString()); } } rowProdottiPerArea["FontBold"] = false; rowProdottiPerArea["ReplaceIfZero"] = "n.d."; rowProdottiPerArea["CanLastRow"] = false; rowProdottiPerArea["IsTotal"] = false; rowProdottiPerArea["IsSubTotal"] = false; ds.Tables["prodottiPerArea"].Rows.Add(rowProdottiPerArea); } #endregion #region PROPOSTO_CCN foreach (var items in PROPOSTO_CCN) { #region dettaglio dei prodotti extra alle risorse finanziarie rowProdottiPerArea = ds.Tables["prodottiPerArea"].NewRow(); rowProdottiPerArea["CodiceAreaBisogno"] = ""; rowProdottiPerArea["DescrizioneProdotto"] = items.prodotto.nomeProdotto; rowProdottiPerArea["ValoreProdotto"] = items.ctvPro; rowProdottiPerArea["ValoreProdottoString"] = Helper.FormatCurrency(rowProdottiPerArea["ValoreProdotto"].ToString()); foreach (var displayInfo in from o in displayInfos.macroAssetDisplayInfos orderby o.value.order select o) { var proposto = (from o in MacroAssetProposto.distribuzione.elencoSlice where o.codice == displayInfo.key && o.sliceRappresentabile select o).LastOrDefault(); if (proposto != null) { rowProdottiPerArea[proposto.codice] = 0; rowProdottiPerArea[proposto.codice + "String"] = Helper.FormatCurrency(rowProdottiPerArea[proposto.codice].ToString()); } } rowProdottiPerArea["FontBold"] = false; rowProdottiPerArea["ReplaceIfZero"] = "n.d."; rowProdottiPerArea["CanLastRow"] = false; rowProdottiPerArea["IsTotal"] = false; rowProdottiPerArea["IsSubTotal"] = false; ds.Tables["prodottiPerArea"].Rows.Add(rowProdottiPerArea); #endregion } #endregion #region PROPOSTO_EF foreach (var items in PROPOSTO_EF) { #region dettaglio dei prodotti extra alle risorse finanziarie rowProdottiPerArea = ds.Tables["prodottiPerArea"].NewRow(); rowProdottiPerArea["CodiceAreaBisogno"] = ""; rowProdottiPerArea["DescrizioneProdotto"] = items.prodotto.nomeProdotto; rowProdottiPerArea["ValoreProdotto"] = items.ctvPro; rowProdottiPerArea["ValoreProdottoString"] = Helper.FormatCurrency(rowProdottiPerArea["ValoreProdotto"].ToString()); foreach (var displayInfo in from o in displayInfos.macroAssetDisplayInfos orderby o.value.order select o) { var proposto = (from o in MacroAssetProposto.distribuzione.elencoSlice where o.codice == displayInfo.key && o.sliceRappresentabile select o).LastOrDefault(); if (proposto != null) { rowProdottiPerArea[proposto.codice] = 0; rowProdottiPerArea[proposto.codice + "String"] = Helper.FormatCurrency(rowProdottiPerArea[proposto.codice].ToString()); } } rowProdottiPerArea["FontBold"] = false; rowProdottiPerArea["ReplaceIfZero"] = "n.d."; rowProdottiPerArea["CanLastRow"] = false; rowProdottiPerArea["IsTotal"] = false; rowProdottiPerArea["IsSubTotal"] = false; ds.Tables["prodottiPerArea"].Rows.Add(rowProdottiPerArea); #endregion } #endregion #region PROPOSTO_ET foreach (var items in PROPOSTO_ET) { #region dettaglio dei prodotti extra alle risorse finanziarie rowProdottiPerArea = ds.Tables["prodottiPerArea"].NewRow(); rowProdottiPerArea["CodiceAreaBisogno"] = ""; rowProdottiPerArea["DescrizioneProdotto"] = items.prodotto.nomeProdotto; rowProdottiPerArea["ValoreProdotto"] = items.ctvPro; rowProdottiPerArea["ValoreProdottoString"] = Helper.FormatCurrency(rowProdottiPerArea["ValoreProdotto"].ToString()); foreach (var displayInfo in from o in displayInfos.macroAssetDisplayInfos orderby o.value.order select o) { var proposto = (from o in MacroAssetProposto.distribuzione.elencoSlice where o.codice == displayInfo.key && o.sliceRappresentabile select o).LastOrDefault(); if (proposto != null) { rowProdottiPerArea[proposto.codice] = 0; rowProdottiPerArea[proposto.codice + "String"] = Helper.FormatCurrency(rowProdottiPerArea[proposto.codice].ToString()); } } rowProdottiPerArea["FontBold"] = false; rowProdottiPerArea["ReplaceIfZero"] = "n.d."; rowProdottiPerArea["CanLastRow"] = false; rowProdottiPerArea["IsTotal"] = false; rowProdottiPerArea["IsSubTotal"] = false; ds.Tables["prodottiPerArea"].Rows.Add(rowProdottiPerArea); #endregion } #endregion //AC #region PROPOSTO_FO foreach (var items in PROPOSTO_FO) { #region dettaglio dei prodotti extra alle risorse finanziarie rowProdottiPerArea = ds.Tables["prodottiPerArea"].NewRow(); rowProdottiPerArea["CodiceAreaBisogno"] = ""; rowProdottiPerArea["DescrizioneProdotto"] = items.prodotto.nomeProdotto; rowProdottiPerArea["ValoreProdotto"] = items.ctvPro; rowProdottiPerArea["ValoreProdottoString"] = Helper.FormatCurrency(rowProdottiPerArea["ValoreProdotto"].ToString()); foreach (var displayInfo in from o in displayInfos.macroAssetDisplayInfos orderby o.value.order select o) { var proposto = (from o in MacroAssetProposto.distribuzione.elencoSlice where o.codice == displayInfo.key && o.sliceRappresentabile select o).LastOrDefault(); if (proposto != null) { rowProdottiPerArea[proposto.codice] = 0; rowProdottiPerArea[proposto.codice + "String"] = Helper.FormatCurrency(rowProdottiPerArea[proposto.codice].ToString()); } } rowProdottiPerArea["FontBold"] = false; rowProdottiPerArea["ReplaceIfZero"] = "n.d."; rowProdottiPerArea["CanLastRow"] = false; rowProdottiPerArea["IsTotal"] = false; rowProdottiPerArea["IsSubTotal"] = false; ds.Tables["prodottiPerArea"].Rows.Add(rowProdottiPerArea); #endregion } #endregion } #region Portafoglio proposto/prospettico DataRow rowProdotti = ds.Tables["prodottiPerArea"].NewRow(); //rowProdotti["CodiceAreaBisogno"] = "RF"; rowProdotti["DescrizioneProdotto"] = "Portafoglio " + (datiSeiUnico.flagAdeguatezzaPro() ? "proposto" : "prospettico"); rowProdotti["ValoreProdotto"] = datiSeiUnico.PROPOSTO_TOTALE; rowProdotti["ValoreProdottoString"] = Helper.FormatCurrency(datiSeiUnico.PROPOSTO_TOTALE.ToString()); foreach (var displayInfo in from o in displayInfos.macroAssetDisplayInfos orderby o.value.order select o) { var proposto = (from o in MacroAssetProposto.distribuzione.elencoSlice where o.codice == displayInfo.key && o.sliceRappresentabile select o).LastOrDefault(); if (proposto != null) { rowProdotti[proposto.codice] = presenzaContocorrenteInMonterio() ? isControvalore() ? proposto.ctvCC : proposto.pesoCC * 100 : isControvalore() ? proposto.ctv : proposto.peso * 100; rowProdotti[proposto.codice + "String"] = totaleRisorse ? "" : presenzaContocorrenteInMonterio() ? isControvalore() ? Helper.FormatCurrency(proposto.ctvCC.ToString()) : Helper.FormatDecimal((proposto.pesoCC * 100).ToString(), 2) : isControvalore() ? Helper.FormatCurrency(proposto.ctv.ToString()) : Helper.FormatDecimal((proposto.peso * 100).ToString(), 2); } } rowProdotti["FontBold"] = true; rowProdotti["ReplaceIfZero"] = "n.d."; rowProdotti["CanLastRow"] = false; rowProdotti["IsTotal"] = false; rowProdotti["IsSubTotal"] = true; ds.Tables["prodottiPerArea"].Rows.Add(rowProdotti); #endregion } #endregion return ds; } public virtual bool presenzaGrafico() { return GetOption().Valore; } public virtual bool presenzaDettaglioProdotti() { return GetOption().Valore; } public virtual bool presenzaContocorrenteInMonterio() { return GetOption().Valore; } public virtual bool isControvalore() { return !GetOption().Valore; } public virtual string getTesto1() { bool Adeguata = datiSeiUnico.flagAdeguatezzaPro(); string nota = ""; if (Adeguata) nota = "Nei grafici sottostanti è riportato il confronto, sulla base delle principali macro asset class finanziarie, " + "tra il patrimonio che lei attualmente detiene presso $/Banca/$ (\"portafoglio attuale\") e il patrimonio derivante dalla presente proposta (\"portafoglio proposto\"), " + "con evidenza dell'esposizione, in termini {0}, del singolo patrimonio a ciascuna macro asset class. "; else nota = "Nei grafici sottostanti è riportato il confronto, sulla base delle principali macro asset class finanziarie, " + "tra il patrimonio che lei attualmente detiene presso $/Banca/$ (\"portafoglio attuale\") e il patrimonio derivante dalle operazioni da lei " + "richieste al suo private banker (\"portafoglio prospettico\"), con evidenza dell'esposizione, in termini {0}, del singolo patrimonio a ciascuna macro asset class. "; return datiSeiUnico.FormatBanca(nota, isControvalore() ? "di controvalore" : "percentuali"); } public virtual string GetNota1() { decimal contoCorrenteNegativo = datiSeiUnico.ATTUTALE_CCN; decimal liqEligoFondiNeg = datiSeiUnico.ATTUTALE_GPELIGOFONDI; decimal liqEligoTitoliNeg = datiSeiUnico.ATTUTALE_GPELIGOTITOLI; // 20181009 AC decimal liqTuoFoglioNeg = datiSeiUnico.ATTUTALE_TUOFOGLIO; //--20181009 AC string nota = ""; string token = " "; // 20181009 AC //if (contoCorrenteNegativo != 0 || liqEligoFondiNeg != 0 || liqEligoTitoliNeg != 0) if (contoCorrenteNegativo != 0 || liqEligoFondiNeg != 0 || liqEligoTitoliNeg != 0 || liqTuoFoglioNeg != 0) //--20181009 AC { nota += "Il controvalore del portafoglio attuale esclude il saldo negativo"; if (contoCorrenteNegativo != 0) { nota += token + "dei conti correnti (" + Helper.FormatCurrencyWithSymbol(contoCorrenteNegativo.ToString()) + ")"; token = ", "; } // 20181009 AC if (liqTuoFoglioNeg != 0) { nota += token + "della liquidità sottostante Il Mio Foglio (" + Helper.FormatCurrencyWithSymbol(liqTuoFoglioNeg.ToString()) + ")"; token = ", "; } //--20181009 if (liqEligoFondiNeg != 0) { nota += token + "della liquidità sottostante la GP Eligo Fondi (" + Helper.FormatCurrencyWithSymbol(liqEligoFondiNeg.ToString()) + ")"; token = ", "; } if (liqEligoTitoliNeg != 0) { nota += token + "della liquidità sottostante la GP Eligo Titoli (" + Helper.FormatCurrencyWithSymbol(liqEligoTitoliNeg.ToString()) + ")"; token = ", "; } nota += ". "; token = ""; } var macroAssetClass = datiSeiUnico.patrimonioUnit().patrimonioCasa.macroAssetClass; decimal gradoCopertura = presenzaContocorrenteInMonterio() ? macroAssetClass.distribuzione.coverageCC * 100 : macroAssetClass.distribuzione.coverage * 100; decimal totaleNonRappr = macroAssetClass.distribuzione.totaleNonRappr; decimal contoCorrente = presenzaContocorrenteInMonterio() ? 0 : datiSeiUnico.ATTUTALE_CC; decimal partiteViaggianti = datiSeiUnico.ATTUTALE_OC; if (gradoCopertura < 100) { nota += "Grado di copertura (%) della rappresentazione grafica per macro asset class del portafoglio attuale pari a " + Helper.FormatDecimal(gradoCopertura.ToString(), 2) + ":"; token = " "; if (totaleNonRappr != 0 || contoCorrente != 0 || partiteViaggianti != 0) { nota += token + "non sono considerati"; if (totaleNonRappr != 0) { nota += token + "i prodotti non rappresentabili (" + Helper.FormatCurrencyWithSymbol(totaleNonRappr.ToString()) + ")"; token = ", "; } if (contoCorrente != 0) { nota += token + "i conti correnti (" + Helper.FormatCurrencyWithSymbol(contoCorrente.ToString()) + ")"; token = ", "; } if (partiteViaggianti != 0) { nota += token + "gli importi relativi alle operazioni in corso (" + Helper.FormatCurrencyWithSymbol(partiteViaggianti.ToString()) + ")"; token = ", "; } nota += ". "; } } return nota; } public virtual string GetNota2() { decimal contoCorrenteNegativo = datiSeiUnico.PROPOSTO_CCN; decimal liqEligoFondiNeg = datiSeiUnico.PROPOSTO_GPELIGOFONDI; decimal liqEligoTitoliNeg = datiSeiUnico.PROPOSTO_GPELIGOTITOLI; // 20181009 AC decimal liqTuoFoglioNeg = datiSeiUnico.PROPOSTO_TUOFOGLIO; //--20181009 AC string nota = ""; string token = " "; // 20181009 AC //if (contoCorrenteNegativo != 0 || liqEligoFondiNeg != 0 || liqEligoTitoliNeg != 0) if (contoCorrenteNegativo != 0 || liqEligoFondiNeg != 0 || liqEligoTitoliNeg != 0 || liqTuoFoglioNeg != 0) //--20181009 AC { nota += "Il controvalore del portafoglio " + (!datiSeiUnico.flagAdeguatezzaPro() ? "prospettico" : "proposto") + " esclude il saldo negativo"; if (contoCorrenteNegativo != 0) { nota += token + "dei conti correnti (" + Helper.FormatCurrencyWithSymbol(contoCorrenteNegativo.ToString()) + ")"; token = ", "; } // 20181009 AC if (liqTuoFoglioNeg != 0) { nota += token + "della liquidità sottostante Il Mio Foglio (" + Helper.FormatCurrencyWithSymbol(liqTuoFoglioNeg.ToString()) + ")"; token = ", "; } //--20181009 if (liqEligoFondiNeg != 0) { nota += token + "della liquidità sottostante la GP Eligo Fondi (" + Helper.FormatCurrencyWithSymbol(liqEligoFondiNeg.ToString()) + ")"; token = ", "; } if (liqEligoTitoliNeg != 0) { nota += token + "della liquidità sottostante la GP Eligo Titoli (" + Helper.FormatCurrencyWithSymbol(liqEligoTitoliNeg.ToString()) + ")"; token = ", "; } nota += ". "; token = ""; } var macroAssetClass = datiSeiUnico.propostaUnit().macroAssetClass; decimal gradoCopertura = presenzaContocorrenteInMonterio() ? macroAssetClass.distribuzione.coverageCC * 100 : macroAssetClass.distribuzione.coverage * 100; decimal totaleNonRappr = macroAssetClass.distribuzione.totaleNonRappr; decimal contoCorrente = presenzaContocorrenteInMonterio() ? 0 : datiSeiUnico.PROPOSTO_CC; decimal partiteViaggianti = datiSeiUnico.PROPOSTO_OC; if (gradoCopertura < 100) { nota += "Grado di copertura (%) della rappresentazione grafica per macro asset class del portafoglio " + (!datiSeiUnico.flagAdeguatezzaPro() ? "prospettico" : "proposto") + " pari a " + Helper.FormatDecimal(gradoCopertura.ToString(), 2) + ":"; token = " "; if (totaleNonRappr != 0 || contoCorrente != 0 || partiteViaggianti != 0) { nota += token + "non sono considerati "; if (totaleNonRappr != 0) { nota += token + "i prodotti non rappresentabili (" + Helper.FormatCurrencyWithSymbol(totaleNonRappr.ToString()) + ")"; token = ", "; } if (contoCorrente != 0) { nota += token + "i conti correnti (" + Helper.FormatCurrencyWithSymbol(contoCorrente.ToString()) + ")"; token = ", "; } if (partiteViaggianti != 0) { nota += token + "gli importi relativi alle operazioni in corso (" + Helper.FormatCurrencyWithSymbol(partiteViaggianti.ToString()) + ")"; token = ", "; } nota += ". "; } } return nota; } public virtual string getTesto2() { bool Adeguata = datiSeiUnico.flagAdeguatezzaPro(); string nota = ""; if (Adeguata) nota = "Nella tabella sottostante sono riportati i prodotti che, sulla base della presente proposta, " + "concorrono alla determinazione del suo patrimonio, con evidenza dell'esposizione, in termini {0}, " + "alle principali macro asset class finanziarie. I prodotti sono raggruppati per area di bisogno e, dove necessario, per progetto di investimento. "; else nota = "Nella tabella sottostante sono riportati i prodotti che, sulla base delle operazioni da lei richiesta al suo private banker, " + "concorrono alla determinazione del suo patrimonio, con evidenza dell'esposizione, in termini {0}, " + "alle principali macro asset class finanziarie. I prodotti sono raggruppati per area di bisogno e, dove necessario, per progetto di investimento. "; return datiSeiUnico.FormatBanca(nota, isControvalore() ? "di controvalore" : "percentuali"); } } }