using System;
using Consulenza.ReportWriter.Business;
using Consulenza.ReportWriter.Business.OBJ_PDF;
using Consulenza.ReportCommon;
using System.Data;

namespace Consulenza.ReportWriter.Manager.Section.Base.Proposta
{
    public class Copertina : Entity.Section
    {
        public Copertina(EnvironmentFacade environmentFacade, int idSection)
            : base(environmentFacade, idSection)
        {
            try
            {
                Draw();
            }
            catch (Exception ex)
            {
                SectionLogger.Write("Copertina", ex.Message, SectionLoggerMessageLevel.E, EnvironmentFacade.ReportEnvironment);
            }
        }

        protected override sealed void Draw()
        {
            var nomeCliente = Helper.CapitalizeWords(EnvironmentFacade.ReportEnvironment.Cliente.Nome);
            var cognomeCliente = Helper.CapitalizeWords(EnvironmentFacade.ReportEnvironment.Cliente.Cognome);
            
            
            var dataStampa = new FormattedTextAreaPDF("Report prodotto il " + Helper.FormatDateMonthName(DateTime.Now), 300, 200, ceTe.DynamicPDF.TextAlign.Left) { Y = 300, FontSize = 10 };

            var cliente = new FormattedTextAreaPDF(string.Format("<B>{0} {1}</B>", nomeCliente, cognomeCliente), 300, 200, ceTe.DynamicPDF.TextAlign.Left) { Y = 319, FontSize = 10 };
            AddElement(dataStampa);
            AddElement(cliente);

            if (EnvironmentFacade.ReportEnvironment.PrivateDelegato.chiaveDelegato > 0)
            {
                var nomeDelegato = Helper.CapitalizeWords(EnvironmentFacade.ReportEnvironment.PrivateDelegato.Nome + " " + EnvironmentFacade.ReportEnvironment.PrivateDelegato.Cognome);
                var descrizione = "(Legale Rappresentante / Delegato)";

                var delegato = new FormattedTextAreaPDF(string.Format("{0} {1}", nomeDelegato, descrizione), 300, 400, ceTe.DynamicPDF.TextAlign.Left) { Y = 339, FontSize = 8 };
                AddElement(delegato);
            }
            
        }

        /// <summary>
        /// Recupera i dati necessari alla Section restituendo un DataTable.
        /// </summary>
        /// <returns></returns>
        protected sealed override DataTable GetDataTable()
        {
            return null;
        }

        /// <summary>
        /// Recupera i dati necessari alla Section restituendo un DataSet.
        /// </summary>
        /// <returns></returns>
        protected sealed override DataSet GetDataSet()
        {
            return null;
        }
    }
}
