184 lines
6.3 KiB
C#
184 lines
6.3 KiB
C#
using System;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Report;
|
|
using DevExpress.XtraReports.UI;
|
|
using System.Data;
|
|
using BeWo.Data.Access;
|
|
using System.Collections.Generic;
|
|
using System.Drawing.Imaging;
|
|
using System.Linq;
|
|
using System.Xml.Schema;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.Plugins;
|
|
using BeWo.Service.ServiceImplementations;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.Extensions;
|
|
using BS.Shared.Services;
|
|
using DevExpress.Xpo.DB;
|
|
|
|
namespace AwoDortmund
|
|
{
|
|
[IDSpecificClass(Identifier = "HilfeplanBearbeitungsdauer")]
|
|
public partial class HilfeplanBearbeitungsdauer : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<QueryRO>
|
|
{
|
|
private Dictionary<long, List<CostBearer2SupportConcept>> customer2CostbearerSupportConcepts = new Dictionary<long, List<CostBearer2SupportConcept>>();
|
|
|
|
public HilfeplanBearbeitungsdauer()
|
|
{
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
public void SetReportDataSource(QueryRO queryRo)
|
|
{
|
|
var ro = CreateRo(queryRo);
|
|
|
|
this.bindingSource1.DataSource = ro;
|
|
}
|
|
|
|
private QueryRO CreateRo(QueryRO queryRo)
|
|
{
|
|
QueryRO result = new QueryRO();
|
|
|
|
long? serviceCategory = null;
|
|
|
|
DateTime reportStart = DateTime.MinValue;
|
|
DateTime reportEnde = DateTime.MaxValue;
|
|
|
|
var alleHps = DAOFactory.GenericDAO.GetAllActiveAndArchived<SupportConcept>();
|
|
|
|
|
|
foreach (var sc in alleHps)
|
|
{
|
|
|
|
var coid = sc.Customer.Oid.Value;
|
|
foreach (var c2s in sc.CostBearer2SupportConceptList)
|
|
{
|
|
if (!customer2CostbearerSupportConcepts.ContainsKey(coid))
|
|
{
|
|
customer2CostbearerSupportConcepts.Add(coid, new List<CostBearer2SupportConcept>());
|
|
}
|
|
customer2CostbearerSupportConcepts[coid].Add(c2s);
|
|
}
|
|
}
|
|
|
|
//long orgOid = 0;
|
|
|
|
DateTime datum = DateTime.Now;
|
|
|
|
if (queryRo.Rows.Count > 0)
|
|
{
|
|
if (queryRo.Rows[0].Field1 != null)
|
|
{
|
|
DateTime.TryParse(queryRo.Rows[0].Field1.ToString(), out datum);
|
|
if (datum == DateTime.MinValue)
|
|
{
|
|
datum = DateTime.Now;
|
|
}
|
|
}
|
|
//if (queryRo.Rows[0].Field2 != null)
|
|
//{
|
|
// Int64.TryParse(queryRo.Rows[0].Field2.ToString(), out orgOid);
|
|
//}
|
|
}
|
|
|
|
datum = new DateTime(datum.Year, datum.Month, 1);
|
|
|
|
String orgStr = "";
|
|
//Organisation org = null;
|
|
//if (orgOid > 0)
|
|
//{
|
|
// org = DAOFactory.GenericDAO.LoadByID<Organisation>(orgOid);
|
|
|
|
// orgStr = String.Format(" durch {0}", org.Name);
|
|
//}
|
|
|
|
lblDauer.Text = String.Format("Bearbeitungsdauer der Anträge{1}, Stand: {0:dd.MM.yyyy}", datum, orgStr);
|
|
|
|
int daysTotal = 0;
|
|
int count = 0;
|
|
decimal betragGesamtGesamt = 0;
|
|
|
|
foreach (var sc in alleHps)
|
|
{
|
|
foreach (var c2s in sc.CostBearer2SupportConceptList)
|
|
{
|
|
if (c2s.StartDate <= datum && c2s.EndDate >= datum) // && (orgOid == 0 || orgOid == c2s.CostBearer.Organisation.Oid))
|
|
{
|
|
var newrow = new QueryRO.Row();
|
|
|
|
newrow.Field1 = String.Format("{0}, {1}", sc.Customer.Person.LastName,
|
|
sc.Customer.Person.FirstName);
|
|
newrow.Field2 = String.Format("{0:dd.MM.yyyy}", c2s.StartDate);
|
|
newrow.Field3 = String.Format("{0:dd.MM.yyyy}", c2s.EndDate);
|
|
|
|
var vc2s = GetVorgaenger(c2s);
|
|
newrow.Field4 = vc2s == null ? "Ja" : "Nein";
|
|
|
|
if (vc2s != null && vc2s.SupportConcept.RenewalSendDate.HasValue)
|
|
{
|
|
newrow.Field5 = String.Format("{0:dd.MM.yyyy}", vc2s.SupportConcept.RenewalSendDate);
|
|
}
|
|
|
|
newrow.Field6 = String.Format("{0:dd.MM.yyyy}", sc.SupportConceptSendDate);
|
|
newrow.Field7 = String.Format("{0:dd.MM.yyyy}", sc.ConferenceDate);
|
|
newrow.Field8 = String.Format("{0:dd.MM.yyyy}", sc.ApprovalDate);
|
|
|
|
if (sc.SupportConceptSendDate.HasValue && sc.ApprovalDate.HasValue)
|
|
{
|
|
int days = (int)sc.ApprovalDate.Value.Subtract(sc.SupportConceptSendDate.Value).TotalDays + 1;
|
|
int weeks = days / 7;
|
|
|
|
newrow.Field9 = String.Format("{0:0.00}", weeks);
|
|
}
|
|
|
|
newrow.Field10 = c2s.CostBearer.Organisation.Name;
|
|
|
|
result.Rows.Add(newrow);
|
|
}
|
|
}
|
|
}
|
|
|
|
result.Rows.Sort((a, b) => a.Field1.ToString().CompareTo(b.Field1));
|
|
|
|
return result;
|
|
}
|
|
|
|
private CostBearer2SupportConcept GetVorgaenger(CostBearer2SupportConcept c2s)
|
|
{
|
|
|
|
if (customer2CostbearerSupportConcepts.ContainsKey(c2s.SupportConcept.Customer.Oid.Value))
|
|
{
|
|
var list = customer2CostbearerSupportConcepts[c2s.SupportConcept.Customer.Oid.Value];
|
|
if (list.Count > 1)
|
|
{
|
|
DateTime thisDate = DateTime.Now;
|
|
|
|
if (c2s.StartDate.HasValue)
|
|
{
|
|
thisDate = c2s.StartDate.Value;
|
|
}
|
|
|
|
|
|
foreach (var c2si in list)
|
|
{
|
|
if (c2si.Oid != c2s.Oid && c2si.CostBearer.Oid == c2s.CostBearer.Oid)
|
|
{
|
|
if (c2si.EndDate.HasValue && c2si.EndDate.Value == thisDate.AddDays(-1))
|
|
{
|
|
return c2si;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|