using System;
using System.Text;
using BeWo.Report;
using BeWo.Report.ReportObjects;

namespace BeWo.ABCBetreuungenReports
{
    public partial class InvoiceCustomerReport : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<InvoiceCustomerRO>
    {
        public InvoiceCustomerReport()
        {
            InitializeComponent();
        }

	    public void SetReportDataSource(InvoiceCustomerRO pRO)
	    {
			StringBuilder sb = new StringBuilder();
			if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && !String.IsNullOrEmpty(pRO.RecipientOrganisation.Trim()))
			{
				sb.AppendLine(pRO.RecipientOrganisation);
			}
			if (!String.IsNullOrEmpty(pRO.RecipientFirstName) && !String.IsNullOrEmpty(pRO.RecipientFirstName.Trim()))
			{
				sb.Append(pRO.RecipientFirstName);
			}
			if (!String.IsNullOrEmpty(pRO.RecipientLastName) && !String.IsNullOrEmpty(pRO.RecipientLastName.Trim()))
			{
				sb.Append(" ");
				sb.AppendLine(pRO.RecipientLastName);
			}
			if (!String.IsNullOrEmpty(pRO.RecipientStreet) && !String.IsNullOrEmpty(pRO.RecipientStreet.Trim()))
			{
				sb.AppendLine(pRO.RecipientStreet);
				sb.AppendLine("");
				
			}
			if (!String.IsNullOrEmpty(pRO.RecipientPostCode) && !String.IsNullOrEmpty(pRO.RecipientPostCode.Trim()))
			{
				sb.Append(pRO.RecipientPostCode);
			}
			if (!String.IsNullOrEmpty(pRO.RecipientTown) && !String.IsNullOrEmpty(pRO.RecipientTown.Trim()))
			{
				sb.Append(" ");
				sb.AppendLine(pRO.RecipientTown);
			}

			lblAddress.Text = sb.ToString();


		    pRO.Notice = String.Format("{0:dd.MM.yyyy}", pRO.InvoiceDateTime.AddDays(10));

			lblBetreff.Text = String.Format("Betreff: Rechnung Monat {0:MMMM}", pRO.AccountingPeriodStart);

		    if (pRO.AccountingPeriodStart.HasValue && pRO.AccountingPeriodStart >= new DateTime(2015, 1, 1))
		    {
			    xrLabel4.Text =
				    "Bei einem vereinbarten Stundensatz von [InvoiceItems.UnitPrice] ergibt sich eine Rechnungssumme von [TotalClaim].\n" +
				    "Bitte überweisen Sie den Rechnungsbetrag bis zum [Notice] auf das u.a Konto.\n\n\n" +
				    "Mit freundlichen Grüßen";
		    }
            this.bindingSource1.DataSource = pRO;
        }
    }
}
