176 lines
5.9 KiB
C#
176 lines
5.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.ServiceImplementations;
|
|
using BS.Shared.DataContracts;
|
|
|
|
namespace BeWo.BloemelingUndTeckhaus
|
|
{
|
|
public partial class Stundenzettel : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public Stundenzettel()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
double minTotal = 0;
|
|
|
|
bool showAssi = false;
|
|
|
|
bool hatGruppen = false;
|
|
|
|
if (pRO.Services != null)
|
|
{
|
|
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
|
|
|
|
foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services)
|
|
{
|
|
if (s.IsBillable)
|
|
{
|
|
if (s.IsGroup)
|
|
{
|
|
//sd.Notice5 = String.Format("{0} Teilnehmer", sd.CustomerCount);
|
|
hatGruppen = true;
|
|
}
|
|
|
|
if (s.ServiceCategory.Contains("Assistenz"))
|
|
{
|
|
showAssi = true;
|
|
}
|
|
else
|
|
{
|
|
minTotal += s.Minutes;
|
|
}
|
|
servicesBillable.Add(s);
|
|
}
|
|
}
|
|
|
|
pRO.Services = servicesBillable;
|
|
}
|
|
|
|
if (String.IsNullOrWhiteSpace(pRO.AbsenceTimes))
|
|
{
|
|
lblHatAbwesenheiten.Text = "X";
|
|
}
|
|
|
|
if (!hatGruppen)
|
|
{
|
|
lblHatGruppen.Text = "X";
|
|
}
|
|
ErstelleAbwesenheitenTabelle(pRO);
|
|
|
|
if (showAssi)
|
|
{
|
|
StundenzettelAssistenz subReport = xrSubreport1.ReportSource as StundenzettelAssistenz;
|
|
|
|
if (subReport != null)
|
|
subReport.SetReportDataSource(pRO);
|
|
|
|
}
|
|
else
|
|
{
|
|
GroupFooter2.Visible = false;
|
|
//xrSubreport1.Visible = false;
|
|
}
|
|
|
|
lblSummeMinuten.Text = string.Format("{0:0.##}", minTotal / 60);
|
|
cellMinuten.Text = string.Format("{0:0.##}", minTotal);
|
|
cellStunden.Text = string.Format("{0:0.00}", minTotal / 60);
|
|
lblSummeMinutenFaktor.Text = string.Format("{0:0.##}", Math.Round(minTotal / 60, 2, MidpointRounding.AwayFromZero) * 1.2);
|
|
|
|
var approved = pRO.ApprovedFLSPerWeek;
|
|
|
|
var stats = GetStatistics(pRO);
|
|
if (stats != null)
|
|
{
|
|
approved = stats.MinutesApprovedPerWeek / 60;
|
|
}
|
|
|
|
lblBewilligteStunden.Text = string.Format("{0:0.##}", approved);
|
|
|
|
|
|
bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void ErstelleAbwesenheitenTabelle(ServicesOverviewRO pRo)
|
|
{
|
|
if (pRo.Abwesenheiten != null)
|
|
{
|
|
int newRows = 0;
|
|
int index = 1;
|
|
foreach (var at in pRo.Abwesenheiten)
|
|
{
|
|
DevExpress.XtraReports.UI.XRTableRow row = null;
|
|
if (index < xrTableAbwesenheiten.Rows.Count)
|
|
{
|
|
row = xrTableAbwesenheiten.Rows[index];
|
|
}
|
|
else
|
|
{
|
|
row = xrTableAbwesenheiten.InsertRowBelow(xrTableAbwesenheiten.Rows[xrTableAbwesenheiten.Rows.Count - 1]);
|
|
newRows++;
|
|
}
|
|
|
|
row.Cells[0].Text = String.Format("{0:dd.MM.yyyy}", at.Start);
|
|
int? days = null;
|
|
|
|
if (at.End.HasValue)
|
|
{
|
|
row.Cells[1].Text = String.Format("{0:dd.MM.yyyy}", at.End);
|
|
days = (int)at.End.Value.Subtract(at.Start.Value).TotalDays + 1;
|
|
}
|
|
else
|
|
{
|
|
row.Cells[1].Text = "unbekannt";
|
|
}
|
|
|
|
row.Cells[2].Text = String.Format("{0:0}", days);
|
|
|
|
index++;
|
|
}
|
|
|
|
if (newRows > 0)
|
|
{
|
|
lblUnterschriftKlient.Top += newRows * 20;
|
|
lblUnterschriftMitarbeiter.Top += newRows * 20;
|
|
}
|
|
}
|
|
}
|
|
|
|
private SupportConceptPeriodStatisticsDC GetStatistics(ServicesOverviewRO ro)
|
|
{
|
|
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.StartsWith("Assistenz"))
|
|
{
|
|
return ps;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|
|
}
|