Files
BeWoPlaner/ReportImp/AssistenzaReports/FLSListReport.cs
2024-03-04 15:55:19 +01:00

87 lines
3.0 KiB
C#

using System;
using System.Collections.Generic;
using BeWo.Report.ReportObjects;
using BeWo.Report;
namespace BeWo.AssistenzaReports
{
public partial class Leistungsdokumentation : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<FLSReportRO>
{
private Dictionary<int, decimal> mIndex2Fahrzeiten = new Dictionary<int, decimal>();
private Dictionary<int, decimal> mIndex2Buerozeiten = new Dictionary<int, decimal>();
private Dictionary<int, decimal> mIndex2Gesamtzeit = new Dictionary<int, decimal>();
private int mCurrentIndex = 0;
public Leistungsdokumentation()
{
InitializeComponent();
}
public void SetReportDataSource(FLSReportRO pRO)
{
int index = 0;
foreach (var group in pRO.FLSReportGroups)
{
decimal fahrzeit = 0;
decimal buero = 0;
foreach (var sr in group.ServiceRecords)
{
if (sr.ServiceCategory.IndexOf("Fahrtzeiten") == 0)
{
fahrzeit += sr.RoundedDuration;
}
else if (sr.ServiceCategory.IndexOf("Büro") == 0)
{
buero += sr.RoundedDuration;
}
else
{
sr.Notice = "";
}
}
mIndex2Fahrzeiten.Add(index, fahrzeit);
mIndex2Buerozeiten.Add(index, buero);
mIndex2Gesamtzeit.Add(index, group.TotalFLM);
index++;
}
this.bindingSource1.DataSource = pRO;
}
private void Detail1_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e)
{
decimal total = 0;
decimal fahrzeit = 0;
decimal buero = 0;
if (mIndex2Buerozeiten.ContainsKey(mCurrentIndex))
{
buero = mIndex2Buerozeiten[mCurrentIndex];
}
if (mIndex2Fahrzeiten.ContainsKey(mCurrentIndex))
{
fahrzeit = mIndex2Fahrzeiten[mCurrentIndex];
}
if (mIndex2Gesamtzeit.ContainsKey(mCurrentIndex))
{
total = mIndex2Gesamtzeit[mCurrentIndex];
}
lblFahrzeitFLM.Text = String.Format("{0:0.##}", fahrzeit);
lblBuerozeitFLM.Text = String.Format("{0:0.##}", buero);
if (total > 0)
{
lblFahrzeitFLSProzent.Text = String.Format("{0:0.00} FLS ({1:0.##}%)", (decimal)(fahrzeit / 60m), (decimal)((fahrzeit / total) * 100m));
lblBuerozeitFLSProzent.Text = String.Format("{0:0.00} FLS ({1:0.##}%)", (decimal)(buero / 60m), (decimal)((buero / total) * 100m));
}
mCurrentIndex++;
}
}
}