using System;
using System.Collections.Generic;
using System.Text;

using ceTe.DynamicPDF.Merger;
using PDFGenerator.BusinessLayer.DataSection;
using PDFGenerator.Presentation.Section.Tables;
using PDFGenerator.BusinessLayer;

namespace PDFGenerator.Presentation.Section
{
    public class S86 : STorta, ISezione
    {
        DataSetS86 set = new DataSetS86();
        bool _hasselectedpatrimnonrap;


        public bool HasSelectedPatrimNonRap
        {
            set { _hasselectedpatrimnonrap = value; }
            get { return _hasselectedpatrimnonrap; }

        }

        public new void writeSezione(DataThread dataThread)
        {
            DocumentPDF document = dataThread.DocumentPDF;

            set = (DataSetS86)dataThread.Data.DatiSezione;

            tabTortaTabella = set.Tables["MacroAssetClass"];
            tabTortaTotali = set.Tables["MacroAssetTotale"];
            tabTortaPatrimonioNonRappresentabile = set.Tables["PatrimonioNonRappresentabile"];
            tabTortaContoCorrenteBancaFideuram = set.Tables["ContoCorrenteBancaFideuram"];
            tabTotale = set.Tables["Totale"];

            this.NoIndicizzato = true;           

            base.writeSezione(dataThread);

            ///// AGGIORNO POSIZIONE CURSORE NEL DOCUMENTO E INSERISCO LA NOTA
            if (set.Tables["PatrimonioNonRappresentabile"].Rows.Count > 0 && _hasselectedpatrimnonrap)
            {
                if (dim > ChartHeigth)
                    this.addNota(document, (int)dim);
                else
                {
                    if(base._saltopaginaeffettuato)
                        this.addNota(document, (int)dim);
                    else
                        this.addNota(document, ChartHeigth);

                }
                
            }
            //V since after S86 we must have a new page we dont update last pos but we add a new page
            /*if (dim > ChartHeigth)            
                document.setLastPos(dim);            
            else           
                document.setLastPos(ChartHeigth);*/
            document.addPage();
            //V Aggiorno l'indicazione dell'ultima sezione stampata
            dataThread.UltimaSezioneStampata = string.Empty;
        }



        private void addNota(DocumentPDF doc, int dim)
        {
            doc.setSezFooter("(*) Il dettaglio del Patrimonio non rappresentabile per Asset class viene riportato nel capitolo ''Patrimonio non rappresentabile''", dim);
        }

    }
}