224 lines
6.9 KiB
C#
224 lines
6.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.Dienstplanung;
|
|
using BS.Shared.Core;
|
|
using DevExpress.XtraReports.UI;
|
|
using static BeWo.Report.ReportObjects.MitarbeiterstundenkontoRO;
|
|
|
|
namespace AkggMid
|
|
{
|
|
[IDSpecificClass(Identifier = "Mitarbeiterarbeitszeitkonto")]
|
|
public partial class Mitarbeiterarbeitszeitkonto : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<MitarbeiterstundenkontoRO>
|
|
{
|
|
public Mitarbeiterarbeitszeitkonto()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(MitarbeiterstundenkontoRO pRO)
|
|
{
|
|
var msb = new CustomMitarbeiterstundenkontoBerechnung();
|
|
msb.CreateReport(pRO);
|
|
|
|
foreach (var ed in pRO.EmployeeDetailList)
|
|
{
|
|
var c = ed.Employee.GetValidContractForDate(pRO.ReportEndDate.AddDays(-1));
|
|
if (c == null)
|
|
{
|
|
c = ed.Employee.GetValidContractForDate(pRO.ReportStartDate);
|
|
}
|
|
if (c != null)
|
|
{
|
|
if (c.MonthlyTotalHours.HasValue)
|
|
{
|
|
ed.Regelarbeitszeit = String.Format("{0:0.00} Stunden im Monat", c.MonthlyTotalHours);
|
|
}
|
|
else if (c.WeeklyTotalHours.HasValue)
|
|
{
|
|
ed.Regelarbeitszeit = String.Format("{0:0.00} Stunden pro Woche", c.WeeklyTotalHours);
|
|
}
|
|
|
|
if (c.EntryDate.HasValue && c.EntryDate.Value.Date > pRO.ReportStartDate)
|
|
{
|
|
ed.Regelarbeitszeit = String.Format("ab {0:dd.MM.yyyy} {1}", c.EntryDate, ed.Regelarbeitszeit);
|
|
//Hat einen Vertragswechsel im Monat
|
|
var vorherigerVertrag = ed.Employee.GetValidContractForDate(c.EntryDate.Value.AddDays(-1));
|
|
{
|
|
if (vorherigerVertrag != null)
|
|
{
|
|
if (vorherigerVertrag.MonthlyTotalHours.HasValue)
|
|
{
|
|
ed.Regelarbeitszeit = String.Format("bis {0:dd.MM.yyyy} {1:0.00} Stunden im Monat, {2}", c.EntryDate.Value.AddDays(-1), vorherigerVertrag.MonthlyTotalHours, ed.Regelarbeitszeit);
|
|
}
|
|
else if (vorherigerVertrag.WeeklyTotalHours.HasValue)
|
|
{
|
|
ed.Regelarbeitszeit = String.Format("bis {0:dd.MM.yyyy} {1:0.00} Stunden pro Woche, {2}", c.EntryDate.Value.AddDays(-1), vorherigerVertrag.WeeklyTotalHours, ed.Regelarbeitszeit);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Alles in Custom6 / 7 / 8 / 9 schreiben
|
|
foreach (var empDetail in pRO.EmployeeDetailList)
|
|
{
|
|
var newDayList = new List<MitarbeiterstundenkontoRO.DayDetail>();
|
|
|
|
foreach (var day in empDetail.Days)
|
|
{
|
|
bool added = false;
|
|
|
|
if (day.Date.Day == 4)
|
|
{
|
|
int test = 0;
|
|
}
|
|
if (day.AbsenceTimes != null && day.AbsenceTimes.Count > 0)
|
|
{
|
|
var hours = day.HoursSick + day.HoursInVacation;
|
|
empDetail.StundenGesamtIst += hours;
|
|
|
|
newDayList.Add(day);
|
|
added = true;
|
|
if (day.AbsenceTimes[0].AbsenceReason.Description.ToLower().Contains("krank"))
|
|
{
|
|
day.ServiceRecords = null;
|
|
}
|
|
|
|
}
|
|
|
|
if (day.ServiceRecords != null && day.ServiceRecords.Count > 0)
|
|
{
|
|
foreach (var sr in day.ServiceRecords)
|
|
{
|
|
var dd = new MitarbeiterstundenkontoRO.DayDetail();
|
|
dd.Date = day.Date;
|
|
dd.ServiceRecords = new List<StundenkontoServiceRecord>();
|
|
dd.ServiceRecords.Add(sr);
|
|
added = true;
|
|
newDayList.Add(dd);
|
|
}
|
|
}
|
|
day.ServiceRecords = null;
|
|
|
|
|
|
if (!added)
|
|
{
|
|
newDayList.Add(day);
|
|
}
|
|
|
|
}
|
|
empDetail.Days = newDayList;
|
|
foreach (var day in empDetail.Days)
|
|
{
|
|
|
|
string custom6 = "";
|
|
string custom7 = "";
|
|
string custom8 = "";
|
|
string custom9 = "";
|
|
|
|
if (day.AbsenceTimes != null && day.AbsenceTimes.Count > 0)
|
|
{
|
|
var hours = day.HoursSick + day.HoursInVacation;
|
|
|
|
custom7 = AddText(custom7, day.AbsenceTimes[0].AbsenceReason.Description);
|
|
custom9 = AddText(custom9, string.Format("{0:0.00}", hours));
|
|
}
|
|
if (day.IstFeiertag)
|
|
{
|
|
custom6 = "keine*r";
|
|
|
|
custom7 = AddText(custom7, day.Feiertag.Name);
|
|
custom8 = "-";
|
|
}
|
|
if (day.ServiceRecords != null && day.ServiceRecords.Count > 0)
|
|
{
|
|
foreach (var sr in day.ServiceRecords)
|
|
{
|
|
var srEntity = DAOFactory.GenericDAO.LoadByID<ServiceRecord>(sr.ServiceRecordOid.Value);
|
|
|
|
custom7 = AddText(custom7, sr.ServiceDescription.Category.Name);
|
|
custom8 = AddText(custom8, sr.ServiceDescription.Name);
|
|
|
|
if (srEntity.Group != null && sr.GroupRoundedDuration.HasValue && sr.GroupPersonCount.HasValue && sr.GroupPersonCount.Value > 1)
|
|
{
|
|
foreach (var gsr in srEntity.Group.ServiceRecordList)
|
|
{
|
|
custom6 = AddText(custom6, gsr.SupportConcept != null ? gsr.SupportConcept.Customer.Person.FirstNameLastName : "");
|
|
}
|
|
custom9 = AddText(custom9, string.Format("{0:0.00}", sr.GroupRoundedDuration / 60));
|
|
}
|
|
else
|
|
{
|
|
custom6 = AddText(custom6, srEntity.SupportConcept != null ? srEntity.SupportConcept.Customer.Person.FirstNameLastName : "keine*r");
|
|
custom9 = AddText(custom9, string.Format("{0:0.00}", sr.RoundedDuration / 60));
|
|
}
|
|
}
|
|
}
|
|
|
|
day.Custom6 = custom6;
|
|
day.Custom7 = custom7;
|
|
day.Custom8 = custom8;
|
|
day.Custom9 = custom9;
|
|
}
|
|
}
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void xrTableCell3_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
XRTableCell cell = sender as XRTableCell;
|
|
|
|
var rowObj = cell.Report.GetCurrentRow();
|
|
|
|
if (rowObj is DayDetail myRow && myRow.Date != null)
|
|
{
|
|
XRTableRow row = cell.Parent as XRTableRow;
|
|
|
|
System.Drawing.Color backColor = System.Drawing.Color.Transparent;
|
|
|
|
if (myRow.Date.DayOfWeek == DayOfWeek.Saturday || myRow.Date.DayOfWeek == DayOfWeek.Sunday || IstFeiertag(myRow.Date))
|
|
{
|
|
backColor = System.Drawing.Color.Gainsboro;
|
|
}
|
|
|
|
foreach (XRTableCell c in row.Cells)
|
|
{
|
|
c.BackColor = backColor;
|
|
}
|
|
}
|
|
}
|
|
|
|
private Service.CustomVacationService _vacationService;
|
|
|
|
private bool IstFeiertag(DateTime date)
|
|
{
|
|
if (_vacationService == null)
|
|
{
|
|
_vacationService = new Service.CustomVacationService();
|
|
}
|
|
|
|
return _vacationService.IstFeiertag(date);
|
|
}
|
|
|
|
private string AddText(string text, string description)
|
|
{
|
|
if (text.Length > 0)
|
|
{
|
|
text += "\n";
|
|
}
|
|
text += description;
|
|
|
|
return text;
|
|
}
|
|
}
|
|
}
|