133 lines
8.1 KiB
C#
133 lines
8.1 KiB
C#
using System;
|
|
using System.Data;
|
|
using Ease.Core.DataAccess;
|
|
using HRM.BO;
|
|
|
|
|
|
namespace HRM.DA
|
|
{
|
|
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,IsDamageManagement)" +
|
|
" VALUES(%n, %n, %n, %n,%n, %s, %b)", oItem.ID, oItem.EmployeeID, oItem.ApproverID, (EnumComponentType)oItem.ComponentType, oItem.ItemID, oItem.Description, oItem.IsDamageManagement);
|
|
}
|
|
#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, oItem.Description, oItem.ID);
|
|
}
|
|
#endregion
|
|
|
|
#region Get function
|
|
|
|
public static DataSet GetUploadedComponent(TransactionContext tc, DateTime uploadMonth)
|
|
{
|
|
return tc.ExecuteDataSet(@"Select Distinct A.Name ComponentName, UC.ComponentId From ALLOWANCEDEDUCTION A
|
|
Join UploadedComponent UC On UC.ComponentId = A.AllowDeductId Where UC.SalaryMonth = %d", GlobalFunctions.LastDateOfMonth(uploadMonth));
|
|
}
|
|
|
|
public static IDataReader Get(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM ComponentUploadSetup ORDER BY EmployeeID");
|
|
}
|
|
public static IDataReader Get(TransactionContext tc, int empid)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM ComponentUploadSetup WHERE EmployeeID=%n", empid);
|
|
//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);
|
|
}
|
|
public static IDataReader GetByEmpIDandItemID(TransactionContext tc, int empid, int itemID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM ComponentUploadSetup WHERE EmployeeID=%n and ItemID=%n Order by COMPONENTUPLOADSETUPID desc", empid, itemID);
|
|
//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);
|
|
}
|
|
public static IDataReader GetByApproverID(TransactionContext tc, int 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);
|
|
}
|
|
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);
|
|
}
|
|
public static DataSet GetUploadedComponentEmpReportData(TransactionContext tc, DateTime salaryMonth, int componentId, string empIds)
|
|
{
|
|
string sql = SQLParser.MakeSQL(@"SELECT UCE.UploadedComponentEmpId, UE.EmployeeNo UploadedEmpNo, UE.Name UploadedEmpName, UCE.Amount, CONVERT(VARCHAR, UCE.CreatedDate, 106) UploadedDate, A.Name ComponentName
|
|
FROM UploadedComponentEmp UCE
|
|
LEFT JOIN Employee UE ON UE.EmployeeId = UCE.EmployeeId
|
|
LEFT JOIN UploadedComponent UC ON UC.UploadedComponentId = UCE.UploadedComponentId
|
|
LEFT JOIN ALLOWANCEDEDUCTION A ON A.AllowDeductId = UC.ComponentId
|
|
WHERE UCE.EmployeeId In (%q) And UC.ComponentId = %n And UC.SalaryMonth = %d", empIds, componentId, GlobalFunctions.LastDateOfMonth(salaryMonth));
|
|
|
|
return tc.ExecuteDataSet(sql);
|
|
}
|
|
|
|
public static DataSet GetUploadedComponentEmpReportData(TransactionContext tc, DateTime salaryMonth, string empIds)
|
|
{
|
|
string sql = SQLParser.MakeSQL(@"SELECT UCE.UploadedComponentEmpId, UE.EmployeeNo UploadedEmpNo, UE.Name UploadedEmpName, UCE.Amount, CONVERT(VARCHAR, UCE.CreatedDate, 106) UploadedDate, A.Name ComponentName
|
|
FROM UploadedComponentEmp UCE
|
|
LEFT JOIN Employee UE ON UE.EmployeeId = UCE.EmployeeId
|
|
LEFT JOIN UploadedComponent UC ON UC.UploadedComponentId = UCE.UploadedComponentId
|
|
LEFT JOIN ALLOWANCEDEDUCTION A ON A.AllowDeductId = UC.ComponentId
|
|
WHERE UCE.EmployeeId In (%q) And UC.SalaryMonth = %d", empIds, GlobalFunctions.LastDateOfMonth(salaryMonth));
|
|
|
|
return tc.ExecuteDataSet(sql);
|
|
}
|
|
#endregion
|
|
|
|
#region Delete function
|
|
public static void Delete(TransactionContext tc, int id)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM ComponentUploadSetup WHERE ComponentUploadSetupID=%n", id);
|
|
}
|
|
public static void DeleteSingleComponent(TransactionContext tc, int empId, int apprvrId, EnumComponentType ComponentType, int itemId)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM ComponentUploadSetup WHERE EmployeeID=%n AND ApproverID = %n AND COMPONENTTYPE=%n AND ItemID=%n", empId, apprvrId, ComponentType, itemId);
|
|
}
|
|
|
|
public static bool IsExist(TransactionContext tc, int empId, int apprvrId, EnumComponentType ComponentType, int itemId)
|
|
{
|
|
object obj = tc.ExecuteScalar("Select COUNT (*) FROM ComponentUploadSetup WHERE EmployeeID=%n AND ApproverID = %n AND COMPONENTTYPE=%n AND ItemID=%n", empId, apprvrId, ComponentType, itemId);
|
|
return Convert.ToInt32(obj) > 0;
|
|
}
|
|
|
|
// True when the employee is set as the approver of at least one component upload setup.
|
|
public static bool HasApproverSetup(TransactionContext tc, int approverId)
|
|
{
|
|
object obj = tc.ExecuteScalar("Select COUNT(*) FROM ComponentUploadSetup WHERE ApproverID=%n", approverId);
|
|
return Convert.ToInt32(obj) > 0;
|
|
}
|
|
|
|
// True when the employee has at least one component upload setup (i.e. can upload components).
|
|
public static bool HasUploaderSetup(TransactionContext tc, int employeeId)
|
|
{
|
|
object obj = tc.ExecuteScalar("Select COUNT(*) FROM ComponentUploadSetup WHERE EmployeeID=%n", employeeId);
|
|
return Convert.ToInt32(obj) > 0;
|
|
}
|
|
|
|
public static void DeleteExisting(TransactionContext tc, ComponentUploadSetup oItem)
|
|
{
|
|
tc.ExecuteNonQuery(
|
|
"DELETE FROM ComponentUploadSetup WHERE EmployeeID=%n AND ApproverID=%n",
|
|
oItem.EmployeeID, oItem.ApproverID);
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
} |