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


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


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

        #region ISezione Members


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

            DataSetS153 set = new DataSetS153();
            set = (DataSetS153)dataThread.Data.DatiSezione;

            tabTortaTabella = set.Tables["Intermediario"];
            tabTortaTotali = set.Tables["IntermediarioTotale"];
            //tabTortaContoCorrenteBancaFideuram = set.Tables["ContoCorrenteBancaFideuram"];
            tabTotale = set.Tables["Totale"];

            

            base.writeSezione(dataThread);

           //document.setSezTitolo(dataThread.SezioneReport.Titolo);


            string nota = "";
            FormatNum formatter = new FormatNum();

            if (dataThread.TotalNegativeCurrentAccountValue != 0 && dataThread.TotalSelfNegCurrentAccountValue == 0)
            {
                nota = "(*) Il controvalore esclude il saldo negativo del conto corrente ({0} €)";
                nota = string.Format(nota, formatter.ConvertNum(dataThread.TotalNegativeCurrentAccountValue));
            }
            else if (dataThread.TotalNegativeCurrentAccountValue == 0 && dataThread.TotalSelfNegCurrentAccountValue != 0)
            {
                nota = "(*) Il controvalore esclude il saldo negativo della liquidità sottostante le linee “GP Eligo” ({0} €)";
                nota = string.Format(nota, formatter.ConvertNum(dataThread.TotalSelfNegCurrentAccountValue));
            }
            else if (dataThread.TotalNegativeCurrentAccountValue != 0 && dataThread.TotalSelfNegCurrentAccountValue != 0)
            {
                nota = "(*) Il controvalore esclude il saldo negativo del conto corrente ({0} €) e il saldo negativo della liquidità sottostante le linee “GP Eligo” ({1} €)";
                nota = string.Format(nota, formatter.ConvertNum(dataThread.TotalNegativeCurrentAccountValue), formatter.ConvertNum(dataThread.TotalSelfNegCurrentAccountValue));
            }

            if (!nota.Equals(""))
            {
                document.setSezFooter(nota, dim+15, 0, 7);
                dim += 15;
            }


            //if (dataThread.TotalNegativeCurrentAccountValue != 0)
            //{
            //    FormatNum formatter = new FormatNum();
            //    string ccneg = formatter.ConvertNum(dataThread.TotalNegativeCurrentAccountValue);
            //    document.setSezFooter(string.Format(Resource.S1_DiagnosesFootNote, ccneg), dim, 0, 7);
            //    dim += 15;
            //}

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


        }

        #endregion
    }
}