Files
BeWoPlaner/ReportImp/BeWoMundo/QuittierungsbelegMitDatum.cs
2021-01-12 01:12:03 +01:00

113 lines
3.6 KiB
C#

using System;
using System.Collections.Generic;
using BeWo.Report;
using BeWo.Report.ReportObjects;
namespace BeWoMundo
{
public partial class Quittierungsbeleg2 : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
{
public Quittierungsbeleg2()
{
InitializeComponent();
}
public void SetReportDataSource(ServicesOverviewRO pRO)
{
bool hatGruppen = false;
String empName = String.Empty;
Dictionary<String, bool> empCountDict = new Dictionary<String, bool>();
if (pRO.Services != null)
{
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
foreach (var sd in pRO.Services)
{
if (sd.IsBillable)
{
if (sd.IsGroup)
{
//sd.Notice5 = String.Format("{0} Teilnehmer", sd.CustomerCount);
hatGruppen = true;
}
if (!String.IsNullOrEmpty(sd.EmployeeFullname))
{
empName = sd.EmployeeFullname;
if (!empCountDict.ContainsKey(sd.EmployeeFullname))
empCountDict.Add(sd.EmployeeFullname, true);
}
servicesBillable.Add(sd);
}
}
pRO.Services = servicesBillable;
}
if (empCountDict.Count == 1)
pRO.MainAttendant = empName;
if (String.IsNullOrWhiteSpace(pRO.AbsenceTimes))
{
lblHatAbwesenheiten.Text = "X";
}
if (!hatGruppen)
{
lblHatGruppen.Text = "X";
}
ErstelleAbwesenheitenTabelle(pRO);
bindingSource1.DataSource = pRO;
}
private void ErstelleAbwesenheitenTabelle(ServicesOverviewRO pRo)
{
if (pRo.Abwesenheiten != null)
{
int newRows = 0;
int index = 1;
foreach (var at in pRo.Abwesenheiten)
{
DevExpress.XtraReports.UI.XRTableRow row = null;
if (index < xrTableAbwesenheiten.Rows.Count)
{
row = xrTableAbwesenheiten.Rows[index];
}
else
{
row = xrTableAbwesenheiten.InsertRowBelow(xrTableAbwesenheiten.Rows[xrTableAbwesenheiten.Rows.Count - 1]);
newRows++;
}
row.Cells[0].Text = String.Format("{0:dd.MM.yyyy}", at.Start);
int? days = null;
if (at.End.HasValue)
{
row.Cells[1].Text = String.Format("{0:dd.MM.yyyy}", at.End);
days = (int)at.End.Value.Subtract(at.Start.Value).TotalDays + 1;
}
else
{
row.Cells[1].Text = "unbekannt";
}
row.Cells[2].Text = String.Format("{0:0}", days);
index++;
}
if (newRows > 0)
{
lblUnterschriftKlient.Top += newRows * 20;
lblUnterschriftMitarbeiter.Top += newRows * 20;
}
}
}
}
}