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 S32 : STorta, ISezione {


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

        #region ISezione Members

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

            DataSetS32 set = (DataSetS32)datathread.Data.DatiSezione;

            tabTortaTabella = set.Tables["MacroAssetClass"];
            tabTortaTotali = set.Tables["MacroAssetTotale"];

            tabTortaPatrimonioNonRappresentabile = set.Tables["PatrimonioNonRappresentabile"];

            tabTotale = set.Tables["Totale"];

            base.writeSezione(datathread);

            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;

            DataSetS32 set = (DataSetS32)datathread.Data.DatiSezione;

            tabTortaTabella = set.Tables["MacroAssetClass"];
            tabTortaTotali = set.Tables["MacroAssetTotale"];

            tabTortaPatrimonioNonRappresentabile = set.Tables["PatrimonioNonRappresentabile"];

            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);
        }

    }
}