128 lines
4.4 KiB
C#
128 lines
4.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 BeWoFuerDich
|
|
{
|
|
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)
|
|
{
|
|
|
|
var rootReport = CreateServicesOverviewReportForRo(lROs[0], serviceCategoryOid);
|
|
if (rootReport.Pages == null || rootReport.Pages.Count == 0)
|
|
rootReport.CreateDocument();
|
|
|
|
for (int i = 1; i < lROs.Count; i++)
|
|
{
|
|
var lNext = CreateServicesOverviewReportForRo(lROs[i], serviceCategoryOid);
|
|
if (lNext.Pages == null || 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, serviceCategoryOid);
|
|
|
|
}
|
|
|
|
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid)
|
|
{
|
|
XtraReport report = null;
|
|
|
|
ServicesOverviewRO fehlkontaktRO = ServicesOverviewRO.CopyFromRO(ro);
|
|
fehlkontaktRO.TotalFLMBillable = 0;
|
|
fehlkontaktRO.TotalFLS = 0;
|
|
ServicesOverviewRO keineFehlkontakteRO = ServicesOverviewRO.CopyFromRO(ro);
|
|
keineFehlkontakteRO.TotalFLMBillable = 0;
|
|
keineFehlkontakteRO.TotalFLS = 0;
|
|
|
|
if (ro.Services != null)
|
|
{
|
|
if (!String.IsNullOrWhiteSpace(ro.Costbearer) && (ro.Costbearer.ToLower().Contains("jugendamt")))
|
|
{
|
|
report = AddReportToReport<LeistungsnachweisJugendamt>(report, ro);
|
|
}
|
|
else
|
|
{
|
|
foreach (ServicesOverviewRO.ServiceDetail s in ro.Services)
|
|
{
|
|
if (s.ServiceDescription.ToLower().Contains("fehlkontakt"))
|
|
{
|
|
fehlkontaktRO.Services.Add(s);
|
|
fehlkontaktRO.TotalFLMBillable += s.Minutes;
|
|
fehlkontaktRO.TotalFLS += s.Minutes / 60;
|
|
}
|
|
else
|
|
{
|
|
keineFehlkontakteRO.Services.Add(s);
|
|
keineFehlkontakteRO.TotalFLMBillable += s.Minutes;
|
|
keineFehlkontakteRO.TotalFLS += s.Minutes / 60;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (report == null)
|
|
report = AddReportToReport<Stundenzettel>(report, keineFehlkontakteRO);
|
|
|
|
if (fehlkontaktRO.Services.Count > 0)
|
|
{
|
|
report = AddReportToReport<QuittierungsbelegMitFehlkontakten>(report, fehlkontaktRO);
|
|
}
|
|
|
|
|
|
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);
|
|
report.CreateDocument();
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
}
|