using System;
using System.Collections;
using System.Collections.Generic;
using BeWo.Report.ReportObjects;
using BeWo.Report;
using BS.Shared.Core;

namespace BeWo.BetreuWoReports
{
    public partial class FLSAuswertung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<FLSReportRO>
    {
        public FLSAuswertung()
        {
            InitializeComponent();
        }

        public void SetReportDataSource(FLSReportRO pRO)
        {
	        if (pRO.FLSReportGroups != null)
	        {
		        foreach (var group in pRO.FLSReportGroups)
		        {
					group.ServiceRecords = new List<FLSReportRO.FLSReportServiceRecord>();
			        if (group.FLSReportDetails != null)
			        {
				        foreach (var detail in group.FLSReportDetails)
				        {
					        if (detail.ServiceRecords != null)
					        {
						        foreach (var sr in detail.ServiceRecords)
						        {
							        sr.GroupName = detail.Name;
									group.ServiceRecords.Add(sr);        
						        }
					        }
					        
				        }
			        }
					group.ServiceRecords.Sort((s1, s2) => Comparer.Default.Compare(s1.Start, s2.Start));
		        }
	        }
	        this.bindingSource1.DataSource = pRO;
        }

    }
}
