72 lines
2.7 KiB
C#
72 lines
2.7 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Collections;
|
|
using System.ComponentModel;
|
|
using DevExpress.XtraReports.UI;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Report;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using System.Linq;
|
|
using BS.Shared.DataContracts;
|
|
|
|
namespace SkmKrefeld
|
|
{
|
|
public partial class Spitzabrechnung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<Settlement2RO>
|
|
{
|
|
public Spitzabrechnung()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(Settlement2RO pRO)
|
|
{
|
|
//if (String.IsNullOrEmpty(pRO.Notice))
|
|
//{
|
|
// lblNotice.Visible = false;
|
|
//}
|
|
var customers = MapperFactory.CustomerDC_Customer.MapToNewDCs(DAOFactory.SearchDAO.FindCustomer(pRO.CustomerFirstName, pRO.CustomerLastName, pRO.CustomerBirthday.Value).ToList());
|
|
if (customers != null && customers.Count > 0)
|
|
{
|
|
CustomerDC richtigerCustomer = null;
|
|
if (customers.Count == 1)
|
|
richtigerCustomer = customers[0];
|
|
else
|
|
richtigerCustomer = customers.FirstOrDefault(c => c.DateOfBirth.Value == pRO.CustomerBirthday.Value);
|
|
|
|
if (richtigerCustomer != null)
|
|
{
|
|
var employeeRelation = richtigerCustomer.RelatedEmployees.FirstOrDefault(re => re.RelationRole.TypeDescription == "Hauptbetreuung" || re.RelationRole.TypeDescription == "Fallverantwortung");
|
|
if (employeeRelation != null)
|
|
{
|
|
var person = MapperFactory.PersonDC_Person.MapToNewDC(DAOFactory.GenericDAO.GetByID<Person>(employeeRelation.Employee.PersonOid));
|
|
var phone = person.ContactInformations.FirstOrDefault(c => c.ContactType == BS.Shared.ContactType.business_Phone);
|
|
var mail = person.ContactInformations.FirstOrDefault(c => c.ContactType == BS.Shared.ContactType.business_Mail);
|
|
pRO.SenderContactPerson = employeeRelation.Employee.FirstName + " " + employeeRelation.Employee.LastName;
|
|
if (phone != null)
|
|
pRO.SenderContactPersonPhone = phone.ContactValue;
|
|
if (mail != null)
|
|
pRO.SenderContactPersonMail = mail.ContactValue;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
decimal rateFactor = 1;
|
|
|
|
foreach (var ii in pRO.InvoiceItems)
|
|
{
|
|
if (ii.RateFactor.HasValue)
|
|
{
|
|
rateFactor = (100 + ii.RateFactor.Value) / 100;
|
|
}
|
|
}
|
|
pRO.RateFactor = (double)rateFactor;
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
}
|
|
}
|