86 lines
2.0 KiB
C#
86 lines
2.0 KiB
C#
using System;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
|
|
namespace AwoKreisverbandPloen
|
|
{
|
|
[IDSpecificClass(Identifier = "Assistenz")]
|
|
public partial class RechnungAssistenz2 : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServiceInvoiceRO>
|
|
{
|
|
public RechnungAssistenz2()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
DateTime start = pRO.AccountingPeriodStart;
|
|
DateTime end = pRO.AccountingPeriodEnd;
|
|
decimal hourlyRate = 0;
|
|
decimal hours = 0;
|
|
if (pRO.RecipientPoBox != null)
|
|
pRO.RecipientStreet = pRO.RecipientPoBox;
|
|
|
|
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)
|
|
{
|
|
if (i.HourlyRate.HasValue)
|
|
hourlyRate = i.HourlyRate.Value;
|
|
|
|
if (i.Hours.HasValue)
|
|
hours += i.Hours.Value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
SetAnrede(pRO);
|
|
|
|
if (!String.IsNullOrEmpty(pRO.CustomerSalutation) && pRO.CustomerSalutation.ToLower() == "herr")
|
|
pRO.CustomerSalutation = "Herrn";
|
|
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void SetAnrede(ServiceInvoiceRO pRO)
|
|
{
|
|
String anrede = "Sehr geehrte Damen und Herren,";
|
|
|
|
var p = GetKontaktPerson(pRO);
|
|
|
|
if (p != null)
|
|
{
|
|
if (p.Sex.HasValue && p.Sex.Value == Sex.Male)
|
|
{
|
|
anrede = "Sehr geehrter Herr " + p.LastName + ",";
|
|
}
|
|
else if (p.Sex.HasValue && p.Sex.Value == Sex.Female)
|
|
{
|
|
anrede = "Sehr geehrte Frau " + p.LastName + ",";
|
|
}
|
|
}
|
|
|
|
lblAnrede.Text = anrede;
|
|
}
|
|
|
|
private Person GetKontaktPerson(ServiceInvoiceRO pRO)
|
|
{
|
|
if (pRO.ServiceInvoicePeriods.Count > 0)
|
|
{
|
|
var c2s = pRO.ServiceInvoicePeriods[0].CostBearer2SupportConcept;
|
|
return c2s.CostBearerContactPerson;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
} |