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

namespace PDFGenerator.Presentation.Section
{
    public class S332 : STorta, ISezione
    {
        DataSetS332 set = new DataSetS332();

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

        #region ISezione Members

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

            set = (DataSetS332)datathread.Data.DatiSezione;


            for (int r = 0; r < set.RisorsePercentuali.Count ; r++)
            {
            #region Test


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

            base.writeSezione(datathread);

            DataThread dsParam = datathread;

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

            if (dim > ChartHeigth)
            {
                document.setLastPos(dim);
            }
            else
            {
                document.setLastPos(ChartHeigth);
            }

            #endregion

            }

        }

        public void writeSezioneCombo(DataThread datathread)
        {

            document = datathread.DocumentPDF;

            set = (DataSetS332)datathread.Data.DatiSezione;

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

            base.writeSezioneComboSX(datathread);

            if (salto)
                document.returnLastPage();

            document.setPotenzialeLastPos(datitab.GetRowDim() * datitab.getNumRow() + dim, salto);

        }

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

        #endregion
    }
}