385 lines
14 KiB
C#
385 lines
14 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Runtime.Remoting.Messaging;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared.Core;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace HphBersenbrueckFreizeitUndReisen
|
|
{
|
|
public class CustomReportCreator : DefaultReportCreator
|
|
{
|
|
public override XtraReport CreateQueryReport(long queryOid, string queryReportId)
|
|
{
|
|
if (queryOid == 200)
|
|
{
|
|
var query = DAOFactory.GenericDAO.LoadByID<Query>(queryOid);
|
|
|
|
if (query == null)
|
|
return new XtraReport();
|
|
|
|
var path = Path.Combine(TempPath, queryReportId + ".xml");
|
|
var table = Utils.XMLDeserialize<DataTable>(path);
|
|
|
|
var roGesamt = QueryRO.Create(query, table);
|
|
|
|
List<QueryRO> roListe = CreateQueryReportObjects(roGesamt);
|
|
|
|
|
|
XtraReport rootReport = null;
|
|
|
|
|
|
foreach (var queryRo in roListe)
|
|
{
|
|
var report = new AbrechnungsbogenFuD();
|
|
report.SetReportDataSource(queryRo);
|
|
report.CreateDocument();
|
|
|
|
if (rootReport == null)
|
|
{
|
|
rootReport = report;
|
|
}
|
|
else
|
|
{
|
|
rootReport.Pages.AddRange(report.Pages);
|
|
}
|
|
}
|
|
|
|
return rootReport;
|
|
}
|
|
|
|
return base.CreateQueryReport(queryOid, queryReportId);
|
|
}
|
|
|
|
private List<QueryRO> CreateQueryReportObjects(QueryRO roGesamt)
|
|
{
|
|
List<QueryRO> roListe = new List<QueryRO>();
|
|
|
|
Dictionary<long, QueryRO> customerOid2Query = new Dictionary<long, QueryRO>();
|
|
|
|
foreach (var row in roGesamt.Rows)
|
|
{
|
|
if (row.Field2 != null && !String.IsNullOrEmpty(row.Field2.ToString()))
|
|
{
|
|
long customerOid = Int64.Parse(row.Field2.ToString());
|
|
|
|
if (!customerOid2Query.ContainsKey(customerOid))
|
|
{
|
|
QueryRO newRo = new QueryRO();
|
|
newRo.Name = roGesamt.Name;
|
|
|
|
customerOid2Query.Add(customerOid, newRo);
|
|
roListe.Add(newRo);
|
|
}
|
|
customerOid2Query[customerOid].Rows.Add(row);
|
|
}
|
|
}
|
|
|
|
return roListe;
|
|
}
|
|
|
|
public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
|
|
{
|
|
|
|
DateTime startDate = new DateTime(year, month, 1);
|
|
|
|
|
|
if (startDay == 1 && endDay == DateTime.DaysInMonth(year, month))
|
|
{
|
|
var endDate = startDate.AddMonths(3);
|
|
|
|
startDate = startDate.AddDays(-1);
|
|
month = startDate.Month;
|
|
year = startDate.Year;
|
|
startDay = startDate.Day;
|
|
|
|
endDay = (int)endDate.Subtract(startDate).TotalDays;
|
|
|
|
endDay += startDay;
|
|
}
|
|
List<ServicesOverviewRO> lROs = ServicesOverviewRO.Create(month, year, orgaOid, empOid, startDay, endDay, true);
|
|
|
|
if (lROs.Count > 0)
|
|
{
|
|
//String reportId = null;
|
|
//if (orgaOid > 0)
|
|
//{
|
|
// var organisation = DAOFactory.GenericDAO.LoadByID<Organisation>(orgaOid);
|
|
// if (organisation != null)
|
|
// reportId = organisation.Name;
|
|
//}
|
|
int startIndex = 0;
|
|
XtraReport rootReport = null;
|
|
while (rootReport == null && startIndex < lROs.Count)
|
|
{
|
|
if (lROs[startIndex].Services.Count > 0)
|
|
{
|
|
rootReport = CreateServicesOverviewReportForRo(lROs[startIndex], null);
|
|
}
|
|
startIndex++;
|
|
}
|
|
|
|
if (rootReport == null)
|
|
{
|
|
rootReport = new XtraReport();
|
|
}
|
|
|
|
if (rootReport.Pages.Count == 0)
|
|
{
|
|
rootReport.CreateDocument();
|
|
}
|
|
for (int i = startIndex; i < lROs.Count; i++)
|
|
{
|
|
var lNext = CreateServicesOverviewReportForRo(lROs[i], null);
|
|
if (lNext.Pages.Count == 0)
|
|
{
|
|
lNext.CreateDocument();
|
|
}
|
|
|
|
rootReport.Pages.AddRange(lNext.Pages);
|
|
}
|
|
|
|
return rootReport;
|
|
}
|
|
return new XtraReport();
|
|
}
|
|
|
|
public override XtraReport CreateServiceOverviewSingleCustomerReport(long customerOid, int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
|
|
{
|
|
//String reportId = null;
|
|
//if (orgaOid > 0)
|
|
//{
|
|
// var organisation = DAOFactory.GenericDAO.LoadByID<Organisation>(orgaOid);
|
|
// if (organisation != null)
|
|
// reportId = organisation.Name;
|
|
//}
|
|
DateTime startDate = new DateTime(year, month, 1);
|
|
|
|
|
|
if (startDay == 1 && endDay == DateTime.DaysInMonth(year, month))
|
|
{
|
|
var endDate = startDate.AddMonths(3);
|
|
|
|
startDate = startDate.AddDays(-1);
|
|
month = startDate.Month;
|
|
year = startDate.Year;
|
|
startDay = startDate.Day;
|
|
|
|
endDay = (int)endDate.Subtract(startDate).TotalDays;
|
|
|
|
endDay += startDay;
|
|
}
|
|
|
|
|
|
var ro = ServicesOverviewRO.Create(customerOid, month, year, false, orgaOid, empOid, startDay, endDay, true, serviceCategoryOid);
|
|
|
|
return CreateServicesOverviewReportForRo(ro, null);
|
|
|
|
}
|
|
|
|
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, String reportId)
|
|
{
|
|
XtraReport report = null;
|
|
|
|
ServicesOverviewRO entlastungsbetragNormal = CreateFromRO(ro);
|
|
ServicesOverviewRO verhinderungspflegeNormal = CreateFromRO(ro);
|
|
ServicesOverviewRO selbstzahlerNormal = CreateFromRO(ro);
|
|
|
|
ServicesOverviewRO reisen = CreateFromRO(ro);
|
|
|
|
//ServicesOverviewRO entlastungsbetragReisen = CreateFromRO(ro);
|
|
//ServicesOverviewRO verhinderungspflegeReisen = CreateFromRO(ro);
|
|
//ServicesOverviewRO selbstzahlerReisen = CreateFromRO(ro);
|
|
|
|
//ServicesOverviewRO kurzzeitpflege = CreateFromRO(ro);
|
|
ServicesOverviewRO eingliederungshilfe = CreateFromRO(ro);
|
|
|
|
Dictionary<String, ServicesOverviewRO> sonstige = new Dictionary<string, ServicesOverviewRO>();
|
|
Dictionary<String, ServicesOverviewRO> sonstigeReisen = new Dictionary<string, ServicesOverviewRO>();
|
|
|
|
bool isPflege = false;
|
|
foreach (var s in ro.Services)
|
|
{
|
|
if (s.ServiceCategory.ToLower().Contains("entlastung"))
|
|
{
|
|
if (s.ServiceDescription == "Reisen" || s.ServiceDescription == "Kurzurlaub")
|
|
{
|
|
reisen.Services.Add(s);
|
|
}
|
|
else
|
|
{
|
|
entlastungsbetragNormal.Services.Add(s);
|
|
}
|
|
|
|
}
|
|
else if (s.ServiceCategory.ToLower().Contains("verhinderung"))
|
|
{
|
|
if (s.ServiceDescription == "Reisen" || s.ServiceDescription == "Kurzurlaub")
|
|
{
|
|
reisen.Services.Add(s);
|
|
}
|
|
else
|
|
{
|
|
verhinderungspflegeNormal.Services.Add(s);
|
|
}
|
|
}
|
|
else if (s.ServiceCategory.ToLower().Contains("selbstzahler"))
|
|
{
|
|
if (s.ServiceDescription == "Reisen" || s.ServiceDescription == "Kurzurlaub")
|
|
{
|
|
reisen.Services.Add(s);
|
|
}
|
|
else
|
|
{
|
|
selbstzahlerNormal.Services.Add(s);
|
|
}
|
|
}
|
|
else if (s.ServiceCategory.ToLower().Contains("kurzzeit"))
|
|
{
|
|
reisen.Services.Add(s);
|
|
}
|
|
else if (s.ServiceCategory.ToLower().Contains("eingliederung"))
|
|
{
|
|
eingliederungshilfe.Services.Add(s);
|
|
}
|
|
else
|
|
{
|
|
if (s.ServiceDescription == "Reisen" || s.ServiceDescription == "Kurzurlaub")
|
|
{
|
|
reisen.Services.Add(s);
|
|
}
|
|
else
|
|
{
|
|
if (!sonstige.ContainsKey(s.ServiceCategory.ToLower()))
|
|
{
|
|
sonstige.Add(s.ServiceCategory.ToLower(), CreateFromRO(ro));
|
|
}
|
|
sonstige[s.ServiceCategory.ToLower()].Services.Add(s);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
report = AddReportToReport(report, entlastungsbetragNormal, false);
|
|
report = AddReportToReport(report, verhinderungspflegeNormal, false);
|
|
report = AddReportToReport(report, selbstzahlerNormal, false);
|
|
|
|
if (sonstige.Count > 0)
|
|
{
|
|
foreach (var servicesOverviewRo in sonstige.Values)
|
|
{
|
|
report = AddReportToReport(report, servicesOverviewRo, false);
|
|
}
|
|
}
|
|
|
|
report = AddReportToReport(report, reisen, true);
|
|
//report = AddReportToReport(report, eingliederungshilfe);
|
|
|
|
if (report == null)
|
|
report = new XtraReport();
|
|
return report;
|
|
}
|
|
|
|
private XtraReport AddReportToReport(XtraReport report, ServicesOverviewRO ro, bool reisen)
|
|
{
|
|
if (ro.Services.Count > 0)
|
|
{
|
|
if (report == null)
|
|
{
|
|
if (reisen)
|
|
{
|
|
report = new AbrechnungsbogenReisen();
|
|
((AbrechnungsbogenReisen)report).SetReportDataSource(ro);
|
|
}
|
|
else
|
|
{
|
|
var ab = new Abrechnungsbogen();
|
|
ab.SetReportDataSource(ro);
|
|
|
|
if (ab.GetPreisGesamt() > 0)
|
|
{
|
|
report = ab;
|
|
}
|
|
//report = new Abrechnungsbogen();
|
|
// ((Abrechnungsbogen)report).SetReportDataSource(ro);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (report.Pages.Count == 0)
|
|
{
|
|
report.CreateDocument();
|
|
}
|
|
|
|
XtraReport newReport = null;
|
|
if (reisen)
|
|
{
|
|
newReport = new AbrechnungsbogenReisen();
|
|
((AbrechnungsbogenReisen)newReport).SetReportDataSource(ro);
|
|
}
|
|
else
|
|
{
|
|
var ab = new Abrechnungsbogen();
|
|
ab.SetReportDataSource(ro);
|
|
|
|
if (ab.GetPreisGesamt() > 0)
|
|
{
|
|
newReport = ab;
|
|
}
|
|
|
|
//newReport = new Abrechnungsbogen();
|
|
//((Abrechnungsbogen)newReport).SetReportDataSource(ro);
|
|
}
|
|
if (newReport != null)
|
|
{
|
|
newReport.CreateDocument();
|
|
report.Pages.AddRange(newReport.Pages);
|
|
}
|
|
}
|
|
}
|
|
return report;
|
|
}
|
|
|
|
private ServicesOverviewRO CreateFromRO(ServicesOverviewRO ro)
|
|
{
|
|
ServicesOverviewRO newRo = new ServicesOverviewRO();
|
|
|
|
newRo.StartDate = ro.StartDate;
|
|
newRo.ApprovedEndDate = ro.ApprovedEndDate;
|
|
newRo.ApprovedFLSPerMonth = ro.ApprovedFLSPerMonth;
|
|
newRo.ApprovedFLSPerMonthTotal = ro.ApprovedFLSPerMonthTotal;
|
|
newRo.ApprovedFLSPerWeek = ro.ApprovedFLSPerWeek;
|
|
newRo.ApprovedFLSPerWeekTotal = ro.ApprovedFLSPerWeekTotal;
|
|
newRo.ApprovedFLSTotal = ro.ApprovedFLSTotal;
|
|
newRo.ApprovedStartDate = ro.ApprovedStartDate;
|
|
newRo.ContactEmployee = ro.ContactEmployee;
|
|
newRo.CostBearer2SupportConceptList = ro.CostBearer2SupportConceptList;
|
|
newRo.Costbearer = ro.Costbearer;
|
|
newRo.CustomerBirthday = ro.CustomerBirthday;
|
|
newRo.CustomerLastName = ro.CustomerLastName;
|
|
newRo.CustomerCity = ro.CustomerCity;
|
|
newRo.CustomerFirstName = ro.CustomerFirstName;
|
|
newRo.CustomerName = ro.CustomerName;
|
|
newRo.CustomerPostalCode = ro.CustomerPostalCode;
|
|
newRo.CustomerStreet = ro.CustomerStreet;
|
|
newRo.EndDate = ro.EndDate;
|
|
newRo.FreeMinutesThisMonth = ro.FreeMinutesThisMonth;
|
|
newRo.Month = ro.Month;
|
|
newRo.Year = ro.Year;
|
|
newRo.MainAttendant = ro.MainAttendant;
|
|
newRo.MainAttendantCommaSeperated = ro.MainAttendantCommaSeperated;
|
|
|
|
return newRo;
|
|
}
|
|
}
|
|
}
|
|
|