112 lines
3.3 KiB
C#
112 lines
3.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using BeWo.Data;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace BeWoDarmstadt
|
|
{
|
|
public class CustomReportCreator : DefaultReportCreator
|
|
{
|
|
public override XtraReport CreateQueryReport(long queryOid, string queryReportId)
|
|
{
|
|
if (queryOid == 100 || queryOid == 101)
|
|
{
|
|
return CreateZeitzuschlagsbeleg(queryOid, queryReportId);
|
|
}
|
|
if (queryOid == 110)
|
|
{
|
|
return CreateTeamuebersicht(queryOid, queryReportId);
|
|
}
|
|
return base.CreateQueryReport(queryOid, queryReportId);
|
|
}
|
|
|
|
private XtraReport CreateZeitzuschlagsbeleg(long queryOid, string queryReportId)
|
|
{
|
|
var query = DAOFactory.GenericDAO.LoadByID<Query>(queryOid);
|
|
|
|
if (query == null)
|
|
return new XtraReport();
|
|
|
|
var path = Path.Combine(TempPath, queryReportId + ".xml");
|
|
var table = Utils.XMLDeserialize<DataTable>(path);
|
|
var qro = QueryRO.Create(query, table);
|
|
|
|
if (qro.Rows.Count > 0)
|
|
{
|
|
long? employeeOid = BeWo.Data.Security.UserRightHelper.GetLoggedInUser().Employee.Oid;
|
|
if (qro.Rows[0].Field2 != null && qro.Rows[0].Field2.ToString() != "0")
|
|
employeeOid = Int64.Parse(qro.Rows[0].Field2.ToString());
|
|
|
|
DateTime monat = DateTime.Parse(qro.Rows[0].Field1.ToString());
|
|
DateTimeSpan span = new DateTimeSpan();
|
|
span.StartDateTime = monat;
|
|
span.EndDateTime = monat.AddMonths(1).AddTicks(-1);
|
|
|
|
MitarbeiterstundenkontoRO ro = MitarbeiterstundenkontoRO.Create(employeeOid, null, monat, monat.AddMonths(1), null);
|
|
var msb = new CustomMitarbeiterstundenkontoBerechnung();
|
|
msb.CreateReport(ro);
|
|
|
|
XtraReport allReports = null;
|
|
|
|
foreach (var ed in ro.EmployeeDetailList)
|
|
{
|
|
ed.StundenGesamtIst += ed.Custom10;
|
|
|
|
Zeitzuschlagsbeleg beleg = new Zeitzuschlagsbeleg();
|
|
|
|
beleg.SetReportDataSource(ro.ReportStartDate, ed);
|
|
|
|
beleg.CreateDocument();
|
|
if (allReports == null)
|
|
allReports = beleg;
|
|
else
|
|
allReports.Pages.AddRange(beleg.Pages);
|
|
}
|
|
|
|
if (allReports != null)
|
|
{
|
|
return allReports;
|
|
}
|
|
}
|
|
return new XtraReport();
|
|
}
|
|
|
|
private XtraReport CreateTeamuebersicht(long queryOid, string queryReportId)
|
|
{
|
|
var query = DAOFactory.GenericDAO.LoadByID<Query>(queryOid);
|
|
|
|
if (query == null)
|
|
return new XtraReport();
|
|
|
|
var path = Path.Combine(TempPath, queryReportId + ".xml");
|
|
var table = Utils.XMLDeserialize<DataTable>(path);
|
|
var qro = QueryRO.Create(query, table);
|
|
|
|
|
|
if (qro.Rows.Count > 0)
|
|
{
|
|
DateTime start = DateTime.Parse(qro.Rows[0].Field1.ToString());
|
|
DateTime end = start.AddMonths(1).AddDays(-1);
|
|
|
|
var ro = FinanceRO.Create(start, end);
|
|
var druck = new Teamuebersicht();
|
|
druck.SetReportDataSource(ro);
|
|
return druck;
|
|
}
|
|
|
|
return new XtraReport();
|
|
}
|
|
}
|
|
}
|