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

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

        public void SetReportDataSource(ServicesOverviewRO pRO)
        {
			lblHeader.Text = "Quittungsbeleg über Fachleistungsstunden";

			var catDict = new Dictionary<string, string>();
            if (pRO.Services != null)
            {
                List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();

                foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services)
                {
	                if (s.IsBillable)
	                {
		                if (s.IsGroup)
							s.FLSQualifiedString = "G";
						else
							s.FLSQualifiedString = "E";
						servicesBillable.Add(s);
	                }

	                if (!catDict.ContainsKey(s.ServiceCategoryAbbr))
	                {
		                catDict.Add(s.ServiceCategoryAbbr, s.ServiceCategoryAbbr);
	                }
                }

				
                pRO.Services = servicesBillable;
            }

	        if (catDict.Count == 1)
	        {
				lblHeader.Text = String.Format("Quittungsbeleg über {0}", catDict.Values.FirstOrDefault());
	        }

            this.bindingSource1.DataSource = pRO;
        }
    }
}


