90 lines
4.5 KiB
C#
90 lines
4.5 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
|
|
{
|
|
public class ComponentUploadSetupDA
|
|
{
|
|
#region Constructor
|
|
public ComponentUploadSetupDA() { }
|
|
#endregion
|
|
|
|
#region Insert function
|
|
public static void Insert(TransactionContext tc, ComponentUploadSetup oItem)
|
|
{
|
|
tc.ExecuteNonQuery("INSERT INTO ComponentUploadSetup(ComponentUploadSetupID, EmployeeID, ApproverID, ComponentType, ItemID, Description)" +
|
|
" VALUES(%n, %n, %n, %n,%n, %s)", oItem.ID.Integer, oItem.EmployeeID, oItem.ApproverID, (EnumComponentType)oItem.ComponentType, oItem.ItemID.Integer, oItem.Description);
|
|
}
|
|
#endregion
|
|
|
|
#region Update function
|
|
public static void Update(TransactionContext tc, ComponentUploadSetup oItem)
|
|
{
|
|
tc.ExecuteNonQuery("UPDATE ComponentUploadSetup SET EmployeeID=%n, ApproverID = %n, ComponentType=%n,ItemID=%n, Description=%s" +
|
|
" WHERE ComponentUploadSetupID=%n", oItem.EmployeeID, oItem.ApproverID, (EnumComponentType)oItem.ComponentType, oItem.ItemID.Integer, oItem.Description, oItem.ID.Integer);
|
|
}
|
|
#endregion
|
|
|
|
#region Get function
|
|
public static IDataReader Get(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM ComponentUploadSetup ORDER BY EmployeeID");
|
|
}
|
|
public static IDataReader Get(TransactionContext tc, ID empid)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM ComponentUploadSetup WHERE EmployeeID=%n", empid.Integer);
|
|
//return tc.ExecuteReader("SELECT DISTinct EmployeeID, PropductSerial= STUFF((SELECT ', ' + DESCRIPTION From ComponentUploadSetup WHERE employeeid = c.EmployeeID FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '') From ComponentUploadSetup c where c.employeeid =%n", empid.Integer);
|
|
}
|
|
public static IDataReader GetByApproverID(TransactionContext tc, ID apprvrID)
|
|
{
|
|
return tc.ExecuteReader("SELECT CUS.*, UCE.UploadedComponentID FROM ComponentUploadSetup AS CUS RIGHT JOIN UploadedComponent UCE ON UCE.UploadedBy = CUS.EMPLOYEEID WHERE CUS.ApproverID=%n", apprvrID.Integer);
|
|
}
|
|
public static DataSet GetUploadedComponentReportData(TransactionContext tc, DateTime fromDate, DateTime toDate)
|
|
{
|
|
string sql = SQLParser.MakeSQL(@"SELECT UE.EmployeeNo UploaderNo, UE.Name UploaderName, CONVERT(VARCHAR, U.UploadedDate, 106) UploadDate, A.Name ComponentName,
|
|
UA.EmployeeNo ApproverNo, UA.Name ApproverName, CONVERT(VARCHAR, U.ApprovedDate, 106) ApproveDate
|
|
FROM UploadedComponent U
|
|
LEFT JOIN Employee UE ON UE.EmployeeId = U.UploadedBy
|
|
LEFT JOIN Employee UA ON UA.EmployeeId = U.ApprovedBy
|
|
LEFT JOIN ALLOWANCEDEDUCTION A ON A.AllowDeductId = U.ComponentId
|
|
WHERE U.UploadedDate BETWEEN %d AND %d", fromDate, toDate);
|
|
|
|
return tc.ExecuteDataSet(sql);
|
|
}
|
|
#endregion
|
|
|
|
#region Delete function
|
|
public static void Delete(TransactionContext tc, ID id)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM ComponentUploadSetup WHERE ComponentUploadSetupID=%n", id.Integer);
|
|
}
|
|
public static void DeleteSingleComponent(TransactionContext tc, int empId, int apprvrId, EnumComponentType ComponentType, ID itemId)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM ComponentUploadSetup WHERE EmployeeID=%n AND ApproverID = %n AND COMPONENTTYPE=%n AND ItemID=%n", empId, apprvrId, ComponentType, itemId.Integer);
|
|
}
|
|
|
|
public static bool IsExist(int empId, int apprvrId, EnumComponentType ComponentType, ID itemId)
|
|
{
|
|
TransactionContext tc = null;
|
|
tc = TransactionContext.Begin();
|
|
|
|
bool Exist = false;
|
|
Object obj = tc.ExecuteScalar("Select COUNT (*) FROM ComponentUploadSetup WHERE EmployeeID=%n AND ApproverID = %n AND COMPONENTTYPE=%n AND ItemID=%n", empId, apprvrId, ComponentType, itemId.Integer);
|
|
Exist = Convert.ToInt32(obj) > 0 ? true : false;
|
|
|
|
tc.End();
|
|
return Exist;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|