Files
BeWoPlaner/ReportImp/TrialogReports/Erstantrag.cs
2017-06-11 16:01:01 +02:00

62 lines
1.6 KiB
C#

using System;
using BeWo.Data.Access;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BeWo.Data.Entities;
using BS.Shared;
namespace TrialogReports
{
public partial class Erstantrag : DevExpress.XtraReports.UI.XtraReport //, IBeWoReport<QueryRO>
{
public Erstantrag()
{
InitializeComponent();
}
public void SetReportDataSource(QueryRO pRO)
{
//var reportDate = DateTime.Parse(pRO.Rows[0].Field1.ToString());
var reportDate = new DateTime(DateTime.Now.Year, 1, 1);
if (pRO.Rows != null)
{
DateTime dt;
if (DateTime.TryParse(pRO.Rows[0].Field1.ToString(), out dt))
{
reportDate = new DateTime(dt.Year, 1, 1);
}
long customerOid;
if (Int64.TryParse(pRO.Rows[0].Field2.ToString(), out customerOid))
{
Customer c = DAOFactory.GenericDAO.LoadByID<Customer>(customerOid);
pRO.Rows[0].Field1 = c.Person.FirstName;
pRO.Rows[0].Field2 = c.Person.LastName;
if (c.Person.Address != null)
{
pRO.Rows[0].Field3 = c.Person.Address.Street;
pRO.Rows[0].Field4 = c.Person.Address.PostalCode;
pRO.Rows[0].Field5 = c.Person.Address.Town;
}
foreach (var e2c in c.Employee2CustomerList)
{
foreach (var v2o in e2c.ValueList)
{
if (v2o.Entry.Type == ValueListEntryType.StaffRoleType && v2o.Entry.SystemEntryID.HasValue &&
v2o.Entry.SystemEntryID.Value == SystemEntryID.EmployeeRoleMainAttendant)
{
pRO.Rows[0].Field6 = e2c.Employee.Person.FirstNameLastName;
}
}
}
}
}
this.bindingSource1.DataSource = pRO;
}
}
}