Files
BeWoPlaner/ReportImp/BeWoMobilReports/CustomReportCreator.cs
Christian 6a8e628d54 cb
2023-02-10 16:18:18 +01:00

85 lines
2.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using DevExpress.XtraReports.UI;
namespace BeWo.BeWoMobilReports
{
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);
if (lROs.Count > 0)
{
String reportId = null;
if (orgaOid > 0)
{
var organisation = DAOFactory.GenericDAO.LoadByID<Organisation>(orgaOid);
if (organisation != null)
reportId = organisation.Name;
}
var rootReport = CreateServicesOverviewReportForRo(lROs[0], reportId);
rootReport.CreateDocument();
for (int i = 1; i < lROs.Count; i++)
{
var lNext = CreateServicesOverviewReportForRo(lROs[i], reportId);
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)
{
String reportId = null;
if (orgaOid > 0)
{
var organisation = DAOFactory.GenericDAO.LoadByID<Organisation>(orgaOid);
if (organisation != null)
reportId = organisation.Name;
}
var ro = ServicesOverviewRO.Create(customerOid, month, year, false, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
return CreateServicesOverviewReportForRo(ro, reportId);
}
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, String reportId)
{
IBeWoReport<ServicesOverviewRO> report = null;
if (ro.StartDate < new DateTime(2017, 4, 1))
{
report = new BeWoMobilReports.Stundenzettel();
}
else if (ro.StartDate < new DateTime(2019, 1, 1))
{
report = new BeWoMobilReports.Neu.Stundenzettel();
}
else if (ro.StartDate < new DateTime(2023, 1, 1))
{
report = new BeWoMobilReports.J2019.Stundenzettel();
}
if (report == null)
report = new BeWoMobilReports.J2023.Stundenzettel();
report.SetReportDataSource(ro);
return report as XtraReport;
}
}
}