113 lines
4.9 KiB
C#
113 lines
4.9 KiB
C#
using HRM.BO;
|
|
using Ease.Core.DataAccess;
|
|
using System;
|
|
using System.Data;
|
|
|
|
|
|
namespace HRM.DA
|
|
{
|
|
#region FSHeadDA
|
|
|
|
internal class FSHeadDA
|
|
{
|
|
#region Constructor
|
|
|
|
private FSHeadDA()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Insert function
|
|
|
|
internal static void Insert(TransactionContext tc, FSHead item)
|
|
{
|
|
string sql = SQLParser.MakeSQL(
|
|
"INSERT INTO FSHead(FSHeadID, Code, Name, Department, IsTaxable, CreatedBy, CreationDate, SequenceNo, Status,IsLoan,IsPaymenttoVendor,Remarks,EMPID,EMPIDTwo,IsFinal,type, CompletionWorkingDays, ClearanceRequired, FinalStage, Instruction, DepartmentToApproveBefore, NeedDepartmentApprove)" +
|
|
" VALUES(%n, %s, %s, %s, %b, %n, %d, %n, %n,%b,%b,%s,%n,%n,%b,%n, %n, %b, %b,%s,%s, %b)", item.ID, item.Code, item.Name, item.Department, item.IsTaxable,
|
|
item.CreatedBy, item.CreatedDate, item.Sequence, item.Status, item.IsLoan, item.IsPaymenttoVendor,
|
|
item.Remarks, item.EmpID, item.EmpIDTwo, item.IsFinal, item.Type, item.CompletionWorkingDays, item.ClearanceRequired, item.FinalStage, item.Instruction, item.DepartmentToApproveBefore, item.NeedDepartmentApprove);
|
|
tc.ExecuteNonQuery(sql);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Update function
|
|
|
|
internal static void Update(TransactionContext tc, FSHead item)
|
|
{
|
|
string sql = SQLParser.MakeSQL(
|
|
"UPDATE FSHead SET Code=%s, Name=%s, Department=%s, IsTaxable=%b, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n,IsLoan=%b,IsPaymenttoVendor=%b,Remarks=%s, type=%n, empid=%n, EMPIDTwo=%n, CompletionWorkingDays=%n, ClearanceRequired=%b, FinalStage=%b, Instruction=%s, DepartmentToApproveBefore=%s, NeedDepartmentApprove=%b" +
|
|
" WHERE FSHeadID=%n", item.Code, item.Name, item.Department, item.IsTaxable, item.ModifiedBy, item.ModifiedDate,
|
|
item.Sequence, item.Status, item.IsLoan, item.IsPaymenttoVendor, item.Remarks, item.Type, item.EmpID != 0 ? item.EmpID : null, item.EmpIDTwo != 0 ? item.EmpIDTwo : null, item.CompletionWorkingDays, item.ClearanceRequired, item.FinalStage, item.Instruction, item.DepartmentToApproveBefore, item.NeedDepartmentApprove, item.ID);
|
|
tc.ExecuteNonQuery(sql);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
internal static IDataReader Get(TransactionContext tc)
|
|
{
|
|
string sql = SQLParser.MakeSQL(@"
|
|
SELECT * FROM FSHead
|
|
ORDER BY
|
|
ClearanceRequired Desc,
|
|
NeedDepartmentApprove,
|
|
CASE
|
|
WHEN DEPARTMENT IN (
|
|
SELECT DISTINCT DepartmentToApproveBefore
|
|
FROM FSHead
|
|
WHERE DepartmentToApproveBefore IS NOT NULL
|
|
) THEN 0
|
|
ELSE 1
|
|
END,
|
|
FinalStage");
|
|
return tc.ExecuteReader(sql);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, EnumStatus status)
|
|
{
|
|
if (EnumStatus.Active == status)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM FSHead where Status=%n order by SequenceNO", status);
|
|
}
|
|
else
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM FSHead order by SequenceNO");
|
|
}
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, int nID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM FSHead Where FSHeadID=%n", nID);
|
|
}
|
|
|
|
internal static IDataReader GetByEmpId(TransactionContext tc,int currentEmpId)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM FSHEAD AS f WHERE f.EMPID=%n OR f.EMPIDTwo=%n", currentEmpId, currentEmpId);
|
|
}
|
|
internal static IDataReader GetByEmpIdName(TransactionContext tc,int currentEmpId, string fsHeadName)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM FSHEAD AS f WHERE f.NAME=%s AND (f.EMPID=%n OR f.EMPIDTwo=%n)", fsHeadName, currentEmpId, currentEmpId);
|
|
}
|
|
internal static DataTable GetDistinctDepartment(TransactionContext tc)
|
|
{
|
|
string sql = SQLParser.MakeSQL(@"SELECT DISTINCT Department FROM FSHEAD Order By Department");
|
|
|
|
return tc.ExecuteDataTable(sql);
|
|
}
|
|
#endregion
|
|
|
|
#region Delete function
|
|
|
|
internal static void Delete(TransactionContext tc, int nID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM FSHead Where FSHeadID=%n", nID);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
} |