112 lines
4.0 KiB
C#
112 lines
4.0 KiB
C#
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 CostcenterDA
|
|
|
|
internal class CostcenterDA
|
|
{
|
|
#region Constructor
|
|
|
|
private CostcenterDA() { }
|
|
|
|
#endregion
|
|
|
|
#region Insert function
|
|
|
|
internal static void Insert(TransactionContext tc, Costcenter item)
|
|
{
|
|
tc.ExecuteNonQuery("INSERT INTO CRG(CrgID, code, description, ProfitCenterName, parentID, parentsID, CreatedBy, CreationDate, SequenceNo, Status, Tier)" +
|
|
" VALUES(%n, %s, %s, %s, %n, %s, %n, %d, %n, %n, %n)", item.ID.Integer, item.Code, item.Name, DataReader.GetNullValue(item.ProfitCenterName), DataReader.GetNullValue(item.ParentID, IDType.Integer), item.ParentsID, item.CreatedBy.Integer, item.CreatedDate, item.Sequence, item.Status, item.Tier);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Update function
|
|
|
|
internal static void Update(TransactionContext tc, Costcenter item)
|
|
{
|
|
tc.ExecuteNonQuery("UPDATE CRG SET code=%s, description=%s, ProfitCenterName=%s, parentID=%n, parentsID=%s, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n, Tier=%n" +
|
|
" WHERE CrgID=%n", item.Code, item.Name, DataReader.GetNullValue(item.ProfitCenterName), DataReader.GetNullValue(item.ParentID, IDType.Integer), item.ParentsID, item.ModifiedBy.Integer, item.ModifiedDate, item.Sequence, item.Status, item.Tier, item.ID.Integer);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
internal static IDataReader Get(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM CRG");
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, string code)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM CRG WHERE CODE = %s",code);
|
|
}
|
|
|
|
internal static IDataReader GetParents(TransactionContext tc,EnumStatus status)
|
|
{
|
|
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM CRG Where ParentID IS NULL and Status=%n Order By DESCRIPTION", status);
|
|
}
|
|
else
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM CRG Where ParentID IS NULL Order By DESCRIPTION");
|
|
}
|
|
}
|
|
|
|
internal static IDataReader GetChilds(TransactionContext tc, ID parentID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM CRG Where ParentID = %n Order By DESCRIPTION", parentID.Integer);
|
|
}
|
|
|
|
internal static IDataReader GetByTire(TransactionContext tc, int nTire)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM CRG Where TIER=%n", nTire);
|
|
}
|
|
internal static IDataReader GetByTireAndProfitCenter(TransactionContext tc, int nTire, string sProfitCenter)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM CRG Where TIER=%n AND ProfitCenterName =%s", nTire, sProfitCenter);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, ID nID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM CRG WHERE CrgID=%n", nID.Integer);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, EnumStatus status,int tier)
|
|
{
|
|
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM CRG Where Status=%n and TIER=%n Order By DESCRIPTION", status, tier);
|
|
}
|
|
else
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM CRG Order By DESCRIPTION");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Delete function
|
|
|
|
internal static void Delete(TransactionContext tc, ID nID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM [CRG] WHERE CrgID=%n", nID.Integer);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
}
|