EchoTex_Payroll/HRM.DA/DA/HRBasic/InstitutionDA.cs

99 lines
3.0 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Data;
using Ease.Core.DataAccess;
using HRM.BO;
namespace HRM.DA
{
#region Class InstitutionDA
internal class InstitutionDA
{
#region constructor
public InstitutionDA()
{
}
#endregion
#region insert function
internal static void Insert(TransactionContext tc, Institution item)
{
tc.ExecuteNonQuery(
"INSERT INTO INSTITUTION(INSTITUTIONID, CODE, NAME, TYPE, SEQUENCENO, STATUS, CREATEDBY, CREATIONDATE, BoardRequired)" +
"VALUES(%n, %s, %s, %n, %n, %n, %n, %d, %n)", item.ID, item.Code, item.Name, item.Type, item.Sequence,
item.Status, item.CreatedBy, item.CreatedDate, item.BoardRequired);
}
#endregion
#region update function
internal static void Update(TransactionContext tc, Institution item)
{
tc.ExecuteNonQuery(
"UPDATE INSTITUTION SET code=%s, name=%s, type=%n, sequencenO=%n, status=%n, modifiedby=%n, modifieddate=%d, boardRequired=%n" +
"WHERE INSTITUTIONID=%n",
item.Code, item.Name, item.Type, item.Sequence, item.Status, item.ModifiedBy, item.ModifiedDate,item.BoardRequired,
item.ID);
}
#endregion
#region Get function
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM INSTITUTION ORDER BY SEQUENCENO");
}
internal static IDataReader Get(TransactionContext tc, EnumStatus status)
{
if (status == EnumStatus.Regardless)
{
return tc.ExecuteReader("SELECT * FROM INSTITUTION Order By SequenceNo");
}
else
{
return tc.ExecuteReader("SELECT * FROM INSTITUTION Where Status=%n Order By SequenceNo", status);
}
}
internal static IDataReader Get(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM INSTITUTION WHERE INSTITUTIONID=%n", nID);
}
internal static IDataReader Get(TransactionContext tc, string sCode)
{
return tc.ExecuteReader("SELECT * FROM INSTITUTION WHERE Code=%s", sCode);
}
internal static IDataReader GetByInstituteType(TransactionContext tc, EnmInstituteType type)
{
return tc.ExecuteReader("SELECT * FROM INSTITUTION Where Type=%n Order By SequenceNo", type);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM INSTITUTION WHERE INSTITUTIONID=%n", nID);
}
internal static bool IsExists(TransactionContext tc, string Code)
{
Object obj = tc.ExecuteScalar("Select Count(*) From INSTITUTION where Code = %s", Code);
return Convert.ToInt32(obj) > 0;
}
#endregion
}
#endregion
}