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.BusinessLayer.DataSection;
using PDFGenerator.BusinessLayer;

namespace PDFGenerator.Presentation.Section {
    public class S2 : STorta, ISezione {

        DataSetS2 set = new DataSetS2();

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

        #region ISezione Members

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

            set = (DataSetS2)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.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);
            }

        }

        public void writeSezioneCombo(DataThread datathread)
        {

            document = datathread.DocumentPDF;

            set = (DataSetS2)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
    }
}