Files
BeWoPlaner/ReportImp/VkmMenden/ServiceInvoiceReport.cs
Christian dbed05ccb2 cb
2018-11-22 14:05:45 +01:00

114 lines
3.5 KiB
C#

using System;
using System.Text;
using System.Windows.Forms.VisualStyles;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using DevExpress.XtraReports.UI;
namespace VkmMenden
{
public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public ServiceInvoiceReport()
{
this.InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
{
pRO.RecipientOrganisation = pRO.RecipientOrganisation.Replace(" - Assistenz", "").Replace(" - Fachleistung", "").Trim();
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();
if (!String.IsNullOrWhiteSpace(pRO.SenderContactPersonPhone))
{
pRO.SenderContactPersonPhone = pRO.SenderContactPersonPhone.Replace("Tel.:", "").Trim();
}
if (!String.IsNullOrWhiteSpace(pRO.SenderContactPersonFax))
{
pRO.SenderContactPersonFax = pRO.SenderContactPersonFax.Replace("Fax:", "").Trim();
}
if (!String.IsNullOrWhiteSpace(pRO.SenderContactPersonMail))
{
pRO.SenderContactPersonMail = pRO.SenderContactPersonMail.Replace("E-Mail:", "").Trim();
}
decimal hourlyRate = 0;
decimal rateFactor = 1;
decimal hours = 0;
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 (!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)
hours += i.Hours.Value;
}
}
}
}
hours *= rateFactor;
lblDatum.Text = String.Format("{0:MMMM}/{0:yyyy}", pRO.AccountingPeriodStart);
if (!String.IsNullOrEmpty(pRO.CustomerSalutation) && pRO.CustomerSalutation.ToLower() == "herr")
pRO.CustomerSalutation = "Herrn";
// cellDesription.Text = String.Format("Fachleistungsstunden {0:MM}/{0:yyyy}", pRO.AccountingPeriodStart);
//cellHours.Text = String.Format("{0:0.00} Stunden x", hours);
//cellHouryRate.Text = String.Format("{0:0.00} Euro", hourlyRate);
//cellClaim.Text = String.Format("{0} Euro", pRO.NetClaim.Replace("€","").Trim());
this.bindingSource1.DataSource = pRO;
}
}
}