2020-09-30 10:00:31 +02:00
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
|
using BeWo.Report.ReportObjects;
|
2021-05-03 15:13:53 +02:00
|
|
|
using System.Collections.Generic;
|
2020-09-30 10:00:31 +02:00
|
|
|
|
|
|
|
|
namespace BeWo.Report.DefaultReports
|
|
|
|
|
{
|
|
|
|
|
public partial class AbsenceReport : XtraReport, IBeWoReport<AbsenceRO>
|
|
|
|
|
{
|
2021-05-03 15:13:53 +02:00
|
|
|
public int Month { get; set; }
|
|
|
|
|
public int Year { get; set; }
|
|
|
|
|
public List<int> Feiertage { get; set; }
|
|
|
|
|
|
2020-09-30 10:00:31 +02:00
|
|
|
public AbsenceReport()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetReportDataSource(AbsenceRO pRO)
|
|
|
|
|
{
|
2020-10-13 14:35:06 +02:00
|
|
|
int i = DateTime.DaysInMonth(pRO.ReportFilter.Year, pRO.ReportFilter.Month);
|
2021-05-03 15:13:53 +02:00
|
|
|
Month = pRO.ReportFilter.Month;
|
|
|
|
|
Year = pRO.ReportFilter.Year;
|
|
|
|
|
Feiertage = pRO.Feiertage;
|
|
|
|
|
|
2020-09-30 10:00:31 +02:00
|
|
|
|
|
|
|
|
cellHeader29.Visible = cellDetail29.Visible = i >= 29;
|
|
|
|
|
cellHeader30.Visible = cellDetail30.Visible = i >= 30;
|
|
|
|
|
cellHeader31.Visible = cellDetail31.Visible = i >= 31;
|
2021-05-03 15:13:53 +02:00
|
|
|
|
|
|
|
|
SetWeekDayNames(pRO.ReportFilter.Year, pRO.ReportFilter.Month, i);
|
|
|
|
|
|
|
|
|
|
string date = SetDate(pRO);
|
2020-09-30 10:00:31 +02:00
|
|
|
|
2021-05-03 15:13:53 +02:00
|
|
|
if (pRO.Teams != null)
|
|
|
|
|
{
|
|
|
|
|
if(pRO.Teams.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
date += " (";
|
|
|
|
|
for (int z = 0; z < pRO.Teams.Count; z++)
|
|
|
|
|
{
|
|
|
|
|
var t = pRO.Teams[z];
|
|
|
|
|
date += t.Name;
|
|
|
|
|
if (t.TeamOid != pRO.Teams[pRO.Teams.Count - 1].TeamOid)
|
|
|
|
|
date += ", ";
|
|
|
|
|
}
|
|
|
|
|
date += ") ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lblReportInformation.Text = date;
|
2020-09-30 10:00:31 +02:00
|
|
|
bindingSource1.DataSource = pRO;
|
|
|
|
|
}
|
2021-05-03 15:13:53 +02:00
|
|
|
|
|
|
|
|
private void SetWeekDayNames(int year, int month, int numberOfDays)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 1; i <= numberOfDays; i++)
|
|
|
|
|
{
|
|
|
|
|
DateTime date = new DateTime(year, month, i);
|
|
|
|
|
CultureInfo c = new CultureInfo("de-DE");
|
|
|
|
|
string weekday = c.DateTimeFormat.GetAbbreviatedDayName(date.DayOfWeek);
|
|
|
|
|
|
|
|
|
|
cellHeader1.Row.Cells[i].Text += "\n" + weekday;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string SetDate(AbsenceRO pRO)
|
|
|
|
|
{
|
|
|
|
|
string date = "";
|
|
|
|
|
DateTimeFormatInfo dti = CultureInfo.GetCultureInfo("de-DE").DateTimeFormat;
|
|
|
|
|
date += dti.GetMonthName(pRO.ReportFilter.Month).ToString() + " " + pRO.ReportFilter.Year;
|
|
|
|
|
|
|
|
|
|
return date;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-30 10:00:31 +02:00
|
|
|
private void Cell_EvaluateBinding(object sender, BindingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var cell = sender as XRTableCell;
|
|
|
|
|
|
|
|
|
|
var sv = e.Value as CellValue;
|
|
|
|
|
if (sv != null && !string.IsNullOrEmpty(sv.Color))
|
|
|
|
|
{
|
|
|
|
|
int argb = Int32.Parse(sv.Color.Replace("#", ""), NumberStyles.HexNumber);
|
|
|
|
|
Color clr = Color.FromArgb(argb);
|
|
|
|
|
|
|
|
|
|
cell.BackColor = clr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cell.BackColor = Color.Transparent;
|
2021-05-03 15:13:53 +02:00
|
|
|
if(cell.Index <= DateTime.DaysInMonth(Year, Month))
|
|
|
|
|
{
|
|
|
|
|
DateTime date = new DateTime(Year, Month, cell.Index);
|
2021-08-05 11:35:55 +02:00
|
|
|
if (date.DayOfWeek == DayOfWeek.Sunday || date.DayOfWeek == DayOfWeek.Saturday)
|
2021-05-07 13:22:01 +02:00
|
|
|
cell.BackColor = Color.LightGray;
|
2021-08-05 11:35:55 +02:00
|
|
|
if (Feiertage != null)
|
2021-05-03 15:13:53 +02:00
|
|
|
{
|
|
|
|
|
if (Feiertage.Contains(date.Day))
|
|
|
|
|
cell.BackColor = Color.LightPink;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-30 10:00:31 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|