using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Collections; using ceTe.DynamicPDF; using ceTe.DynamicPDF.Text; using PDFGenerator.Presentation.Section.Tables; using PDFGenerator.BusinessLayer.DataSection; using PDFGenerator.BusinessLayer; using ContrattoSei.Utilities; using ceTe.DynamicPDF.PageElements; namespace PDFGenerator.Presentation.Section { class S151 : ISezione { private string _header = ""; public string Header { get { return _header; } set { _header = value; } } private TipoReport _tipologiaReport; public TipoReport TipologiaReport { get { return _tipologiaReport; } set { _tipologiaReport = value; } } private string _testoIntroduttivo = string.Empty; public string TestoIntroduttivo { get { return _testoIntroduttivo; } set { _testoIntroduttivo = value; } } private string _testoChiusura = string.Empty; public string TestoChiusura { get { return _testoChiusura; } set { _testoChiusura = value; } } public S151() { // // TODO: Add constructor logic here // } #region ISezione Members public void writeSezione(DataThread dataThread) { DocumentPDF document = dataThread.DocumentPDF; DataSetS151 set = (DataSetS151)dataThread.Data.DatiSezione; document.setSezTitoloDiagnosi(dataThread.SezioneReport.Titolo,"S151"); //MIFID2 20180709 Modifica testo introduttivo // string tempTesto = dataThread.SezioneReport.TestoIntroduttivo; string tempTesto = dataThread.IsProffesionalClient ? dataThread.SezioneReport.TestoIntroduttivoAlternativo : dataThread.SezioneReport.TestoIntroduttivo; //--MIFID2 // MIFID2 20180405 //if (dataThread.Rete.ToUpper() == "S") // tempTesto = tempTesto.Replace("Fideuram", "Sanpaolo Invest"); //document.setChapterHeader(tempTesto, 0, 520, 8); document.setChapterHeader(tempTesto.Replace("/$Banca$/", dataThread.NomeRete).Replace("Sanpaolo Invest", "Fideuram S.p.A., tramite la rete di private banker Sanpaolo Invest,"), 0, 520, 8,"S151"); //--MIFID2 20180405 #region profilofinanziario DatiTabella profilofinanziarioDatiTab = new DatiTabella(); profilofinanziarioDatiTab.table = set.Tables["Profilofinanziario"]; //MIFID2 Correzioni 20180626 profilofinanziarioDatiTab.SetRowDim(40); //--MIFID2 profilofinanziarioDatiTab.setIsLinee(1); profilofinanziarioDatiTab.setCell(210, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, true); //profilofinanziarioDatiTab.setCell(273, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false); profilofinanziarioDatiTab.setCell(300, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false,8); profilofinanziarioDatiTab.setX(document.getMargineLeft()); Tabella profilofinanziarioTab = new Tabella(); if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") profilofinanziarioTab.HeaderFont = 8; profilofinanziarioTab.LineaFineTabella = true; # endregion # region ProfiloRischio DatiTabella datitab = new DatiTabella(); Tabella tab = new Tabella(); tab.LineaFineTabella = false; // MIFID2 20180406 Per diagnosi vanno escluse le righe "Rischio Credito massimo" ed "experience" if (dataThread.ReportType().TipoReport == TipoReport.MONITORAGGIO) { datitab.table = set.Tables["ProfiloRischio"]; datitab.setIsLinee(1); datitab.setX(document.getMargineLeft() + 45); datitab.setCell(210, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, true); datitab.setCell(300, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false,8); } else { tab.HeaderFont = 8; // modifiche Diagnosi CR 2023_05_09 Report Diagnosi SEI_FID_MUA+ESG.pptx: 23 giu 2023 //if (dataThread.IsProffesionalClient) // datitab.table = set.Tables["ProfiloRischio"].AsEnumerable().Where( // x => x.Field("Descrizione").ToLower() != "rischio credito massimo" // && x.Field("Descrizione").ToLower() != "experince" // && x.Field("Descrizione").ToLower() != "livello di esperienza e conoscenza in materia di investimenti" // ).CopyToDataTable(); //else datitab.table = set.Tables["ProfiloRischio"].AsEnumerable().Where( x => x.Field("Descrizione").ToLower() != "rischio credito massimo" && x.Field("Descrizione").ToLower() != "experince" ).CopyToDataTable(); datitab.setIsLinee(1); datitab.setX(document.getMargineLeft()); datitab.setCell(210, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, true); //datitab.setCell(273, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false); datitab.setCell(300, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false,8); } //MIFID2 Correzioni 20180626 datitab.SetRowDim(30); //--MIFID2 # endregion # region ProfiloDate DatiTabella ProfiloDateDatiTab = new DatiTabella(); ProfiloDateDatiTab.table = set.Tables["ProfiloDate"]; ProfiloDateDatiTab.setIsLinee(1); ProfiloDateDatiTab.setCell(210, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdanaB, true); //ProfiloDateDatiTab.setCell(273, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false); ProfiloDateDatiTab.setCell(300, ceTe.DynamicPDF.TextAlign.Left, Globals.OpenTypeFontVerdana, false,8); ProfiloDateDatiTab.setX(document.getMargineLeft()); Tabella ProfiloDateTab = new Tabella(); if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") ProfiloDateTab.HeaderFont = 8; ProfiloDateTab.LineaFineTabella = true; //MIFID2 Correzioni 20180626 ProfiloDateDatiTab.SetRowDim(30); //--MIFID2 # endregion var currentY = document.getLastPos() - 30; profilofinanziarioDatiTab.setY(currentY); document.InsertTable(profilofinanziarioTab.getTabella(profilofinanziarioDatiTab)); // MIFID2 20180406 differenzio tra monitoraggio e diagnosi float yFooter; ceTe.DynamicPDF.Merger.ImportedPage page = document.getCurrentPage(); if (dataThread.ReportType().TipoReport == TipoReport.MONITORAGGIO) { //float ydatitab = document.getLastPos() + profilofinanziarioDatiTab.getNumRow() * profilofinanziarioDatiTab.GetRowDim(); currentY = currentY + profilofinanziarioDatiTab.getNumRow() * profilofinanziarioDatiTab.GetRowDim(); datitab.setY(currentY); //float yProfiloDateDatiTab = ydatitab + (datitab.getNumRow() - 1) * datitab.GetRowDim(); currentY = currentY + (datitab.getNumRow() - 1) * datitab.GetRowDim(); ProfiloDateDatiTab.setY(currentY); //float yFooter = yProfiloDateDatiTab + ProfiloDateDatiTab.getNumRow() * ProfiloDateDatiTab.GetRowDim() ; yFooter = ProfiloDateDatiTab.GetRowDim() * 4; } else { //float yProfiloDateDatiTab = document.getLastPos() + (profilofinanziarioDatiTab.getNumRow() * profilofinanziarioDatiTab.GetRowDim()); currentY = currentY + (profilofinanziarioDatiTab.getNumRow() * profilofinanziarioDatiTab.GetRowDim()) - 10; //ProfiloDateDatiTab.setY(yProfiloDateDatiTab); ProfiloDateDatiTab.setY(currentY); //float ydatitab = yProfiloDateDatiTab + (ProfiloDateDatiTab.getNumRow() * ProfiloDateDatiTab.GetRowDim()); //document.getLastPos() + profilofinanziarioDatiTab.getNumRow() * profilofinanziarioDatiTab.GetRowDim(); currentY = currentY + (ProfiloDateDatiTab.getNumRow() * ProfiloDateDatiTab.GetRowDim()); //document.getLastPos() + profilofinanziarioDatiTab.getNumRow() * profilofinanziarioDatiTab.GetRowDim(); datitab.setY(currentY); //float yFooter = yProfiloDateDatiTab + ProfiloDateDatiTab.getNumRow() * ProfiloDateDatiTab.GetRowDim() ; //yFooter = ydatitab + (datitab.GetRowDim() * datitab.getNumRow()); yFooter = (currentY + (datitab.GetRowDim() * datitab.getNumRow())-15); } decimal totalePartiteViaggianti = dataThread.PartiteViaggiantiInvestimento + dataThread.PartiteViaggiantiDisinvestimento; FormatNum conv = new FormatNum(); //IMPORTANT //V When doing S95 Remove from here and make the right value into the DSS95 datitab.table.Rows[0]["Valore"] = conv.ConvertNum(Convert.ToDouble(datitab.table.Rows[0]["Valore"])) + "%"; if (dataThread.ReportType().TipoReport == TipoReport.MONITORAGGIO) { string relativePath = UtilityManager.getAppSetting("Slider"); System.Reflection.Assembly thisExe; thisExe = System.Reflection.Assembly.GetExecutingAssembly(); System.IO.Stream fileSlider = thisExe.GetManifestResourceStream(relativePath); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(fileSlider, 57 + 150 + 85 + 25, document.getLastPos() + datitab.GetRowDim() * 0.7F, 0.25F)); //datitab.setY(document.getLastPos()); relativePath = UtilityManager.getAppSetting("SliderRischioCredito"); System.IO.Stream fileRischioCreditoSlider = thisExe.GetManifestResourceStream(relativePath); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(fileRischioCreditoSlider, 57 + 150 + 85 + 25, document.getLastPos() + datitab.GetRowDim() * 0.7F + datitab.GetRowDim(), 0.25F)); relativePath = UtilityManager.getAppSetting("MarkerLarge"); System.IO.Stream fileMarker = thisExe.GetManifestResourceStream(relativePath); float VaRMassimo = Convert.ToSingle(datitab.table.Rows[0]["Valore"]); float xMarker = getX(VaRMassimo.ToString()); float yMarker = document.getLastPos() + datitab.GetRowDim() * 0.7F; string note = string.Empty; note = getExperinceLevel(datitab.table.Rows[2]["Valore"].ToString(), dataThread.NomeRete); datitab.table.Rows[2].Delete(); document.InsertTable(tab.getTabella(datitab)); document.InsertTable(ProfiloDateTab.getTabella(ProfiloDateDatiTab)); if (dataThread.TotalNegativeCurrentAccountValue >= 0 && totalePartiteViaggianti == 0) { #region TOTALE PATRIMONIO page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(string.Format(Resource.S95_NotaOperazioniInCorsZero, dataThread.NomeRete), ProfiloDateDatiTab.getX(), document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 4, 500F, 30F, Globals.OpenTypeFontVerdana, 8)); DatiTabella totalitab = new DatiTabella(); totalitab.table = set.Tables["Totali"]; Tabella tabellaTotale = new Tabella(document.getMargineLeft(), document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 7); if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tabellaTotale.HeaderFont = 8; tabellaTotale.SaltoPagina = false; tabellaTotale.Header = false; tabellaTotale.Colonne.Add(new Colonna("Descrizione", "", 130, TipoAllineamento.SINISTRA, true, 9, true)); tabellaTotale.Colonne.Add(new Colonna("Controvalore", "", 150, TipoAllineamento.DESTRA, true, 9, true)); tabellaTotale.Draw(totalitab, document); document.setSezFooter(string.Format(Resource.S95_Monitoring_Note, dataThread.NomeRete).Replace("Sanpaolo Invest", "Fideuram S.p.A., tramite la rete di private banker Sanpaolo Invest").Replace("Sanpaolo Invest", "Fideuram S.p.A., commercializzato tramite la rete di private banker Sanpaolo Invest") + " " + note, ProfiloDateDatiTab.GetRowDim() * 6 + totalitab.GetRowDim(), 0, 9); #endregion } else if (dataThread.TotalNegativeCurrentAccountValue < 0 && totalePartiteViaggianti == 0) { page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(string.Format(Resource.S95_NotaOperazioniInCorsoZero_CCNegativo, dataThread.NomeRete), ProfiloDateDatiTab.getX(), document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 4, 500F, 30F, Globals.OpenTypeFontVerdana, 8)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Line(document.getMargineLeft() - 5, document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 4 + 30, document.getMargineLeft() + 285, document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 4 + 30, 2F, new RgbColor(232, 236, 237))); DatiTabella ctvdatitab = new DatiTabella(); ctvdatitab.table = set.Tables["Dati"]; Tabella tabellaDati = new Tabella(document.getMargineLeft(), document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 7); if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tabellaDati.HeaderFont = 8; tabellaDati.DimensioneLinea = 2; tabellaDati.Colonne.Add(new Colonna("Descrizione", "", 130, TipoAllineamento.SINISTRA, false, 8, false)); tabellaDati.Colonne.Add(new Colonna("Controvalore", "", 150, TipoAllineamento.DESTRA, false, 8, false)); tabellaDati.Draw(ctvdatitab, document); DatiTabella totalitab = new DatiTabella(); totalitab.table = set.Tables["Totali"]; Tabella tabellaTotale = new Tabella(document.getMargineLeft(), document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 7 + datitab.GetRowDim() * 2); if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tabellaTotale.HeaderFont = 8; tabellaTotale.Colonne.Add(new Colonna("Descrizione", "", 130, TipoAllineamento.SINISTRA, true, 9, true)); tabellaTotale.Colonne.Add(new Colonna("Controvalore", "", 150, TipoAllineamento.DESTRA, true, 9, true)); tabellaTotale.Draw(totalitab, document); document.setSezFooter(string.Format(Resource.S95_Monitoring_Note, dataThread.NomeRete).Replace("Sanpaolo Invest", "Fideuram S.p.A., tramite la rete di private banker Sanpaolo Invest") + " " + note, ProfiloDateDatiTab.GetRowDim() * 6 + datitab.GetRowDim() * 2 + totalitab.GetRowDim(), 0, 9); } else if (dataThread.TotalNegativeCurrentAccountValue < 0 && totalePartiteViaggianti != 0) { page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(string.Format(Resource.S95_NotaOperazioniInCorsoNotZero_CCNegativo, dataThread.NomeRete), ProfiloDateDatiTab.getX(), document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 4, 500F, 30F, Globals.OpenTypeFontVerdana, 8)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Line(document.getMargineLeft() - 5, document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 4 + 30, document.getMargineLeft() + 285, document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 4 + 30, 2F, new RgbColor(232, 236, 237))); DatiTabella ctvdatitab = new DatiTabella(); ctvdatitab.table = set.Tables["Dati"]; Tabella tabellaDati = new Tabella(document.getMargineLeft(), document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 7); if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tabellaDati.HeaderFont = 8; tabellaDati.DimensioneLinea = 2; tabellaDati.Colonne.Add(new Colonna("Descrizione", "", 130, TipoAllineamento.SINISTRA, false, 9, false)); tabellaDati.Colonne.Add(new Colonna("Controvalore", "", 150, TipoAllineamento.DESTRA, false, 9, false)); tabellaDati.Draw(ctvdatitab, document); DatiTabella totalitab = new DatiTabella(); totalitab.table = set.Tables["Totali"]; Tabella tabellaTotale = new Tabella(document.getMargineLeft(), document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 7 + datitab.GetRowDim() * 3); if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tabellaTotale.HeaderFont = 8; tabellaTotale.Colonne.Add(new Colonna("Descrizione", "", 130, TipoAllineamento.SINISTRA, true, 9, true)); tabellaTotale.Colonne.Add(new Colonna("Controvalore", "", 150, TipoAllineamento.DESTRA, true, 9, true)); tabellaTotale.Draw(totalitab, document); document.setSezFooter(string.Format(Resource.S95_Monitoring_Note, dataThread.NomeRete).Replace("Sanpaolo Invest", "Fideuram S.p.A., tramite la rete di private banker Sanpaolo Invest") + " " + note, ProfiloDateDatiTab.GetRowDim() * 6 + datitab.GetRowDim() * 3 + totalitab.GetRowDim(), 0, 9); } else if (dataThread.TotalNegativeCurrentAccountValue == 0 && totalePartiteViaggianti != 0) { page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(string.Format(Resource.S95_NotaOperazioniInCorsoNotZero_CCNegativo, dataThread.NomeRete), ProfiloDateDatiTab.getX(), document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 4, 500F, 30F, Globals.OpenTypeFontVerdana, 8)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Line(document.getMargineLeft() - 5, document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 4 + 30, document.getMargineLeft() + 285, document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 4 + 30, 2F, new RgbColor(232, 236, 237))); DatiTabella ctvdatitab = new DatiTabella(); ctvdatitab.table = set.Tables["Dati"]; Tabella tabellaDati = new Tabella(document.getMargineLeft(), document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 7); if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tabellaDati.HeaderFont = 8; tabellaDati.DimensioneLinea = 2; tabellaDati.Colonne.Add(new Colonna("Descrizione", "", 130, TipoAllineamento.SINISTRA, false, 9, false)); tabellaDati.Colonne.Add(new Colonna("Controvalore", "", 150, TipoAllineamento.DESTRA, false, 9, false)); tabellaDati.Draw(ctvdatitab, document); DatiTabella totalitab = new DatiTabella(); totalitab.table = set.Tables["Totali"]; Tabella tabellaTotale = new Tabella(document.getMargineLeft(), document.getLastPos() + ProfiloDateDatiTab.GetRowDim() * 7 + datitab.GetRowDim() * 2); if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tabellaTotale.HeaderFont = 8; tabellaTotale.Colonne.Add(new Colonna("Descrizione", "", 130, TipoAllineamento.SINISTRA, true, 9, true)); tabellaTotale.Colonne.Add(new Colonna("Controvalore", "", 150, TipoAllineamento.DESTRA, true, 9, true)); tabellaTotale.Draw(totalitab, document); document.setSezFooter(string.Format(Resource.S95_Monitoring_Note, dataThread.NomeRete).Replace("Sanpaolo Invest", "Fideuram S.p.A., tramite la rete di private banker Sanpaolo Invest") + " " + note, ProfiloDateDatiTab.GetRowDim() * 6 + datitab.GetRowDim() * 2 + totalitab.GetRowDim(), 0, 9); } document.setLastPos(yFooter + 30); } else { // MIFID 2 20180405 Invertite le tabelle //datitab.table.Rows[2].Delete(); //document.InsertTable(tab.getTabella(datitab)); //document.InsertTable(ProfiloDateTab.getTabella(ProfiloDateDatiTab)); document.InsertTable(ProfiloDateTab.getTabella(ProfiloDateDatiTab)); document.InsertTable(tab.getTabella(datitab)); //nota statica sotto tabella string nota = "(*) Maggiori dettagli nella sezione «Avvertenze e Glossario»"; FormattedTextArea text = new FormattedTextArea(nota, document.getMargineLeft(), yFooter, 510, 0, new ceTe.DynamicPDF.FontFamily("pipp", Globals.OpenTypeFontVerdana, Globals.OpenTypeFontVerdanaB, Globals.OpenTypeFontVerdanaZ, Globals.OpenTypeFontVerdanaZ), 7, false); text.Height = text.GetRequiredHeight(); text.Style.Paragraph.Align = ceTe.DynamicPDF.TextAlign.Justify; page.Elements.Add(text); //document.setLastPos((ProfiloDateDatiTab.getNumRow() * ProfiloDateDatiTab.GetRowDim()) + (datitab.GetRowDim() * datitab.getNumRow()) + text.Height + 30); document.setLastPos((ProfiloDateDatiTab.getNumRow() * ProfiloDateDatiTab.GetRowDim()) + (datitab.GetRowDim() * datitab.getNumRow()) + text.Height); //--MIFID 2 } // MIFID 2 20180405 eliminata immagine //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Image(fileMarker, xMarker, yMarker, 0.25F)); //--MIFID 2 20180405 } #endregion /// /// Ritorna la x sulla quale andrà posizionato il marker (barra nera) in funzione del VaR massimo del profilo. /// Il posizionamento della x in questa sezione è fisso e non graduale. /// La funzione è valida per le fasce di profilo 1.5 , 3.5 , 7.5 , 12 , 23 /// /// var massimo del profilo /// private float getX(string varmassimo) { float xPartenza = 292; if (varmassimo == SoglieVar.sVar1) return xPartenza + 7 + 25; if (varmassimo == SoglieVar.sVar2) return xPartenza + 21 + 25; if (varmassimo == SoglieVar.sVar3) return xPartenza + 42 + 25; if (varmassimo == SoglieVar.sVar4) return xPartenza + 70 + 25; if (varmassimo == SoglieVar.sVar5 || varmassimo == "50" || varmassimo == "50,00") return xPartenza + 107 + 25; return xPartenza; } /// /// Return the Experince Level depending on the passed value /// Marian Zaki /// 04052010 /// /// /// case 1: low /// case 2: medium /// case 3: high /// /// The footer note depend on the experince level private string getExperinceLevel(string experinceLevel, string reteName) { int experinceLevelValue; string experinceLevelName = string.Empty; if (int.TryParse(experinceLevel, out experinceLevelValue)) { switch (experinceLevel) { case "1": //experinceLevelName = Resource.S95_Monitoring_Note_ExperinceLevel_Low; experinceLevelName = string.Format(Resource.S95_Monitoring_Note_ExperinceLevel_Low, reteName); break; case "2": //experinceLevelName = Resource.S95_Monitoring_Note_ExperinceLevel_Medium; experinceLevelName = string.Format(Resource.S95_Monitoring_Note_ExperinceLevel_Medium, reteName); break; case "3": //experinceLevelName = Resource.S95_Monitoring_Note_ExperinceLevel_High; experinceLevelName = string.Format(Resource.S95_Monitoring_Note_ExperinceLevel_High, reteName); break; default: experinceLevelName = string.Empty; break; } return experinceLevelName; } else return string.Empty; } } }