CEL_Payroll/Payroll.Service/Basic/DA/AutoObjectDA.cs
2024-09-17 14:30:13 +06:00

91 lines
2.7 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 AutoObjectDA
internal class AutoObjectDA
{
#region Constructor
private AutoObjectDA() { }
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, AutoObject item)
{
tc.ExecuteNonQuery("INSERT INTO AutoObjectName(TableID, FormName,MenuKey)" +
" VALUES(%n, %s,%s)", item.ID.Integer,item.Name,item.MenuKey);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, AutoObject item)
{
tc.ExecuteNonQuery("UPDATE AutoObjectName SET FormName=%s,MenuKey=%s" +
" WHERE TableID=%n", item.Name,item.MenuKey, item.ID.Integer);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc, string sFormName)
{
return tc.ExecuteReader("SELECT * FROM AutoObjectName WHERE MenuKey=%s", sFormName);
}
internal static DataSet GetInformation(TransactionContext tc, DateTime FromDate, DateTime ToDate, string sTableName)
{
DataSet ds = new DataSet();
try
{
ds = tc.ExecuteDataSet("select a.Code,a.description Name,case a.__$operation "+
"when 1 then 'Deleted' "+
"when 2 then 'Inserted' "+
"when 3 then 'Before Updated'"+
"when 4 then 'After Updated'"+
" end operation,b.tran_begin_time fromdate from cdc.dbo_Category_CT a, cdc.lsn_time_mapping b" +
" where a.__$start_lsn=b.start_lsn AND b.tran_begin_time between %D AND %D ORDER BY b.tran_begin_time", FromDate, ToDate);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return ds;
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, ID nID)
{
tc.ExecuteNonQuery("DELETE FROM AutoObjectName WHERE TableID=%n", nID.Integer);
}
internal static void DeleteAll(TransactionContext tc)
{
tc.ExecuteNonQuery("DELETE FROM AutoObjectName");
}
#endregion
}
#endregion
}