using System;
using System.Collections;
using System.ComponentModel;
using System.Text;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using DevExpress.XtraReports.UI;
using BeWo.Report.ReportObjects;
using BeWo.Report;
using System.Collections.Generic;
using BS.Shared.Extensions;

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

        public void SetReportDataSource(ServicesOverviewRO pRO)
        {

			Dictionary<string, string> empDict = 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)
					{
						
						servicesBillable.Add(s);
					}
					if (!empDict.ContainsKey(s.EmployeeFullname))
					{
						empDict.Add(s.EmployeeFullname, s.EmployeeFullname);
					}
				}
				
				pRO.Services = servicesBillable;
			}
	        if (empDict.Count > 0)
	        {
		        pRO.MainAttendant = empDict.Values.ToSeparatedString(", ");
	        }
	        this.bindingSource1.DataSource = pRO;
        }
    }
}

