144 lines
4.7 KiB
C#
144 lines
4.7 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;
|
|
|
|
namespace BeWo.DerKarren
|
|
{
|
|
public partial class Stundenzettel : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public Stundenzettel()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
bool hatGruppen = false;
|
|
|
|
Dictionary<string, string> cats = new Dictionary<string, string>();
|
|
|
|
if (pRO.Services != null)
|
|
{
|
|
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
|
|
|
|
foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services)
|
|
{
|
|
if (s.IsBillable || s.ServiceDescription.ToLower().Contains("fehlkontakt"))
|
|
{
|
|
if (s.ServiceDescription.ToLower().Contains("fehlkontakt"))
|
|
s.Notice5 = "Fehlkontakt";
|
|
else if (s.IsGroup)
|
|
s.Notice5 = "Gruppe";
|
|
else if (!s.IsGroup)
|
|
s.Notice5 = "Einzeln";
|
|
|
|
|
|
if (s.IsGroup)
|
|
{
|
|
hatGruppen = true;
|
|
}
|
|
|
|
servicesBillable.Add(s);
|
|
|
|
if (!cats.ContainsKey(s.ServiceCategory))
|
|
{
|
|
cats.Add(s.ServiceCategory, s.ServiceCategory);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
pRO.Services = servicesBillable;
|
|
}
|
|
|
|
bool istAssistenz = false;
|
|
if (cats.Count == 1 && cats.ContainsKey("Assistenzleistung"))
|
|
{
|
|
istAssistenz = true;
|
|
}
|
|
|
|
|
|
|
|
var minutesWithFactor = pRO.TotalFLMBillable*(double)pRO.RateFactor;
|
|
|
|
DateTime dt = DateTime.Now.Date.AddMinutes(minutesWithFactor);
|
|
TimeSpan tspan = dt.Subtract(DateTime.Now.Date);
|
|
|
|
double d = tspan.TotalHours;
|
|
d = Math.Floor(d);
|
|
|
|
|
|
cellHoursMinutes.Text = pRO.TotalFLHoursMinutesString;
|
|
cellHoursMinutesFactor.Text = String.Format("{0}:{1:00}", d, tspan.Minutes);
|
|
cellHoursFactor.Text = String.Format("{0:0.00}", minutesWithFactor / 60);
|
|
|
|
if (istAssistenz)
|
|
{
|
|
cellHoursMinutesFactor.Visible = false;
|
|
cellHoursFactor.Visible = false;
|
|
cellFactorText.Visible = false;
|
|
cellFactorBorder.Visible = false;
|
|
lblTitel.Text = "Quittierungsbeleg über Assistenzleistungen";
|
|
}
|
|
|
|
if (String.IsNullOrWhiteSpace(pRO.AbsenceTimes))
|
|
{
|
|
lblHatAbwesenheiten.Text = "X";
|
|
}
|
|
|
|
if (!hatGruppen)
|
|
{
|
|
lblHatGruppen.Text = "X";
|
|
}
|
|
|
|
ErstelleAbwesenheitenTabelle(pRO);
|
|
|
|
this.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++;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|