103 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
		
		
			
		
	
	
			103 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| 
								 | 
							
								using Ease.Core.DataAccess;
							 | 
						|||
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Data;
							 | 
						|||
| 
								 | 
							
								using HRM.BO;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace HRM.DA
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    internal class PayScaleDA
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        #region Constructor
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        private PayScaleDA()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region Insert function
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        internal static void Insert(TransactionContext tc, PayScale item)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            tc.ExecuteNonQuery(
							 | 
						|||
| 
								 | 
							
								                "INSERT INTO PayScale(PAYSCALEID, GradeID, ALLOWANCEID, InitialAmount, NOOFSLABS, EffectDate,PercentageInc, Type)" +
							 | 
						|||
| 
								 | 
							
								                " VALUES(%n, %n, %n, %n, %n, %d, %n, %n)", item.ID, item.GradeID, item.ItemID, item.InitialAmount,
							 | 
						|||
| 
								 | 
							
								                item.NoOfStep, item.EffectDate, item.IncPercentage, item.ItemType);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region Update function
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        internal static void Update(TransactionContext tc, PayScale item)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            tc.ExecuteNonQuery(
							 | 
						|||
| 
								 | 
							
								                "UPDATE PayScale SET gradeID=%n, ALLOWANCEID=%n, initialAmount=%n, NOOFSLABS=%n, effectDate=%d, PercentageInc=%n, Type=%n" +
							 | 
						|||
| 
								 | 
							
								                " WHERE PAYSCALEID=%n", item.GradeID, item.ItemID, item.InitialAmount, item.NoOfStep, item.EffectDate,
							 | 
						|||
| 
								 | 
							
								                item.IncPercentage, item.ItemType, item.ID);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region Get Function
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        internal static IDataReader Get(TransactionContext tc)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return tc.ExecuteReader("SELECT * FROM PayScale");
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        internal static IDataReader Get(TransactionContext tc, int ID)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return tc.ExecuteReader("SELECT * FROM PayScale WHERE PAYSCALEID=%n", ID);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        internal static IDataReader GetByAllowance(TransactionContext tc, int AllowID)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return tc.ExecuteReader("SELECT * FROM PayScale WHERE ALLOWANCEID=%n", AllowID);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        internal static IDataReader Get(TransactionContext tc, int GradeID, int AllowID, DateTime nextPayProcessDate)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return tc.ExecuteReader("SELECT * FROM PayScale WHERE GRADEID=%n AND ALLOWANCEID=%n AND EffectDate=%d",
							 | 
						|||
| 
								 | 
							
								                GradeID, AllowID, nextPayProcessDate);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        internal static IDataReader GetMaxEffectDate(TransactionContext tc, int payrollTypeID)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return tc.ExecuteReader(
							 | 
						|||
| 
								 | 
							
								                "SELECT Max(EFFECTDATE) FROM PayScale Where GradeID IN(Select GradeID from Grades where PayRollTypeID=%n)",
							 | 
						|||
| 
								 | 
							
								                payrollTypeID);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        internal static IDataReader GetLatest(TransactionContext tc, int payrollTypeID)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return tc.ExecuteReader(
							 | 
						|||
| 
								 | 
							
								                "SELECT * FROM PayScale WHERE EFFECTDATE =(SELECT MAX(EFFECTDATE) FROM PayScale Where GradeID IN(Select GradeID from Grades where PayRollTypeID=%n))",
							 | 
						|||
| 
								 | 
							
								                payrollTypeID);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        internal static IDataReader GetByGrade(TransactionContext tc, int id)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return tc.ExecuteReader(
							 | 
						|||
| 
								 | 
							
								                "SELECT * FROM PayScale WHERE GRADEID=%n and EffectDate= (SELECT MAX(EFFECTDATE) FROM PayScale)", id);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region Delete function
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        internal static void Delete(TransactionContext tc, int id)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            tc.ExecuteNonQuery("DELETE FROM PAYSCALEITEM WHERE PAYSCALEID=%n", id);
							 | 
						|||
| 
								 | 
							
								            tc.ExecuteNonQuery("DELETE FROM PayScale WHERE PAYSCALEID=%n", id);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        internal static void DeleteByGrade(TransactionContext tc, int GradeID)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            tc.ExecuteNonQuery("DELETE FROM PAYSCALEITEM WHERE GRADEID=%n", GradeID);
							 | 
						|||
| 
								 | 
							
								            tc.ExecuteNonQuery("DELETE FROM PayScale WHERE GRADEID=%n", GradeID);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |