136 lines
5.3 KiB
C#
136 lines
5.3 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using Ease.CoreV35.DataAccess;
|
|||
|
using Payroll.BO;
|
|||
|
using System.Data;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
|
|||
|
namespace Payroll.Service.Attendence.DA
|
|||
|
{
|
|||
|
#region ShiftDA
|
|||
|
|
|||
|
internal class ShiftDA
|
|||
|
{
|
|||
|
#region Constructor
|
|||
|
|
|||
|
private ShiftDA() { }
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Insert function
|
|||
|
|
|||
|
internal static void Insert(TransactionContext tc, Shift item)
|
|||
|
{
|
|||
|
string sql = SQLParser.MakeSQL(@"INSERT INTO Shift(
|
|||
|
ShiftID, Code, Name,
|
|||
|
InTime, OutTime,hasAbsentTime,
|
|||
|
AbsentTime, LateCalcualtion,DelayCalcualtion,
|
|||
|
EarlyExitBefore,MinimumOTHour, IsOverlapingDay,
|
|||
|
ShortName, CreatedBy, CreatedDate,
|
|||
|
SequenceNo, Status, ShiftType)
|
|||
|
VALUES(
|
|||
|
%n, %s, %s,
|
|||
|
%D, %D,%b,
|
|||
|
%D,%n, %n,
|
|||
|
%n, %n, %b,
|
|||
|
%s, %n, %D,
|
|||
|
%n, %n, %n)",
|
|||
|
item.ID.Integer, item.Code, item.Name,
|
|||
|
item.InTime, item.OutTime,item.hasAbsentTime,
|
|||
|
DataReader.GetNullValue(item.AbsentTime), item.LateCalcualtion,item.DelayCalcualtion,
|
|||
|
item.EarlyExitBefore, item.MinimumOTHour, item.IsOverlapingDay,
|
|||
|
item.ShortName, item.CreatedBy.Integer, item.CreatedDate,
|
|||
|
item.Sequence, item.Status, item.ShiftType);
|
|||
|
|
|||
|
tc.ExecuteNonQuery(sql);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Update function
|
|||
|
|
|||
|
internal static void Update(TransactionContext tc, Shift item)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery(@"UPDATE Shift SET
|
|||
|
Code=%s, Name=%s, InTime=%D,
|
|||
|
OutTime=%D, hasAbsentTime=%b, AbsentTime=%D,
|
|||
|
LateCalcualtion=%n,DelayCalcualtion=%n,EarlyExitBefore=%n,
|
|||
|
MinimumOTHour=%n, IsOverlapingDay=%b,ShortName=%s,
|
|||
|
ModifiedBy=%n, ModifiedDate=%d,SequenceNo=%n,
|
|||
|
Status=%n, ShiftType=%n WHERE ShiftID=%n",
|
|||
|
item.Code, item.Name, item.InTime,
|
|||
|
item.OutTime,item.hasAbsentTime,DataReader.GetNullValue(item.AbsentTime),
|
|||
|
item.LateCalcualtion,item.DelayCalcualtion, item.EarlyExitBefore,
|
|||
|
item.MinimumOTHour, item.IsOverlapingDay, item.ShortName,
|
|||
|
item.ModifiedBy.Integer, item.ModifiedDate, item.Sequence,
|
|||
|
item.Status, (int)item.ShiftType, item.ID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get Function
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Shift");
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, bool isCounterClock)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Shift Where IsCounterClock=%b ORDER BY Code", isCounterClock);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, ID nID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Shift WHERE ShiftID=%n", nID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, string shiftName)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Shift WHERE ShortName=%s", shiftName);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete function
|
|||
|
|
|||
|
internal static void Delete(TransactionContext tc, ID nID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM [Shift] WHERE ShiftID=%n", nID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IsExist
|
|||
|
internal static bool IsExist(TransactionContext tc, string shiftCode, string shortName)
|
|||
|
{
|
|||
|
bool isExist = false;
|
|||
|
if (shiftCode != string.Empty && shortName != string.Empty)
|
|||
|
{
|
|||
|
object obj = tc.ExecuteScalar("SELECT Count(*) from Shift Where Code=%s AND ShortName=%s", shiftCode, shortName);
|
|||
|
isExist = Convert.ToInt32(obj) > 0 ? true : false;
|
|||
|
}
|
|||
|
else if (shiftCode != string.Empty)
|
|||
|
{
|
|||
|
object obj = tc.ExecuteScalar("SELECT Count(*) from Shift Where Code=%s", shiftCode);
|
|||
|
isExist = Convert.ToInt32(obj) > 0 ? true : false;
|
|||
|
}
|
|||
|
else if (shortName != string.Empty)
|
|||
|
{
|
|||
|
object obj = tc.ExecuteScalar("SELECT Count(*) from Shift Where ShortName=%s", shortName);
|
|||
|
isExist = Convert.ToInt32(obj) > 0 ? true : false;
|
|||
|
}
|
|||
|
return isExist;
|
|||
|
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|