94 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			94 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using Payroll.BO;
 | 
						|
using System.Data;
 | 
						|
using System.Linq;
 | 
						|
using Ease.CoreV35.Model;
 | 
						|
using System.Data.SqlClient;
 | 
						|
using Ease.CoreV35.DataAccess;
 | 
						|
using System.Collections.Generic;
 | 
						|
using Ease.CoreV35.DataAccess.SQL;
 | 
						|
 | 
						|
namespace Payroll.Service
 | 
						|
{
 | 
						|
    #region  ESBProvisionDA
 | 
						|
 | 
						|
    internal class ESBProvisionDA
 | 
						|
    {
 | 
						|
        #region  Constructor
 | 
						|
 | 
						|
        private ESBProvisionDA() { }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region  Insert function
 | 
						|
 | 
						|
 | 
						|
        internal static void Insert(TransactionContext tc, ESBProvision item)
 | 
						|
        {
 | 
						|
            //, ProvisionOne,ProvisionTwo  , %n, %n    , item.ProvisionOne, item.ProvisionTwo
 | 
						|
            tc.ExecuteNonQuery("INSERT INTO ESBProvision(EmployeeID, SalaryMonthlyID, UserID, ProcessMonthDate, Provision)" +
 | 
						|
            " VALUES(%n, %n, %n, %d, %n)", item.EmployeeID.Integer, item.SalaryMonthlyID.Integer, item.UserID.Integer, item.ProcessMonthDate, item.Provision);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
        
 | 
						|
 | 
						|
        #region Get Function
 | 
						|
        
 | 
						|
        internal static IDataReader Get(TransactionContext tc, ID nID)
 | 
						|
        {
 | 
						|
            return tc.ExecuteReader("SELECT * FROM ESBProvision WHERE EmployeeID=%n",nID.Integer );
 | 
						|
        }
 | 
						|
 | 
						|
        internal static IDataReader GetProvision(TransactionContext tc, string sEmpID, DateTime GratuityMonth)
 | 
						|
        {
 | 
						|
            string sSQL = string.Empty;
 | 
						|
            sSQL = SQLParser.MakeSQL("SELECT * FROM ESBProvision WHERE EmployeeID in (%q) and ProcessMonthDate=%d", sEmpID, GratuityMonth);
 | 
						|
            return tc.ExecuteReader("SELECT * FROM ESBProvision WHERE EmployeeID in (%q) and ProcessMonthDate=%d", sEmpID, GratuityMonth);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region  Delete function
 | 
						|
 | 
						|
        internal static void Delete(TransactionContext tc, ID nEmpID, ID nSalaryMonthlyID)
 | 
						|
        {
 | 
						|
            tc.ExecuteNonQuery("DELETE FROM [ESBProvision] WHERE EmployeeID=%n and SalaryMonthlyID=%n", nEmpID.Integer,nSalaryMonthlyID.Integer);
 | 
						|
        }
 | 
						|
        internal static IDataReader GetProvision(TransactionContext tc, DateTime dFromDate, DateTime dToDate)
 | 
						|
        {
 | 
						|
            return tc.ExecuteReader("SELECT * FROM ESBProvision where ProcessMonthDate between %d and %d ", dFromDate,dToDate);
 | 
						|
        }
 | 
						|
        internal static IDataReader GetProvision(TransactionContext tc,int nEmpID, DateTime dFromDate, DateTime dToDate)
 | 
						|
        {
 | 
						|
            return tc.ExecuteReader("SELECT * FROM ESBProvision where EmployeeID=%n AND ProcessMonthDate between %d and %d ",nEmpID, dFromDate, dToDate);
 | 
						|
        }
 | 
						|
        internal static double GetOpeningBalance(TransactionContext tc, int nEmpID, DateTime fromDate)
 | 
						|
        {
 | 
						|
            object amount = tc.ExecuteScalar("SELECT SUM(Provision) FROM ESBProvision WHERE"
 | 
						|
            + " EmployeeID=%n AND ProcessMonthDate < %d",nEmpID,fromDate);
 | 
						|
            if (amount == DBNull.Value)
 | 
						|
                return 0;
 | 
						|
            else return Convert.ToDouble(amount);
 | 
						|
        }
 | 
						|
        internal static DataSet GetCumulativeProv(TransactionContext tc, DateTime dateTime)
 | 
						|
        {
 | 
						|
            DataSet oCumulativeProvs = new DataSet();
 | 
						|
            try
 | 
						|
            {
 | 
						|
                oCumulativeProvs = tc.ExecuteDataSet("SELECT EmployeeID,SUM(Provision) FROM ESBProvision WHERE"
 | 
						|
                                                    + " ProcessMonthDate < %d Group by EmployeeID", dateTime);
 | 
						|
 | 
						|
            }
 | 
						|
            catch (Exception ex)
 | 
						|
            {
 | 
						|
                throw new Exception(ex.Message);
 | 
						|
            }
 | 
						|
            return oCumulativeProvs;
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
 | 
						|
    #endregion
 | 
						|
}
 |