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;
using System.Threading;
using System.Globalization;

namespace PDFGenerator.Presentation.Section
{
    class S138
    {
        public void writeSezione(DataThread dataThread)   {

            DocumentPDF document = dataThread.DocumentPDF;
            DataSetS138 set = (DataSetS138)dataThread.Data.DatiSezione;
            DatiTabella datiTabella =  new DatiTabella(set.Proventi);

            

            document.setSezTitolo(dataThread.SezioneReport.Titolo);
            document.setChapterHeader(dataThread.SezioneReport.TestoIntroduttivo.Replace("/$Banca$/", dataThread.NomeRete).Replace("Sanpaolo Invest", "Fideuram S.p.A., commercializzati tramite la rete di private banker Sanpaolo Invest"), 0, 520, 8);

             
            

            #region TABLE PROVENTI
                  

            Tabella tabellaDati = new Tabella(document.getMargineLeft(), document.getLastPos());
            tabellaDati.HeaderFont = 8;
            tabellaDati.Header = true;
            tabellaDati.Colonne.Add(new Colonna("DTRIFE", "Data", 100, TipoAllineamento.SINISTRA, false, 7, false));
            tabellaDati.Colonne.Add(new Colonna("DESPROD", "Strumento", 222, TipoAllineamento.SINISTRA, false, 7, false));
            tabellaDati.Colonne.Add(new Colonna("TIPMOV", "Tipo Movimento", 80, TipoAllineamento.SINISTRA, false, 7, false));
            // FIX 20180828 Allineamento della tabella
            //tabellaDati.Colonne.Add(new Colonna("IMPORTO", "Importo (€)", 100, TipoAllineamento.DESTRA, false, 7, false));
            tabellaDati.Colonne.Add(new Colonna("IMPORTO", "Importo (€)", 110, TipoAllineamento.DESTRA, false, 7, false));
            //--FIX 20180828 Allineamento della tabella


            tabellaDati.Draw(datiTabella, document);

            #endregion

            document.setLastPos(tabellaDati.AltezzaTabella);

            #region TOTALE 

            DatiTabella totalitab = new DatiTabella();
            totalitab.table = set.Totale;

            Tabella tabellaTotale = new Tabella(document.getMargineLeft(), document.getLastPos());
            tabellaTotale.HeaderFont = 8;
            tabellaTotale.SaltoPagina = false;
            tabellaTotale.Header = false;

            // FIX 20180828 Allineamento della tabella
            //tabellaTotale.Colonne.Add(new Colonna("Descrizione", "", 380, TipoAllineamento.SINISTRA, true, 8, true));
            //tabellaTotale.Colonne.Add(new Colonna("Totale", "", 132, TipoAllineamento.DESTRA, true, 8, true));

            tabellaTotale.Colonne.Add(new Colonna("Descrizione", "", 402, TipoAllineamento.SINISTRA, true, 8, true));
            tabellaTotale.Colonne.Add(new Colonna("Totale", "", 110, TipoAllineamento.DESTRA, true, 8, true));
            //--FIX 20180828 Allineamento della tabella

            tabellaTotale.Draw(totalitab, document);

            #endregion 

            document.setLastPos(tabellaTotale.AltezzaTabella);           

             
        }
    }
}