Files
BeWoPlaner/ReportImp/KetteReports/SoziotherapieRechnung.cs

106 lines
3.9 KiB
C#

using BeWo.Report;
using BeWo.Report.ReportObjects;
using BS.Shared.Core;
using DevExpress.XtraReports.UI;
using System;
using System.Text;
namespace KetteReports
{
[IDSpecificClass(Identifier = "RechnungSoziotherapie")]
public partial class SoziotherapieRechnung : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public SoziotherapieRechnung()
{
this.InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
if (!String.IsNullOrEmpty(pRO.SenderContactPersonPhone))
pRO.SenderContactPersonPhone = pRO.SenderContactPersonPhone.Replace("Tel.:", "").Trim();
if (!String.IsNullOrEmpty(pRO.SenderContactPersonFax))
pRO.SenderContactPersonFax = pRO.SenderContactPersonFax.Replace("Fax:", "").Trim();
if (!String.IsNullOrEmpty(pRO.SenderContactPersonMail))
pRO.SenderContactPersonMail = pRO.SenderContactPersonMail.Replace("E-Mail:", "").Trim();
string poBox = null;
if (pRO.InvoiceBase.RecipientContactInformations.Count > 0)
{
foreach (var i in pRO.InvoiceBase.RecipientContactInformations)
{
if (i.ContactType == BS.Shared.ContactType.private_POBox)
poBox = i.ContactValue;
}
}
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
{
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))
{
sb.AppendLine(pRO.RecipientDivision);
}
if (!String.IsNullOrEmpty(poBox))
{
sb.AppendLine(poBox);
}
else 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("");
sb.AppendLine(pRO.RecipientPostCodeAndTown);
}
lblAdresse.Text = sb.ToString();
decimal hours = 0;
if (pRO.ServiceInvoicePeriods != null)
{
foreach (var sip in pRO.ServiceInvoicePeriods)
{
foreach (var ii in sip.ServiceInvoiceItems)
{
hours += ii.Hours ?? 0;
if (ii.UnitDescription == null || !ii.UnitDescription.StartsWith("GPos"))
{
ii.UnitDescription = "";
}
// Einheit setzen
ii.HourlyRateString = "Stunde(n)";
if (ii.ServiceDescription != null)
{
if (ii.ServiceDescription.ToLower().Contains("hausbesuchspauschale"))
ii.HourlyRateString = "Anzahl";
else if (ii.ServiceDescription.ToLower().Contains("gruppe"))
ii.HourlyRateString = "Einheit(en)";
}
}
}
}
lblInfotext.Text = lblInfotext.Text.Replace("[Zahlungsziel]",
String.Format("{0:dd.MM.yyyy}", ((DateTime)pRO.InvoiceDateTime).AddDays(21)));
this.bindingSource1.DataSource = pRO;
}
}
}