CEL_Payroll/Payroll.Service/HRBasic/DA/HRDocDA.cs

83 lines
2.7 KiB
C#
Raw Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.CoreV35.Model;
using System.Data.SqlClient;
using Ease.CoreV35.DataAccess;
using Payroll.BO;
using System.Data;
using Ease.CoreV35.DataAccess.SQL;
namespace Payroll.Service
{
#region HRDocDA
public class HRDocDA
{
#region Constructor
private HRDocDA() { }
#endregion
#region Get
internal static IDataReader Get(TransactionContext tc, ID id)
{
return tc.ExecuteReader("SELECT * FROM HRDoc WHERE HRDocID=%n", id.Integer);
}
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM HRDoc");
}
internal static IDataReader GetParent(TransactionContext tc, EnumStatus status)
{
return tc.ExecuteReader("SELECT * FROM HRDoc WHERE Status=%n", status);
}
internal static IDataReader GetChilds(TransactionContext tc, ID parentID)
{
return tc.ExecuteReader("SELECT * FROM HRDoc Where ParentID=%n", parentID.Integer);
}
internal static bool IsExists(TransactionContext tc, string Code)
{
Object obj = tc.ExecuteScalar("Select Count(*) From HRDoc where Code = %s", Code);
return Convert.ToInt32(obj) > 0;
}
#endregion
#region Insert
internal static void Insert(TransactionContext tc, HRDoc oHRDoc)
{
tc.ExecuteNonQuery("INSERT INTO HRDoc(HRDocID, Code, Name,Description,ParentID,Status," +
" CreatedBy, CreationDate)" +
" VALUES(%n, %s, %s, %s, %n,%n,%n,%d)",
oHRDoc.ID.Integer, oHRDoc.Code, oHRDoc.Name, oHRDoc.Description, DataReader.GetNullValue(oHRDoc.ParentID, IDType.Integer),
oHRDoc.Status,DataReader.GetNullValue(oHRDoc.CreatedBy.Integer),
DataReader.GetNullValue(oHRDoc.CreatedDate));
}
#endregion
#region Update
internal static void Update(TransactionContext tc, HRDoc oHRDoc)
{
tc.ExecuteNonQuery("UPDATE HRDoc SET [Code]=%s,[Name]=%s,[Description]=%s,[ParentID]=%n,[Status]=%n, [ModifiedBy]=%n,[ModifiedDate]=%d WHERE [HRDocID]=%n" ,
oHRDoc.Code, oHRDoc.Name, oHRDoc.Description, DataReader.GetNullValue(oHRDoc.ParentID, IDType.Integer),oHRDoc.Status,
DataReader.GetNullValue(oHRDoc.ModifiedBy, IDType.Integer),
DataReader.GetNullValue(oHRDoc.ModifiedDate), oHRDoc.ID.Integer);
}
#endregion
#region Delete
internal static void Delete(TransactionContext tc, ID id)
{
tc.ExecuteNonQuery("DELETE FROM HRDoc WHERE HRDocID=%n", id.Integer);
}
#endregion
}
#endregion
}