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

namespace BeWo.Report.DefaultReports
{
    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))
	        {
		        sb.AppendLine(pRO.RecipientOrganisation);
	        }
			if (!String.IsNullOrEmpty(pRO.RecipientFirstName) || !String.IsNullOrEmpty(pRO.RecipientLastName))
			{
				sb.AppendLine(String.Format("{0} {1}", pRO.RecipientFirstName, pRO.RecipientLastName).Trim());
			}
			if (!String.IsNullOrEmpty(pRO.RecipientDivision))
	        {
		        sb.AppendLine(pRO.RecipientDivision);
	        }
			if (!String.IsNullOrEmpty(pRO.RecipientStreet))
	        {
		        sb.AppendLine(pRO.RecipientStreet);
	        }
			if (!String.IsNullOrEmpty(pRO.RecipientPostCode))
	        {
		        sb.Append(pRO.RecipientPostCode);
				sb.Append(" ");
	        }
			if (!String.IsNullOrEmpty(pRO.RecipientTown))
	        {
		        sb.Append(pRO.RecipientTown);
	        }
	        lblAdresse.Text = sb.ToString();
			


			//pRO.InvoiceNumber = String.Format("8235-{0}", pRO.InvoiceNumber);
	        pRO.InvoiceItems.Sort((a, b) => a.AccountingPeriodStart.CompareTo(b.AccountingPeriodStart));
            this.bindingSource1.DataSource = pRO;
        }
    }
}
