init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
247
Kreta.BusinessLogic/Helpers/TantervHelper.cs
Normal file
247
Kreta.BusinessLogic/Helpers/TantervHelper.cs
Normal file
|
@ -0,0 +1,247 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Kreta.BusinessLogic.HelperClasses;
|
||||
using Kreta.BusinessLogic.Utils;
|
||||
using Kreta.Core;
|
||||
using Kreta.Core.ConnectionType;
|
||||
using Kreta.Core.Exceptions;
|
||||
using Kreta.DataAccess.Interfaces;
|
||||
using Kreta.DataAccessManual;
|
||||
using Kreta.DataAccessManual.Interfaces;
|
||||
using Kreta.Resources;
|
||||
|
||||
namespace Kreta.BusinessLogic.Helpers
|
||||
{
|
||||
public class TantervHelper : LogicBase
|
||||
{
|
||||
public TantervHelper(IConnectionType connectionType) : base(connectionType) { }
|
||||
|
||||
public TantervCO GetCo(int id)
|
||||
{
|
||||
return Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var dal = h.TantervDAL();
|
||||
var oTanterv = dal.Get(id);
|
||||
|
||||
var tantervCo = new TantervCO()
|
||||
{
|
||||
ID = id,
|
||||
CsoportTipusa = oTanterv.CsoportTipusa,
|
||||
Evfolyamig = oTanterv.Evfolyamig,
|
||||
Evfolyamtol = oTanterv.Evfolyamtol,
|
||||
KerettantervreEpulo = oTanterv.KerettantervreEpulo,
|
||||
Megjegyzes = oTanterv.Megjegyzes,
|
||||
Nev = oTanterv.Nev,
|
||||
IsKerettanterv = oTanterv.IsKerettanterv
|
||||
};
|
||||
|
||||
return tantervCo;
|
||||
});
|
||||
}
|
||||
|
||||
public IDictionary<string, string> GetTanterv(string baseText)
|
||||
{
|
||||
var result = Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
LogicUtil.CreateDropdownContent(h.TantervDAL(GridParameters).GetAktivTantervek(TanevId), "ID", "Nev", baseText));
|
||||
return result;
|
||||
}
|
||||
|
||||
public DataSet GetAktivTantervDataSet()
|
||||
{
|
||||
return Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var dal = h.TantervDAL();
|
||||
return dal.GetAktivTantervek(TanevId);
|
||||
});
|
||||
}
|
||||
|
||||
public void Insert(TantervCO co)
|
||||
{
|
||||
if (!IsValid(co))
|
||||
return;
|
||||
|
||||
Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var dal = h.TantervDAL();
|
||||
|
||||
var oTanterv = Convert_CO_to_Entity(dal, co, false);
|
||||
|
||||
oTanterv.TanevId = TanevId;
|
||||
dal.Insert(oTanterv);
|
||||
});
|
||||
}
|
||||
|
||||
public void Update(TantervCO co)
|
||||
{
|
||||
if (!IsValid(co))
|
||||
return;
|
||||
|
||||
Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var dal = h.TantervDAL();
|
||||
|
||||
var oTanterv = Convert_CO_to_Entity(dal, co, true);
|
||||
|
||||
oTanterv.TanevId = TanevId;
|
||||
dal.Update(oTanterv);
|
||||
});
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
{
|
||||
Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var dal = h.TantervDAL();
|
||||
var oTanterv = dal.Get(id);
|
||||
dal.Delete(oTanterv);
|
||||
});
|
||||
}
|
||||
|
||||
public DataSet GetTantervOsztalyai(int tantervId)
|
||||
{
|
||||
return Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var dal = h.TantervDAL(GridParameters);
|
||||
return dal.GetTantervOsztalyai(tantervId, TanevId);
|
||||
});
|
||||
}
|
||||
|
||||
public DataSet GetTantervTanuloi(int tantervId)
|
||||
{
|
||||
return Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var dal = h.TantervDAL(GridParameters);
|
||||
return dal.GetTantervTanuloi(tantervId, TanevId);
|
||||
});
|
||||
}
|
||||
|
||||
public DataSet TantervKereses(string tantervNev = null,
|
||||
int? jellemzoCsopTipId = null,
|
||||
int? kezdoEvfolyamId = null,
|
||||
int? vegzoEvfolyamId = null,
|
||||
int? isKerettantervreEpul = null,
|
||||
int? isKerettanterv = null
|
||||
)
|
||||
{
|
||||
return Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var dal = h.TantervDAL(GridParameters);
|
||||
return dal.TantervKereses(TanevId, tantervNev, jellemzoCsopTipId, kezdoEvfolyamId, vegzoEvfolyamId, isKerettantervreEpul, isKerettanterv);
|
||||
});
|
||||
}
|
||||
|
||||
public void TantervTobbesModify(TantervTobbesModCO co)
|
||||
{
|
||||
if (!co.ID.HasValue)
|
||||
{
|
||||
throw new BlException(TantargyResource.NemLetezoTanterv);
|
||||
}
|
||||
|
||||
Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var dal = h.TantervDAL();
|
||||
var tanterv = dal.Get(co.ID.Value);
|
||||
|
||||
if (co.CsoportTipusa.HasValue)
|
||||
{
|
||||
tanterv.CsoportTipusa = co.CsoportTipusa.Value;
|
||||
}
|
||||
|
||||
if (co.Evfolyamtol.HasValue)
|
||||
{
|
||||
tanterv.Evfolyamtol = co.Evfolyamtol.Value;
|
||||
}
|
||||
|
||||
if (co.Evfolyamig.HasValue)
|
||||
{
|
||||
tanterv.Evfolyamig = co.Evfolyamig.Value;
|
||||
}
|
||||
|
||||
if (co.KerettantervreEpulo.HasValue)
|
||||
{
|
||||
tanterv.KerettantervreEpulo = co.KerettantervreEpulo.ToBool();
|
||||
}
|
||||
|
||||
if (co.IsKerettanterv.HasValue)
|
||||
{
|
||||
tanterv.IsKerettanterv = co.IsKerettanterv.ToBool();
|
||||
}
|
||||
|
||||
dal.FullUpdate(tanterv);
|
||||
});
|
||||
}
|
||||
|
||||
private bool IsValid(TantervCO co)
|
||||
{
|
||||
bool ret = true;
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(co.Nev))
|
||||
{
|
||||
ret = false;
|
||||
}
|
||||
else if (co.CsoportTipusa < 0)
|
||||
{
|
||||
ret = false;
|
||||
}
|
||||
else if (co.Evfolyamig < 0)
|
||||
{
|
||||
ret = false;
|
||||
}
|
||||
else if (co.Evfolyamtol < 0)
|
||||
{
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private ITanterv Convert_CO_to_Entity(ITantervDAL dal, TantervCO co, bool isUpdate = false)
|
||||
{
|
||||
var oTanterv = dal.Get();
|
||||
if (isUpdate)
|
||||
{
|
||||
if (co.ID != null)
|
||||
{
|
||||
oTanterv = dal.Get(co.ID.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BlException("Update esetén a ID megadása kötelező");
|
||||
}
|
||||
}
|
||||
|
||||
oTanterv.CsoportTipusa = co.CsoportTipusa;
|
||||
oTanterv.Evfolyamig = co.Evfolyamig;
|
||||
oTanterv.Evfolyamtol = co.Evfolyamtol;
|
||||
if (co.KerettantervreEpulo.HasValue)
|
||||
oTanterv.KerettantervreEpulo = co.KerettantervreEpulo.Value;
|
||||
else
|
||||
oTanterv.KerettantervreEpulo = null;
|
||||
oTanterv.IsKerettanterv = co.IsKerettanterv.Value;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(co.Megjegyzes))
|
||||
oTanterv.Megjegyzes = co.Megjegyzes;
|
||||
else
|
||||
oTanterv.Megjegyzes = null;
|
||||
oTanterv.Nev = co.Nev;
|
||||
|
||||
return oTanterv;
|
||||
}
|
||||
|
||||
public int GetTop1TantervId()
|
||||
{
|
||||
return Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var dal = h.TantervDAL();
|
||||
return dal.GetTop1TantervId(TanevId);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue