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

using DevExpress.XtraReports.UI;

namespace CaritasWuppertalSolingen
{
    public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
    {
        public ServiceInvoiceReport()
        {
            InitializeComponent();
        }

        public void SetReportDataSource(ServiceInvoiceRO pRO)
        {
			bool isBeWo67 = false;
			bool isJugendamt = false;
			if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
			{
				if (pRO.RecipientOrganisation == "LVR 2")
				{
					isBeWo67 = true;
				}
				else if (pRO.RecipientOrganisation.Contains("Jugendamt"))
				{
					isJugendamt = true;
				}

				pRO.RecipientOrganisation = pRO.RecipientOrganisation.Replace("LVR 1", "LVR");
				pRO.RecipientOrganisation = pRO.RecipientOrganisation.Replace("LVR 2", "LVR");
			}
			if (isBeWo67)
			{
				lblBetreuungskosten.Text = "Betreuungskostenabrechnung § 67 SGB XII";
			}
			else if (isJugendamt)
			{
				lblBetreuungskosten.Text = "Betreuungskostenabrechnung § 35a SGB XII";
			}

			if (!String.IsNullOrEmpty(pRO.SenderContactPersonFax))
				pRO.SenderContactPersonFax   = pRO.SenderContactPersonFax.Substring(5);
			if (!String.IsNullOrEmpty(pRO.SenderContactPersonPhone))
				pRO.SenderContactPersonPhone = pRO.SenderContactPersonPhone.Substring(6);
			customerNameUntenLabel.Text = String.Format("{0}, {1}", pRO.CustomerLastName, pRO.CustomerFirstName);
            bindingSource1.DataSource = pRO;
        }
    }
}