117 lines
4.8 KiB
C#
117 lines
4.8 KiB
C#
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;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace SkmViersen
|
|
{
|
|
public class CustomReportCreator : DefaultReportCreator
|
|
{
|
|
public override XtraReport CreateServiceInvoiceReport(string dcIds, long? invoiceBaseOid)
|
|
{
|
|
#region Standardkram
|
|
if (String.IsNullOrEmpty(dcIds) && invoiceBaseOid.HasValue)
|
|
{
|
|
var serviceInvoice = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(invoiceBaseOid.Value);
|
|
dcIds = String.Format("{0}", serviceInvoice.Oid);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(dcIds))
|
|
{
|
|
var serviceInvoiceOid2CostbearerId = new Dictionary<long, string>();
|
|
var dcList = new List<ServiceInvoiceDC>();
|
|
|
|
var dcidStrs = dcIds.Split(';');
|
|
foreach (var oidStr in dcidStrs)
|
|
{
|
|
var oid = long.Parse(oidStr);
|
|
var invoice = DAOFactory.GenericDAO.LoadByID<ServiceInvoice>(oid);
|
|
var dc = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(invoice);
|
|
dcList.Add(dc);
|
|
|
|
if (serviceInvoiceOid2CostbearerId.ContainsKey(oid))
|
|
continue;
|
|
|
|
if (!String.IsNullOrEmpty(invoice.InvoiceBase.InvoiceId))
|
|
serviceInvoiceOid2CostbearerId.Add(oid, invoice.InvoiceBase.InvoiceId);
|
|
else
|
|
{
|
|
foreach (var period in invoice.ServiceInvoicePeriodList)
|
|
{
|
|
try
|
|
{
|
|
if (period.SupportConceptApprovalPeriod != null)
|
|
{
|
|
AddCostBearerIdToDict(oid, serviceInvoiceOid2CostbearerId,
|
|
period.SupportConceptApprovalPeriod.CostBearer2SupportConcept);
|
|
|
|
}
|
|
foreach (var item in period.InvoiceItemList)
|
|
{
|
|
if (item.SupportConceptApprovalPeriodOid.HasValue)
|
|
{
|
|
var approvalPeriod =
|
|
DAOFactory.GenericDAO.LoadByID<SupportConceptApprovalPeriod>(item.SupportConceptApprovalPeriodOid.Value);
|
|
if (approvalPeriod.CostBearer2SupportConcept != null)
|
|
{
|
|
AddCostBearerIdToDict(oid, serviceInvoiceOid2CostbearerId, approvalPeriod.CostBearer2SupportConcept);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
//ignore
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
IBeWoReport<ServiceInvoiceRO> allReports = null;
|
|
|
|
foreach (var iDC in dcList)
|
|
{
|
|
String reportId = null;
|
|
if (serviceInvoiceOid2CostbearerId.ContainsKey(iDC.ServiceInvoiceOid.Value))
|
|
reportId = serviceInvoiceOid2CostbearerId[iDC.ServiceInvoiceOid.Value];
|
|
|
|
IBeWoReport<ServiceInvoiceRO> reportSeite1 = new SammelrechnungSeite1();
|
|
IBeWoReport<ServiceInvoiceRO> reportSeite2 = new SammelrechnungSeite2();
|
|
|
|
var ro = ServiceInvoiceRO.Create(iDC);
|
|
reportSeite1.SetReportDataSource(ro);
|
|
reportSeite2.SetReportDataSource(ro);
|
|
((XtraReport)reportSeite1).CreateDocument();
|
|
((XtraReport)reportSeite2).CreateDocument();
|
|
|
|
if (allReports == null)
|
|
{
|
|
((XtraReport)reportSeite1).Pages.AddRange(((XtraReport)reportSeite2).Pages);
|
|
allReports = reportSeite1;
|
|
|
|
}
|
|
else
|
|
{
|
|
((XtraReport)allReports).Pages.AddRange(((XtraReport)reportSeite1).Pages);
|
|
((XtraReport)allReports).Pages.AddRange(((XtraReport)reportSeite2).Pages);
|
|
}
|
|
}
|
|
|
|
return allReports as XtraReport;
|
|
}
|
|
return new XtraReport();
|
|
}
|
|
}
|
|
}
|