Files
BeWoPlaner/ReportImp/BeWoRichartz/ServicesOverviewReport.cs
2016-06-27 01:45:38 +02:00

45 lines
1.4 KiB
C#

using System;
using System.Linq;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BS.Shared.Extensions;
namespace BeWoRichartz
{
public partial class Stundenzettel : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
{
public Stundenzettel()
{
InitializeComponent();
}
public void SetReportDataSource(ServicesOverviewRO pRO)
{
if (pRO.Services != null)
{
var servicesBillable = pRO.Services.Where(s => s.IsBillable).ToList();
var parsedMonthDate = DateTime.Parse(String.Format("01. {0} {1}", pRO.Month, pRO.Year));
var tageImMonat = DateTime.DaysInMonth(parsedMonthDate.Year, parsedMonthDate.Month);
for (var i = 0; i < tageImMonat; i++)
{
var date = new DateTime(pRO.Year, parsedMonthDate.Month, i + 1);
if (!servicesBillable.Any(a => a.StartDate.CompareShortDates(date)))
{
servicesBillable.Add(new ServicesOverviewRO.ServiceDetail { StartDate = date });
}
}
pRO.Services = servicesBillable.OrderBy(o => o.StartDate).ToList();
}
bindingSource1.DataSource = pRO;
}
}
}