using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using PDFGenerator.Presentation.Section.Tables;
using PDFGenerator.BusinessLayer.DataSection;
using PDFGenerator.BusinessLayer;
using ceTe.DynamicPDF.PageElements;
using ceTe.DynamicPDF.Text;


/// <summary>
/// Summary description for S103
/// </summary>
/// 
namespace PDFGenerator.Presentation.Section
{


    public class S131 : ISezione
    {
        private string _titolo = string.Empty;
        private string _testointroduttivo = string.Empty;

        /// <summary>
        /// Titolo della sezione
        /// </summary>
        public string Titolo
        {
            get
            {
                return _titolo;
            }
            set
            {
                _titolo = value;
            }
        }


        /// <summary>
        /// Testo introduttivo della Sezione.
        /// </summary>
        public string TestoIntroduttivo
        {
            get
            {
                return _testointroduttivo;
            }
            set
            {
                _testointroduttivo = value;
            }
        }


        public S131()
        {
            //
            // TODO: Add constructor logic here
            //
        }


        public void writeSezione(DataThread dataThread)
        {
            DocumentPDF document = dataThread.DocumentPDF;
            DataSetS131 set = (DataSetS131)dataThread.Data.DatiSezione;

            if (document.checkMargin(95))
                document.addPage();

            document.setSezTitolo(dataThread.SezioneReport.Titolo); 

            string tempTesto = dataThread.SezioneReport.TestoIntroduttivo;
            if (dataThread.IsProffesionalClient)
                tempTesto = "Di seguito sono riportati i prodotti che contribuiscono maggiormente alla determinazione del livello di Rischio Mercato (VaR) del patrimonio che lei detiene presso Fideuram, con indicazione del controvalore, del Rischio Mercato (VaR) e del relativo contributo percentuale alla determinazione del Rischio Mercato (VaR) dell’intero patrimonio (“rischio relativo”).";

            //if (dataThread.Rete.ToUpper() == "S")
            //    tempTesto = tempTesto.Replace("Fideuram", "Sanpaolo Invest");

            //**************************** Cecco modifiche dicitura IWBANK*******************
            if (dataThread.Rete.ToUpper() == "S")
                //Rosaspina Andrea 
            //    tempTesto = tempTesto.Replace("Fideuram", "Fideuram S.p.A");
            tempTesto = tempTesto.Replace("Fideuram", "Fideuram S.p.A., commercializzato tramite la rete di private banker Sanpaolo Invest");
           // tempTesto = tempTesto.Replace("Fideuram", "Sanpaolo Invest");
            else if (dataThread.Rete.ToUpper() == "W")
                tempTesto = tempTesto.Replace("Fideuram", "IW Private Investments");
            //****************************************************************************

            document.setChapterHeader(tempTesto, 0, 520, 8);


            float YTable = document.getLastPos() - 8;
            float XTable = document.getMargineLeft();  

            DatiTabella datitab = new DatiTabella();
            datitab.table = set.Tables["Prodotti"];
            datitab.SetRowDim(14); //15
            Tabella tabellaDati = new Tabella(XTable, YTable);

            tabellaDati.LineaFineTabella = true;

            tabellaDati.Header = true;
            tabellaDati.AltezzaCella = 14; //15
            tabellaDati.Datasource = datitab.table;
            tabellaDati.Colonne.Add(new Colonna("Prodotto", "Prodotto", 242, TipoAllineamento.SINISTRA, false, 9, false));
            tabellaDati.Colonne.Add(new Colonna("Controvalore", "Controvalore (€)", 85, TipoAllineamento.DESTRA, false, 9, false));
            tabellaDati.Colonne.Add(new Colonna("RischioMercato", "Rischio Mercato (VAR %)", 100, TipoAllineamento.DESTRA, false, 9, false));
            tabellaDati.Colonne.Add(new Colonna("RischioRelativo", "Rischio Relativo (%)", 85, TipoAllineamento.DESTRA, false, 9, false));
            tabellaDati.IgnoreLimitYOffset = 150;
            tabellaDati.Draw(datitab, document);





            bool notaNeeded = false;
            if (notaNeeded)            
                document.getCurrentPage().Elements.Add(new Label(Resource.Nota_TabellaEmittenti, XTable, YTable + tabellaDati.AltezzaTabella, 500F, 30F, Globals.OpenTypeFontVerdana, 8));
                 
            
           

        
          


            document.addPage();
        }

               


    }

}