CEL_Payroll/Payroll.Service/Organogram/DA/SkillDA.cs

89 lines
2.9 KiB
C#
Raw Permalink Normal View History

2024-09-17 14:30:13 +06:00
using System;
using Payroll.BO;
using System.Data;
using System.Linq;
using Ease.CoreV35.Model;
using System.Data.SqlClient;
using Ease.CoreV35.DataAccess;
using System.Collections.Generic;
using Ease.CoreV35.DataAccess.SQL;
namespace Payroll.Service
{
#region SkillDA
internal class SkillDA
{
#region Constructor
private SkillDA() { }
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, Skill item)
{
tc.ExecuteNonQuery("INSERT INTO Skill(SkillID, Code, Name,ParentID,CreatedBy, CreationDate, SequenceNo,Status,Tire)" +
" VALUES(%n, %s, %s, %n,%n, %d, %n,%n,%n)", item.ID.Integer, item.Code, item.Name,DataReader.GetNullValue(item.ParentID,IDType.Integer), item.CreatedBy.Integer, item.CreatedDate,item.Sequence,item.Status,item.Tier);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, Skill item)
{
tc.ExecuteNonQuery("UPDATE Skill SET Code=%s, Name=%s,ParentID=%n, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n,Tire=%n" +
"WHERE SkillID=%n", item.Code, item.Name, DataReader.GetNullValue(item.ParentID, IDType.Integer), item.ModifiedBy.Integer, item.ModifiedDate, item.Sequence, item.Status, item.Tier, item.ID.Integer);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, ID nID)
{
tc.ExecuteNonQuery("DELETE FROM [Skill] Where SkillID=%n", nID.Integer);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM Skill Order By SequenceNo");
}
internal static IDataReader Get(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM Skill Where SkillID=%n", nID.Integer);
}
internal static IDataReader GetParents(TransactionContext tc, EnumStatus status)
{
if (EnumStatus.Active == status)
{
return tc.ExecuteReader("SELECT * FROM Skill Where ParentID IS NULL and Status=%n Order By SequenceNo", status);
}
else
{
return tc.ExecuteReader("SELECT * FROM Skill Where ParentID IS NULL Order By SequenceNo");
}
}
internal static IDataReader GetChilds(TransactionContext tc, ID parentID)
{
return tc.ExecuteReader("SELECT * FROM Skill Where ParentID=%n", parentID.Integer);
}
#endregion
internal static bool IsExists(TransactionContext tc, string Code)
{
Object obj = tc.ExecuteScalar("Select Count(*) From Skill where Code = %s", Code);
return Convert.ToInt32(obj) > 0;
}
}
#endregion
}