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


namespace HRM.DA
{
    class LMObjectiveDA
    {
        internal static IDataReader Get(TransactionContext tc)
        {
            string sql = SQLParser.MakeSQL("SELECT * FROM LMObjective");
            return tc.ExecuteReader(sql);
        }

        internal static IDataReader Get(TransactionContext tc, int id)
        {
            string sql = SQLParser.MakeSQL("SELECT * FROM LMObjective WHERE LMObjectiveID = %n", id);
            return tc.ExecuteReader(sql);
        }

        internal static void Save(TransactionContext tc, LMObjective item)
        {
            string sql = SQLParser.MakeSQL(
                "Insert Into LMObjective(LMObjectiveID, ParentID, ObjectiveID) Values(%n,%n, %n)",
                item.ID, item.ParentID, item.ObjectiveID);
            tc.ExecuteNonQuery(sql);
        }

        internal static void Update(TransactionContext tc, LMObjective item)
        {
            string sql = SQLParser.MakeSQL(
                "Update LMObjective Set ObjectiveID = %n, ParentID=%n where LMObjectiveID= %n",
                item.ObjectiveID, item.ParentID, item.ID);
            tc.ExecuteNonQuery(sql);
        }

        internal static void Delete(TransactionContext tc, int id)
        {
            string sql = SQLParser.MakeSQL("Delete From LMObjective Where LMObjectiveID = %n", id);
            tc.ExecuteNonQuery(sql);
        }
    }
}