129 lines
4.3 KiB
C#
129 lines
4.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using DevExpress.XtraReports.UI;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Report;
|
|
using System.Text.RegularExpressions;
|
|
using System.Drawing;
|
|
using BS.Shared.Core;
|
|
using System.IO;
|
|
using BS.Shared.DataContracts;
|
|
using BeWo.Service.ServiceImplementations;
|
|
|
|
namespace BeWo.BetreutesWohnenWoellReports
|
|
{
|
|
public partial class QuittierungsbelegASL : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public QuittierungsbelegASL()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
double total = 0;
|
|
string cat = "";
|
|
|
|
|
|
if (pRO.Services != null)
|
|
{
|
|
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
|
|
|
|
foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services)
|
|
{
|
|
if (s.IsBillable)
|
|
{
|
|
ServicesOverviewRO.CreateSignatureString(s);
|
|
s.Notice5 = s.CustomerCount.ToString();
|
|
if (s.ServiceDescription.StartsWith("Fehlkontakt"))
|
|
{
|
|
s.Notice5 = "FK";
|
|
s.Minutes = Math.Round(0.8 * s.Minutes, 0);
|
|
}
|
|
total += s.Minutes;
|
|
servicesBillable.Add(s);
|
|
cat = s.ServiceCategory;
|
|
}
|
|
}
|
|
|
|
pRO.Services = servicesBillable;
|
|
}
|
|
|
|
pRO.TotalFLMBillable = total;
|
|
|
|
SetBewilligung(pRO, cat);
|
|
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void SetBewilligung(ServicesOverviewRO pRO, String name)
|
|
{
|
|
var stats = GetStatistics(pRO, name);
|
|
if (stats != null)
|
|
{
|
|
pRO.ApprovedFLSPerWeek = stats.MinutesApprovedPerWeek / 60;
|
|
}
|
|
else
|
|
pRO.ApprovedFLSPerWeek = 0;
|
|
}
|
|
|
|
private SupportConceptPeriodStatisticsDC GetStatistics(ServicesOverviewRO ro, String name)
|
|
{
|
|
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.StartsWith(name) ||
|
|
cb2sc.CostBearer.Organisation.Name == ro.Costbearer)
|
|
{
|
|
return ps;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void picSignature_BeforePrint(object sender, 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);
|
|
Image img = ByteArrayToImage(binData);
|
|
xrBox.Image = Utils.CropImage(img);
|
|
}
|
|
else
|
|
{
|
|
xrBox.Image = null;
|
|
}
|
|
}
|
|
|
|
public Image ByteArrayToImage(byte[] byteArrayIn)
|
|
{
|
|
using (var memoryStream = new MemoryStream(byteArrayIn))
|
|
{
|
|
return Image.FromStream(memoryStream);
|
|
}
|
|
}
|
|
}
|
|
}
|