using HRM.BO;
using Ease.Core.DataAccess;
using System;
using System.Collections.Generic;
using System.Data;


namespace HRM.DA
{
    internal class SurveyCategoryDA
    {
        #region Constructor

        private SurveyCategoryDA()
        {
        }

        #endregion

        #region Insert function

        internal static void Insert(TransactionContext tc, SurveyCategory item)
        {
            tc.ExecuteNonQuery(
                "INSERT INTO SurveyCategory(CategoryID,Code, Description, CreatedBy, CreationDate, Status)" +
                " VALUES(%n, %s, %s,%n, %d, %n)", item.ID, item.Code, item.Description, item.CreatedBy,
                item.CreatedDate, item.Status);
        }

        #endregion

        #region Update function

        internal static void Update(TransactionContext tc, SurveyCategory item)
        {
            tc.ExecuteNonQuery(
                "UPDATE SurveyCategory SET Code=%s, Description=%s, ModifiedBy=%n, ModifiedDate=%d, Status=%n" +
                " WHERE CategoryID=%n", item.Code, item.Description, item.ModifiedBy, item.ModifiedDate, item.Status,
                item.ID);
        }

        #endregion

        #region Get Function

        internal static IDataReader Get(TransactionContext tc, EnumStatus status)
        {
            if (EnumStatus.Active == status || EnumStatus.Inactive == status)
            {
                return tc.ExecuteReader("SELECT * FROM SurveyCategory where Status=%n order by Description", status);
            }
            else
            {
                return tc.ExecuteReader("SELECT * FROM SurveyCategory order by Description");
            }
        }

        internal static IDataReader Get(TransactionContext tc, int nID)
        {
            return tc.ExecuteReader("SELECT * FROM SurveyCategory WHERE CategoryID=%n", nID);
        }

        internal static IDataReader Get(TransactionContext tc, string sCode)
        {
            return tc.ExecuteReader("SELECT * FROM SurveyCategory WHERE Code=%s", sCode);
        }

        #endregion

        #region Delete function

        internal static void Delete(TransactionContext tc, int nID)
        {
            tc.ExecuteNonQuery("DELETE FROM SurveyCategory WHERE CategoryID=%n", nID);
        }

        #endregion
    }
}