Files
BeWoPlaner/ReportImp/AssistenzaReports/FLSGroupReport.cs

152 lines
6.8 KiB
C#

using System;
using BeWo.Report.ReportObjects;
using BeWo.Report;
using System.Collections.Generic;
namespace BeWo.AssistenzaReports
{
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)
{
var abrechenbar = 0m;
var indirekt = 0m;
FLSReportRO.FLSReportDetail sonstigesAlt = null;
FLSReportRO.FLSReportDetail fahrzeiten = null;
FLSReportRO.FLSReportDetail buerozeiten = null;
FLSReportRO.FLSReportDetail sonstigesNeu = null;
if (group.FLSReportDetails != null)
{
foreach (var detail in group.FLSReportDetails)
{
Dictionary<string, decimal> leistungenZuMinuten = new Dictionary<string, decimal>();
if (detail.ServiceRecords != null)
{
foreach (var sr in detail.ServiceRecords)
{
if (!leistungenZuMinuten.ContainsKey(sr.ServiceDescription))
leistungenZuMinuten.Add(sr.ServiceDescription, 0m);
leistungenZuMinuten[sr.ServiceDescription] += sr.Duration;
}
}
if (leistungenZuMinuten.Count > 0)
{
// Hier DictValues rein
detail.CustomValue1 = "";
detail.CustomValue2 = "";
foreach (var item in leistungenZuMinuten)
{
if (item.Key == "Sonstiges")
indirekt += item.Value;
else
abrechenbar += item.Value;
detail.CustomValue1 += string.Format("{0}\n", item.Key);
detail.CustomValue2 += string.Format("{0:0.00}\n", item.Value);
}
}
if (detail.Name == "Sonstiges")
{
detail.Name = "Indirekte Leistungen";
//sonstigesAlt = detail;
}
else
{
if (detail.ServiceRecords != null)
{
foreach (var sr in detail.ServiceRecords)
{
sr.Notice = "";
}
}
}
}
}
if (sonstigesAlt != null)
{
group.FLSReportDetails.Remove(sonstigesAlt);
if (sonstigesAlt.ServiceRecords != null)
{
foreach (var sr in sonstigesAlt.ServiceRecords)
{
if (sr.ServiceCategory.IndexOf("Fahrtzeiten") == 0)
{
if (fahrzeiten == null)
{
fahrzeiten = new FLSReportRO.FLSReportDetail();
fahrzeiten.ServiceRecords = new List<FLSReportRO.FLSReportServiceRecord>();
fahrzeiten.Name = "Fahrtzeiten";
}
fahrzeiten.TotalFLM += sr.RoundedDuration;
fahrzeiten.ServiceRecords.Add(sr);
}
else if (sr.ServiceCategory.IndexOf("Büro") == 0)
{
if (buerozeiten == null)
{
buerozeiten = new FLSReportRO.FLSReportDetail();
buerozeiten.ServiceRecords = new List<FLSReportRO.FLSReportServiceRecord>();
buerozeiten.Name = "Bürozeiten";
}
buerozeiten.TotalFLM += sr.RoundedDuration;
buerozeiten.ServiceRecords.Add(sr);
}
else
{
if (sonstigesNeu == null)
{
sonstigesNeu = new FLSReportRO.FLSReportDetail();
sonstigesNeu.ServiceRecords = new List<FLSReportRO.FLSReportServiceRecord>();
sonstigesNeu.Name = sonstigesAlt.Name;
}
sonstigesNeu.TotalFLM += sr.RoundedDuration;
sonstigesNeu.ServiceRecords.Add(sr);
}
}
if (buerozeiten != null)
group.FLSReportDetails.Insert(0, buerozeiten);
if (fahrzeiten != null)
group.FLSReportDetails.Insert(0, fahrzeiten);
if (sonstigesNeu != null)
group.FLSReportDetails.Add(sonstigesNeu);
}
}
group.CustomValue1 = string.Format("{0:0}", abrechenbar); // Abrechenbar in Minuten
group.CustomValue2 = string.Format("{0:0.00}", abrechenbar / 60); // Abrechenbar in Stunden
group.CustomValue3 = string.Format("{0:0}", indirekt); // Indirekt in Minuten
group.CustomValue4 = string.Format("{0:0.00}", indirekt / 60); // Indirekt in Stunden
}
}
this.bindingSource1.DataSource = pRO;
}
}
}