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 DesignationDA internal class DesignationDA { #region Constructor private DesignationDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, Designation item) { tc.ExecuteNonQuery("INSERT INTO Designation(DesignationID,Code, Name,GradeID, CreatedBy, CreationDate, SequenceNo, Status)" + " VALUES(%n, %s, %s,%n, %n, %d, %n, %n)", item.ID.Integer, item.Code, item.Name,DataReader.GetNullValue(item.GradeID, IDType.Integer), item.CreatedBy.Integer, item.CreatedDate, item.Sequence, item.Status); } #endregion #region Update function internal static void Update(TransactionContext tc, Designation item) { tc.ExecuteNonQuery("UPDATE Designation SET Code=%s, Name=%s,GradeID=%n, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n" + " WHERE DesignationID=%n", item.Code, item.Name, DataReader.GetNullValue(item.GradeID, IDType.Integer), 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 Designation where Status=%n order by Name", status); } else { return tc.ExecuteReader("SELECT * FROM Designation order by Name"); } } internal static IDataReader Get(TransactionContext tc, ID nID) { return tc.ExecuteReader("SELECT * FROM Designation WHERE DesignationID=%n", nID.Integer); } internal static IDataReader Get(TransactionContext tc, string sCode) { return tc.ExecuteReader("SELECT * FROM Designation WHERE Code=%s", sCode); } #endregion #region Delete function internal static void Delete(TransactionContext tc, ID nID) { tc.ExecuteNonQuery("UPDATE [Designation] SET CreatedBy=%n,ModifiedBy=%n Where DesignationID=%n", Payroll.BO.User.CurrentUser.ID.Integer, Payroll.BO.User.CurrentUser.ID.Integer, nID.Integer); tc.ExecuteNonQuery("DELETE FROM [Designation] WHERE DesignationID=%n", nID.Integer); } #endregion } #endregion }