Files
BeWoPlaner/ReportImp/SKFLeverkusenJuHi/ServiceInvoiceReport.cs

129 lines
4.9 KiB
C#

using System;
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;
using BS.Shared.Extensions;
using DevExpress.XtraReports.UI;
namespace SKFLeverkusenJuHi
{
public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public ServiceInvoiceReport()
{
this.InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
SetzeAdresse(pRO);
SetzeRegion(pRO);
SetzeBetreuungsart(pRO);
SetzeDebitornummer(pRO);
this.bindingSource1.DataSource = pRO;
}
private void SetzeDebitornummer(ServiceInvoiceRO pRO)
{
foreach (var sip in pRO.ServiceInvoicePeriods)
{
if (sip.Customer != null)
{
var cust = DAOFactory.GenericDAO.GetByID<Customer>(sip.Customer.CustomerOid);
if (!cust.DebitorNumber.IsNullOrEmpty())
lblDebitorNummer.Text = cust.DebitorNumber;
}
}
}
private void SetzeAdresse(ServiceInvoiceRO pRO)
{
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && pRO.RecipientOrganisation.ToLower() != "selbstzahler")
{
sb.AppendLine(pRO.RecipientOrganisation);
}
//if (!String.IsNullOrEmpty(pRO.RecipientAddressLine1))
//{
// sb.AppendLine(pRO.RecipientAddressLine1);
//}
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
{
sb.AppendLine(pRO.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(pRO.RecipientDivision) && !String.IsNullOrEmpty(pRO.RecipientOrganisation) && pRO.RecipientOrganisation.ToLower() != "selbstzahler")
{
sb.AppendLine(pRO.RecipientDivision);
}
if (!String.IsNullOrEmpty(pRO.RecipientPoBox))
{
sb.AppendLine(pRO.RecipientPoBox);
}
else if (!String.IsNullOrEmpty(pRO.RecipientStreet))
{
sb.AppendLine(pRO.RecipientStreet);
}
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
{
sb.AppendLine(pRO.RecipientPostCodeAndTown);
}
lblAdresse.Text = sb.ToString();
}
private void SetzeRegion(ServiceInvoiceRO pRO)
{
if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0)
{
string region = "";
foreach (var sip in pRO.ServiceInvoicePeriods)
{
var cb2scListItem = sip.CostBearer2SupportConcept.SupportConcept.Customer.Customer2CostBearerList.Where(i => i.Oid == sip.CostBearer2SupportConcept.Oid || i.CostBearer.Oid == sip.CostBearer2SupportConcept.CostBearer.Oid).FirstOrDefault();
if (cb2scListItem != null)
{
region = cb2scListItem.Notice;
if (!String.IsNullOrEmpty(region))
pRO.OrganisationCostCenter = ", " + region;
}
if (String.IsNullOrEmpty(pRO.RecipientContactPerson) && sip.CostBearer2SupportConcept.CostBearerContactPerson != null) // falls bei Rechnungsstellung Fallführung noch nicht gesetzt war
{
pRO.RecipientContactPerson = sip.CostBearer2SupportConcept.CostBearerContactPerson.FirstNameLastName;
}
}
}
}
private void SetzeBetreuungsart(ServiceInvoiceRO pRO)
{
if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0)
{
var c = DAOFactory.GenericDAO.LoadByID<Customer>(pRO.ServiceInvoicePeriods[0].Customer.Oid.Value);
if (c != null)
{
StringBuilder betreuungsartSb = new StringBuilder();
foreach (var v2o in c.ValueList)
{
if (v2o.Entry.Type == ValueListEntryType.CustomerCareType)
{
if (betreuungsartSb.Length > 0)
{
betreuungsartSb.Append(", ");
}
betreuungsartSb.Append(v2o.Entry.Value);
}
}
if (betreuungsartSb.Length > 0)
{
lblHilfeart.Text = "Kosten für Hilfe gem. " + betreuungsartSb.ToString();
}
}
}
}
}
}