152 lines
5.6 KiB
C#
152 lines
5.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text.RegularExpressions;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.ServiceImplementations;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
|
|
|
|
namespace Wabe
|
|
{
|
|
public partial class QuittierungsbelegAbw : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public QuittierungsbelegAbw()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
String betreuungsschluessel = "";
|
|
double minuten = 0;
|
|
var emps = DAOFactory.GenericDAO.GetAllActiveAndArchived<Employee>();
|
|
if (pRO.Services != null && pRO.Services.Count > 0)
|
|
{
|
|
if (pRO.Services.Any(s => s.ServiceCategory == "Genesungsbegleitung"))
|
|
{
|
|
pRO.Services = pRO.Services.Where(s => s.ServiceCategory != "Genesungsbegleitung").ToList();
|
|
}
|
|
foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services)
|
|
{
|
|
minuten += s.Minutes;
|
|
if (s.ServiceCategory.Contains("Indirekt"))
|
|
{
|
|
s.MinutesUnqualified = s.Minutes;
|
|
s.MinutesQualified = 0;
|
|
}
|
|
else
|
|
{
|
|
s.MinutesQualified = s.Minutes;
|
|
s.MinutesUnqualified = 0;
|
|
}
|
|
s.EmployeeFullname = GetEmployeeQualifikation(s.EmployeeOid, emps);
|
|
}
|
|
}
|
|
pRO.TotalFLMBillable = minuten;
|
|
betreuungsschluessel = GetBetreuungsschluessel(pRO);
|
|
lblBewilligteStunden.Text = betreuungsschluessel;
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private string GetEmployeeQualifikation(long employeeOid, IList<Employee> emps)
|
|
{
|
|
string quali = "";
|
|
var emp = emps.Where(e => e.Oid == employeeOid).FirstOrDefault();
|
|
if (emp != null)
|
|
{
|
|
foreach (var valueEntry in emp.ValueList)
|
|
{
|
|
if (valueEntry.Entry.Type == ValueListEntryType.StaffQualificationsType)
|
|
{
|
|
if (quali.Length > 0)
|
|
{
|
|
quali += ", ";
|
|
}
|
|
quali += valueEntry.Entry.Value.ToString();
|
|
}
|
|
}
|
|
}
|
|
return quali;
|
|
}
|
|
|
|
private string GetBetreuungsschluessel(ServicesOverviewRO pRO)
|
|
{
|
|
var schluessel = "HEG";
|
|
foreach (var c2s in pRO.CostBearer2SupportConceptList)
|
|
{
|
|
var app = c2s.ApprovalPeriodList.Where(a => a.ServiceCategory != null && a.ServiceCategory.Name.Contains("HEG")
|
|
&& a.StartDate.HasValue && a.StartDate <= pRO.StartDate && a.EndDate >= pRO.EndDate).FirstOrDefault();
|
|
if (app != null && app.ServiceCategory.Name.Contains("HEG"))
|
|
{
|
|
schluessel = app.ServiceCategory.Name;
|
|
}
|
|
}
|
|
return schluessel;
|
|
}
|
|
|
|
private SupportConceptPeriodStatisticsDC GetFlsStatistics(ServicesOverviewRO ro, String assName)
|
|
{
|
|
if (ro.CostBearer2SupportConceptList != null && ro.CostBearer2SupportConceptList.Count > 0)
|
|
{
|
|
var service = new OperationsServiceImp();
|
|
|
|
foreach (var cb2sc in ro.CostBearer2SupportConceptList)
|
|
{
|
|
long cb2scOid = cb2sc.Oid.Value;
|
|
var stats = service.CreateSupportConceptStatistics(cb2scOid, ro.EndDate);
|
|
|
|
if (stats.PeriodStatistics != null && stats.PeriodStatistics.Count > 0)
|
|
{
|
|
foreach (var ps in stats.PeriodStatistics)
|
|
{
|
|
if ((ps.SupportConceptApprovalPeriod != null && ps.SupportConceptApprovalPeriod.ServiceCategory != null &&
|
|
!ps.SupportConceptApprovalPeriod.ServiceCategory.Name.ToLower().Contains(assName)) || ps.SupportConceptApprovalPeriod.ServiceCategory == null)
|
|
{
|
|
return ps;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void picSignature_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
XRPictureBox xrBox = sender as XRPictureBox;
|
|
//var test = this.GetCurrent
|
|
string base64String = xrBox.Tag as string;
|
|
if (!String.IsNullOrWhiteSpace(base64String))
|
|
{
|
|
var base64Data = Regex.Match(base64String, @"data:image/(?<type>.+?),(?<data>.+)").Groups["data"].Value;
|
|
var binData = Convert.FromBase64String(base64Data);
|
|
System.Drawing.Image img = ByteArrayToImage(binData);
|
|
xrBox.Image = Utils.CropImage(img);
|
|
}
|
|
else
|
|
{
|
|
xrBox.Image = null;
|
|
}
|
|
}
|
|
|
|
public System.Drawing.Image ByteArrayToImage(byte[] byteArrayIn)
|
|
{
|
|
using (var memoryStream = new MemoryStream(byteArrayIn))
|
|
{
|
|
return System.Drawing.Image.FromStream(memoryStream);
|
|
}
|
|
}
|
|
}
|
|
}
|