using Ease.Core.DataAccess;
using HRM.BO;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HRM.DA
{
    internal class PMSObjectiveProgressDA
    {
        #region Insert
        internal static void Insert(TransactionContext tc, PMSObjectiveProgress item)
        {
            string sql = SQLParser.MakeSQL(
                @"INSERT INTO PMSOBJECTIVEPROGRESS (PMSOBJECTIVEPROGRESSID, OBJECTIVEID, EMPLOYEEID, DESCRIPTION, UPDATETIME, ACHIVEPERCENT, ISREAD, READTIME, ISEMPLOYEE, RATINGSTART)
                VALUES (%n, %n, %n, %s, %D, %n, %b, %D, %b, %n)",
                item.ID, item.ObjectiveID, item.EmployeeID, item.Description, item.UpdateTime, item.AchivePercent, item.IsRead, item.ReadTime, item.IsEmployee, item.RatingStart);
            tc.ExecuteNonQuery(sql);
        }

        #endregion Insert

        #region Update
        internal static void Update(TransactionContext tc, PMSObjectiveProgress item)
        {
            string sql = SQLParser.MakeSQL(@"UPDATE PMSOBJECTIVEPROGRESS
                SET OBJECTIVEID = %n,  EMPLOYEEID = %n,  DESCRIPTION = %s,  UPDATETIME = %D, ACHIVEPERCENT = %n, ISREAD = %b, READTIME = %D, ISEMPLOYEE = %b, RATINGSTART = %b
                where PMSOBJECTIVEPROGRESSID = %n",
                item.ObjectiveID, item.EmployeeID, item.Description, item.UpdateTime, item.AchivePercent, item.IsRead, item.ReadTime, item.IsEmployee, item.RatingStart, item.ID);
            tc.ExecuteNonQuery(sql);
        }
        #endregion Update

        #region GetAll
        internal static IDataReader Get(TransactionContext tc)
        {
            string sql = SQLParser.MakeSQL("SELECT * FROM PMSOBJECTIVEPROGRESS");
            return tc.ExecuteReader(sql);
        }
        #endregion

        #region Get functions

        internal static IDataReader Get(TransactionContext tc, int id)
        {
            string sql = SQLParser.MakeSQL("SELECT * FROM PMSOBJECTIVEPROGRESS WHERE PMSOBJECTIVEPROGRESSID = %n", id);
            return tc.ExecuteReader(sql);
        }
        internal static IDataReader GetByObjectiveID(TransactionContext tc, int objectiveId, int employeeid)
        {
            string sql = SQLParser.MakeSQL("SELECT * FROM PMSOBJECTIVEPROGRESS WHERE ObjectiveID = %n and EmployeeId = %n order by UPDATETIME", objectiveId, employeeid);
            return tc.ExecuteReader(sql);
        }
        #endregion
    }
}