210 lines
9.6 KiB
C#
210 lines
9.6 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
|
|
{
|
|
#region EmployeeUnAuthorizeLeaveDA
|
|
|
|
internal class EmployeeUnAuthorizeLeaveDA
|
|
{
|
|
#region Constructor
|
|
|
|
private EmployeeUnAuthorizeLeaveDA() { }
|
|
|
|
#endregion
|
|
|
|
#region Insert function
|
|
|
|
internal static void Insert(TransactionContext tc, EmployeeUnAuthorizeLeave item)
|
|
{
|
|
tc.ExecuteNonQuery("INSERT INTO MONTHLYLEAVEENTRY(EmpLeaveID, EMPLOYEEID, LEAVEID, MONTHDATE, LEAVEDAY, CreatedBy, LEAVEMONTH, FROMDATE, TODATE, CreationDate, Type, ReferenceID, ParamID,RemainingDays)" +
|
|
" VALUES(%n, %n, %n, %d, %n, %n, %d, %d, %d, %d, %n, %n, %n,%n)", item.ID.Integer, item.EmployeeID.Integer, item.UnAuthorizeleaveID.Integer, item.MonthDate, item.LeaveDays , item.CreatedBy.Integer, item.LeaveMonth
|
|
, item.FromDate, item.ToDate, item.CreatedDate, (int)item.Type, DataReader.GetNullValue(item.ReferenceID, IDType.Integer), item.RemainingDays, item.ParamID.Integer);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Update function
|
|
|
|
internal static void Update(TransactionContext tc, EmployeeUnAuthorizeLeave item)
|
|
{
|
|
tc.ExecuteNonQuery("UPDATE MONTHLYLEAVEENTRY SET EmpLeaveID=%n, LEAVEID=%n, MONTHDATE=%d, LEAVEDAY=%n, LEAVEMONTH=%d, FROMDATE=%d, TODATE=%d, ModifiedDate=%d, Type=%n, ReferenceID=%n, ModifiedBy=%n, ParamID = %n,RemainingDays=%n" +
|
|
" WHERE EmpLeaveID=%n", item.EmployeeID.Integer, item.UnAuthorizeleaveID.Integer, item.MonthDate, item.LeaveDays, item.LeaveMonth, item.FromDate, item.ToDate, item.ModifiedDate, item.Type, item.ReferenceID.Integer, item.ModifiedBy.Integer, item.ParamID.Integer, item.RemainingDays, item.ID.Integer);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
internal static IDataReader Get(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM MONTHLYLEAVEENTRY");
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, ID nID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM MONTHLYLEAVEENTRY WHERE EmployeeUnAuthorizeLeaveID=%n", nID.Integer);
|
|
}
|
|
|
|
internal static IDataReader GetByEmployee(TransactionContext tc, ID nID,EnumLeaveEntryType type)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM MONTHLYLEAVEENTRY WHERE EmployeeID=%n AND MONTHDATE>%d AND Type=%n", nID.Integer, SystemInformation.CurrentSysInfo.LastPayProcessDate, type);
|
|
}
|
|
|
|
internal static IDataReader GetDeductedLeave(TransactionContext tc, ID nEmpID, ID nLeaveID, EnumLeaveEntryType type, DateTime nextPayProcessDate)
|
|
{
|
|
DateTime dDate = nextPayProcessDate;
|
|
return tc.ExecuteReader("SELECT * FROM MONTHLYLEAVEENTRY ML WHERE EmployeeID=%n AND MONTHDATE<%d AND Type=%n AND LeaveID=%n" +
|
|
"AND EmpLeaveID NOT IN ( " +
|
|
"Select MLP.ReferenceID From MONTHLYLEAVEENTRY MLP " +
|
|
"WHERE MLP.EmployeeID=%n AND MLP.ReferenceID > 0 AND MLP.ReferenceID = ML.EmpLeaveID AND MLP.LeaveID=%n " +
|
|
"Group By MLP.ReferenceID Having Sum(MLP.LeaveDay) >= ML.LeaveDay) ", nEmpID.Integer, dDate, type, nLeaveID.Integer, nEmpID.Integer , nLeaveID.Integer);
|
|
|
|
|
|
}
|
|
|
|
internal static IDataReader GetByEmployee(TransactionContext tc, ID nID,DateTime dMonth,EnumLeaveEntryType type)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM MONTHLYLEAVEENTRY WHERE EmployeeID=%n AND MONTHDATE=%d and Type=%n", nID.Integer,dMonth,type);
|
|
}
|
|
|
|
internal static int GetAdjustedDays(TransactionContext tc, ID nID)
|
|
{
|
|
object value= tc.ExecuteScalar("SELECT Sum(LeaveDay) FROM MONTHLYLEAVEENTRY Where ReferenceID = %n AND Type= %n",nID.Integer,EnumLeaveEntryType.PaidLeave);
|
|
if (value == DBNull.Value)
|
|
return 0;
|
|
else return Convert.ToInt32(value);
|
|
}
|
|
|
|
internal static int GetAdjustedDays(TransactionContext tc, ID nID, DateTime month)
|
|
{
|
|
object value = tc.ExecuteScalar("SELECT Sum(LeaveDay) FROM MONTHLYLEAVEENTRY Where ReferenceID = %n AND Type= %n AND MonthDate=%d", nID.Integer, EnumLeaveEntryType.PaidLeave, month);
|
|
if (value == DBNull.Value)
|
|
return 0;
|
|
else return Convert.ToInt32(value);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, EnumLeaveEntryType type, DateTime month)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM MONTHLYLEAVEENTRY WHERE MONTHDATE=%d AND Type=%n Order By EmployeeID,MONTHDATE", month, type);
|
|
}
|
|
internal static IDataReader Get(TransactionContext tc, DateTime fromDate, DateTime todate, EnumLeaveEntryType type)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM MONTHLYLEAVEENTRY WHERE MONTHDATE Between %d AND %d "
|
|
+" AND Type=%n Order By EmployeeID, MONTHDATE",
|
|
fromDate, todate, type);
|
|
}
|
|
|
|
internal static IDataReader GetByEmployee(TransactionContext tc, ID nEmpID, ID nLeaveID, EnumLeaveEntryType type)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM MONTHLYLEAVEENTRY WHERE EmployeeID=%n AND LeaveID=%n AND MONTHDATE>%d AND Type=%n", nEmpID.Integer, nLeaveID.Integer, SystemInformation.CurrentSysInfo.LastPayProcessDate, type);
|
|
|
|
}
|
|
|
|
internal static IDataReader GetLeaveTypeByEmployee(TransactionContext tc, ID nID, DateTime dMonth, EnumLeaveEntryType type)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM MONTHLYLEAVEENTRY WHERE EmployeeID=%n AND MONTHDATE=%d and Type=%n", nID.Integer, dMonth, type);
|
|
}
|
|
internal static DataSet GetUnAuthorizeLeave(TransactionContext tc, DateTime date)
|
|
{
|
|
DataSet unAuthoLeave = new DataSet();
|
|
try
|
|
{
|
|
string sql = SQLParser.MakeSQL("select EmployeeID,COUNT(EmployeeID) as TotalAbsent from DailyAttnProcess "
|
|
+ "where AttnDate between %d AND %d AND AttnType=%n group by EmployeeID order by EmployeeID ", GlobalFunctions.FirstDateOfMonth(date), GlobalFunctions.LastDateOfMonth(date), EnumAttendanceType.Absent);
|
|
|
|
unAuthoLeave = tc.ExecuteDataSet(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return unAuthoLeave;
|
|
}
|
|
internal static DataSet GetCurrentUnAuthorizeLeave(TransactionContext tc, DateTime date)
|
|
{
|
|
DataSet unAuthoLeave = new DataSet();
|
|
try
|
|
{
|
|
string sql = SQLParser.MakeSQL("select EmployeeID,sum(LEAVEDAY) as Total from MONTHLYLEAVEENTRY "
|
|
+ "where LeaveMonth between %d AND %d group by EmployeeID order by EmployeeID ", GlobalFunctions.FirstDateOfMonth(date), GlobalFunctions.LastDateOfMonth(date));
|
|
|
|
unAuthoLeave = tc.ExecuteDataSet(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return unAuthoLeave;
|
|
}
|
|
internal static DataSet GetPreviousUnAuthorizeLeave(TransactionContext tc, DateTime date)
|
|
{
|
|
DataSet unAuthoLeave = new DataSet();
|
|
try
|
|
{
|
|
string sql = SQLParser.MakeSQL("select EmployeeID,sum(LEAVEDAY) as Total from MONTHLYLEAVEENTRY "
|
|
+ "where MONTHDATE between %d AND %d group by EmployeeID order by EmployeeID ", GlobalFunctions.FirstDateOfMonth(date), GlobalFunctions.LastDateOfMonth(date));
|
|
|
|
unAuthoLeave = tc.ExecuteDataSet(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return unAuthoLeave;
|
|
}
|
|
internal static DataSet GetUnPaidLeave(TransactionContext tc, int nYear)
|
|
{
|
|
DataSet unAuthoLeave = new DataSet();
|
|
try
|
|
{
|
|
string sql = SQLParser.MakeSQL("select * from UnPaidLeave where UnPaidLeaveYear=%n",nYear);
|
|
|
|
unAuthoLeave = tc.ExecuteDataSet(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return unAuthoLeave;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Delete function
|
|
|
|
internal static void Delete(TransactionContext tc, ID nID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM [MONTHLYLEAVEENTRY] WHERE EmpLeaveID=%n", nID.Integer);
|
|
}
|
|
|
|
internal static void Delete(TransactionContext tc, DateTime dateTime, ID nLeaveID, ID nEmpID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM [MONTHLYLEAVEENTRY] WHERE MONTHDATE=%d AND LEAVEID=%n AND EMPLOYEEID=%n", dateTime,nLeaveID.Integer,nEmpID.Integer);
|
|
}
|
|
|
|
internal static void Delete(TransactionContext tc, DateTime month, ID nEmpID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM [MONTHLYLEAVEENTRY] WHERE MONTHDATE=%d AND EMPLOYEEID=%n", month, nEmpID.Integer);
|
|
}
|
|
|
|
internal static void Delete(TransactionContext tc,DateTime dateTime)
|
|
{
|
|
string sql = SQLParser.MakeSQL("DELETE FROM [MONTHLYLEAVEENTRY] WHERE MONTHDATE between %d AND %d ",GlobalFunctions.FirstDateOfMonth(dateTime), GlobalFunctions.LastDateOfMonth(dateTime));
|
|
tc.ExecuteNonQuery(sql);
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
#endregion
|
|
}
|