kreta/Kreta.BusinessLogic/Helpers/Nyomtatvanyok/Excel/OsztalyokCsoportokTantargyiStatisztika.cs
2024-03-13 00:33:46 +01:00

67 lines
3.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using Kreta.Core.ConnectionType;
using OfficeOpenXml;
namespace Kreta.BusinessLogic.Helpers.Nyomtatvanyok.Excel
{
public class OsztalyokCsoportokTantargyiStatisztika : BaseNyomtatvanyExcel
{
public OsztalyokCsoportokTantargyiStatisztika(IConnectionType connectionType, bool isMultisheetExcel = false, string templateFilename = null) : base(connectionType, isMultisheetExcel)
{
StoredProcedure = "sp_Nyomtatvany_Excel_IdoszakiOsztalyokCsoportokTantargyiStatisztika";
FileInfo exFile = null;
if (templateFilename != null)
{
exFile = new FileInfo(templateFilename);
}
ExcelPackage = (exFile == null) ? new ExcelPackage() : new ExcelPackage(exFile);
//Munkalap tulajdonságok beállítása
SetWorkbookProperties();
}
public override void CreateSheet(Dictionary<string, string> dbParameters, int sheetIndex = 1)
{
DbParameters = dbParameters;
dbParameters.TryGetValue("pErtekelestipusaId", out string ertekelesTipusaId);
if (string.IsNullOrWhiteSpace(ertekelesTipusaId))
ertekelesTipusaId = Convert.ToString(Enums.ErtekelesTipusEnum.evvegi_jegy_ertekeles);
// Adatforrás összeállítása
SetExcelDataSet();
DataTable ocsDt = DataSet.Tables[0];
DataTable tantargyDt = DataSet.Tables[1];
DataTable tantargyiAtlagDt = DataSet.Tables[2];
DataAccessManual.Util.DataAccessBase.SetBoolFields(DataSet.Tables[3], "OJCSJKeresztfeleves,OJTechnikaiOsztaly,OJNemzetisegi,OJKettannyelvu,OJNyelviElokeszito,OJIsGyogypedagogiaiLogopediai,OJSportOsztaly,OJAranyJanosProgram");
DataAccessManual.Util.DataAccessBase.SetBoolFields(DataSet.Tables[4], "OJCSJKeresztfeleves,CSJVegzosEvfolyamu");
//Munkalap összeállítása
ExcelWorksheet worksheet = CreateSheet(Resources.ExcelNyomtatvanyResource.ResourceManager.GetString("OsztalyokCsoportokTantargyiStatisztikaMunkalapnev_" + ertekelesTipusaId), sheetIndex, eOrientation.Landscape, true, 2);
worksheet.Row(1).Height = 120;
worksheet.Column(1).Width = 30;
worksheet.Column(2).Width = 3;
worksheet.View.FreezePanes(2, 3);
for (int col = 3; col <= tantargyDt.Rows.Count + 3; col++)
worksheet.Column(col).Width = 7;
string[] adatMezo = { "ATLAG" };
int[] retDimErtekeles = AddDataTablePivotTable(worksheet, 1, 1,
tantargyDt, "TANTARGYID", "TANTARGY_NEV",
ocsDt, "TECHNIKAIID", new[] { "OSZTALYCSOPORTNEV", "AKTUALISLETSZAM" },
tantargyiAtlagDt, Numeric2StyleBottomBordered, HeaderStyle90BottomBordered, HeaderStyleBottomBordered, adatMezo,
null,
new[] { "AVERAGE" }, new[] { Resources.ExcelNyomtatvanyResource.OsztalyCsoportStatisztikaCsoportAtlag }, new[] { Numeric2BoldStyleBottomBordered },
new[] { "AVERAGE" }, new[] { Resources.ExcelNyomtatvanyResource.OsztalyStatisztikaTantargyiAtlag },
new[] { Numeric2BoldStyleBottomBordered });
AddLabelCell(worksheet, 1, 1, Resources.ExcelNyomtatvanyResource.OsztalyCsoportStatisztikaCsoportNevek, HeaderStyleBottomBordered);
AddLabelCell(worksheet, 1, 2, Resources.ExcelNyomtatvanyResource.OsztalyCsoportStatisztikaCsoportAktualisLetszam, HeaderStyle90BottomBordered);
}
}
}