Files
BeWoPlaner/ReportImp/NahDran/ServicesOverviewReport2.cs
2019-02-12 19:32:04 +01:00

89 lines
2.9 KiB
C#

using System;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using BeWo.Report.ReportObjects;
using BeWo.Report;
using System.Collections.Generic;
using BeWo.Service.ServiceImplementations;
using BS.Shared.DataContracts;
namespace NahDran
{
public partial class Stundenzettel2 : DevExpress.XtraReports.UI.XtraReport//, IBeWoReport<ServicesOverviewRO>
{
public Stundenzettel2()
{
InitializeComponent();
}
public void SetReportDataSource(ServicesOverviewRO pRO)
{
if (pRO.Services != null)
{
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
double minuten = 0;
foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services)
{
if (s.IsBillable)
{
if (s.ServiceCategory.ToLower().IndexOf("assistenz") < 0)
{
servicesBillable.Add(s);
minuten += s.Minutes;
}
}
}
pRO.TotalFLMBillable = minuten;
pRO.Services = servicesBillable;
}
var approved = pRO.ApprovedFLSPerWeek;
SupportConceptPeriodStatisticsDC stats = GetFlsStatistics(pRO, "assistenz"); ;
if (stats != null)
{
approved = stats.MinutesApprovedPerWeek / 60;
}
lblBewilligteStunden.Text = string.Format("{0:0.##}", approved);
this.bindingSource1.DataSource = pRO;
}
private SupportConceptPeriodStatisticsDC GetFlsStatistics(ServicesOverviewRO ro, String assName)
{
if (ro.CostBearer2SupportConceptList != null && ro.CostBearer2SupportConceptList.Count > 0)
{
var service = new OperationsServiceImp();
foreach (var cb2sc in ro.CostBearer2SupportConceptList)
{
long cb2scOid = cb2sc.Oid.Value;
var stats = service.CreateSupportConceptStatistics(cb2scOid, ro.EndDate);
if (stats.PeriodStatistics != null && stats.PeriodStatistics.Count > 0)
{
foreach (var ps in stats.PeriodStatistics)
{
if ((ps.SupportConceptApprovalPeriod != null && ps.SupportConceptApprovalPeriod.ServiceCategory != null &&
!ps.SupportConceptApprovalPeriod.ServiceCategory.Name.ToLower().Contains(assName)) || ps.SupportConceptApprovalPeriod.ServiceCategory == null)
{
return ps;
}
}
}
}
}
return null;
}
}
}