182 lines
5.4 KiB
C#
182 lines
5.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.ComponentModel;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Report;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using BeWo.Service.ServiceImplementations;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace AlphaEv
|
|
{
|
|
public partial class StundenzettelAssistenz : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public StundenzettelAssistenz()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
|
|
|
|
var ba = GetTeam(pRO);
|
|
if (!String.IsNullOrEmpty(ba))
|
|
{
|
|
lblHeader.Text += " " + ba;
|
|
|
|
}
|
|
|
|
double minutesEinzel = 0;
|
|
double minutesGruppe = 0;
|
|
|
|
bool hatUnterschrift = false;
|
|
|
|
Dictionary<string, string> cats = new Dictionary<string, string>();
|
|
if (pRO.Services != null)
|
|
{
|
|
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
|
|
|
|
foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services)
|
|
{
|
|
if (s.IsBillable)
|
|
{
|
|
|
|
minutesEinzel += s.Minutes;
|
|
s.Notice = String.Format("{0:0.##}", s.Minutes);
|
|
|
|
|
|
if (!String.IsNullOrEmpty(s.Signature))
|
|
{
|
|
hatUnterschrift = true;
|
|
}
|
|
|
|
servicesBillable.Add(s);
|
|
}
|
|
}
|
|
|
|
pRO.Services = servicesBillable;
|
|
}
|
|
|
|
|
|
bindingSource1.DataSource = pRO;
|
|
cellGesamtEinzel.Text = string.Format("{0:0.##}", minutesEinzel);
|
|
|
|
lblSummeMinuten.Text = string.Format("{0:0.##}", minutesEinzel + minutesGruppe);
|
|
lblSummeStunden.Text = string.Format("{0:0.##}", (minutesEinzel + minutesGruppe) / 60);
|
|
|
|
//if (!hatUnterschrift)
|
|
//{
|
|
// //cellUnterschriftHeader.Visible = false;
|
|
// //cellUnterschrift.Visible = false;
|
|
|
|
// lblUnterschriftKlientDatum.Visible = true;
|
|
// lblUnterschriftKlient.Visible = true;
|
|
|
|
// lblUnterschriftKlientDatum.Location = lblUnterschriftMitarbeiterDatum.Location;
|
|
// lblUnterschriftKlient.Location = lblUnterschriftMitarbeiter.Location;
|
|
|
|
// lblUnterschriftMitarbeiterDatum.Top += 80;
|
|
// lblUnterschriftMitarbeiter.Top += 80;
|
|
|
|
// lblAbsenceTime.Top += 80;
|
|
|
|
//}
|
|
//else
|
|
//{
|
|
lblUnterschriftKlientDatum.Visible = false;
|
|
lblUnterschriftKlient.Visible = false;
|
|
//}
|
|
|
|
var stats = GetStatistics(pRO);
|
|
if (stats != null)
|
|
{
|
|
pRO.ApprovedFLSPerWeek = stats.MinutesApprovedPerWeek / 60;
|
|
}
|
|
lblSollImMonat.Text = string.Format("{0:0.##}", pRO.ApprovedFLSPerWeek * 4.3m);
|
|
|
|
}
|
|
|
|
public String GetTeam(ServicesOverviewRO pRO)
|
|
{
|
|
if (pRO.CostBearer2SupportConceptList != null && pRO.CostBearer2SupportConceptList.Count > 0)
|
|
{
|
|
var c2s = pRO.CostBearer2SupportConceptList[0];
|
|
var c = c2s.SupportConcept.Customer;
|
|
pRO.Costbearer = c.DebitorNumber;
|
|
foreach (var t2c in c.Team2CustomerList)
|
|
{
|
|
return t2c.Team.Name;
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
}
|
|
|
|
|
|
private SupportConceptPeriodStatisticsDC GetStatistics(ServicesOverviewRO ro)
|
|
{
|
|
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("Assistenz"))
|
|
{
|
|
return ps;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void xrPictureBox1_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)
|
|
{
|
|
Image returnImage = null;
|
|
MemoryStream ms = new System.IO.MemoryStream(byteArrayIn);
|
|
returnImage = Image.FromStream(ms);
|
|
|
|
return returnImage;
|
|
}
|
|
}
|
|
}
|