Files
BeWoPlaner/ReportImp/AutismusKoelnBonn/InvoiceCustomerReport.cs

120 lines
5.1 KiB
C#

using System;
using System.Text;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report;
using BeWo.Report.ReportObjects;
namespace AutismusKoelnBonn
{
public partial class InvoiceCustomerReport : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<InvoiceCustomerRO>
{
public InvoiceCustomerReport()
{
InitializeComponent();
}
public void SetReportDataSource(InvoiceCustomerRO pRO)
{
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && !String.IsNullOrEmpty(pRO.RecipientOrganisation.Trim()))
{
sb.AppendLine(pRO.RecipientOrganisation);
}
if (!String.IsNullOrEmpty(pRO.RecipientDivision) && !String.IsNullOrEmpty(pRO.RecipientDivision.Trim()))
{
sb.AppendLine(pRO.RecipientDivision);
}
if ((!String.IsNullOrEmpty(pRO.RecipientFirstName) && !String.IsNullOrEmpty(pRO.RecipientFirstName.Trim()))
|| (!String.IsNullOrEmpty(pRO.RecipientLastName) && !String.IsNullOrEmpty(pRO.RecipientLastName.Trim())))
{
sb.AppendLine(String.Format("{0} {1}", pRO.RecipientFirstName, pRO.RecipientLastName).Trim());
}
if (!String.IsNullOrEmpty(pRO.RecipientStreet) && !String.IsNullOrEmpty(pRO.RecipientStreet.Trim()))
{
sb.AppendLine(pRO.RecipientStreet);
}
if (!String.IsNullOrEmpty(pRO.RecipientPostCode) && !String.IsNullOrEmpty(pRO.RecipientPostCode.Trim()))
{
sb.Append(pRO.RecipientPostCode);
sb.Append(" ");
}
if (!String.IsNullOrEmpty(pRO.RecipientTown) && !String.IsNullOrEmpty(pRO.RecipientTown.Trim()))
{
sb.Append(pRO.RecipientTown);
}
lblAddress.Text = sb.ToString();
if (!String.IsNullOrEmpty(pRO.CustomerSalutation) && pRO.CustomerSalutation.ToLower().Contains("herr"))
lblAnrede.Text = String.Format("Sehr geehrter Herr {0},", pRO.CustomerLastName);
else if (!String.IsNullOrEmpty(pRO.CustomerSalutation) && pRO.CustomerSalutation.ToLower().Contains("frau"))
lblAnrede.Text = String.Format("Sehr geehrte Frau {0},", pRO.CustomerLastName);
string lvrBescheid = "";
string team = "MoveAut Team Köln";
if (pRO.InvoiceBase != null && pRO.InvoiceBase.SupportConceptOid != null)
{
var sc = DAOFactory.GenericDAO.LoadByID<SupportConcept>((long)pRO.InvoiceBase.SupportConceptOid);
if (sc.Customer.Team2CustomerList.Count > 0)
team = sc.Customer.Team2CustomerList[0].Team.Name;
lvrBescheid = String.Format("gemäß Bescheid des LVR vom {0:dd.MM.yyyy}, ", sc.ApprovalDate);
lblBewilligungszeitraum.Text += String.Format("Bewillingszeitraum: {0:dd.MM.yyyy} - {1:dd.MM.yyyy}", sc.StartDate, sc.EndDate);
pRO.CreatorFirstName = sc.Customer.DebitorNumber;
}
if (pRO.AccountingPeriodStart.HasValue && pRO.AccountingPeriodEnd.HasValue
&& pRO.AccountingPeriodStart.Value.Month != pRO.AccountingPeriodEnd.Value.Month && pRO.InvoiceItems[0].UnitCount > 1)
{
lblText.Text = String.Format("hiermit erlauben wir uns, Ihnen für die Monate {0:MMMM yyyy} bis {1:MMMM yyyy} folgende Leistungen {2}" +
"in Rechnung zu stellen:", pRO.AccountingPeriodStart, pRO.AccountingPeriodEnd, lvrBescheid);
foreach (var ii in pRO.InvoiceItems)
{
ii.AccountingPeriodEnd = String.Format("{0:MM.yyyy}-{1:MM.yyyy}", ii.AccountingPeriodStartDateTime, ii.AccountingPeriodEndDateTime);
}
}
else
{
lblText.Text = String.Format("hiermit erlauben wir uns, Ihnen für den Monat {0:MMMM yyyy} folgende Leistungen {1}" +
"in Rechnung zu stellen:", pRO.AccountingPeriodStart, lvrBescheid);
foreach (var ii in pRO.InvoiceItems)
{
ii.AccountingPeriodEnd = String.Format("{0:MM.yyyy}", ii.AccountingPeriodEndDateTime);
}
}
if (team.Contains("BeWo Bonn"))
{
lblAbsenderBonn.Visible = true;
lblTeamBonn.Visible = true;
lblAbsenderKoeln.Visible = false;
lblHeaderKoeln.Visible = false;
lblTeamKoeln.Visible = false;
}
else if (team.Contains("HZE Bonn"))
{
lblAbsenderBonn.Visible = true;
lblTeamBonn.Visible = false;
lblBonnHZE.Visible = true;
lblAbsenderKoeln.Visible = false;
lblHeaderKoeln.Visible = false;
lblTeamKoeln.Visible = false;
}
else if (team.Contains("HZE Köln"))
{
lblTeamKoelnHZE.Visible = true;
lblHeaderKoelnHZE.Visible = true;
lblHeaderKoeln.Visible = false;
lblTeamKoeln.Visible = false;
}
if (String.IsNullOrEmpty(pRO.Notice))
{
lblNotice.Visible = false;
}
this.bindingSource1.DataSource = pRO;
}
}
}