init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
328
Kreta.DataAccessManual/NemKotottMunkaidoDAL.cs
Normal file
328
Kreta.DataAccessManual/NemKotottMunkaidoDAL.cs
Normal file
|
@ -0,0 +1,328 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Kreta.Core;
|
||||
using Kreta.DataAccess.Interfaces;
|
||||
using Kreta.DataAccessManual.Interfaces;
|
||||
using Kreta.DataAccessManual.Util;
|
||||
using Kreta.Framework;
|
||||
using Kreta.Framework.Entities;
|
||||
using Kreta.Framework.Util;
|
||||
using SDA.DataProvider;
|
||||
using SDA.Kreta.Entities;
|
||||
|
||||
namespace Kreta.DataAccessManual
|
||||
{
|
||||
internal class NemKotottMunkaidoDAL : DataAccessBase, INemKotottMunkaidoDal
|
||||
{
|
||||
public NemKotottMunkaidoDAL(DalHandler handler, GridParameters parameters)
|
||||
: base(handler, parameters)
|
||||
{
|
||||
}
|
||||
|
||||
public NemKotottMunkaidoDAL(DalHandler handler) : base(handler)
|
||||
{
|
||||
}
|
||||
|
||||
public INemKotottMunkaido Get()
|
||||
{
|
||||
return NemKotottMunkaido.GiveAnInstance();
|
||||
}
|
||||
|
||||
public INemKotottMunkaido GetNemKotottMunkaidoById(int Id)
|
||||
{
|
||||
var entity = NemKotottMunkaido.GiveAnInstance();
|
||||
entity.LoadByID(Id);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public int Insert(INemKotottMunkaido entity)
|
||||
{
|
||||
var nemKotottMunkaido = entity as NemKotottMunkaido;
|
||||
nemKotottMunkaido.Insert();
|
||||
DalHelper.Commit();
|
||||
|
||||
return entity.ID;
|
||||
}
|
||||
|
||||
public void Update(int id, bool megtartott, string megjegyzes = null, DateTime? kezdet = null, DateTime? vege = null, int? tipus = null)
|
||||
{
|
||||
var entity = GetNemKotottMunkaidoById(id) as NemKotottMunkaido;
|
||||
|
||||
if (kezdet.HasValue && vege.HasValue && tipus.IsEntityId())
|
||||
{
|
||||
entity.Kezdete = kezdet.Value;
|
||||
entity.Vege = vege.Value;
|
||||
entity.TevekenysegTipusa = tipus.Value;
|
||||
}
|
||||
if (megtartott)
|
||||
{
|
||||
entity.NaplozottMegjegyzes = megjegyzes;
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.NaplozottMegjegyzes = null;
|
||||
}
|
||||
entity.Megtartott = megtartott;
|
||||
entity.IsTanarAltalTorolt = false;
|
||||
|
||||
entity.Update();
|
||||
DalHelper.Commit();
|
||||
}
|
||||
|
||||
public void UpdateNemKotottMunkaIdoByGroupId(int pTanevId, string pGroupId, DateTime pIdoszakKezdete, DateTime pIdoszakVege,
|
||||
string pNewGroupId, int pTorvenyikategoria, string pMegjegyzes, int userId)
|
||||
{
|
||||
using (SDACommand command = new SDACommand())
|
||||
{
|
||||
command.Connection = UserContext.Instance.SDAConnection;
|
||||
command.Transaction = UserContext.Instance.SDATransaction;
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
command.CommandText = "uspUpdateNemKotottMunkaIdoByGroupId";
|
||||
|
||||
command.Parameters.Add("pTanevId", pTanevId);
|
||||
command.Parameters.Add("pIdoszakKezdete", pIdoszakKezdete);
|
||||
command.Parameters.Add("pIdoszakVege", pIdoszakVege);
|
||||
command.Parameters.Add("pGroupId", pGroupId);
|
||||
command.Parameters.Add("pNewGroupId", pNewGroupId);
|
||||
command.Parameters.Add("pTorvenyikategoria", pTorvenyikategoria);
|
||||
if (string.IsNullOrWhiteSpace(pMegjegyzes))
|
||||
{
|
||||
command.Parameters.Add("pMegjegyzes", DBNull.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
command.Parameters.Add("pMegjegyzes", pMegjegyzes);
|
||||
}
|
||||
|
||||
command.Parameters.Add("pUserId", userId);
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
DalHelper.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(int Id)
|
||||
{
|
||||
var entity = this.GetNemKotottMunkaidoById(Id) as NemKotottMunkaido;
|
||||
|
||||
entity.Delete();
|
||||
DalHelper.Commit();
|
||||
}
|
||||
|
||||
public void AdminDelete(int Id)
|
||||
{
|
||||
var entity = this.GetNemKotottMunkaidoById(Id) as NemKotottMunkaido;
|
||||
|
||||
entity.AdminAltalTorolt = true;
|
||||
|
||||
entity.Torolt = true;
|
||||
|
||||
entity.Update();
|
||||
DalHelper.Commit();
|
||||
}
|
||||
|
||||
public void TanarDelete(int Id)
|
||||
{
|
||||
var entity = GetNemKotottMunkaidoById(Id) as NemKotottMunkaido;
|
||||
entity.IsTanarAltalTorolt = true;
|
||||
entity.Megtartott = true;
|
||||
|
||||
entity.Update();
|
||||
DalHelper.Commit();
|
||||
}
|
||||
|
||||
public DataSet GetNapokForNemKotottMunkaidoInsert(int intezmenyId, int tanevId, DateTime start, DateTime end, DateTime selected, int hetirend)
|
||||
{
|
||||
using (SDACommand command = new SDACommand())
|
||||
{
|
||||
command.Connection = UserContext.Instance.SDAConnection;
|
||||
command.Transaction = UserContext.Instance.SDATransaction;
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
command.CommandText = "sp_GetNemKotottMunkaIdoDateByInsert";
|
||||
|
||||
command.Parameters.Add("IntezmenyId", intezmenyId);
|
||||
command.Parameters.Add("TanevId", tanevId);
|
||||
|
||||
command.Parameters.Add("IdoszakKezdete", start);
|
||||
command.Parameters.Add("IdoszakVege", end);
|
||||
command.Parameters.Add("KivalaszottDatum", selected);
|
||||
command.Parameters.Add("HetirendId", hetirend);
|
||||
|
||||
var dts = new DataSet();
|
||||
using (var adapter = new SDADataAdapter())
|
||||
{
|
||||
adapter.SelectCommand = command;
|
||||
adapter.Fill(dts);
|
||||
}
|
||||
|
||||
return dts;
|
||||
}
|
||||
}
|
||||
|
||||
public DataSet GetNapokForNemKotottMunkaidoDelete(int intezmenyId, int tanevId, DateTime start, DateTime end, string groupId)
|
||||
{
|
||||
using (SDACommand command = new SDACommand())
|
||||
{
|
||||
command.Connection = UserContext.Instance.SDAConnection;
|
||||
command.Transaction = UserContext.Instance.SDATransaction;
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
command.CommandText = "sp_GetNemKotottMunkaIdoIdByDelete";
|
||||
|
||||
command.Parameters.Add("IntezmenyId", intezmenyId);
|
||||
command.Parameters.Add("TanevId", tanevId);
|
||||
|
||||
command.Parameters.Add("IdoszakKezdete", start);
|
||||
command.Parameters.Add("IdoszakVege", end);
|
||||
command.Parameters.Add("GroupId", groupId);
|
||||
|
||||
var dts = new DataSet();
|
||||
using (var adapter = new SDADataAdapter())
|
||||
{
|
||||
adapter.SelectCommand = command;
|
||||
adapter.Fill(dts);
|
||||
}
|
||||
|
||||
return dts;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetNemKotottMunkaidoId(int oralatogatasId, int tanarId)
|
||||
{
|
||||
var oraLatogatas = Oralatogatas.GiveAnInstance();
|
||||
oraLatogatas.LoadByID(oralatogatasId);
|
||||
|
||||
using (SDACommand command = new SDACommand())
|
||||
{
|
||||
command.Connection = UserContext.Instance.SDAConnection;
|
||||
command.Transaction = UserContext.Instance.SDATransaction;
|
||||
command.Parameters.Add("pTanarId", tanarId);
|
||||
command.Parameters.Add("pKezdet", oraLatogatas.MegtartottOra.OraKezdete);
|
||||
command.Parameters.Add("pVeg", oraLatogatas.MegtartottOra.OraVege);
|
||||
|
||||
command.CommandText = @"
|
||||
select
|
||||
nkm.ID
|
||||
from T_NEMKOTOTTMUNKAIDO nkm
|
||||
where
|
||||
nkm.C_TANARID = :pTanarId and nkm.C_TULAJDONOSID = :pTanarId
|
||||
and :pKezdet = nkm.C_KEZDETE and :pVeg = nkm.C_VEGE
|
||||
and nkm.TOROLT = 'F'
|
||||
";
|
||||
|
||||
var result = command.ExecuteScalar();
|
||||
return result != null ? int.Parse(result.ToString()) : -1;
|
||||
}
|
||||
}
|
||||
|
||||
public DataSet GetNemKotottMunkaidoData(int tanevId, int? pFeladatKategoriaId = null, int? pFeladatEllatasiHelyId = null)
|
||||
{
|
||||
using (var command = new SDACommand())
|
||||
{
|
||||
command.Connection = UserContext.Instance.SDAConnection;
|
||||
command.Transaction = UserContext.Instance.SDATransaction;
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
command.CommandText = "uspGetNevOktLeNemKotottMunkaido";
|
||||
command.Parameters.Add("pTanevId", SDADBType.Int).Value = tanevId;
|
||||
|
||||
if (pFeladatKategoriaId.IsEntityId())
|
||||
{
|
||||
command.Parameters.Add("pFeladatKategoriaId", SDADBType.Int).Value = pFeladatKategoriaId.Value;
|
||||
}
|
||||
|
||||
if (pFeladatEllatasiHelyId.IsEntityId())
|
||||
{
|
||||
command.Parameters.Add("pFeladatEllatasiHelyId", SDADBType.Int).Value = pFeladatEllatasiHelyId.Value;
|
||||
}
|
||||
|
||||
var ds = new DataSet();
|
||||
|
||||
using (var adapter = new SDADataAdapter())
|
||||
{
|
||||
adapter.SelectCommand = command;
|
||||
adapter.Fill(ds);
|
||||
}
|
||||
|
||||
return ds;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsElmaradtOraAndPedagogusHasNemkotottMunkaido(int tanitasioraId)
|
||||
{
|
||||
using (var command = new SDACommand())
|
||||
{
|
||||
command.Connection = UserContext.Instance.SDAConnection;
|
||||
command.Transaction = UserContext.Instance.SDATransaction;
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
command.CommandText = "uspGetIsElmaradtOraAndPedagogusHasNemkotottMunkaido";
|
||||
|
||||
command.Parameters.Add("pTanitasioraId", tanitasioraId);
|
||||
|
||||
var dts = new DataSet();
|
||||
using (var adapter = new SDADataAdapter())
|
||||
{
|
||||
adapter.SelectCommand = command;
|
||||
adapter.Fill(dts);
|
||||
}
|
||||
return Convert.ToBoolean(dts.Tables[0].Rows[0]["HasUtkozes"].ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasTanarNemKotottMunkaidoUtkozes(int tanarId, DateTime oraKezdete, DateTime oraVege, int? nemkotottId)
|
||||
{
|
||||
var parameters = new List<CommandParameter>
|
||||
{
|
||||
new CommandParameter("pTanarId", tanarId),
|
||||
new CommandParameter("pKezdet", oraKezdete),
|
||||
new CommandParameter("pVeg", oraVege)
|
||||
};
|
||||
|
||||
string command = @"
|
||||
SELECT TOP 1
|
||||
1
|
||||
FROM T_NEMKOTOTTMUNKAIDO_OSSZES
|
||||
WHERE
|
||||
C_TANARID = @pTanarId
|
||||
AND C_KEZDETE < @pVeg AND C_VEGE > @pKezdet
|
||||
AND TOROLT = 'F'";
|
||||
|
||||
if (nemkotottId.IsEntityId())
|
||||
{
|
||||
parameters.Add(new CommandParameter("pId", nemkotottId.Value));
|
||||
command += @"
|
||||
AND ID <> @pId";
|
||||
}
|
||||
|
||||
var ds = GetData(command, parameters);
|
||||
|
||||
var result = ds.Tables[0].Rows.Count > 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public DataSet GetNemKotottMunkaIdoHelyettesiteshez(int tanevId, DateTime start, DateTime end)
|
||||
{
|
||||
using (var command = new SDACommand())
|
||||
{
|
||||
command.Connection = UserContext.Instance.SDAConnection;
|
||||
command.Transaction = UserContext.Instance.SDATransaction;
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
command.CommandText = "uspGetNemKotottMunkaIdoHelyettesiteshez";
|
||||
|
||||
command.Parameters.Add("TanevId", tanevId);
|
||||
command.Parameters.Add("IdoszakKezdete", start);
|
||||
command.Parameters.Add("IdoszakVege", end);
|
||||
|
||||
var dts = new DataSet();
|
||||
using (var adapter = new SDADataAdapter())
|
||||
{
|
||||
adapter.SelectCommand = command;
|
||||
adapter.Fill(dts);
|
||||
}
|
||||
|
||||
return dts;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue