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


namespace PDFGenerator.Presentation.Section
{
    public class S26 : ISezione
    {

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

        #region ISezione Members

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

            //aggiorna l'indice
            if (dataThread.TipoReport.ToUpper() == "DIAGNOSI")
                document.setSezTitoloDiagnosi(dataThread.SezioneReport.Titolo);
            else
                document.setSezTitolo(dataThread.SezioneReport.Titolo);
            document.setSezHeader("Di seguito viene fornito il dettaglio delle sue propriet� immobiliari.");
            document.setHeaderSpace(5);

            DatiTabella datitab = new DatiTabella();
            Tabella tab = new Tabella(document.getMargineLeft(), document.getLastPos());
            if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tab.HeaderFont = 8;
            tab.Header = true;
            tab.Datasource = datitab.table;

            DataSetS26 set = (DataSetS26)dataThread.Data.DatiSezione;
            datitab.table = set.Tables["Patrimonio"];

            datitab.setY(document.getLastPos());
            datitab.setIsLinee(1);

            tab.Colonne.Add(new Colonna("Descrizione", "Descrizione", 200, TipoAllineamento.SINISTRA, false, 7, false));
            //tabellaDati.Colonne.Add(new Colonna("Tipologia", "Tipologia", 100, TipoAllineamento.SINISTRA, false, 7, false));
            tab.Colonne.Add(new Colonna("Localita", "Localit�", 132, TipoAllineamento.SINISTRA, false, 7, false));
            tab.Colonne.Add(new Colonna("Affitti", "Affitto annuo<br>percepito (�)", 86, TipoAllineamento.DESTRA, false, 7, false));
            //7 spazi per allineare il simbolo dell'euro al centro
            tab.Colonne.Add(new Colonna("Valore", "Valore Stimato<br>(�)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", 92, TipoAllineamento.DESTRA, false, 7, false));

            datitab.setCellSpace(0);

            //setta posizione tabella
            tab.Draw(datitab, document);

            float dim = datitab.GetRowDim() * (datitab.getNumRow() + 1);

            #region Tabella Totale
            datitab = new DatiTabella();

            Tabella tabellaTotale = new Tabella(document.getMargineLeft(), document.getLastPos() + tab.AltezzaTabella + 25);
            if (dataThread.TipoReport.ToUpper() == "DIAGNOSI") tabellaTotale.HeaderFont = 8;
            tabellaTotale.SaltoPagina = false;
            tabellaTotale.Header = false;
            tabellaTotale.Datasource = set.Tables["TotalePatrimonio"];
            datitab.table = set.Tables["TotalePatrimonio"];

            tabellaTotale.Colonne.Add(new Colonna("Descrizione", "", 332, TipoAllineamento.SINISTRA, true, 8, true));
            tabellaTotale.Colonne.Add(new Colonna("TotaleAffitto", "", 86, TipoAllineamento.DESTRA, true, 8, true));
            tabellaTotale.Colonne.Add(new Colonna("Valore", "", 92, TipoAllineamento.DESTRA, true, 8, true));

            tabellaTotale.Draw(datitab, document);

            #endregion

            ///// setto la posizione aggiornata
            document.setLastPos(datitab.GetRowDim() + dim);

        }

        #endregion
    }
}