180 lines
5.9 KiB
C#
180 lines
5.9 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 BeWo.HphBersenbrueckAtz
|
|
{
|
|
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 + 1;
|
|
|
|
endDay += startDay;
|
|
}
|
|
List<ServicesOverviewRO> lROs = ServicesOverviewRO.Create(month, year, orgaOid, empOid, startDay, endDay);
|
|
|
|
if (lROs.Count > 0)
|
|
{
|
|
//String reportId = null;
|
|
//if (orgaOid > 0)
|
|
//{
|
|
// var organisation = DAOFactory.GenericDAO.LoadByID<Organisation>(orgaOid);
|
|
// if (organisation != null)
|
|
// reportId = organisation.Name;
|
|
//}
|
|
|
|
|
|
var rootReport = CreateServicesOverviewReportForRo(lROs[0], null);
|
|
rootReport.CreateDocument();
|
|
|
|
for (int i = 1; i < lROs.Count; i++)
|
|
{
|
|
var lNext = CreateServicesOverviewReportForRo(lROs[i], null);
|
|
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).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, serviceCategoryOid);
|
|
|
|
return CreateServicesOverviewReportForRo(ro, null);
|
|
|
|
}
|
|
|
|
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, String reportId)
|
|
{
|
|
NachweisTherapieeinheiten report = new NachweisTherapieeinheiten();
|
|
report.SetReportDataSource(ro);
|
|
|
|
return report;
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|