using System;
using System.Collections.Generic;
using System.Linq;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using DevExpress.XtraReports.UI;

namespace CaritasUnnaWohnungslosenhilfe
{
    public partial class MittelbareLeistungenReport : XtraReport
    {
		public MittelbareLeistungenReport()
        {
            InitializeComponent();
        }

        public void SetReportDataSource(ServicesOverviewRO pRO)
        {
	        double minTotal = 0;

			if (pRO.Services != null)
			{
				List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();

				foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services)
				{
					if (s.ServiceCategory.StartsWith("Mittelbar"))
					{
						minTotal += s.Minutes;
						if (s.ServiceDescription.StartsWith("Aufsuchen"))
							s.ServiceDescription = "1";
						if (s.ServiceDescription.StartsWith("Gespräche"))
							s.ServiceDescription = "2";
						if (s.ServiceDescription.StartsWith("Kontakte"))
							s.ServiceDescription = "3";
						if (s.ServiceDescription.StartsWith("Telefon"))
							s.ServiceDescription = "4";
					}
					if (s.IsBillable)
						servicesBillable.Add(s);
				}

				pRO.Services = servicesBillable;
			}
            bindingSource1.DataSource = pRO;
           // rechnungsDatum.Text = DateTime.Now.ToShortDateString();

			summeMinuten.Text = string.Format("{0:0.##}", minTotal);

            if (pRO.SupportConceptCostBearer != null)
                aktenzeichenLV.Text = pRO.SupportConceptCostBearer.CustomerReferenceNumber ?? string.Empty;

            bewilligteFLSW.Text = string.Format("{0:0.##}", pRO.ApprovedFLSPerWeek);
        }
    }
}
