100 lines
3.7 KiB
C#
100 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using DevExpress.XtraReports.UI;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Core;
|
|
|
|
namespace BeWo.Report.DefaultReports
|
|
{
|
|
public partial class SBDCharacteristicsReport : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<SBDCharacteristicsRO>
|
|
{
|
|
public SBDCharacteristicsReport()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(SBDCharacteristicsRO pRO)
|
|
{
|
|
StringBuilder sbSchule = new StringBuilder();
|
|
if (pRO.EnvironmentOrganisations != null)
|
|
{
|
|
foreach (var org in pRO.EnvironmentOrganisations)
|
|
{
|
|
if (org.RelationRole != null && org.RelationRole.DisplayName == "Schule")
|
|
{
|
|
sbSchule.AppendLine(org.Organisation.Name);
|
|
|
|
sbSchule.AppendLine(org.Organisation.Street);
|
|
sbSchule.Append(org.Organisation.PostalCode);
|
|
sbSchule.Append(" ");
|
|
sbSchule.AppendLine(org.Organisation.Town);
|
|
sbSchule.AppendLine("");
|
|
|
|
sbSchule.AppendLine(org.Organisation.ContactSummaryInfo);
|
|
sbSchule.AppendLine("");
|
|
|
|
var o = DAOFactory.GenericDAO.LoadByID<Organisation>(org.Organisation.OrganisationOid);
|
|
sbSchule.Append(o.Notice);
|
|
}
|
|
}
|
|
}
|
|
|
|
CreateArbeitszeitenTable(pRO.Customer.Arbeitszeiten);
|
|
|
|
lblSchule.Text = sbSchule.ToString();
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void CreateArbeitszeitenTable(List<ArbeitszeitDC> zeiten)
|
|
{
|
|
if (zeiten != null)
|
|
{
|
|
foreach (var az in zeiten)
|
|
{
|
|
if ((!az.GueltigVon.HasValue || az.GueltigVon <= DateTime.Now) &&
|
|
(!az.GueltigBis.HasValue || az.GueltigBis >= DateTime.Now) && az.Eintraege != null)
|
|
{
|
|
SortiereArbeitszeiten(az.Eintraege);
|
|
foreach (var e in az.Eintraege)
|
|
{
|
|
AddArbeitszeit(e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void SortiereArbeitszeiten(List<ArbeitszeitEintragDC> zeiten)
|
|
{
|
|
zeiten.Sort(
|
|
(a, b) =>
|
|
{
|
|
var at1 = DateTimeUtils.GetAssistanceTimeComparisonDateTime(a.UhrzeitVon, a.UhrzeitBis, DateTime.Now.Date.AddDays((int)a.DayOfWeek));
|
|
var at2 = DateTimeUtils.GetAssistanceTimeComparisonDateTime(b.UhrzeitVon, b.UhrzeitBis, DateTime.Now.Date.AddDays((int)b.DayOfWeek));
|
|
|
|
return at1.Start.CompareTo(at2.Start);
|
|
});
|
|
}
|
|
|
|
private void AddArbeitszeit(ArbeitszeitEintragDC ae)
|
|
{
|
|
XRTableRow newRow = tableBetreuungszeiten.InsertRowBelow(tableBetreuungszeiten.Rows[tableBetreuungszeiten.Rows.Count - 1]);
|
|
newRow.Font = new System.Drawing.Font("Arial", 10F);
|
|
|
|
newRow.Cells[0].Text = String.Format("{0}", ae.Tag);
|
|
newRow.Cells[1].Text = String.Format("{0} - {1}", ae.UhrzeitVon, ae.UhrzeitBis);
|
|
if (ae.Employee != null)
|
|
{
|
|
newRow.Cells[2].Text = String.Format("{0} {1}", ae.Employee.LastName, ae.Employee.FirstName);
|
|
}
|
|
|
|
newRow.Cells[3].Text = ae.Notice;
|
|
}
|
|
}
|
|
}
|