151 lines
6.0 KiB
C#
151 lines
6.0 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using Ease.CoreV35.DataAccess;
|
|||
|
using System.Data;
|
|||
|
using HRM.BO;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
#region WorkPlanGroupDA
|
|||
|
|
|||
|
internal class WorkPlanGroupDA
|
|||
|
{
|
|||
|
#region Constructor
|
|||
|
|
|||
|
private WorkPlanGroupDA()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Insert function
|
|||
|
|
|||
|
internal static void Insert(TransactionContext tc, WorkPlanGroup item, int PayrollTypeID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery(@"INSERT INTO WorkPlanGroup(WorkPlanGroupID, Name, Type,
|
|||
|
CreatedBy, CreatedDate, SequenceNo, Status,PayrollTypeID, ShiftID, SaturdayShiftID,
|
|||
|
SundayShiftID, MondayShiftID, TuesdayShiftID, WednesdayShiftID, ThursdayShiftID,
|
|||
|
FridayShiftID, HolidayOne, HolidayTwo)" +
|
|||
|
" VALUES(%n, %s, %n, %n, %d, %n, %n, %n, %n, %n, %n, %n, %n, %n, %n, %n, %n, %n)",
|
|||
|
item.ID, item.Name, item.Type,
|
|||
|
item.CreatedBy, item.CreatedDate, item.Sequence, item.Status,
|
|||
|
PayrollTypeID, DataReader.GetNullValue(item.InitialShiftID),
|
|||
|
DataReader.GetNullValue(item.SaturdayShiftID), DataReader.GetNullValue(item.SundayShiftID),
|
|||
|
DataReader.GetNullValue(item.MondayShiftID), DataReader.GetNullValue(item.TuesdayShiftID),
|
|||
|
DataReader.GetNullValue(item.WednesdayShiftID), DataReader.GetNullValue(item.ThursdayShiftID),
|
|||
|
DataReader.GetNullValue(item.FridayShiftID), item.HolidayOne, item.HolidayTwo);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Update function
|
|||
|
|
|||
|
internal static void Update(TransactionContext tc, WorkPlanGroup item, int PayrollTypeID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery(@"UPDATE WorkPlanGroup SET Name=%s, Type=%n, ModifiedBy=%n, ModifiedDate=%d,
|
|||
|
SequenceNo=%n, Status=%n, PayrollTypeID=%n, ShiftID=%n, SaturdayShiftID=%n,
|
|||
|
SundayShiftID=%n, MondayShiftID=%n, TuesdayShiftID=%n, WednesdayShiftID=%n,
|
|||
|
ThursdayShiftID=%n, FridayShiftID=%n, HolidayOne=%n, HolidayTwo=%n" +
|
|||
|
" WHERE WorkPlanGroupID=%n", item.Name, item.Type, item.ModifiedBy,
|
|||
|
item.ModifiedDate, item.Sequence, item.Status,
|
|||
|
PayrollTypeID, DataReader.GetNullValue(item.InitialShiftID),
|
|||
|
DataReader.GetNullValue(item.SaturdayShiftID), DataReader.GetNullValue(item.SundayShiftID),
|
|||
|
DataReader.GetNullValue(item.MondayShiftID), DataReader.GetNullValue(item.TuesdayShiftID),
|
|||
|
DataReader.GetNullValue(item.WednesdayShiftID), DataReader.GetNullValue(item.ThursdayShiftID),
|
|||
|
DataReader.GetNullValue(item.FridayShiftID), item.HolidayOne,
|
|||
|
item.HolidayTwo, item.ID);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get Function
|
|||
|
|
|||
|
internal static IDataReader GetUsingPayrollType(TransactionContext tc, int PayrollTypeID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM WorkPlanGroup WHERE PayrollTypeID=%n", PayrollTypeID);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, int nID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM WorkPlanGroup " +
|
|||
|
"WHERE WorkPlanGroupID=%n ", nID);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, EnumStatus status, int payrollTypeID,
|
|||
|
string name, EnumWorkPlanGroup? wPlanGroup)
|
|||
|
{
|
|||
|
|
|||
|
string sqlClause = string.Empty;
|
|||
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("PayrollTypeID = %n", payrollTypeID);
|
|||
|
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
|
|||
|
{
|
|||
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("status = %n", status);
|
|||
|
}
|
|||
|
|
|||
|
if (wPlanGroup!=null)
|
|||
|
{
|
|||
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("type = %n", wPlanGroup);
|
|||
|
}
|
|||
|
|
|||
|
if (!string.IsNullOrWhiteSpace(name))
|
|||
|
{
|
|||
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("Name LIKE %s", ("%" + name + "%"));
|
|||
|
}
|
|||
|
|
|||
|
return tc.ExecuteReader("SELECT * FROM WorkPlanGroup %q order by type, Name", sqlClause);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete function
|
|||
|
|
|||
|
internal static void Delete(TransactionContext tc, int nID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM WorkPlanGroup WHERE WorkPlanGroupID=%n", nID);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
internal static IDataReader GetByName(TransactionContext tc, string name, int payrollTypeID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader(
|
|||
|
"SELECT * FROM WorkPlanGroup where Name LIKE %s and PayrollTypeID=%n order by SequenceNO",
|
|||
|
('%' + name + '%'), payrollTypeID);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader GetAll(TransactionContext tc)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM WorkPlanGroup");
|
|||
|
}
|
|||
|
internal static IDataReader GetByPayrollTypeId(TransactionContext tc, int payrollTypeId)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM WorkPlanGroup WHERE PayrollTypeID=%n order by SequenceNO", payrollTypeId);
|
|||
|
|
|||
|
}
|
|||
|
internal static IDataReader GetByEmpId(TransactionContext tc, int empId)
|
|||
|
{
|
|||
|
string query = SQLParser.MakeSQL(@"
|
|||
|
SELECT wpg.* FROM WorkPlanGroup wpg
|
|||
|
JOIN EMPLOYEEWORKPLANSETUP empwpg ON wpg.WorkPlanGroupID = empwpg.WORKPLANGROUPID
|
|||
|
WHERE empwpg.EMPLOYEEID = %n", empId);
|
|||
|
|
|||
|
return tc.ExecuteReader(query);
|
|||
|
}
|
|||
|
internal static IDataReader Get(TransactionContext tc, Employee oEmployee)
|
|||
|
{
|
|||
|
string query = SQLParser.MakeSQL(@"
|
|||
|
SELECT * FROM WorkPlanGroup wpg
|
|||
|
LEFT JOIN EmployeeWorkPlanSetup ewps ON wpg.WorkPlanGroupID = ewps.WORKPLANGROUPID
|
|||
|
WHERE ewps.EmployeeID = %n
|
|||
|
", oEmployee.ID);
|
|||
|
|
|||
|
return tc.ExecuteReader(query);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|