using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using BS.Shared;
using DevExpress.XtraReports.UI;
using BeWo.Report.ReportObjects;
using BeWo.Report;

namespace BeWo.SchillingerReports
{
    public partial class Stundenzettel : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
    {
        public Stundenzettel()
        {
            InitializeComponent();
        }

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

                foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services)
                {
                    if (s.IsBillable)
                        servicesBillable.Add(s);
                }

                pRO.Services = servicesBillable;
            }

	        var ba = GetBetreuungsart(pRO);
	        if (!String.IsNullOrEmpty(ba) && ba.ToLower().Contains("essen"))
	        {
				lblAnbieter.Text = "Anbieter: TaB Essen";
	        }
	        else
	        {
				lblAnbieter.Text = "Anbieter: Die Hilfe Daheim Pro BeWo";
	        }
            this.bindingSource1.DataSource = pRO;
        }

	    public String GetBetreuungsart(ServicesOverviewRO pRO)
	    {
		    if (pRO.CostBearer2SupportConceptList != null && pRO.CostBearer2SupportConceptList.Count > 0)
		    {
			    var c2s = pRO.CostBearer2SupportConceptList[0];

				foreach (var v2o in c2s.SupportConcept.Customer.ValueList)
			    {
				    if (v2o.Entry.Type == ValueListEntryType.CustomerCareType)
				    {
					    return v2o.Entry.Value;
				    }
			    }
			    
		    }

		    return "";
	    }

    }
}
