Files
BeWoPlaner/ReportImp/ChristianLuft/ServiceInvoiceReport.cs
2019-11-24 15:33:32 +01:00

106 lines
3.6 KiB
C#

using System;
using System.Text;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using DevExpress.XtraReports.UI;
namespace ChristianLuft
{
public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public ServiceInvoiceReport()
{
this.InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
//DateTime start = pRO.AccountingPeriodStart;
//DateTime end = pRO.AccountingPeriodEnd;
//if (start.Month == end.Month && start.Year == end.Year)
//{
// lblAbrechnungszeitraum.Text = String.Format("hiermit berechnen wir für den Monat {0:MMMM yyyy} folgende erbrachte Tätigkeiten:", start);
//}
//else
//{
// lblAbrechnungszeitraum.Text = String.Format("hiermit berechnen wir für den Zeitraum {0:MMMM yyyy} - {1:MMMM yyyy} folgende erbrachte Tätigkeiten:", start, end);
//}
if (!String.IsNullOrWhiteSpace(pRO.CustomerSalutation) && pRO.CustomerSalutation == "Herr")
{
pRO.CustomerSalutation = "Herrn";
}
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
{
sb.AppendLine(pRO.RecipientOrganisation);
}
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
{
sb.AppendLine(pRO.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(pRO.RecipientDivision))
{
sb.AppendLine(pRO.RecipientDivision);
}
if (!String.IsNullOrEmpty(pRO.RecipientStreet))
{
sb.AppendLine(pRO.RecipientStreet);
}
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
{
sb.AppendLine(pRO.RecipientPostCodeAndTown);
}
lblAdresse.Text = sb.ToString();
lblBemerkungen.Text = lblBemerkungen.Text.Replace("{Frist}",
String.Format("{0:dd.MM.yyyy}", pRO.InvoiceDateTime.Value.AddDays(14)));
if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0)
{
foreach (var p in pRO.ServiceInvoicePeriods)
{
if (p.ServiceInvoiceItems != null && p.ServiceInvoiceItems.Count > 0)
{
foreach (var i in p.ServiceInvoiceItems)
{
i.ServiceDescription = "Unterstützungsleistung";
i.Duration = String.Format("{0:MM}/{0:yy}", i.AccountingPeriodStart);
decimal rateFactor = 1;
if (i.HourlyRate.HasValue)
{
if (!String.IsNullOrEmpty(i.RateFactor))
{
var rfStr = i.RateFactor.Replace("%", "").Replace(",00", "").Trim();
int rfInt = 0;
Int32.TryParse(rfStr, out rfInt);
rateFactor = (100m + rfInt) / 100m;
}
}
if (i.Hours.HasValue)
{
i.Hours *= rateFactor;
}
}
}
}
}
this.bindingSource1.DataSource = pRO;
}
}
}