CEL_Payroll/Payroll.Service/Basic/DA/LocationDA.cs

109 lines
3.9 KiB
C#
Raw 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 LocationDA
internal class LocationDA
{
#region Constructor
private LocationDA() { }
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, Location item)
{
tc.ExecuteNonQuery("INSERT INTO Location(LocationID, code, description, 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, Location item)
{
tc.ExecuteNonQuery("UPDATE Location SET code=%s, description=%s, parentID=%n,ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n" +
" WHERE LocationID=%n", item.Code, item.Name, DataReader.GetNullValue(item.ParentID,IDType.Integer),item.ModifiedBy.Integer, item.ModifiedDate, item.Sequence, item.Status, item.ID.Integer);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM Location");
}
internal static IDataReader Get(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM Location WHERE LocationID=%n", nID.Integer);
}
internal static IDataReader Get(TransactionContext tc,string sCode)
{
return tc.ExecuteReader("SELECT * FROM Location WHERE Code=%s", sCode);
}
internal static IDataReader GetChilds(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM Location WHERE ParentID=%n Order By DESCRIPTION", nID.Integer);
}
internal static IDataReader GetParents(TransactionContext tc,EnumStatus status )
{
if(EnumStatus.Active==status || EnumStatus.Inactive==status)
{
return tc.ExecuteReader("SELECT * FROM Location Where PARENTID IS NULL and Status=%n Order By DESCRIPTION", status);
}
else
{
return tc.ExecuteReader("SELECT * FROM Location Where PARENTID IS NULL Order By DESCRIPTION");
}
}
internal static IDataReader GetByTier(TransactionContext tc, int tier)
{
return tc.ExecuteReader("SELECT * FROM Location Where Tire=%n Order by Description", tier);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, ID nID)
{
tc.ExecuteNonQuery("UPDATE [Location] SET CreatedBy=%n,ModifiedBy=%n Where LocationID=%n", Payroll.BO.User.CurrentUser.ID.Integer, Payroll.BO.User.CurrentUser.ID.Integer, nID.Integer);
tc.ExecuteNonQuery("DELETE FROM [Location] WHERE LocationID=%n", nID.Integer);
}
#endregion
internal static IDataReader Get(TransactionContext tc, EnumStatus sts)
{
string sql = SQLParser.MakeSQL("Select * From Location where [Status] = %n", sts);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetForJV(TransactionContext tc, DateTime dSalaryMonth,ID PayrollTypeID)
{
string sql = SQLParser.MakeSQL("Select * from Location where LocationID in(Select Distinct LocationID from SalaryMonthly where PayrollTypeID=%n and SalaryMonth=%d) order by Code", PayrollTypeID.Integer, dSalaryMonth);
return tc.ExecuteReader(sql);
}
}
#endregion
}