diff --git a/ReportImp/OwnSoftTestSchmitzi/Reporting/CustomReportCreator.cs b/ReportImp/OwnSoftTestSchmitzi/Reporting/CustomReportCreator.cs index 1cac1c021..ba5f17a3e 100644 --- a/ReportImp/OwnSoftTestSchmitzi/Reporting/CustomReportCreator.cs +++ b/ReportImp/OwnSoftTestSchmitzi/Reporting/CustomReportCreator.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using BeWo.Data.Access; +using BeWo.Data.Access; using BeWo.Data.Entities; using BeWo.Report; using BeWo.Report.DefaultReports; @@ -8,6 +6,9 @@ using BeWo.Report.ReportObjects; using BeWo.Service.DCEntityMapper; using BS.Shared.DataContracts; using DevExpress.XtraReports.UI; +using System; +using System.Collections.Generic; +using System.Linq; namespace OwnSoftTestSchmitzi { @@ -37,8 +38,77 @@ namespace OwnSoftTestSchmitzi return base.CreateSettlementReport(dcId, invoiceBaseOid, false); } + public override XtraReport CreateQueryReport(long queryOid, string queryReportId) + { + if (queryOid == 500) + { + return CreateLwlPruefliste(CreateQueryRO(queryOid, queryReportId)); - public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay) + } + return base.CreateQueryReport(queryOid, queryReportId); + } + private LwlPruefliste CreateLwlPruefliste(QueryRO queryRo) + { + var liste = new LwlPruefliste(); + + if (queryRo.Rows.Count > 0) + { + DateTime start = DateTime.MaxValue; + DateTime end = DateTime.MinValue; + + if (queryRo.Rows[0].Field1 != null) + { + DateTime.TryParse(queryRo.Rows[0].Field1.ToString(), out start); + } + if (queryRo.Rows[0].Field2 != null) + { + DateTime.TryParse(queryRo.Rows[0].Field2.ToString(), out end); + } + long? customerOid = null; + if (queryRo.Rows[0].Field3.ToString() == "0") + { + var masterReport = new LwlPruefliste(); + //masterReport.CreateDocument(); + + var customerList = DAOFactory.GenericDAO.GetAllActive(); + var customerListOrd = customerList.OrderBy(c => c.Person.LastNameFirstName).ToList(); + foreach (var c in customerListOrd) + { + var ro = LwlPrueflisteRO.Create(start, end, "9009847", c.Oid); + if (ro.ServiceRecords != null && ro.ServiceRecords.Count > 0) + { + try + { + liste = new LwlPruefliste(); + liste.SetReportDataSource(ro); + liste.CreateDocument(); + masterReport.Pages.AddRange(liste.Pages); + } + catch + { + // ignore - z.B. kein Hilfeplan + } + } + } + return (LwlPruefliste)masterReport; + } + + if (queryRo.Rows[0].Field3 != null) + { + if (Int64.TryParse(queryRo.Rows[0].Field3.ToString(), out var oidOut)) + { + customerOid = oidOut; + } + var ro = LwlPrueflisteRO.Create(start, end, "9009847", customerOid); + liste.SetReportDataSource(ro); + return liste; + } + } + + return liste; + } + + public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay) { List lROs = ServicesOverviewRO.Create(month, year, orgaOid, empOid, startDay, endDay, serviceCategoryOid);