EchoTex_Payroll/HRM.DA/DA/Budget/AppraisalPointRatingDA.cs

91 lines
4.3 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using HRM.BO;
using Ease.Core.DataAccess;
using System;
using System.Data;
namespace HRM.DA
{
public class AppraisalPointRatingDA
{
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("Select * From AppraisalPointRating order by minparcent, maxparcent, appraisalpointid");
}
internal static IDataReader Get(TransactionContext tc, DateTime appYear)
{
string sql = SQLParser.MakeSQL("Select * From AppraisalPointRating where AppraisalYear=%d order by minparcent, maxparcent, appraisalpointid",
Ease.Core.Utility.Global.DateFunctions.LastDateOfYear(appYear));
return tc.ExecuteReader(sql);
}
internal static IDataReader Get(TransactionContext tc, EnumAppraisalPointType type, DateTime? appYear)
{
string sql = "";
if(type == EnumAppraisalPointType.Objective)
{
sql = SQLParser.MakeSQL("Select * From AppraisalPointRating where type=%n and AppraisalYear=%d order by minparcent, appraisalpointid",
(int)type, Ease.Core.Utility.Global.DateFunctions.LastDateOfYear((DateTime)appYear));
}
else if (type == EnumAppraisalPointType.Values)
{
sql = SQLParser.MakeSQL("Select * From AppraisalPointRating where type=%n order by minparcent, appraisalpointid",
(int)type);
}
return tc.ExecuteReader(sql);
}
internal static void Insert(TransactionContext tc, AppraisalPointRating item)
{
string sql = "";
if(item.Type == EnumAppraisalPointType.Objective)
{
sql = SQLParser.MakeSQL(
"Insert into AppraisalPointRating(AppraisalPointRatingID,AppraisalPointID,MaxParcent,MinParcent,AppraisalYear,Type,CreatedBy,CreatedDate,status) Values(%n,%n,%n,%n,%d,%n,%n,%d,%n)",
item.ID, item.AppraisalPointID, item.MaxParcent, item.MinParcent, PayrollGlobalFunctions.LastDateOfYear((DateTime)item.AppraisalYear), (int)item.Type, item.CreatedBy, item.CreatedDate, Convert.ToInt32(item.Status));
}
if (item.Type == EnumAppraisalPointType.Values)
{
sql = SQLParser.MakeSQL(
"Insert into AppraisalPointRating(AppraisalPointRatingID,AppraisalPointID,Type,CreatedBy,CreatedDate,status) Values(%n,%n,%n,%n,%d,%n)",
item.ID, item.AppraisalPointID, (int)item.Type, item.CreatedBy, item.CreatedDate, Convert.ToInt32(item.Status));
}
tc.ExecuteNonQuery(sql);
}
internal static void Update(TransactionContext tc, AppraisalPointRating item)
{
tc.ExecuteNonQuery(
"Update AppraisalPointRating Set AppraisalPointID = %n, MaxParcent = %n, MinParcent = %n, AppraisalYear = %d, Type = %n, ModifiedBy = %n,ModifiedDate = %d,status = %n Where AppraisalPointRatingID = %n",
item.AppraisalPointID, DataReader.GetNullValue(item.MaxParcent), DataReader.GetNullValue(item.MinParcent), DataReader.GetNullValue(item.AppraisalYear), item.Type,
item.ModifiedBy, item.ModifiedDate, Convert.ToInt32(item.Status), item.ID);
}
internal static void Delete(TransactionContext tc, int id)
{
tc.ExecuteNonQuery("Delete From AppraisalPointRating Where AppraisalPointRatingID = %n", id);
}
internal static DataSet CheckAppraisalPointRating(TransactionContext tc, int id, DateTime year)
{
return tc.ExecuteDataSet(
"Select * From AppraisalPointRating Where AppraisalPointID = %n And AppraisalYear = %d", id, year);
}
//internal static DataSet CheckAppraisalPointValid(TransactionContext tc, AppraisalPointRating item)
//{
// string sql = SQLParser.MakeSQL(@"Select * From AppraisalPointRating
// WHERE APPRAISALYEAR = %d
// AND TYPE = %n
// AND APPRAISALPOINT = %n ", item.AppraisalYear, item.Type, item.AppraisalPoint);
// if (!item.IsNew)
// {
// sql += SQLParser.MakeSQL("And APPRAISALPOINTRATINGID <> %n", item.ID);
// }
// return tc.ExecuteDataSet(sql);
//}
}
}