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

namespace HRM.DA
{
    internal class GrossDefinationDA
    {
        #region Insert Methods

        internal static void Save(TransactionContext tc, GrossDefination oItem)
        {
            string strSQL = SQLParser.MakeSQL("INSERT INTO GrossDefination(GrossDefinationID, SalaryComponentType," +
                                              " ComponentID, CreatedBy, CreatedDate, Quantity, BenefitDefinationType, Description)" +
                                              " VALUES(%n ,%n, %n, %n, %d, %n, %n, %s)", oItem.ID,
                oItem.SalaryComponentType, oItem.ComponentID,
                oItem.CreatedBy, oItem.CreatedDate, oItem.Quantity, oItem.BenefitDefinationType, oItem.Description);
            tc.ExecuteNonQuery(strSQL);
        }

        #endregion Insert Methods

        #region Update Methods

        internal static bool Update(TransactionContext tc, GrossDefination item)
        {
            string strSql = SQLParser.MakeSQL(
                "UPDATE GrossDefination SET SalaryComponentType=%n, ComponentID=%d, ModifiedBy=%n, ModifiedDate=%D, Quantity=%n, BenefitDefinationType=%n, Description=%s"
                + "WHERE GrossDefinationID=%n", item.SalaryComponentType, item.ComponentID, item.ModifiedBy,
                item.ModifiedDate, item.Quantity, item.BenefitDefinationType, item.Description, item.ID);
            tc.ExecuteNonQuery(strSql);
            return true;
        }

        #endregion Update Methods


        #region Get Methods

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

        internal static IDataReader Get(TransactionContext tc, EnumBenefitDefinationType type)
        {
            return tc.ExecuteReader("SELECT * FROM GrossDefination WHERE BENEFITDEFINATIONTYPE=%n", type);
        }

        internal static IDataReader Get(TransactionContext tc)
        {
            return tc.ExecuteReader("SELECT * FROM GrossDefination");
        }

        #endregion Get Methods

        #region Delete Methods

        internal static void Delete(TransactionContext tc, int grossDefinationID)
        {
            tc.ExecuteNonQuery("DELETE FROM GrossDefination WHERE GrossDefinationID=%n", grossDefinationID);
        }

        #endregion Delete Methods
    }
}