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 OpiItem internal class OpiItemDA { #region Constructor public OpiItemDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, OpiItem oItem) { tc.ExecuteNonQuery("INSERT INTO OpiItem(OpiItemID, Code, Name, OpiType, SequenceNO, Status, CreatedBy, CreationDate)" + " VALUES(%n, %s, %s, %n, %n, %n, %n, %d)", oItem.ID.Integer, oItem.Code, oItem.Name, oItem.OpiType, oItem.Sequence, oItem.Status, DataReader.GetNullValue(oItem.CreatedBy.Integer), DataReader.GetNullValue(oItem.CreatedDate)); } #endregion #region Update function internal static void Update(TransactionContext tc, OpiItem oItem) { tc.ExecuteNonQuery("UPDATE OpiItem SET Code=%s, Name=%s, OpiType=%n, SequenceNO=%n, Status=%n, ModifiedBy=%n, ModifiedDate=%d" + " WHERE OpiItemID=%n", oItem.Code, oItem.Name, oItem.OpiType, oItem.Sequence, oItem.Status, DataReader.GetNullValue(oItem.ModifiedBy.Integer), DataReader.GetNullValue(oItem.ModifiedDate), oItem.ID.Integer); } #endregion #region Get Function internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM OpiItem WHERE STATUS=%n Order By Code",(int)EnumStatus.Active); } internal static IDataReader Get(TransactionContext tc, ID nID) { return tc.ExecuteReader("SELECT * FROM OpiItem WHERE OpiItemID=%n", nID.Integer); } internal static IDataReader Get(TransactionContext tc, EnumStatus status) { if (EnumStatus.Active == status || EnumStatus.Inactive == status) { return tc.ExecuteReader("SELECT * FROM OpiItem where Status=%n Order By SequenceNo", status); } else { return tc.ExecuteReader("SELECT * FROM OpiItem Order By SequenceNo"); } } internal static IDataReader Get(TransactionContext tc, EnumOpiType opiType, EnumStatus status) { if (EnumStatus.Active == status || EnumStatus.Inactive == status) { return tc.ExecuteReader("SELECT * FROM OpiItem WHERE OpiType=%n AND Status=%n", opiType, status); } else { return tc.ExecuteReader("SELECT * FROM OpiItem WHERE OpiType=%n", opiType); } } #endregion #region Delete function internal static void Delete(TransactionContext tc, ID nID) { tc.ExecuteNonQuery("DELETE FROM [OpiItem] WHERE OpiItemID=%n", nID.Integer); } #endregion } #endregion }