Files
BeWoPlaner/ReportImp/WahlEv/CustomReportCreator.cs
2020-08-17 15:50:00 +02:00

126 lines
4.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using DevExpress.XtraReports.UI;
namespace WahlEv
{
public class CustomReportCreator : DefaultReportCreator
{
public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
{
List<ServicesOverviewRO> lROs = ServicesOverviewRO.Create(month, year, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
if (lROs.Count > 0)
{
var rootReport = CreateServicesOverviewReportForRo(lROs[0]);
if (rootReport.Pages.Count == 0)
{
rootReport.CreateDocument();
}
for (int i = 1; i < lROs.Count; i++)
{
var lNext = CreateServicesOverviewReportForRo(lROs[i]);
if (lNext.Pages.Count == 0)
{
lNext.CreateDocument();
}
rootReport.Pages.AddRange(lNext.Pages);
}
return rootReport;
}
return new XtraReport();
}
public override XtraReport CreateServiceOverviewSingleCustomerReport(long customerOid, int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
{
var ro = ServicesOverviewRO.Create(customerOid, month, year, false, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
return CreateServicesOverviewReportForRo(ro);
}
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro)
{
XtraReport report = null;
if (ro.StartDate < new DateTime(2020, 4, 1))
{
report = new Stundenzettel();
((Stundenzettel)report).SetReportDataSource(ro);
}
else
{
ServicesOverviewRO flsRo = ServicesOverviewRO.CopyFromRO(ro);
ServicesOverviewRO fahrtRo = ServicesOverviewRO.CopyFromRO(ro);
ServicesOverviewRO bewoRo = ServicesOverviewRO.CopyFromRO(ro);
if (ro.Services != null)
{
foreach (ServicesOverviewRO.ServiceDetail s in ro.Services)
{
//ServicesOverviewRO.CreateSignatureString(s);
if (s.ServiceCategory.ToLower().Contains("betreutes wohnen"))
{
bewoRo.Services.Add(s);
}
else if (s.ServiceCategory.ToLower().Contains("fahrtzeit") || s.ServiceCategory.ToLower().Contains("fahrzeit"))
{
fahrtRo.Services.Add(s);
}
else
{
flsRo.Services.Add(s);
}
}
}
report = AddReportToReport<QuittierungsbelegNeu>(report, flsRo);
report = AddReportToReport<Fahrtzeiten>(report, fahrtRo);
report = AddReportToReport<QuittierungsbelegBeWo>(report, bewoRo);
}
if (report == null)
report = new QuittierungsbelegNeu();
return report;
}
private XtraReport AddReportToReport<T>(XtraReport report, ServicesOverviewRO ro) where T : XtraReport, IBeWoReport<ServicesOverviewRO>, new()
{
if (ro.Services.Count > 0)
{
if (report == null)
{
report = new T();
((T)report).SetReportDataSource(ro);
}
else
{
if (report.Pages.Count == 0)
{
report.CreateDocument();
}
XtraReport newReport = new T();
((T)newReport).SetReportDataSource(ro);
newReport.CreateDocument();
report.Pages.AddRange(newReport.Pages);
}
}
return report;
}
}
}