Files
BeWoPlaner/Report/ReportObjects/JahresReportRO.cs
2021-02-21 19:01:51 +01:00

203 lines
7.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
using BS.Shared.Extensions;
using BS.Shared;
using BeWo.Service.ServiceImplementations;
using BeWo.Data;
namespace BeWo.Report.ReportObjects
{
public class JahresReportRO : AbstractBeWoReportObject<JahresReportRO>
{
public IList<JahresReportTabelle> JahresReportTabelleList { get; set; }
public class JahresReportTabelle
{
public string Name { get; set; }
public IList<JahresReportDetail> JahresReportDetailList { get; set; }
//public charControll BarChart{get; set;}
}
public class JahresReportDetail
{
public string Name { get; set; }
public int Anzahl { get; set; }
public int MaennlichAnzahl { get; set; }
public int WeiblichAnzahl { get; set; }
public int? Custom1 { get; set; }
public int? Custom2 { get; set; }
public int? Custom3 { get; set; }
public IList<String> CustomerNames { get; set; }
public String AllCustomerString { get; set; }
}
public static JahresReportRO Create(int year, long? orgOid, long? teamOid, long? betreuungsartOid)
{
AnalysisServiceImp service = new AnalysisServiceImp();
DateTime startDate = new DateTime(year, 1, 1);
var list = service.CreateAnnualReport(orgOid, teamOid, betreuungsartOid, startDate, startDate.AddYears(1));
return Create(list);
}
public static JahresReportRO Create(List<AnnualReportDC> annualReports)
{
var lResult = new JahresReportRO();
lResult.JahresReportTabelleList = new List<JahresReportTabelle>();
foreach (var item in annualReports)
{
JahresReportTabelle tabelle = new JahresReportTabelle();
tabelle.JahresReportDetailList = new List<JahresReportDetail>();
tabelle.Name = item.Name;
lResult.JahresReportTabelleList.Add(tabelle);
int MaenlichVar = 0;
int WeiblichVar = 0;
int anzVar = 0;
foreach (var data in item.Data)
{
JahresReportDetail detail = new JahresReportDetail();
detail.Name = data.Name;
detail.MaennlichAnzahl = (int)data.Male;
MaenlichVar += detail.MaennlichAnzahl;
detail.WeiblichAnzahl = (int)data.Female;
WeiblichVar += detail.WeiblichAnzahl;
detail.Anzahl = data.Value.HasValue ? (int)data.Value : 0;
if (data.Value1 != null)
{
int i = 0;
if (Int32.TryParse(data.Value1.ToString(), out i))
{
detail.Custom1 = (detail.Custom1 ?? 0) + i;
}
}
if (data.Value2 != null)
{
int i = 0;
if (Int32.TryParse(data.Value2.ToString(), out i))
{
detail.Custom2 = (detail.Custom2 ?? 0) + i;
}
}
detail.CustomerNames = data.CustomerNames;
if (data.CustomerNames != null)
{
StringBuilder sb = new StringBuilder();
foreach (var name in data.CustomerNames.OrderBy(s => s))
{
if (sb.Length > 0)
sb.Append("; ");
sb.Append(name);
}
detail.AllCustomerString = sb.ToString();
}
//wert
anzVar += detail.Anzahl;
tabelle.JahresReportDetailList.Add(detail);
}
//--------- Hier muss der BAr chat code hin -----------------------------
/*ChartControl sideBySideBarChart = new ChartControl();
// Create the first side-by-side bar series and add points to it.
Series series1 = new Series("Side-by-Side Bar Series 1", ViewType.Bar);
series1.Points.Add(new SeriesPoint("Anzahl", new double[] { anzVar }));
series1.Points.Add(new SeriesPoint("Weiblich", new double[] { WeiblichVar }));
series1.Points.Add(new SeriesPoint("Männlich", new double[] { MaenlichVar }));
// Add the series to the chart.
sideBySideBarChart.Series.Add(series1);
// Hide the legend (if necessary).
sideBySideBarChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.true;
// Rotate the diagram (if necessary).
((XYDiagram)sideBySideBarChart.Diagram).Rotated = true;
// Add a title to the chart (if necessary).
ChartTitle chartTitle1 = new ChartTitle();
chartTitle1.Text = "Voll was Los";
sideBySideBarChart.Titles.Add(chartTitle1);
// Add the chart to the form.
sideBySideBarChart.Dock = DockStyle.Fill;
this.Controls.Add(sideBySideBarChart);
*/
//-----------------------------------------------------------------------
}
return lResult;
}
//----------------------- Code fÜR EIN BAR Chart Beispiel------------------------------//
/*
public void Form1_Load(object sender, EventArgs e) {
// Create an empty chart.
ChartControl sideBySideBarChart = new ChartControl();
// Create the first side-by-side bar series and add points to it.
Series series1 = new Series("Side-by-Side Bar Series 1", ViewType.Bar);
series1.Points.Add(new SeriesPoint("A", new double[] { 10 }));
series1.Points.Add(new SeriesPoint("B", new double[] { 12 }));
series1.Points.Add(new SeriesPoint("C", new double[] { 14 }));
series1.Points.Add(new SeriesPoint("D", new double[] { 17 }));
// Create the second side-by-side bar series and add points to it.
Series series2 = new Series("Side-by-Side Bar Series 2", ViewType.Bar);
series2.Points.Add(new SeriesPoint("A", new double[] { 15 }));
series2.Points.Add(new SeriesPoint("B", new double[] { 18 }));
series2.Points.Add(new SeriesPoint("C", new double[] { 25 }));
series2.Points.Add(new SeriesPoint("D", new double[] { 33 }));
// Add the series to the chart.
sideBySideBarChart.Series.Add(series1);
sideBySideBarChart.Series.Add(series2);
// Hide the legend (if necessary).
sideBySideBarChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
// Rotate the diagram (if necessary).
((XYDiagram)sideBySideBarChart.Diagram).Rotated = true;
// Add a title to the chart (if necessary).
ChartTitle chartTitle1 = new ChartTitle();
chartTitle1.Text = "Side-by-Side Bar Chart";
sideBySideBarChart.Titles.Add(chartTitle1);
// Add the chart to the form.
sideBySideBarChart.Dock = DockStyle.Fill;
this.Controls.Add(sideBySideBarChart);
}
*/
}
}