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 FunctionDA internal class FunctionDA { #region Constructor private FunctionDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, Function item) { tc.ExecuteNonQuery("INSERT INTO [Function](FunctionID, code, description, CreatedBy, CreatedDate, SequenceNo, Status)" + " VALUES(%n, %s, %s, %n, %d, %n, %n)", item.ID.Integer, item.Code, item.Name, item.CreatedBy.Integer, item.CreatedDate, item.Sequence, item.Status); } #endregion #region Update Function internal static void Update(TransactionContext tc, Function item) { tc.ExecuteNonQuery("UPDATE [Function] SET code=%s, description=%s, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n" + " WHERE FunctionID=%n", item.Code, item.Name, item.ModifiedBy.Integer, item.ModifiedDate, item.Sequence, item.Status, item.ID.Integer); } #endregion #region Get Function internal static IDataReader Get(TransactionContext tc, EnumStatus status) { if (EnumStatus.Active == status || EnumStatus.Inactive == status) { return tc.ExecuteReader("SELECT * FROM [Function] where Status=%n Order By SequenceNo", status); } else { return tc.ExecuteReader("SELECT * FROM [Function] Order By SequenceNo"); } } internal static IDataReader Get(TransactionContext tc, ID nID) { return tc.ExecuteReader("SELECT * FROM [Function] WHERE FunctionID=%n", nID.Integer); } internal static IDataReader Get(TransactionContext tc, string sCode) { return tc.ExecuteReader("SELECT * FROM [Function] WHERE Code=%s", sCode); } #endregion #region Delete Function internal static void Delete(TransactionContext tc, ID nID) { tc.ExecuteNonQuery("UPDATE [Function] SET CreatedBy=%n,ModifiedBy=%n Where FunctionID=%n", Payroll.BO.User.CurrentUser.ID.Integer, Payroll.BO.User.CurrentUser.ID.Integer, nID.Integer); tc.ExecuteNonQuery("DELETE FROM [Function] WHERE FunctionID=%n", nID.Integer); } #endregion } #endregion }