69 lines
3.2 KiB
C#
69 lines
3.2 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 System.Collections.Generic;
|
|
|
|
namespace BeWo.Report.DefaultReports
|
|
{
|
|
public partial class Spitzabrechnung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<Settlement2RO>
|
|
{
|
|
public Spitzabrechnung()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(Settlement2RO pRO)
|
|
{
|
|
List<Customer> customerList = new List<Customer>();
|
|
if (pRO.CustomerBirthday.HasValue)
|
|
customerList = DAOFactory.SearchDAO.FindCustomer(pRO.CustomerFirstName, pRO.CustomerLastName, pRO.CustomerBirthday.Value).ToList();
|
|
else
|
|
customerList = DAOFactory.SearchDAO.FindCustomer(pRO.CustomerFirstName, pRO.CustomerLastName, pRO.CustomerReferenceNumber).ToList();
|
|
|
|
if (customerList.Count == 1)
|
|
{
|
|
var customer = MapperFactory.CustomerDC_Customer.MapToNewDC(customerList[0]);
|
|
var geburtstag = customer.DateOfBirth.HasValue ? string.Format("{0:dd.MM.yyyy}", customer.DateOfBirth.Value) : "-";
|
|
lblRechnungsinfos.Text = string.Format("Rechnungsnummer: {0}\nSpitzabrechnung: {1}, {2}, {3} {4} *{5}\nAZ: {6}",
|
|
pRO.InvoiceNumber, pRO.CustomerName, customerList[0].Person.Address.Street, customerList[0].Person.Address.PostalCode,
|
|
customerList[0].Person.Address.Town, geburtstag, pRO.CustomerReferenceNumber);
|
|
}
|
|
else if (customerList.Count > 1)
|
|
{
|
|
var customer = MapperFactory.CustomerDC_Customer.MapToNewDC(customerList.FirstOrDefault(c => c.Person.DateOfBirth.Value.Date == pRO.CustomerBirthday.Value));
|
|
var geburtstag = customer.DateOfBirth.HasValue ? string.Format("{0:dd.MM.yyyy}", customer.DateOfBirth.Value) : "-";
|
|
if (customer != null)
|
|
{
|
|
lblRechnungsinfos.Text = string.Format("Rechnungsnummer: {0}\nSpitzabrechnung: {1}, {2}, {3} {4} *{5}\nAZ: {6}",
|
|
pRO.InvoiceNumber, pRO.CustomerName, customerList[0].Person.Address.Street, customerList[0].Person.Address.PostalCode,
|
|
customerList[0].Person.Address.Town, geburtstag, pRO.CustomerReferenceNumber);
|
|
}
|
|
}
|
|
else
|
|
lblRechnungsinfos.Text = string.Format("Rechnungsnummer: {0}\nSpitzabrechnung: {1}, *{2}\nAZ: {3}",
|
|
pRO.InvoiceNumber, pRO.CustomerName, pRO.CustomerBirthday.HasValue ? string.Format("{0:dd.MM.yyyy}", pRO.CustomerBirthday.Value) : "-", pRO.CustomerReferenceNumber);
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|