Files
BeWoPlaner/ReportImp/SBBMainzReports/CustomerDataReport.cs
Christian cf90774667 bugfixing
2017-06-11 15:50:31 +02:00

101 lines
3.7 KiB
C#

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Linq;
using BS.Shared.DataContracts.Compact;
using BeWo.Report;
using DevExpress.XtraReports.UI;
using BeWo.Report.ReportObjects;
using BeWo.Data.Entities;
using BeWo.Data.Access;
using System.Text;
namespace BeWo.SBBMainzReports
{
public partial class Klientenstammblatt : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<CustomerDataRO>
{
public Klientenstammblatt()
{
InitializeComponent();
}
public void SetReportDataSource(CustomerDataRO pRO)
{
CompactEmployeeDC hauptBetreuuer = null;
if (pRO.RelatedEmployees != null)
{
foreach (var empRel in pRO.RelatedEmployees)
{
if (hauptBetreuuer == null && empRel.RelationRole != null)
{
hauptBetreuuer = empRel.Employee;
}
}
}
StringBuilder abwesenheiten = new StringBuilder();
if (hauptBetreuuer != null)
{
Employee emp = DAOFactory.GenericDAO.LoadByID<Employee>(hauptBetreuuer.EmployeeOid);
if (emp.AbsenceTimes != null)
{
var sortedAt = emp.AbsenceTimes.OrderBy(at => at.Start);
foreach (var at in sortedAt)
{
if (!at.End.HasValue || at.End.Value >= DateTime.Now.Date)
{
if (abwesenheiten.Length > 0)
abwesenheiten.Append("\r\n");
if (at.End.HasValue)
abwesenheiten.Append(String.Format("{0:dd.MM.yyyy} bis {1:dd.MM.yyyy}", at.Start, at.End));
else
abwesenheiten.Append(String.Format("ab {0:dd.MM.yyyy}", at.Start));
if (at.AbsenceReason != null)
{
abwesenheiten.Append(": ");
abwesenheiten.Append(at.AbsenceReason.Description);
}
}
}
}
}
lblAbwesenheitenHauptbetreuuer.Text = abwesenheiten.ToString();
abwesenheiten = new StringBuilder();
if (pRO.Customer.AbsenceTimes != null)
{
var sortedAt = pRO.Customer.AbsenceTimes.OrderBy(at => at.Start);
foreach (var at in sortedAt)
{
if (!at.End.HasValue || at.End.Value >= DateTime.Now.Date)
{
if (abwesenheiten.Length > 0)
abwesenheiten.Append("\r\n");
if (at.End.HasValue)
abwesenheiten.Append(String.Format("{0:dd.MM.yyyy} bis {1:dd.MM.yyyy}", at.Start, at.End));
else
abwesenheiten.Append(String.Format("ab {0:dd.MM.yyyy}", at.Start));
if (at.Reason != null)
{
abwesenheiten.Append(": ");
abwesenheiten.Append(at.Reason.Description);
}
}
}
}
lblAbwesenheitKlient.Text = abwesenheiten.ToString();
this.bindingSource1.DataSource = pRO;
}
}
}