110 lines
4.2 KiB
C#
110 lines
4.2 KiB
C#
using System;
|
|
using BS.Shared;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Report;
|
|
using System.Collections.Generic;
|
|
using BeWo.Data.Access;
|
|
using DevExpress.XtraReports.UI;
|
|
using System.Text.RegularExpressions;
|
|
using BS.Shared.Core;
|
|
using System.IO;
|
|
using BeWo.Data.Entities;
|
|
|
|
namespace BeWo.TeamGSReports
|
|
{
|
|
public partial class Stundenzettel : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public Stundenzettel()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
if (!String.IsNullOrWhiteSpace(pRO.AbsenceTimes))
|
|
{
|
|
lblAbsenceTimes.Visible = true;
|
|
lblHatAbwesenheiten.Visible = false;
|
|
textAbsenceTimes.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
lblAbsenceTimes.Visible = false;
|
|
lblHatAbwesenheiten.Text = "X";
|
|
}
|
|
if (pRO.Services != null)
|
|
{
|
|
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
|
|
|
|
foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services)
|
|
{
|
|
if (s.IsBillable)
|
|
servicesBillable.Add(s);
|
|
}
|
|
|
|
pRO.Services = servicesBillable;
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.TotalFLSPerCostBearer))
|
|
{
|
|
int pos1 = pRO.TotalFLSPerCostBearer.IndexOf("FLS");
|
|
|
|
if (pos1 >= 0)
|
|
{
|
|
int pos2 = pRO.TotalFLSPerCostBearer.IndexOf("FLS", pos1 + 2);
|
|
{
|
|
if (pos2 >= 0)
|
|
{
|
|
IList<ServiceCategory> categories = DAOFactory.GenericDAO.GetAll<ServiceCategory>();
|
|
|
|
int smallestIndex = Int32.MaxValue;
|
|
|
|
foreach (var cat in categories)
|
|
{
|
|
if (!cat.IsBillable && !String.IsNullOrEmpty(cat.Name) && cat.IsActive == ActivationTypeId.Active && pRO.TotalFLSPerCostBearer.IndexOf(cat.Name) >= 0)
|
|
{
|
|
if (pRO.TotalFLSPerCostBearer.IndexOf(cat.Name) < smallestIndex)
|
|
{
|
|
smallestIndex = pRO.TotalFLSPerCostBearer.IndexOf(cat.Name);
|
|
}
|
|
}
|
|
}
|
|
if (smallestIndex < pRO.TotalFLSPerCostBearer.Length && smallestIndex > 0)
|
|
{
|
|
pRO.TotalFLSPerCostBearer = pRO.TotalFLSPerCostBearer.Substring(0, smallestIndex).Trim();
|
|
if (pRO.TotalFLSPerCostBearer.EndsWith(","))
|
|
pRO.TotalFLSPerCostBearer = pRO.TotalFLSPerCostBearer.Substring(0, pRO.TotalFLSPerCostBearer.Length - 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void picSignature_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
XRPictureBox xrBox = sender as XRPictureBox;
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|