This commit is contained in:
skidoodle 2024-03-13 00:33:46 +01:00
commit e124a47765
19374 changed files with 9806149 additions and 0 deletions

View file

@ -0,0 +1,125 @@
using System;
using System.Data;
using Kreta.BusinessLogic.Classes;
using Kreta.BusinessLogic.HelperClasses;
using Kreta.Core;
using Kreta.Core.ConnectionType;
using Kreta.DataAccessManual;
using Kreta.DataAccessManual.Interfaces;
using Kreta.Enums;
namespace Kreta.BusinessLogic.Helpers
{
public class KozmuszamlaHelper : LogicBase
{
public KozmuszamlaHelper(IConnectionType connectionType) : base(connectionType) { }
public DataSet KozmuszamlaKereses(DateTime? fizetesiHataridoTol, DateTime? fizetesiHataridoIg, int? isFizetve, string kibocsato, int? kozmuSzamlaTipusId, double? osszegTol, double? osszegIg)
{
var ds = Dal.CustomConnection.Run(ConnectionType, helper =>
{
IKozmuszamlaDal dal = helper.KozmuszamlaDal();
return dal.KozmuszamlaKereses(
TanevId,
IntezmenyId,
fizetesiHataridoTol,
fizetesiHataridoIg,
isFizetve,
kibocsato,
kozmuSzamlaTipusId,
osszegTol,
osszegIg);
});
return SetDataSet(ds);
}
private DataSet SetDataSet(DataSet ds)
{
ds.Tables[0].Columns.Add("OsszegText");
foreach (DataRow dr in ds.Tables[0].Rows)
{
if ((int)dr["PenznemId"] == (int)PenznemTipusEnum.Dollar)
{
dr["OsszegText"] = $"{SDAConvert.ToDecimal(dr["Osszeg"])} USD";
}
else if ((int)dr["PenznemId"] == (int)PenznemTipusEnum.Euro)
{
dr["OsszegText"] = $"{SDAConvert.ToDecimal(dr["Osszeg"])} EUR";
}
else
{
dr["OsszegText"] = $"{SDAConvert.ToDecimal(dr["Osszeg"])} Ft";
}
}
return ds;
}
public KozmuszamlaCO GetKozmuszamlaById(int id)
{
return Dal.CustomConnection.Run(ConnectionType, h =>
{
var dal = h.KozmuszamlaDal();
var entity = dal.Get(id);
var co = new KozmuszamlaCO();
co.Id = entity.ID;
co.BefizetesDatuma = entity.BefizetesDatuma;
co.FizetesiHatarido = entity.FizetesiHatarido;
co.Fizetve = entity.Fizetve;
co.InvaliditasOka = entity.Invaliditasoka;
co.Kelte = entity.Kelte;
co.Kibocsato = entity.Kibocsato;
co.KozmuszamlaTipusId = entity.KozmuSzamlaTipusId;
co.Osszeg = entity.Osszeg;
co.PenznemId = entity.PenznemId;
co.MerohelyId = entity.MerohelyId;
return co;
});
}
public void DeleteKozmuszamlaById(int id)
{
Dal.CustomConnection.Run(ConnectionType, helper =>
{
var dal = helper.KozmuszamlaDal();
dal.Delete(id);
});
}
public void SaveKozmuszamla(KozmuszamlaCO kozmuszamlaCO)
{
Dal.CustomConnection.Run(ConnectionType, helper =>
{
var dal = helper.KozmuszamlaDal();
bool isNew = !kozmuszamlaCO.Id.IsEntityId();
var kozmuszamla = isNew ? dal.Get() : dal.Get(kozmuszamlaCO.Id.Value);
kozmuszamla.BefizetesDatuma = kozmuszamlaCO.BefizetesDatuma;
kozmuszamla.FizetesiHatarido = kozmuszamlaCO.FizetesiHatarido;
kozmuszamla.Fizetve = kozmuszamlaCO.Fizetve;
kozmuszamla.Invaliditasoka = kozmuszamlaCO.InvaliditasOka;
kozmuszamla.Kelte = kozmuszamlaCO.Kelte;
kozmuszamla.Kibocsato = kozmuszamlaCO.Kibocsato;
kozmuszamla.KozmuSzamlaTipusId = kozmuszamlaCO.KozmuszamlaTipusId;
kozmuszamla.Osszeg = kozmuszamlaCO.Osszeg;
kozmuszamla.PenznemId = kozmuszamlaCO.PenznemId;
kozmuszamla.Valid = kozmuszamlaCO.Valid;
kozmuszamla.ValidalasAlatt = kozmuszamlaCO.ValidalasAlatt;
kozmuszamla.IntezmenyId = IntezmenyId;
kozmuszamla.TanevId = TanevId;
kozmuszamla.MerohelyId = kozmuszamlaCO.MerohelyId;
if (isNew)
{
dal.Insert(kozmuszamla);
}
else
{
dal.FullUpdate(kozmuszamla);
}
});
}
}
}