70 lines
2.8 KiB
C#
70 lines
2.8 KiB
C#
using System;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Report;
|
|
using System.Collections.Generic;
|
|
using static BeWo.Report.ReportObjects.FLSReportRO;
|
|
using System.Linq;
|
|
|
|
namespace CaritasverbandDuerenJuelichEV
|
|
{
|
|
public partial class Leistungsdokumentation : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<FLSReportRO>
|
|
{
|
|
public Leistungsdokumentation()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(FLSReportRO pRO)
|
|
{
|
|
List<FLSReportDetail> mittelbareDetails = new List<FLSReportDetail>();
|
|
FLSReportDetail sonstiges = null;
|
|
// Alles in "Sonstiges" aufteilen in eigene Leistungen
|
|
foreach (var group in pRO.FLSReportGroups)
|
|
{
|
|
foreach (var detail in group.FLSReportDetails)
|
|
{
|
|
// Sonstiges raussuchen
|
|
if (detail.Name == "Sonstiges")
|
|
{
|
|
sonstiges = detail;
|
|
Dictionary<string, List<FLSReportServiceRecord>> cat2ServiceRecords = new Dictionary<string, List<FLSReportServiceRecord>>();
|
|
|
|
// Für jede Leistung eine Liste nur mit den entsprechenden ServiceRecords erstellen
|
|
foreach (var item in detail.ServiceRecords)
|
|
{
|
|
if (!cat2ServiceRecords.ContainsKey(item.ServiceDescription))
|
|
cat2ServiceRecords.Add(item.ServiceDescription, new List<FLSReportServiceRecord>());
|
|
|
|
cat2ServiceRecords[item.ServiceDescription].Add(item);
|
|
}
|
|
|
|
// Für jede der erstellten Listen ein ReportDetail mit den entsprechenden ServiceRecords erstellen und die Zeiten summieren
|
|
foreach (var item in cat2ServiceRecords)
|
|
{
|
|
mittelbareDetails.Add(new FLSReportDetail()
|
|
{
|
|
Name = item.Key,
|
|
ServiceRecords = item.Value,
|
|
TotalFLM = item.Value.Sum(s => s.Duration),
|
|
TotalHourMinuteString = string.Format("{0:00}:{1:00}", item.Value.Sum(s => s.Duration) / 60, item.Value.Sum(s => s.Duration) % 60)
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
// Sonstiges löschen und dafür die aufgeteilten Details hinzufügen
|
|
if (sonstiges != null)
|
|
{
|
|
group.FLSReportDetails.Remove(sonstiges);
|
|
group.FLSReportDetails.AddRange(mittelbareDetails);
|
|
}
|
|
}
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
}
|
|
}
|