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 BeWo.Service.DCEntityMapper; using BS.Shared.DataContracts; using DevExpress.XtraReports.UI; namespace BellaDonna { public class CustomReportCreator : DefaultReportCreator { public override XtraReport CreateServiceInvoiceReport(string dcIds, long? invoiceBaseOid) { if (!invoiceBaseOid.HasValue && !string.IsNullOrEmpty(dcIds)) { var dcList = new List(); var dcidStrs = dcIds.Split(';'); foreach (var oidStr in dcidStrs) { var oid = long.Parse(oidStr); var invoice = DAOFactory.GenericDAO.LoadByID(oid); var dc = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(invoice); dcList.Add(dc); } IBeWoReport allReports = null; foreach (var idc in dcList) { IBeWoReport singleReport = null; if (idc.InvoiceBase.RecipientOrganisation == "Landschaftsverband Rheinland" || idc.InvoiceBase.RecipientOrganisation.Contains("Amt für Soziales ")) { singleReport = new Rechnung67(); } else { if (idc.InvoiceBase.RecipientOrganisation == "Jugendamt der Stadt Essen") singleReport = new RechnungFlexJAEssen(); else singleReport = new RechnungFlex(); } singleReport.SetReportDataSource(ServiceInvoiceRO.Create(idc)); ((XtraReport)singleReport).CreateDocument(); if (allReports == null) allReports = singleReport; else ((XtraReport)allReports).Pages.AddRange(((XtraReport)singleReport).Pages); } return allReports as XtraReport; } if (invoiceBaseOid.HasValue && invoiceBaseOid.Value > 0) { var ib = DAOFactory.GenericDAO.LoadByID(invoiceBaseOid.Value); if (ib.CostBearer2SupportConcept.CostBearer.Organisation.Name == "Landschaftsverband Rheinland" || ib.CostBearer2SupportConcept.CostBearer.Organisation.Name.Contains("Amt für Soziales ")) { var report = new Rechnung67(); var si = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(invoiceBaseOid.Value); report.SetReportDataSource(ServiceInvoiceRO.Create(MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(si))); report.CreateDocument(); return report; //return base.CreateServiceInvoiceReport("Rechnung67", invoiceBaseOid); } } return base.CreateServiceInvoiceReport(dcIds, invoiceBaseOid); } 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); if (lROs.Count > 0) { var rootReport = CreateServicesOverviewReportForRo(lROs[0], serviceCategoryOid); rootReport.CreateDocument(); for (int i = 1; i < lROs.Count; i++) { var lNext = CreateServicesOverviewReportForRo(lROs[i], serviceCategoryOid); 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) { IBeWoReport report = null; if (!String.IsNullOrWhiteSpace(ro.Costbearer)) { if (ro.Costbearer.ToLower().Contains("jugendamt")) { report = new QuittierungsbelegJa(); } } if (report == null) report = new Quittierungsbeleg(); report.SetReportDataSource(ro); return report as XtraReport; } } }