using System; using System.Text; using System.Windows.Forms.VisualStyles; using BeWo.Report; using BeWo.Report.ReportObjects; using DevExpress.XtraReports.UI; namespace Inkomm { public partial class ServiceInvoiceReport : XtraReport , IBeWoReport { public ServiceInvoiceReport() { this.InitializeComponent(); } public void SetReportDataSource(ServiceInvoiceRO pRO) { 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(); 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; if (!String.IsNullOrEmpty(pRO.CustomerSalutation) && pRO.CustomerSalutation.ToLower() == "herr") pRO.CustomerSalutation = "Herrn"; cellRechnungstext.Text = String.Format("{0:0} Min. = {1:0.##} Stunden a EUR {2:0.00} (Leistungsart 1)", hours * 60, hours, hourlyRate); this.bindingSource1.DataSource = pRO; } } }