155 lines
5.4 KiB
C#
155 lines
5.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared.Core;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace SHKServiceSBD
|
|
{
|
|
public partial class Quittierungsbeleg : XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public Quittierungsbeleg()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
|
|
double totalHours = 0;
|
|
|
|
if (pRO.Services != null)
|
|
{
|
|
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
|
|
|
|
Dictionary<String, ServicesOverviewRO.ServiceDetail> dict = new Dictionary<string, ServicesOverviewRO.ServiceDetail>();
|
|
|
|
foreach (var sd in pRO.Services)
|
|
{
|
|
if (sd.ServiceDescription.Contains("Unterricht"))
|
|
{
|
|
sd.Notice = "";
|
|
sd.StartDateMinutes = null;
|
|
sd.EndDateMinutes = null;
|
|
sd.Minutes /= 60;
|
|
|
|
if (!dict.ContainsKey(String.Format("{0:dd.MM.yyyy}", sd.StartDate)))
|
|
{
|
|
dict.Add(String.Format("{0:dd.MM.yyyy}", sd.StartDate), sd);
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach (var sd in pRO.Services)
|
|
{
|
|
if (!sd.ServiceDescription.Contains("Unterricht"))
|
|
{
|
|
if (dict.ContainsKey(String.Format("{0:dd.MM.yyyy}", sd.StartDate)))
|
|
{
|
|
var usd = dict[String.Format("{0:dd.MM.yyyy}", sd.StartDate)];
|
|
DateTime minstart = usd.StartDate;
|
|
|
|
if (usd.StartDateMinutes.HasValue)
|
|
{
|
|
minstart = usd.StartDateMinutes.Value;
|
|
}
|
|
DateTime maxend = usd.EndDate;
|
|
|
|
if (usd.EndDateMinutes.HasValue)
|
|
{
|
|
maxend = usd.EndDateMinutes.Value;
|
|
}
|
|
if (sd.StartDate < minstart)
|
|
{
|
|
usd.StartDateMinutes = sd.StartDate;
|
|
}
|
|
if (sd.EndDate > maxend)
|
|
{
|
|
usd.EndDateMinutes = sd.EndDate;
|
|
}
|
|
usd.Minutes += sd.Minutes / 60;
|
|
}
|
|
}
|
|
}
|
|
|
|
var atimes = GetAbsenceTimes(pRO);
|
|
|
|
var date = pRO.StartDate;
|
|
|
|
while (date <= pRO.EndDate)
|
|
{
|
|
ServicesOverviewRO.ServiceDetail sd = null;
|
|
if (!dict.ContainsKey(String.Format("{0:dd.MM.yyyy}", date)))
|
|
{
|
|
sd = new ServicesOverviewRO.ServiceDetail();
|
|
sd.StartDate = date;
|
|
sd.StartDateString = "";
|
|
sd.TimeRangeString = "";
|
|
sd.Notice5 = "";
|
|
}
|
|
else
|
|
{
|
|
sd = dict[String.Format("{0:dd.MM.yyyy}", date)];
|
|
|
|
sd.StartDateString = String.Format("{0:HH:mm}", sd.StartDate);
|
|
sd.TimeRangeString = String.Format("{0:HH:mm}", sd.EndDate);
|
|
sd.Notice5 = String.Format("{0:0.00}", sd.Minutes);
|
|
}
|
|
|
|
if (IstAbwesend(atimes, date))
|
|
{
|
|
sd.Notice = "x";
|
|
}
|
|
|
|
if (date.DayOfWeek == DayOfWeek.Saturday)
|
|
{
|
|
sd.IstSamstag = true;
|
|
}
|
|
else if (date.DayOfWeek == DayOfWeek.Sunday)
|
|
{
|
|
sd.IstSonntag = true;
|
|
}
|
|
servicesBillable.Add(sd);
|
|
|
|
date = date.AddDays(1);
|
|
}
|
|
pRO.Services = servicesBillable;
|
|
}
|
|
|
|
bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private bool IstAbwesend(IList<AbsenceTime> atimes, DateTime date)
|
|
{
|
|
foreach (var at in atimes)
|
|
{
|
|
if (at.Start.Value.Date <= date && (!at.End.HasValue || at.End.Value >= date))
|
|
{
|
|
var desc = at.AbsenceReason.Description.ToLower();
|
|
if (desc.Contains("krank") || desc.Contains("abwesenheit") || desc.Contains("arzttermin") || desc.Contains("ferien"))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private IList<AbsenceTime> GetAbsenceTimes(ServicesOverviewRO pRO)
|
|
{
|
|
if (pRO.CustomerOid > 0)
|
|
{
|
|
var c = DAOFactory.GenericDAO.LoadByID<Customer>(pRO.CustomerOid);
|
|
return c.AbsenceTimes;
|
|
}
|
|
return new List<AbsenceTime>();
|
|
}
|
|
}
|
|
}
|