3692 lines
128 KiB
C#
3692 lines
128 KiB
C#
using System;
|
|
using System.Data;
|
|
using Ease.Core;
|
|
using Ease.Core.Model;
|
|
using Ease.Core.DataAccess;
|
|
using System.Collections.Generic;
|
|
using Ease.Core.Utility;
|
|
using HRM.BO;
|
|
using HRM.DA;
|
|
using Microsoft.Data.SqlClient;
|
|
using System.Linq;
|
|
using static iTextSharp.text.pdf.AcroFields;
|
|
using System.Diagnostics;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
#region SalaryMonthly Service
|
|
|
|
public class SalaryMonthlyService : ServiceTemplate, ISalaryMonthlyService
|
|
{
|
|
#region Private functions and declaration
|
|
|
|
private int _crgSerialId;
|
|
int nSalID = 0;
|
|
int nDetailID = 0;
|
|
|
|
#endregion
|
|
|
|
public SalaryMonthlyService()
|
|
{
|
|
_crgSerialId = 0;
|
|
}
|
|
|
|
private void MapObject(SalaryMonthly oSalaryMonthly, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oSalaryMonthly, (oReader.GetInt32("SalaryMonthlyID").Value));
|
|
oSalaryMonthly.SalaryMonth = oReader.GetDateTime("SalaryMonth").Value;
|
|
oSalaryMonthly.EuroRate = oReader.GetDouble("EuroRate", 0);
|
|
oSalaryMonthly.EmployeeID = oReader.GetInt32("EmployeeID").Value;
|
|
oSalaryMonthly.CategoryID = oReader.GetInt32("CategoryID").Value;
|
|
oSalaryMonthly.DepartmentID = oReader.GetInt32("DepartmentID").Value;
|
|
oSalaryMonthly.DesignationID = oReader.GetInt32("DesignationID").Value;
|
|
oSalaryMonthly.LocationID = oReader.GetInt32("LocationID").Value;
|
|
oSalaryMonthly.GradeID = oReader.GetInt32("GradeID").Value;
|
|
oSalaryMonthly.IsFinalized = oReader.GetBoolean("IsFinalized").Value;
|
|
oSalaryMonthly.PaymentDate = oReader.GetDateTime("PaymentDate");
|
|
oSalaryMonthly.PrevMonthBasic = oReader.GetDouble("PrevMonthBasic").Value;
|
|
oSalaryMonthly.ThisMonthBasic = oReader.GetDouble("ThisMonthBasic").Value;
|
|
oSalaryMonthly.ThisMonthGross = oReader.GetDouble("ThisMonthGross").Value;
|
|
oSalaryMonthly.IsConfirmed = oReader.GetBoolean("IsConfirmed").Value;
|
|
oSalaryMonthly.IsEligibleOT = oReader.GetBoolean("IsEligibleOT").Value;
|
|
oSalaryMonthly.ReligionID = oReader.GetInt32("ReligionID").Value;
|
|
oSalaryMonthly.PayrollTypeID = oReader.GetInt32("PayrollTypeID").Value;
|
|
oSalaryMonthly.OutPayBranchID = oReader.GetInt32("OutPayBranchID");
|
|
oSalaryMonthly.OutPayAccountNo = oReader.GetString("OutPayAccountNo");
|
|
oSalaryMonthly.Remarks = oReader.GetString("Remarks");
|
|
oSalaryMonthly.AccountNo = oReader.GetString("AccountNo");
|
|
oSalaryMonthly.BranchID = oReader.GetInt32("BranchID");
|
|
oSalaryMonthly.DesignationText = oReader.GetString("DESIGNATION");
|
|
oSalaryMonthly.SalaryProcessID = oReader.GetInt32("SalaryProcessID").Value;
|
|
oSalaryMonthly.PFMembershipType = (EnumPFMembershipType)oReader.GetInt32("PFMEMBERTYPE").Value;
|
|
oSalaryMonthly.salaryWithHeld = oReader.GetBoolean("salaryWithHeld", true, false);
|
|
this.SetObjectState(oSalaryMonthly, Ease.Core.ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
SalaryMonthly oSalaryMonthly = new SalaryMonthly();
|
|
MapObject(oSalaryMonthly, oReader);
|
|
return oSalaryMonthly as T;
|
|
}
|
|
|
|
protected SalaryMonthly CreateObject(DataReader oReader)
|
|
{
|
|
SalaryMonthly oSalaryMonthly = new SalaryMonthly();
|
|
MapObject(oSalaryMonthly, oReader);
|
|
return oSalaryMonthly;
|
|
}
|
|
|
|
private void MapEmpCostCenterObject(SalaryEmpCostCenter oSalaryEmpCostCenter, DataReader oReader)
|
|
{
|
|
_crgSerialId = _crgSerialId + 1;
|
|
base.SetObjectID(oSalaryEmpCostCenter, (_crgSerialId));
|
|
oSalaryEmpCostCenter.SalaryMontlyID = oReader.GetInt32("SalaryMonthlyID").Value;
|
|
oSalaryEmpCostCenter.CostCenterID = oReader.GetInt32("CostCenterID").Value;
|
|
oSalaryEmpCostCenter.Percentage = oReader.GetDouble("Percentage").Value;
|
|
oSalaryEmpCostCenter.EmployeeID = oReader.GetInt32("EmployeeID").Value;
|
|
this.SetObjectState(oSalaryEmpCostCenter, Ease.Core.ObjectState.Saved);
|
|
}
|
|
|
|
protected List<SalaryEmpCostCenter> CreateEmpCostCenterObject(DataReader oReader)
|
|
{
|
|
List<SalaryEmpCostCenter> oSalaryEmpCostCenters = new List<SalaryEmpCostCenter>();
|
|
while (oReader.Read())
|
|
{
|
|
SalaryEmpCostCenter oSalaryEmpCostCenter = new SalaryEmpCostCenter();
|
|
MapEmpCostCenterObject(oSalaryEmpCostCenter, oReader);
|
|
oSalaryEmpCostCenters.Add(oSalaryEmpCostCenter);
|
|
}
|
|
|
|
return oSalaryEmpCostCenters;
|
|
}
|
|
|
|
private void MapSalaryMonthlyDetailObject(SalaryMonthlyDetail oSalaryMonthlyDetail, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oSalaryMonthlyDetail, (oReader.GetInt32("DetailID").Value));
|
|
oSalaryMonthlyDetail.SalaryMonthlyID = oReader.GetInt32("SalaryMonthlyID").Value;
|
|
oSalaryMonthlyDetail.ItemID = oReader.GetInt32("ItemID").Value;
|
|
oSalaryMonthlyDetail.SupportID = oReader.GetInt32("SupportID");
|
|
oSalaryMonthlyDetail.Description = oReader.GetString("Description");
|
|
oSalaryMonthlyDetail.Position = oReader.GetInt32("Position").Value;
|
|
oSalaryMonthlyDetail.CalculatedAmount = oReader.GetDouble("CalculatedAmount").Value;
|
|
oSalaryMonthlyDetail.ChangedAmount = oReader.GetDouble("ChangedAmount").Value;
|
|
oSalaryMonthlyDetail.ItemCode = (EnumSalaryItemCode)oReader.GetInt32("ItemCode").Value;
|
|
oSalaryMonthlyDetail.itemGroupCode = (EnumSalaryGroup)oReader.GetInt32("ITEMGROUP");
|
|
this.SetObjectState(oSalaryMonthlyDetail, Ease.Core.ObjectState.Saved);
|
|
}
|
|
|
|
protected List<SalaryMonthlyDetail> CreateSalaryMonthlyDetailObject(DataReader oReader)
|
|
{
|
|
List<SalaryMonthlyDetail> oSalaryMonthlyDetails = new List<SalaryMonthlyDetail>();
|
|
while (oReader.Read())
|
|
{
|
|
SalaryMonthlyDetail oSalaryMonthlyDetail = new SalaryMonthlyDetail();
|
|
MapSalaryMonthlyDetailObject(oSalaryMonthlyDetail, oReader);
|
|
oSalaryMonthlyDetails.Add(oSalaryMonthlyDetail);
|
|
}
|
|
|
|
return oSalaryMonthlyDetails;
|
|
}
|
|
|
|
#region Service implementation
|
|
|
|
public SalaryMonthly Get(int id)
|
|
{
|
|
SalaryMonthly oSalaryMonthly = new SalaryMonthly();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(SalaryMonthlyDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oSalaryMonthly = this.CreateObject<SalaryMonthly>(oreader);
|
|
}
|
|
|
|
oreader.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthly;
|
|
}
|
|
//public SalaryMonthly GetbyId(int id)
|
|
//{
|
|
// SalaryMonthly oSalaryMonthly = new SalaryMonthly();
|
|
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin();
|
|
// DataReader oreader = new DataReader(SalaryMonthlyDA.GetbyId(tc, id));
|
|
// if (oreader.Read())
|
|
// {
|
|
// oSalaryMonthly = this.CreateObject<SalaryMonthly>(oreader);
|
|
// }
|
|
|
|
// oreader.Close();
|
|
// tc.End();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
// throw new ServiceException(e.Message, e);
|
|
|
|
// #endregion
|
|
// }
|
|
|
|
// return oSalaryMonthly;
|
|
//}
|
|
#region Try Get
|
|
public SalaryMonthly GetbyId(int id)
|
|
{
|
|
SalaryMonthly oSalaryMonthly = new SalaryMonthly();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(SalaryMonthlyDA.GetbyId(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oSalaryMonthly = this.CreateObject<SalaryMonthly>(oreader);
|
|
}
|
|
if (oSalaryMonthly.ID > 0)
|
|
{
|
|
List<SalaryMonthlyDetail> items = GetSalaryDetail(oSalaryMonthly.ID);
|
|
foreach (var item in items)
|
|
oSalaryMonthly.Details.Add(item);
|
|
}
|
|
|
|
oreader.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthly;
|
|
}
|
|
|
|
#endregion tryGet End
|
|
|
|
public DateTime? GetLastPaidSalaryMonth(int nEmpID)
|
|
{
|
|
DateTime? dt;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
dt = SalaryMonthlyDA.GetLastPaidSalaryMonth(tc, nEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return dt;
|
|
}
|
|
|
|
public SalaryMonthly Get(int nEmpID, DateTime dateTime)
|
|
{
|
|
SalaryMonthly oSalaryMonthly = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(SalaryMonthlyDA.Get(tc, nEmpID, dateTime));
|
|
if (oreader.Read())
|
|
{
|
|
oSalaryMonthly = this.CreateObject<SalaryMonthly>(oreader);
|
|
}
|
|
|
|
oreader.Close();
|
|
|
|
if (oSalaryMonthly != null)
|
|
{
|
|
oreader = new DataReader(SalaryMonthlyDA.GetSalaryDetail(tc, oSalaryMonthly.ID));
|
|
oSalaryMonthly.Details = this.CreateSalaryMonthlyDetailObject(oreader);
|
|
oreader.Close();
|
|
}
|
|
if (oSalaryMonthly != null)
|
|
{
|
|
oreader = new DataReader(SalaryMonthlyDA.GetEmpCostCenter(tc, oSalaryMonthly.ID));
|
|
oSalaryMonthly.CostCentersInvolments = this.CreateEmpCostCenterObject(oreader);
|
|
oreader.Close();
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthly;
|
|
}
|
|
|
|
public DataSet GetSumOnRange(string sEmpID, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,
|
|
EnumSalaryItemCode itemCode, int itemId, int payrollTypeID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetSumOnRange(tc, sEmpID, fromDate, toDate, groupCode, itemCode,
|
|
itemId, payrollTypeID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public double GetSumOnRange(int employeeId,
|
|
DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,
|
|
EnumSalaryItemCode itemCode, int itemId, int payrollTypeID)
|
|
{
|
|
double amount = 0;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
amount = SalaryMonthlyDA.GetSumOnRange(tc, employeeId,
|
|
fromDate, toDate, groupCode, itemCode, itemId, payrollTypeID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return amount;
|
|
}
|
|
|
|
public double GetSumOnRangeOnRound(int employeeId,
|
|
DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,
|
|
EnumSalaryItemCode itemCode, int itemId, int payrollTypeID)
|
|
{
|
|
double amount = 0;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
amount = SalaryMonthlyDA.GetSumOnRangeOnRound(tc, employeeId,
|
|
fromDate, toDate, groupCode, itemCode, itemId, payrollTypeID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return amount;
|
|
}
|
|
|
|
public double GetAmountOnDateDiff(int employeeId,
|
|
DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,
|
|
EnumSalaryItemCode itemCode, int itemId, int payrollTypeID)
|
|
{
|
|
double amount = 0;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
amount = SalaryMonthlyDA.GetAmountOnDateDiff(tc, employeeId,
|
|
fromDate, toDate, groupCode, itemCode, itemId, payrollTypeID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return amount;
|
|
}
|
|
|
|
|
|
public double GetThisMonthBasicOnDateDiff(int employeeId,
|
|
DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,
|
|
EnumSalaryItemCode itemCode, int itemId, int payrollTypeID)
|
|
{
|
|
double amount = 0;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
amount = SalaryMonthlyDA.GetThisMonthBasicOnDateDiff(tc, employeeId,
|
|
fromDate, toDate, groupCode, itemCode, itemId, payrollTypeID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return amount;
|
|
}
|
|
|
|
|
|
public double GetAmountOnDateDiffForAll(int employeeId,
|
|
DateTime fromDate, DateTime toDate, int payrollTypeID)
|
|
{
|
|
double amount = 0;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
amount = SalaryMonthlyDA.GetAmountOnDateDiffForAll(tc, employeeId,
|
|
fromDate, toDate, payrollTypeID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return amount;
|
|
}
|
|
|
|
public double GetPrvTaxAmount(EnumIncomeTaxDataFrom dataFrom, int employeeId,
|
|
DateTime fromDate, DateTime toDate)
|
|
{
|
|
double amount = 0;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
amount = SalaryMonthlyDA.GetPrvTaxAmount(tc, dataFrom, employeeId,
|
|
fromDate, toDate);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return amount;
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
public double GetAmountOnDateDiffForOverTime(int employeeId,
|
|
DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,
|
|
EnumSalaryItemCode itemCode, int itemId, int payrollTypeID)
|
|
{
|
|
double amount = 0;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
amount = SalaryMonthlyDA.GetAmountOnDateDiffForOverTime(tc, employeeId,
|
|
fromDate, toDate, groupCode, itemCode, itemId, payrollTypeID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return amount;
|
|
}
|
|
|
|
public double GetUnAuthorizeAmountOnDateRange(int employeeId, DateTime fromDate, DateTime toDate,
|
|
EnumSalaryGroup groupCode)
|
|
{
|
|
double amount = 0;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
amount = SalaryMonthlyDA.GetUnAuthorizeAmountOnDateRange(tc, employeeId, fromDate, toDate, groupCode);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return amount;
|
|
}
|
|
|
|
// public double GetGrossOnRange(int employeeId,
|
|
//DateTime fromDate, DateTime toDate, EnumSalaryItemCode itemCode, int itemId)
|
|
// {
|
|
// double amount = 0;
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin();
|
|
// amount = SalaryMonthlyDA.GetSumOnRange(tc, employeeId,
|
|
// fromDate, toDate, groupCode, itemCode, itemId);
|
|
// tc.End();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
// throw new ServiceException(e.Message, e);
|
|
// #endregion
|
|
// }
|
|
// return amount;
|
|
// }
|
|
|
|
public DataSet GetEmpPaySlipGrossForOthersNew(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipGrossForOthersNew(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
public DataSet GetEmpPaySlipGrossForOthers(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipGrossForOthers(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpPaySlipDeductForOthers(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipDeductForOthers(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpPaySlipDeductForCitiOthers(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipDeductForCitiOthers(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetPFForLetterRequest(int sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetPFForLetterRequest(tc,sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpPaySlipDeductForLR(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipDeductForLR(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpPaySlipIncomeTaxAmountForOthers(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipIncomeTaxAmountForOthers(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpSalaryProcessedData(DateTime dateTime, string employeeno)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalaryProcessedData(tc, dateTime, employeeno);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpPaySlipGross(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipGross(tc, dateTime, sEmpID);
|
|
//DataReader oreader = new DataReader(SalaryMonthlyDA.GetEmpPaySlip(tc,dateTime));
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpOverAllSummaryGross(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpOverAllSummaryGross(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpOverAllSummaryDeduct(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpOverAllSummaryDeduct(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpSalarySheet(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheet(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpSalarySheetWithoutCostCenterOT(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheetWithoutCostCenterOT(tc, dateTime, sEmpID);
|
|
//oSalaryMonthlys = SalaryMonthlyDA.GetSGSSalarySheet(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
public DataSet GetEmpSalarySheetWithoutCostcenter(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheetWithoutCostcenter(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpSalarySheetForNonManagement(DateTime sdMonth, string empId)
|
|
{
|
|
DataSet SalarySheetForNonMngt = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
SalarySheetForNonMngt = SalaryMonthlyDA.GetEmpSalarySheetForNonManagement(tc, sdMonth, empId);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new ServiceException(ex.Message);
|
|
}
|
|
|
|
return SalarySheetForNonMngt;
|
|
}
|
|
|
|
public DataSet GetEmpSalarySheetForManagement(DateTime sdMonth, string empId)
|
|
{
|
|
DataSet oSalarymonthformngt = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalarymonthformngt = SalaryMonthlyDA.GetEmpSalarySheetForManagement(tc, sdMonth, empId);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new ServiceException(ex.Message);
|
|
}
|
|
|
|
return oSalarymonthformngt;
|
|
}
|
|
|
|
public DataSet GetCasualSalarySheet(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetCasualSalarySheet(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpSalarySheetForIDLC(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheetForIDLC(tc, dateTime, sEmpID);
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpSalarySheetByYear(DateTime dSalaryMonth, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheetByYear(tc, dSalaryMonth, sEmpID);
|
|
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpStartDateAndEndDate(DateTime fstdate, DateTime endDate, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpStartDateAndEndDate(tc, fstdate, endDate, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetOnRange(string sEmpID, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,
|
|
EnumSalaryItemCode itemCode)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetOnRange(tc, sEmpID, fromDate, toDate, groupCode, itemCode);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetOnRange(string sEmpID, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,
|
|
EnumSalaryItemCode itemCode, int itemId)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetOnRange(tc, sEmpID, fromDate, toDate, groupCode, itemCode, itemId);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataTable GetNetAmount(DateTime salaryMonth, int payrollTypeid )
|
|
{
|
|
DataTable oSalaryMonthlys = new DataTable();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys =
|
|
SalaryMonthlyDA.GetNetAmount(tc, salaryMonth,payrollTypeid);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
public DataTable GetWithheldData(DateTime salaryMonth, int payrollTypeID)
|
|
{
|
|
DataTable oSalaryMonthlys = new DataTable();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys =
|
|
SalaryMonthlyDA.GetWithheldData(tc, salaryMonth, payrollTypeID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
public DataSet GetGrossDeduction(int empID, DateTime salaryMonth)
|
|
{
|
|
DataSet oSalarySummary = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalarySummary = SalaryMonthlyDA.GetGrossDeduction(tc, empID, salaryMonth);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
return oSalarySummary;
|
|
}
|
|
public void Updatepayment(DateTime paymentDate, int salarymonthlyid, string chequeNo, string remarks, int userID)
|
|
{
|
|
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
SalaryMonthlyDA.Updatepayment(tc, paymentDate, salarymonthlyid, chequeNo, remarks, userID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public DataSet GetOTHourByReverseCal(string sEmpID, DateTime fromDate, DateTime toDate,
|
|
EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int itemId)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys =
|
|
SalaryMonthlyDA.GetOTHourByReverseCal(tc, sEmpID, fromDate, toDate, groupCode, itemCode, itemId);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpPrevDataForSRecon(DateTime dateTime)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpPrevDataForSRecon(tc, dateTime);
|
|
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpSalaryReconForNovertis(DateTime dateTime)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalaryReconForNovertis(tc, dateTime);
|
|
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetLTAData(int EmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetLTAData(tc, EmpID);
|
|
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpSalarySheetForNovertis(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheetForNovertis(tc, dateTime, sEmpID);
|
|
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public void IsSalaryProcessedAndFinalized(DateTime SalaryMonth, ref bool isprocessed, ref bool isfinalized)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
isfinalized = false;
|
|
isprocessed = SalaryMonthlyDA.IsSalaryProcessed(tc, SalaryMonth);
|
|
if (isprocessed)
|
|
{
|
|
isfinalized = SalaryMonthlyDA.IsSalaryFinalized(tc, SalaryMonth);
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
|
|
public List<salaryHistory> GetSalaryHistories(int payrolltypeid, string emps, DateTime fromMonth, DateTime toMonth)
|
|
{
|
|
List<salaryHistory> histories = new List<salaryHistory>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(SalaryMonthlyDA.GetHistory(tc, payrolltypeid,
|
|
emps, fromMonth, toMonth));
|
|
while (oreader.Read())
|
|
{
|
|
salaryHistory item = new salaryHistory();
|
|
|
|
item.salaryMonth = oreader.GetDateTime("SalaryMonth").Value;
|
|
item.empid = oreader.GetInt32("EmployeeID").Value;
|
|
item.itemID = oreader.GetInt32("ITEMID").Value;
|
|
item.itemCode = (EnumSalaryItemCode) oreader.GetInt32("ITEMCODE").Value;
|
|
item.groupCode = (EnumSalaryGroup) oreader.GetInt32("ITEMGROUP").Value;
|
|
item.referenceID = oreader.GetInt32("SUPPORTID");
|
|
item.amount = oreader.GetDouble("Amount").Value;
|
|
histories.Add(item);
|
|
}
|
|
|
|
oreader.Close();
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return histories;
|
|
}
|
|
public DataSet GetEmpSalaryReconForCurrMonth(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalaryReconForCurrMonth(tc, dateTime, sEmpID);
|
|
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpSalarySheetByCC(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheetByCC(tc, dateTime, sEmpID);
|
|
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetSGSSalarySheet(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetSGSSalarySheet(tc, dateTime, sEmpID);
|
|
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetExtendedSalarySheet(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetExtendedSalarySheet(tc, dateTime, sEmpID);
|
|
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpPaySlipDeduct(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipDeduct(tc, dateTime, sEmpID);
|
|
//DataReader oreader = new DataReader(SalaryMonthlyDA.GetEmpPaySlip(tc,dateTime));
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetPrvMonthNetSalary(DateTime dateTime, string sEmpID, bool IsNetSum)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetPrvMonthNetSalary(tc, dateTime, sEmpID, IsNetSum);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpPaySlipIncomeTaxAmount(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpPaySlipIncomeTaxAmount(tc, dateTime, sEmpID);
|
|
//DataReader oreader = new DataReader(SalaryMonthlyDA.GetEmpPaySlip(tc,dateTime));
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetEmpSSSummaryByDept(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
/*TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
List<Term> allTerms = Term.Get(((EnumStatus)).Active);
|
|
string str = String.Empty;
|
|
str += "(";
|
|
int count = 0;
|
|
foreach (Term item in allTerms)
|
|
{
|
|
count++;
|
|
if (count != allTerms.Count) str += item.ID.ToString() + ",";
|
|
else str += item.ID.ToString();
|
|
}
|
|
str += ")";
|
|
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpSSSummaryByDeptNew(tc, str, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}*/
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
/*
|
|
public List<SalaryMonthly> Get(int payrollTypeID)
|
|
{
|
|
List<SalaryMonthly> salaryMonthlys = new List<SalaryMonthly>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(SalaryMonthlyDA.Get(tc, payrollTypeID));
|
|
salaryMonthlys = this.CreateObjects<SalaryMonthly>(dr);
|
|
dr.Close();
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return salaryMonthlys;
|
|
}
|
|
*/
|
|
|
|
public List<SalaryEmpCostCenter> GetCostCenter(DateTime salaryMonth)
|
|
{
|
|
List<SalaryEmpCostCenter> empCostcenters;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(SalaryMonthlyDA.GetCostCenter(tc, salaryMonth));
|
|
empCostcenters = this.CreateEmpCostCenterObject(dr);
|
|
dr.Close();
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
|
|
return empCostcenters;
|
|
}
|
|
|
|
public List<SalaryMonthly> Get(DateTime salaryMonth, int payrollTypeID)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<SalaryMonthly> salaryMonthlys = null;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(SalaryMonthlyDA.Get(tc, salaryMonth, payrollTypeID));
|
|
salaryMonthlys = this.CreateObjects<SalaryMonthly>(dr);
|
|
dr.Close();
|
|
|
|
dr = new DataReader(SalaryMonthlyDA.GetDetail(tc, salaryMonth));
|
|
|
|
List<SalaryMonthlyDetail> details = this.CreateSalaryMonthlyDetailObject(dr);
|
|
dr.Close();
|
|
int check = 0;
|
|
foreach (SalaryMonthly salary in salaryMonthlys)
|
|
{
|
|
check = 0;
|
|
foreach (SalaryMonthlyDetail detail in details)
|
|
{
|
|
if (salary.ID == detail.SalaryMonthlyID)
|
|
{
|
|
salary.Details.Add(detail);
|
|
check = 1;
|
|
}
|
|
else
|
|
{
|
|
if (check == 1) break;
|
|
}
|
|
}
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return salaryMonthlys;
|
|
}
|
|
|
|
|
|
public List<SalaryMonthly> GetWithoutDetail(DateTime salaryMonth, int payrollTypeID)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<SalaryMonthly> salaryMonthlys = null;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(SalaryMonthlyDA.Get(tc, salaryMonth, payrollTypeID));
|
|
salaryMonthlys = this.CreateObjects<SalaryMonthly>(dr);
|
|
dr.Close();
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return salaryMonthlys;
|
|
}
|
|
|
|
public List<SalaryMonthly> GetForJV(DateTime salaryMonth, int payrollTypeID)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<SalaryMonthly> salaryMonthlys = null;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(SalaryMonthlyDA.Get(tc, salaryMonth, payrollTypeID));
|
|
salaryMonthlys = this.CreateObjects<SalaryMonthly>(dr);
|
|
dr.Close();
|
|
|
|
dr = new DataReader(SalaryMonthlyDA.GetDetail(tc, salaryMonth, payrollTypeID));
|
|
|
|
List<SalaryMonthlyDetail> details = this.CreateSalaryMonthlyDetailObject(dr);
|
|
dr.Close();
|
|
foreach (SalaryMonthly salary in salaryMonthlys)
|
|
{
|
|
foreach (SalaryMonthlyDetail detail in details)
|
|
{
|
|
if (salary.ID == detail.SalaryMonthlyID)
|
|
{
|
|
salary.Details.Add(detail);
|
|
}
|
|
}
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return salaryMonthlys;
|
|
}
|
|
|
|
public List<SalaryMonthly> GetByDateRange(DateTime startDate, DateTime endDate, int payrollTypeID)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<SalaryMonthly> salaryMonthlys = null;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(SalaryMonthlyDA.Get(tc, startDate, endDate, payrollTypeID));
|
|
salaryMonthlys = this.CreateObjects<SalaryMonthly>(dr);
|
|
dr.Close();
|
|
|
|
dr = new DataReader(SalaryMonthlyDA.GetDetail(tc, startDate, endDate, payrollTypeID));
|
|
|
|
List<SalaryMonthlyDetail> details = this.CreateSalaryMonthlyDetailObject(dr);
|
|
dr.Close();
|
|
int check = 0;
|
|
foreach (SalaryMonthly salary in salaryMonthlys)
|
|
{
|
|
check = 0;
|
|
foreach (SalaryMonthlyDetail detail in details)
|
|
{
|
|
if (salary.ID == detail.SalaryMonthlyID)
|
|
{
|
|
salary.Details.Add(detail);
|
|
check = 1;
|
|
}
|
|
else
|
|
{
|
|
if (check == 1) break;
|
|
}
|
|
}
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return salaryMonthlys;
|
|
}
|
|
|
|
public List<SalaryMonthly> GetByDateRange(int nEmpID, DateTime startDate, DateTime endDate, int payrollTypeID)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<SalaryMonthly> salaryMonthlys = null;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(SalaryMonthlyDA.Get(tc, nEmpID, startDate, endDate, payrollTypeID));
|
|
salaryMonthlys = this.CreateObjects<SalaryMonthly>(dr);
|
|
dr.Close();
|
|
|
|
dr = new DataReader(SalaryMonthlyDA.GetDetail(tc, nEmpID, startDate, endDate, payrollTypeID));
|
|
|
|
List<SalaryMonthlyDetail> details = this.CreateSalaryMonthlyDetailObject(dr);
|
|
dr.Close();
|
|
int check = 0;
|
|
foreach (SalaryMonthly salary in salaryMonthlys)
|
|
{
|
|
check = 0;
|
|
foreach (SalaryMonthlyDetail detail in details)
|
|
{
|
|
if (salary.ID == detail.SalaryMonthlyID)
|
|
{
|
|
salary.Details.Add(detail);
|
|
check = 1;
|
|
}
|
|
else
|
|
{
|
|
if (check == 1) break;
|
|
}
|
|
}
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return salaryMonthlys;
|
|
}
|
|
|
|
public List<SalaryEmpCostCenter> GetForCC(int nSMonthID)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<SalaryEmpCostCenter> salaryEmpCCs = null;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(SalaryMonthlyDA.GetEmpCostCenter(tc, nSMonthID));
|
|
salaryEmpCCs = this.CreateEmpCostCenterObject(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return salaryEmpCCs;
|
|
}
|
|
|
|
public List<SalaryMonthlyDetail> GetHead(int index, DateTime salaryMonth)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<SalaryMonthlyDetail> salaryMonthlyDetails = null;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(SalaryMonthlyDA.GetHead(tc, index, salaryMonth));
|
|
salaryMonthlyDetails = this.CreateSalaryMonthlyDetailObject(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return salaryMonthlyDetails;
|
|
}
|
|
/// <summary>
|
|
/// This function will get provide description
|
|
/// </summary>
|
|
/// <param name="itemCode"></param>
|
|
/// <param name="salaryMonth"></param>
|
|
/// <returns></returns>
|
|
public List<salaryHistory> getbyItemCode(List<EnumSalaryItemCode> itemCode , int payrolltypeid, DateTime salaryMonth)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<salaryHistory> salaryMonthlyDetails = new List<salaryHistory>();
|
|
|
|
#endregion
|
|
string scode = "";
|
|
itemCode.ForEach(x =>
|
|
{
|
|
scode = scode + ((int)x).ToString() + ", ";
|
|
});
|
|
scode = scode.Substring(0, scode.Length - 2);
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader oReader = new DataReader(SalaryMonthlyDA.GetByItemCode(tc, payrolltypeid, scode, salaryMonth));
|
|
|
|
while (oReader.Read())
|
|
{
|
|
salaryHistory odetail = new salaryHistory();
|
|
odetail.salaryMonth = salaryMonth;
|
|
odetail.empid = oReader.GetInt32("EmployeeID").Value;
|
|
odetail.itemID = oReader.GetInt32("ItemID").Value;
|
|
odetail.referenceID = oReader.GetInt32("SupportID");
|
|
odetail.amount = oReader.GetDouble("ChangedAmount").Value;
|
|
odetail.itemCode = (EnumSalaryItemCode)oReader.GetInt32("ItemCode").Value;
|
|
odetail.groupCode = (EnumSalaryGroup)oReader.GetInt32("ITEMGROUP");
|
|
salaryMonthlyDetails.Add(odetail);
|
|
}
|
|
|
|
oReader.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return salaryMonthlyDetails;
|
|
}
|
|
|
|
|
|
public List<SalaryMonthly> Get(string sEmpID, DateTime salaryMonth, int payrollTypeID)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<SalaryMonthly> salaryMonthlys = null;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(SalaryMonthlyDA.Get(tc, sEmpID, salaryMonth));
|
|
salaryMonthlys = this.CreateObjects<SalaryMonthly>(dr);
|
|
dr.Close();
|
|
|
|
dr = new DataReader(SalaryMonthlyDA.GetDetail(tc, salaryMonth, payrollTypeID));
|
|
|
|
List<SalaryMonthlyDetail> details = this.CreateSalaryMonthlyDetailObject(dr);
|
|
dr.Close();
|
|
int check = 0;
|
|
foreach (SalaryMonthly salary in salaryMonthlys)
|
|
{
|
|
check = 0;
|
|
foreach (SalaryMonthlyDetail detail in details)
|
|
{
|
|
if (salary.ID == detail.SalaryMonthlyID)
|
|
{
|
|
salary.Details.Add(detail);
|
|
check = 1;
|
|
}
|
|
else
|
|
{
|
|
if (check == 1) break;
|
|
}
|
|
}
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return salaryMonthlys;
|
|
}
|
|
|
|
public List<SalaryMonthly> GetForWTP(string sEmpID, DateTime salaryMonth, int payrollTypeID)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<SalaryMonthly> salaryMonthlys = null;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(SalaryMonthlyDA.GetForWTP(tc, sEmpID, salaryMonth));
|
|
salaryMonthlys = this.CreateObjects<SalaryMonthly>(dr);
|
|
dr.Close();
|
|
|
|
dr = new DataReader(SalaryMonthlyDA.GetDetail(tc, salaryMonth, payrollTypeID));
|
|
|
|
List<SalaryMonthlyDetail> details = this.CreateSalaryMonthlyDetailObject(dr);
|
|
dr.Close();
|
|
int check = 0;
|
|
foreach (SalaryMonthly salary in salaryMonthlys)
|
|
{
|
|
check = 0;
|
|
foreach (SalaryMonthlyDetail detail in details)
|
|
{
|
|
if (salary.ID == detail.SalaryMonthlyID)
|
|
{
|
|
salary.Details.Add(detail);
|
|
check = 1;
|
|
}
|
|
else
|
|
{
|
|
if (check == 1) break;
|
|
}
|
|
}
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return salaryMonthlys;
|
|
}
|
|
|
|
public int GetUnAuthorizeDays(int employeeid, DateTime salaryMonth)
|
|
{
|
|
int leaveDays = 0;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
leaveDays = SalaryMonthlyDA.GetUnAuthorizeDays(tc, employeeid, salaryMonth);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return leaveDays;
|
|
}
|
|
|
|
public bool IsSalaryProcessed(int employeeID, DateTime SalaryMonth)
|
|
{
|
|
bool isProcessed = false;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
isProcessed = SalaryMonthlyDA.IsSalaryProcessed(tc, employeeID, SalaryMonth);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return isProcessed;
|
|
}
|
|
|
|
public bool IsSalaryProcessedWeb(DateTime SalaryMonth, int payrollTypeID)
|
|
{
|
|
bool isProcessed = false;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
isProcessed = SalaryMonthlyDA.IsSalaryProcessedWeb(tc, SalaryMonth, payrollTypeID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return isProcessed;
|
|
}
|
|
|
|
public bool IsPermanentEmp(int employeeID, DateTime SalaryMonth, int payrollTypeID)
|
|
{
|
|
bool isPermanent = false;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
isPermanent = SalaryMonthlyDA.IsPermanentEmp(tc, employeeID, SalaryMonth, payrollTypeID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return isPermanent;
|
|
}
|
|
|
|
public int GetTotalEmp(int SProcessID)
|
|
{
|
|
int nTotalEmp = 0;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
nTotalEmp = SalaryMonthlyDA.GetTotalEmp(tc, SProcessID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return nTotalEmp;
|
|
}
|
|
|
|
|
|
public List<SalaryMonthly> GetByProcessID(int SProcessID)
|
|
{
|
|
List<SalaryMonthly> oSalaryMonthlies = new List<SalaryMonthly>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(SalaryMonthlyDA.GetByProcessID(tc, SProcessID));
|
|
|
|
oSalaryMonthlies = this.CreateObjects<SalaryMonthly>(oreader);
|
|
|
|
oreader.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlies;
|
|
}
|
|
|
|
public void IsSalaryProcessedAndFinalized(int employeeID, DateTime SalaryMonth, ref bool isprocessed,
|
|
ref bool isfinalized)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
isfinalized = false;
|
|
isprocessed = SalaryMonthlyDA.IsSalaryProcessed(tc, employeeID, SalaryMonth);
|
|
if (isprocessed)
|
|
{
|
|
isfinalized = SalaryMonthlyDA.IsSalaryFinalized(tc, employeeID, SalaryMonth);
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<SalaryEmpCostCenter> GetEmpCostCenter(int id)
|
|
{
|
|
List<SalaryEmpCostCenter> oSalaryEmpCostCenters = new List<SalaryEmpCostCenter>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(SalaryMonthlyDA.GetEmpCostCenter(tc, id));
|
|
oSalaryEmpCostCenters = this.CreateEmpCostCenterObject(oreader);
|
|
oreader.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryEmpCostCenters;
|
|
}
|
|
|
|
public List<SalaryMonthlyDetail> GetSalaryDetail(int id)
|
|
{
|
|
List<SalaryMonthlyDetail> oSalaryMonthlyDetails = new List<SalaryMonthlyDetail>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(SalaryMonthlyDA.GetSalaryDetail(tc, id));
|
|
oSalaryMonthlyDetails = this.CreateSalaryMonthlyDetailObject(oreader);
|
|
oreader.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlyDetails;
|
|
}
|
|
|
|
public List<SalaryMonthlyDetail> GetSalaryDetail(string SalaryMonthlyIds)
|
|
{
|
|
List<SalaryMonthlyDetail> oSalaryMonthlyDetails = new List<SalaryMonthlyDetail>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(SalaryMonthlyDA.GetSalaryDetail(tc, SalaryMonthlyIds));
|
|
oSalaryMonthlyDetails = this.CreateSalaryMonthlyDetailObject(oreader);
|
|
oreader.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlyDetails;
|
|
}
|
|
//public void Insert(SalaryProcess process, List<SalaryMonthly> items)
|
|
//{
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin(true);
|
|
// SalaryProcessService sv = new SalaryProcessService();
|
|
// ID processId = sv.Insert(tc, process);
|
|
|
|
// foreach (SalaryMonthly item in items)
|
|
// {
|
|
// item.SalaryProcessID = processId;
|
|
// item.DesignationText = item.Employee.DescriptionText;
|
|
// this.Insert(tc, item);
|
|
// }
|
|
// tc.End();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
// throw new ServiceException(e.Message, e);
|
|
// #endregion
|
|
// }
|
|
//}
|
|
public void Save(SalaryProcess process, List<SalaryMonthly> items)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
SalaryProcessService sv = new SalaryProcessService();
|
|
int processId = sv.Save(tc, process);
|
|
if (items.Count == 1)
|
|
{
|
|
nSalID = tc.GenerateID("SalaryMonthly", "SalaryMonthlyID");
|
|
nDetailID = tc.GenerateID("SALARYMONTHLYDETAIL", "DetailID");
|
|
foreach (SalaryMonthly item in items)
|
|
{
|
|
item.SalaryProcessID = processId;
|
|
item.DesignationText = item.Employee.DescriptionText;
|
|
nDetailID = this.Save(tc, item, nSalID, nDetailID + 1);
|
|
nSalID++;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
items.ForEach(x =>
|
|
{
|
|
x.SalaryProcessID = processId;
|
|
});
|
|
this.SaveBulk(tc, items);
|
|
}
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
|
|
public void SaveBulk(TransactionContext tc, List<SalaryMonthly> items)
|
|
{
|
|
try
|
|
{
|
|
if (items.Count > 0)
|
|
{
|
|
int salaryPKID = tc.GenerateID("SalaryMonthly", "SalaryMonthlyID");
|
|
DataTable attnProcessEntryTable = new DataTable("SalaryMonthly");
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("SALARYMONTHLYID", typeof(int)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("SALARYMONTH", typeof(DateTime)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("EMPLOYEEID", typeof(int)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("DEPARTMENTID", typeof(int))); // NULL
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("DESIGNATIONID", typeof(int))); // NULL
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("LOCATIONID", typeof(int))); // NULL
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("GRADEID", typeof(int)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("CATEGORYID", typeof(int)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("PREVMONTHBASIC", typeof(double)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("THISMONTHBASIC", typeof(double)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("PFMEMBERTYPE", typeof(int))); // NULL
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("GENDER", typeof(int))); // NULL,
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("ISCONFIRMED", typeof(bool))); // NULL,
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("ISELIGIBLEOT", typeof(bool))); // NULL,
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("RELIGIONID", typeof(int)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("PAYROLLTYPEID", typeof(int)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("WITHNODETAIL", typeof(bool)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("DETAILID", typeof(int))); // NULL,
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("SBUID", typeof(int))); // NULL,
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("THISMONTHGROSS", typeof(double))); // NULL,
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("SALARYPROCESSID", typeof(int))); // NULL,
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("OUTPAYBRANCHID", typeof(int))); // NULL,
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("OUTPAYACCOUNTNO", typeof(string))); // NULL,
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("MODIFIEDBY", typeof(int)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("MODIFIEDDATE", typeof(DateTime)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("PAYMENTMODE", typeof(int)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("DESIGNATION", typeof(string)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("DESIGAITON", typeof(string)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("DESIGNAITON", typeof(string)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("FUNCTIONID", typeof(int)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("GRATUITYPARAMID", typeof(int)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("ISFINALIZED", typeof(bool)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("ACCOUNTNO", typeof(string)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("BRANCHID", typeof(int)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("PAYMENTDATE", typeof(DateTime)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("REMARKS", typeof(string)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("SALARYWITHHELD", typeof(int)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("EURORATE", typeof(double)));
|
|
attnProcessEntryTable.Columns.Add(new DataColumn("CHEQUENO", typeof(string)));
|
|
|
|
foreach (SalaryMonthly item in items)
|
|
{
|
|
|
|
salaryPKID = salaryPKID +1;
|
|
item.ID = salaryPKID;
|
|
attnProcessEntryTable.Rows.Add(
|
|
|
|
salaryPKID,
|
|
item.SalaryMonth,
|
|
item.EmployeeID,
|
|
item.DepartmentID,
|
|
item.DesignationID,
|
|
item.LocationID,
|
|
item.GradeID,
|
|
item.CategoryID,
|
|
item.PrevMonthBasic,
|
|
item.ThisMonthBasic,
|
|
item.PFMembershipType,
|
|
item.Gender,
|
|
item.IsConfirmed,
|
|
item.IsEligibleOT,
|
|
item.ReligionID,
|
|
item.PayrollTypeID,
|
|
false,
|
|
0, //not found detailid
|
|
0,// not found sbuid
|
|
item.ThisMonthGross,
|
|
item.SalaryProcessID,
|
|
item.OutPayBranchID,
|
|
item.OutPayAccountNo,
|
|
item.ModifiedBy,
|
|
item.ModifiedDate,
|
|
0, // payment mode not found
|
|
item.DesignationText,
|
|
item.DesignationText,
|
|
item.DesignationText,
|
|
null,// functionid not found
|
|
null, // gratuity pramid not found
|
|
item.IsFinalized,
|
|
item.AccountNo,
|
|
item.BranchID,
|
|
item.PaymentDate,
|
|
item.Remarks,
|
|
item.salaryWithHeld,
|
|
item.EuroRate,
|
|
""
|
|
);
|
|
|
|
}
|
|
|
|
using (SqlBulkCopy bulkCopy = new SqlBulkCopy((SqlConnection)tc.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)tc.Transaction))
|
|
{
|
|
bulkCopy.BulkCopyTimeout = 6000; // in seconds
|
|
bulkCopy.ColumnMappings.Add("SALARYMONTHLYID", "SALARYMONTHLYID");
|
|
bulkCopy.ColumnMappings.Add("SALARYMONTH", "SALARYMONTH");
|
|
bulkCopy.ColumnMappings.Add("EMPLOYEEID", "EMPLOYEEID");
|
|
bulkCopy.ColumnMappings.Add("DEPARTMENTID", "DEPARTMENTID");
|
|
bulkCopy.ColumnMappings.Add("DESIGNATIONID", "DESIGNATIONID");
|
|
bulkCopy.ColumnMappings.Add("LOCATIONID", "LOCATIONID");
|
|
bulkCopy.ColumnMappings.Add("GRADEID", "GRADEID");
|
|
bulkCopy.ColumnMappings.Add("CATEGORYID", "CATEGORYID");
|
|
bulkCopy.ColumnMappings.Add("PREVMONTHBASIC", "PREVMONTHBASIC");
|
|
bulkCopy.ColumnMappings.Add("THISMONTHBASIC", "THISMONTHBASIC");
|
|
bulkCopy.ColumnMappings.Add("PFMEMBERTYPE", "PFMEMBERTYPE");
|
|
bulkCopy.ColumnMappings.Add("GENDER", "GENDER");
|
|
bulkCopy.ColumnMappings.Add("ISCONFIRMED", "ISCONFIRMED");
|
|
bulkCopy.ColumnMappings.Add("ISELIGIBLEOT", "ISELIGIBLEOT");
|
|
bulkCopy.ColumnMappings.Add("RELIGIONID", "RELIGIONID");
|
|
bulkCopy.ColumnMappings.Add("PAYROLLTYPEID", "PAYROLLTYPEID");
|
|
bulkCopy.ColumnMappings.Add("WITHNODETAIL", "WITHNODETAIL");
|
|
bulkCopy.ColumnMappings.Add("DETAILID", "DETAILID");
|
|
bulkCopy.ColumnMappings.Add("SBUID", "SBUID");
|
|
bulkCopy.ColumnMappings.Add("THISMONTHGROSS", "THISMONTHGROSS");
|
|
bulkCopy.ColumnMappings.Add("SALARYPROCESSID", "SALARYPROCESSID");
|
|
bulkCopy.ColumnMappings.Add("OUTPAYBRANCHID", "OUTPAYBRANCHID");
|
|
bulkCopy.ColumnMappings.Add("OUTPAYACCOUNTNO", "OUTPAYACCOUNTNO");
|
|
bulkCopy.ColumnMappings.Add("MODIFIEDBY", "MODIFIEDBY");
|
|
bulkCopy.ColumnMappings.Add("MODIFIEDDATE", "MODIFIEDDATE");
|
|
bulkCopy.ColumnMappings.Add("PAYMENTMODE", "PAYMENTMODE");
|
|
bulkCopy.ColumnMappings.Add("DESIGNATION", "DESIGNATION");
|
|
bulkCopy.ColumnMappings.Add("DESIGAITON", "DESIGAITON");
|
|
bulkCopy.ColumnMappings.Add("DESIGNAITON", "DESIGNAITON");
|
|
bulkCopy.ColumnMappings.Add("FUNCTIONID", "FUNCTIONID");
|
|
bulkCopy.ColumnMappings.Add("GRATUITYPARAMID", "GRATUITYPARAMID");
|
|
bulkCopy.ColumnMappings.Add("ISFINALIZED", "ISFINALIZED");
|
|
bulkCopy.ColumnMappings.Add("ACCOUNTNO", "ACCOUNTNO");
|
|
bulkCopy.ColumnMappings.Add("BRANCHID", "BRANCHID");
|
|
bulkCopy.ColumnMappings.Add("PAYMENTDATE", "PAYMENTDATE");
|
|
bulkCopy.ColumnMappings.Add("REMARKS", "REMARKS");
|
|
bulkCopy.ColumnMappings.Add("SALARYWITHHELD", "SALARYWITHHELD");
|
|
bulkCopy.ColumnMappings.Add("EURORATE", "EURORATE");
|
|
bulkCopy.ColumnMappings.Add("CHEQUENO", "CHEQUENO");
|
|
|
|
bulkCopy.DestinationTableName = "SALARYMONTHLY";
|
|
|
|
bulkCopy.WriteToServer(attnProcessEntryTable);
|
|
}
|
|
|
|
|
|
int nDetailID = tc.GenerateID("SALARYMONTHLYDETAIL", "DetailID");
|
|
DataTable detailtable = new DataTable("SALARYMONTHLYDETAIL");
|
|
detailtable.Columns.Add(new DataColumn("DETAILID", typeof(int)));
|
|
detailtable.Columns.Add(new DataColumn("SALARYMONTHLYID", typeof(int)));
|
|
detailtable.Columns.Add(new DataColumn("ITEMCODE", typeof(int)));
|
|
detailtable.Columns.Add(new DataColumn("ITEMGROUP", typeof(int)));
|
|
detailtable.Columns.Add(new DataColumn("ITEMID", typeof(int))); // NULL
|
|
detailtable.Columns.Add(new DataColumn("SUPPORTID", typeof(int))); // NULL
|
|
detailtable.Columns.Add(new DataColumn("DESCRIPTION", typeof(string))); // NULL
|
|
detailtable.Columns.Add(new DataColumn("POSITION", typeof(int)));
|
|
detailtable.Columns.Add(new DataColumn("CALCULATEDAMOUNT", typeof(double)));
|
|
detailtable.Columns.Add(new DataColumn("CHANGEDAMOUNT", typeof(double)));
|
|
detailtable.Columns.Add(new DataColumn("MODIFIEDBY", typeof(int)));
|
|
detailtable.Columns.Add(new DataColumn("MODIFIEDDATE", typeof(DateTime))); // NULL
|
|
foreach (SalaryMonthly m in items)
|
|
{
|
|
foreach (SalaryMonthlyDetail detail in m.Details)
|
|
{
|
|
nDetailID = nDetailID + 1;
|
|
detailtable.Rows.Add(
|
|
|
|
nDetailID,
|
|
m.ID,
|
|
detail.ItemCode,
|
|
detail.itemGroupCode,
|
|
detail.ItemID,
|
|
detail.SupportID,
|
|
detail.Description,
|
|
detail.Position,
|
|
detail.CalculatedAmount,
|
|
detail.ChangedAmount,
|
|
detail.ModifiedBy,
|
|
detail.ModifiedDate);
|
|
}
|
|
}
|
|
|
|
using (SqlBulkCopy bulkCopy = new SqlBulkCopy((SqlConnection)tc.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)tc.Transaction))
|
|
{
|
|
bulkCopy.BulkCopyTimeout = 6000; // in seconds
|
|
bulkCopy.ColumnMappings.Add("DETAILID", "DETAILID");
|
|
bulkCopy.ColumnMappings.Add("SALARYMONTHLYID", "SALARYMONTHLYID");
|
|
bulkCopy.ColumnMappings.Add("CHANGEDAMOUNT", "CHANGEDAMOUNT");
|
|
bulkCopy.ColumnMappings.Add("ITEMCODE", "ITEMCODE");
|
|
bulkCopy.ColumnMappings.Add("ITEMGROUP", "ITEMGROUP");
|
|
bulkCopy.ColumnMappings.Add("ITEMID", "ITEMID");
|
|
bulkCopy.ColumnMappings.Add("SUPPORTID", "SUPPORTID");
|
|
bulkCopy.ColumnMappings.Add("DESCRIPTION", "DESCRIPTION");
|
|
bulkCopy.ColumnMappings.Add("POSITION", "POSITION");
|
|
bulkCopy.ColumnMappings.Add("CALCULATEDAMOUNT", "CALCULATEDAMOUNT");
|
|
bulkCopy.ColumnMappings.Add("MODIFIEDBY", "MODIFIEDBY");
|
|
bulkCopy.ColumnMappings.Add("MODIFIEDDATE", "MODIFIEDDATE");
|
|
|
|
bulkCopy.DestinationTableName = "SALARYMONTHLYDETAIL";
|
|
bulkCopy.WriteToServer(detailtable);
|
|
}
|
|
|
|
|
|
|
|
|
|
DataTable tax = new DataTable("SALARYTEMPIT");
|
|
tax.Columns.Add(new DataColumn("ITEMID", typeof(int)));
|
|
tax.Columns.Add(new DataColumn("PREVIOUSAMOUNT", typeof(double)));
|
|
tax.Columns.Add(new DataColumn("THISMONTHAMOUNT", typeof(double)));
|
|
tax.Columns.Add(new DataColumn("PROJECTEDAMOUNT", typeof(double))); // NULL
|
|
tax.Columns.Add(new DataColumn("SIDE", typeof(int))); // NULL
|
|
tax.Columns.Add(new DataColumn("POSITION", typeof(int))); // NULL
|
|
tax.Columns.Add(new DataColumn("ISCHANGED", typeof(bool)));
|
|
tax.Columns.Add(new DataColumn("EMPLOYEEID", typeof(int)));
|
|
tax.Columns.Add(new DataColumn("ITEMCODE", typeof(int)));
|
|
tax.Columns.Add(new DataColumn("HEADID", typeof(int)));
|
|
tax.Columns.Add(new DataColumn("DESCRIPTION", typeof(string))); // NULL
|
|
|
|
tax.Columns.Add(new DataColumn("THISYEARTOTAL", typeof(double)));
|
|
tax.Columns.Add(new DataColumn("MODIFIEDBY", typeof(int)));
|
|
tax.Columns.Add(new DataColumn("MODIFIEDDATE", typeof(DateTime)));
|
|
|
|
foreach (SalaryMonthly m in items)
|
|
{
|
|
foreach (IncomeTax tx in m.Incometaxes)
|
|
{
|
|
tax.Rows.Add(
|
|
|
|
tx.ItemID,
|
|
tx.PreviousAmount,
|
|
tx.ThisMonthAmount,
|
|
tx.ProjectedAmount,
|
|
tx.Side,
|
|
tx.Position,
|
|
tx.IsChanged,
|
|
tx.EmployeeID,
|
|
tx.ItemGroup,
|
|
null, // headid
|
|
tx.Description,
|
|
tx.TotalAmount,
|
|
tx.ModifiedBy,
|
|
tx.ModifiedDate
|
|
|
|
);
|
|
}
|
|
}
|
|
|
|
using (SqlBulkCopy bulkCopy = new SqlBulkCopy((SqlConnection)tc.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)tc.Transaction))
|
|
{
|
|
bulkCopy.BulkCopyTimeout = 6000; // in seconds
|
|
|
|
bulkCopy.ColumnMappings.Add("EMPLOYEEID", "EMPLOYEEID");
|
|
bulkCopy.ColumnMappings.Add("ITEMCODE", "ITEMCODE");
|
|
bulkCopy.ColumnMappings.Add("ITEMID", "ITEMID");
|
|
bulkCopy.ColumnMappings.Add("DESCRIPTION", "DESCRIPTION");
|
|
bulkCopy.ColumnMappings.Add("THISYEARTOTAL", "THISYEARTOTAL");
|
|
bulkCopy.ColumnMappings.Add("PREVIOUSAMOUNT", "PREVIOUSAMOUNT");
|
|
bulkCopy.ColumnMappings.Add("THISMONTHAMOUNT", "THISMONTHAMOUNT");
|
|
bulkCopy.ColumnMappings.Add("PROJECTEDAMOUNT", "PROJECTEDAMOUNT");
|
|
bulkCopy.ColumnMappings.Add("SIDE", "SIDE");
|
|
bulkCopy.ColumnMappings.Add("POSITION", "POSITION");
|
|
bulkCopy.ColumnMappings.Add("MODIFIEDBY", "MODIFIEDBY");
|
|
bulkCopy.ColumnMappings.Add("MODIFIEDDATE", "MODIFIEDDATE");
|
|
bulkCopy.ColumnMappings.Add("ISCHANGED", "ISCHANGED");
|
|
bulkCopy.ColumnMappings.Add("HEADID", "HEADID");
|
|
|
|
bulkCopy.DestinationTableName = "SALARYTEMPIT";
|
|
bulkCopy.WriteToServer(tax);
|
|
}
|
|
|
|
|
|
|
|
|
|
DataTable cost = new DataTable("SALARYEMPCOSTCENTER");
|
|
cost.Columns.Add(new DataColumn("SALARYMONTHLYID", typeof(int)));
|
|
cost.Columns.Add(new DataColumn("COSTCENTERID", typeof(int)));
|
|
cost.Columns.Add(new DataColumn("PERCENTAGE", typeof(double)));
|
|
cost.Columns.Add(new DataColumn("EMPLOYEEID", typeof(int)));
|
|
|
|
foreach (SalaryMonthly m in items)
|
|
{
|
|
foreach (SalaryEmpCostCenter cc in m.CostCentersInvolments)
|
|
{
|
|
cost.Rows.Add(
|
|
|
|
m.ID,
|
|
cc.CostCenterID,
|
|
cc.Percentage,
|
|
cc.EmployeeID
|
|
);
|
|
}
|
|
}
|
|
|
|
using (SqlBulkCopy bulkCopy = new SqlBulkCopy((SqlConnection)tc.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)tc.Transaction))
|
|
{
|
|
bulkCopy.BulkCopyTimeout = 6000; // in seconds
|
|
bulkCopy.ColumnMappings.Add("SALARYMONTHLYID", "SALARYMONTHLYID");
|
|
bulkCopy.ColumnMappings.Add("COSTCENTERID", "COSTCENTERID");
|
|
bulkCopy.ColumnMappings.Add("PERCENTAGE", "PERCENTAGE");
|
|
bulkCopy.ColumnMappings.Add("EMPLOYEEID", "EMPLOYEEID");
|
|
|
|
bulkCopy.DestinationTableName = "SALARYEMPCOSTCENTER";
|
|
bulkCopy.WriteToServer(cost);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
|
|
public void Update(SalaryMonthly item)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
SalaryProcessService sv = new SalaryProcessService();
|
|
this.Save(tc, item);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void UpdateDetail(List<SalaryMonthlyDetail> oSalaryDetails, List<IncomeTax> taxdeducteditems)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
foreach (SalaryMonthlyDetail odetail in oSalaryDetails)
|
|
{
|
|
if (odetail.IsNew == false)
|
|
SalaryMonthlyDA.UpdateSalaryDetail(tc, odetail);
|
|
else
|
|
{
|
|
int id = tc.GenerateID("SALARYMONTHLYDETAIL", "DetailID");
|
|
this.SetObjectID(odetail, (id));
|
|
SalaryMonthlyDA.Insert(tc, odetail);
|
|
}
|
|
}
|
|
|
|
foreach (IncomeTax taxItem in taxdeducteditems)
|
|
{
|
|
IncomeTaxDA.UpdateTaxAmountFromSalary(tc, taxItem.ThisMonthAmount, taxItem.EmployeeID);
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
private int Save(TransactionContext tc, SalaryMonthly oSalaryMonthly)
|
|
{
|
|
string tableName = "SalaryMonthly";
|
|
try
|
|
{
|
|
int id = tc.GenerateID("SalaryMonthly", "SalaryMonthlyID");
|
|
if (oSalaryMonthly.IsNew)
|
|
{
|
|
base.SetObjectID(oSalaryMonthly, (id));
|
|
SalaryMonthlyDA.Insert(tc, oSalaryMonthly);
|
|
id = id + 1;
|
|
}
|
|
else
|
|
{
|
|
SalaryMonthlyDA.Update(tc, oSalaryMonthly);
|
|
SalaryMonthlyDA.DeleteSalaryDetail(tc, oSalaryMonthly.ID);
|
|
SalaryMonthlyDA.DeleteSalaryEmpCC(tc, oSalaryMonthly.ID);
|
|
// IncomeTaxDA.Delete(tc, oSalaryMonthly.EmployeeID, EnumIncomeTaxDataFrom.SalaryITTempData);
|
|
}
|
|
|
|
tableName = "SalaryDetail";
|
|
id = tc.GenerateID("SALARYMONTHLYDETAIL", "DetailID");
|
|
foreach (SalaryMonthlyDetail oSMDetail in oSalaryMonthly.Details)
|
|
{
|
|
oSMDetail.SalaryMonthlyID = oSalaryMonthly.ID;
|
|
base.SetObjectID(oSMDetail, (id));
|
|
SalaryMonthlyDA.Insert(tc, oSMDetail);
|
|
id = id + 1;
|
|
}
|
|
|
|
tableName = "IncomeTax";
|
|
foreach (IncomeTax item in oSalaryMonthly.Incometaxes)
|
|
{
|
|
IncomeTaxService iis = new IncomeTaxService();
|
|
// this.SetObjectState(item, ObjectState.New);
|
|
// item.ModifiedBy = User.CurrentUser.ID;
|
|
item.ModifiedDate = DateTime.Now;
|
|
iis.SaveForEdit(tc, item, EnumIncomeTaxDataFrom.SalaryITTempData);
|
|
}
|
|
|
|
if (oSalaryMonthly.CostCentersInvolments != null)
|
|
{
|
|
tableName = "Salary CostCenter";
|
|
foreach (SalaryEmpCostCenter oSEmpCostCenter in oSalaryMonthly.CostCentersInvolments)
|
|
{
|
|
oSEmpCostCenter.SalaryMontlyID = oSalaryMonthly.ID;
|
|
SalaryMonthlyDA.Insert(tc, oSEmpCostCenter);
|
|
}
|
|
}
|
|
|
|
|
|
return oSalaryMonthly.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
string smessage = "Faliled to save salary (table:" + tableName + ") for the employee:("
|
|
+ oSalaryMonthly.Employee.EmployeeNo + ") " + oSalaryMonthly.Employee.Name +
|
|
". Error :";
|
|
throw new ServiceException(smessage + e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
private int Save(TransactionContext tc, SalaryMonthly oSalaryMonthly, int nSalID, int nDetailID)
|
|
{
|
|
string tableName = "SalaryMonthly";
|
|
try
|
|
{
|
|
//int id = tc.GenerateID("SalaryMonthly", "SalaryMonthlyID");
|
|
if (oSalaryMonthly.IsNew)
|
|
{
|
|
base.SetObjectID(oSalaryMonthly, (nSalID));
|
|
SalaryMonthlyDA.Insert(tc, oSalaryMonthly);
|
|
//id = id + 1;
|
|
}
|
|
else
|
|
{
|
|
SalaryMonthlyDA.Update(tc, oSalaryMonthly);
|
|
SalaryMonthlyDA.DeleteSalaryDetail(tc, oSalaryMonthly.ID);
|
|
SalaryMonthlyDA.DeleteSalaryEmpCC(tc, oSalaryMonthly.ID);
|
|
IncomeTaxDA.Delete(tc, oSalaryMonthly.EmployeeID, EnumIncomeTaxDataFrom.SalaryITTempData);
|
|
}
|
|
|
|
tableName = "SalaryDetail";
|
|
//id = tc.GenerateID("SALARYMONTHLYDETAIL", "DetailID");
|
|
foreach (SalaryMonthlyDetail oSMDetail in oSalaryMonthly.Details)
|
|
{
|
|
oSMDetail.SalaryMonthlyID = oSalaryMonthly.ID;
|
|
base.SetObjectID(oSMDetail, (nDetailID));
|
|
SalaryMonthlyDA.Insert(tc, oSMDetail);
|
|
nDetailID++;
|
|
//id = id + 1;
|
|
}
|
|
|
|
tableName = "IncomeTax";
|
|
foreach (IncomeTax item in oSalaryMonthly.Incometaxes)
|
|
{
|
|
IncomeTaxService iis = new IncomeTaxService();
|
|
|
|
// item.ModifiedBy = User.CurrentUser.ID;
|
|
item.ModifiedDate = DateTime.Now;
|
|
item.ID = 0;
|
|
this.SetObjectState(item, ObjectState.New);
|
|
iis.SaveForEdit(tc, item, EnumIncomeTaxDataFrom.SalaryITTempData);
|
|
}
|
|
|
|
tableName = "Salary CostCenter";
|
|
foreach (SalaryEmpCostCenter oSEmpCostCenter in oSalaryMonthly.CostCentersInvolments)
|
|
{
|
|
oSEmpCostCenter.SalaryMontlyID = oSalaryMonthly.ID;
|
|
SalaryMonthlyDA.Insert(tc, oSEmpCostCenter);
|
|
}
|
|
|
|
|
|
return nDetailID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
string smessage = "Faliled to save salary (table:" + tableName + ") for the employee:("
|
|
+ oSalaryMonthly.Employee.EmployeeNo + ") " + oSalaryMonthly.Employee.Name +
|
|
". Error :";
|
|
throw new ServiceException(smessage + e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void Delete(int id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
SalaryMonthlyDA.Delete(tc, id);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
public DataSet GetLastPayDate(int empid)
|
|
{
|
|
DataSet lastPayDate = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
lastPayDate = SalaryMonthlyDA.GetLastPayDate(tc, empid);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return lastPayDate;
|
|
}
|
|
|
|
public DataSet GetEmpSalaryReconciliationSummary(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalaryReconciliationSummary(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetCCWiseSalarySheet(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetCCWiseSalarySheet(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetCCWiseSalarySheetDetail(DateTime dSMonthDate, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetCCWiseSalarySheetDetail(tc, dSMonthDate, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet CostCenterCount(DateTime dSMonthDate)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.CostCenterCount(tc, dSMonthDate);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
|
|
public DataSet GetCCWiseSalarySummary(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetCCWiseSalarySummary(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetNewCCWiseSalarySummary(DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetNewCCWiseSalarySummary(tc, dateTime, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
public List<SalaryMonthly> Get(string sEmpID, DateTime fromdate, DateTime toDate, int payrollTypeID)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<SalaryMonthly> salaryMonthlys = null;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(SalaryMonthlyDA.Get(tc, sEmpID, fromdate, toDate));
|
|
salaryMonthlys = this.CreateObjects<SalaryMonthly>(dr);
|
|
dr.Close();
|
|
|
|
|
|
//dr = new DataReader(SalaryMonthlyDA.GetSalaryDetail(tc, salaryMonthlys.CommaSeparatedIDs()));
|
|
dr = new DataReader(SalaryMonthlyDA.GetDetail(tc, fromdate, toDate, payrollTypeID));
|
|
|
|
List<SalaryMonthlyDetail> details = this.CreateSalaryMonthlyDetailObject(dr);
|
|
dr.Close();
|
|
int check = 0;
|
|
foreach (SalaryMonthly salary in salaryMonthlys)
|
|
{
|
|
check = 0;
|
|
foreach (SalaryMonthlyDetail detail in details)
|
|
{
|
|
if (salary.ID == detail.SalaryMonthlyID)
|
|
{
|
|
salary.Details.Add(detail);
|
|
check = 1;
|
|
}
|
|
else
|
|
{
|
|
if (check == 1) break;
|
|
}
|
|
}
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return salaryMonthlys;
|
|
}
|
|
|
|
public DataSet GetSalaryStracture(string SempIds)
|
|
{
|
|
DataSet oSalaryStracture = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryStracture = SalaryMonthlyDA.GetSalaryStracture(tc, SempIds);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryStracture;
|
|
}
|
|
|
|
public DataSet GetEmpSalarySheet(DateTime dSMonthDate, DateTime dEMonthDate, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalarySheet(tc, dSMonthDate, dEMonthDate, sEmpID);
|
|
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
|
|
|
|
|
|
private double GetAmountOnRangeintr(Employee employee, DateTime fromDate, DateTime toDate,
|
|
EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int itemId, int supportid, EmployeeGradeSalary gradeSalary, ADParameter apraram)
|
|
{
|
|
double fractionMonthAmount = 0;
|
|
double amount = 0;
|
|
if (Global.DateFunctions.DateDiff("m", GlobalFunctions.FirstDateOfMonth(fromDate), GlobalFunctions.LastDateOfMonth(toDate)) > 1)
|
|
{
|
|
amount = this.GetSumOnRange(employee.ID,
|
|
GlobalFunctions.FirstDateOfMonth(fromDate.AddMonths(1)), GlobalFunctions.LastDateOfMonth(toDate.AddMonths(-1)),
|
|
groupCode, itemCode, itemId, employee.PayrollTypeID);
|
|
}
|
|
|
|
bool dataNotFound = false;
|
|
if (Global.DateFunctions.FirstDateOfMonth(fromDate) != Global.DateFunctions.FirstDateOfMonth(fromDate))
|
|
{
|
|
// EmployeeGradeSalary oge = EmployeeGradeSalary.Get(employee.ID, fromDate, EnumArrearType.NotPresent);
|
|
if (gradeSalary != null)
|
|
{
|
|
switch (itemCode)
|
|
{
|
|
case EnumSalaryItemCode.Basic_Salary:
|
|
fractionMonthAmount = gradeSalary.BasicSalary * GlobalFunctions.GetFractinalOfMonth(fromDate);
|
|
dataNotFound = true;
|
|
break;
|
|
case EnumSalaryItemCode.Allowance:
|
|
case EnumSalaryItemCode.Deduction:
|
|
//ADParameter op = ADParameter.Get(ID.FromInteger(supportid));
|
|
if (apraram != null)
|
|
{
|
|
if (apraram.EntitleType == EnumEntitleType.Grade)
|
|
{
|
|
fractionMonthAmount = new ADParameterService().GetGradeDefinedAmount(employee, gradeSalary.BasicSalary, gradeSalary.GrossSalary, gradeSalary, apraram);
|
|
fractionMonthAmount = fractionMonthAmount * GlobalFunctions.GetFractinalOfMonth(fromDate);
|
|
dataNotFound = true;
|
|
}
|
|
else dataNotFound = false;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (dataNotFound == false)
|
|
{
|
|
fractionMonthAmount = this.GetSumOnRange(employee.ID,
|
|
GlobalFunctions.FirstDateOfMonth(fromDate), GlobalFunctions.LastDateOfMonth(fromDate),
|
|
groupCode, itemCode, itemId, employee.PayrollTypeID) * GlobalFunctions.GetFractinalOfMonth(fromDate);
|
|
}
|
|
|
|
// if (Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("m", fromDate, toDate) > 0)
|
|
if (Global.DateFunctions.FirstDateOfMonth(fromDate) != GlobalFunctions.FirstDateOfMonth(toDate)) // if cross two month
|
|
{
|
|
fractionMonthAmount = fractionMonthAmount + this.GetSumOnRange(employee.ID,
|
|
GlobalFunctions.FirstDateOfMonth(toDate), GlobalFunctions.LastDateOfMonth(toDate),
|
|
groupCode, itemCode, itemId, employee.PayrollTypeID) * GlobalFunctions.GetFractinalOfTillDate(toDate);
|
|
}
|
|
return amount = amount + fractionMonthAmount;
|
|
|
|
}
|
|
public double GetAmountOnRange(Employee employee, DateTime fromDate, DateTime toDate,
|
|
EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int itemId, int payrollTypeId)
|
|
{
|
|
double fractionMonthAmount = 0;
|
|
double amount = 0;
|
|
amount = this.GetSumOnRange(employee.ID,
|
|
GlobalFunctions.FirstDateOfMonth(fromDate.AddMonths(1)), GlobalFunctions.LastDateOfMonth(toDate.AddMonths(-1)),
|
|
groupCode, itemCode, itemId, payrollTypeId);
|
|
|
|
if (fromDate.Month != toDate.Month)
|
|
{
|
|
fractionMonthAmount = this.GetSumOnRange(employee.ID,
|
|
GlobalFunctions.FirstDateOfMonth(fromDate), GlobalFunctions.LastDateOfMonth(fromDate),
|
|
groupCode, itemCode, itemId, payrollTypeId);
|
|
|
|
// need to change below condition
|
|
if (employee.JoiningDate.Month != fromDate.Month)
|
|
fractionMonthAmount = fractionMonthAmount * GlobalFunctions.GetFractinalOfMonth(fromDate);
|
|
|
|
fractionMonthAmount = fractionMonthAmount + this.GetSumOnRange(employee.ID,
|
|
GlobalFunctions.FirstDateOfMonth(toDate), GlobalFunctions.LastDateOfMonth(toDate),
|
|
groupCode, itemCode, itemId, payrollTypeId) * GlobalFunctions.GetFractinalOfTillDate(toDate);
|
|
}
|
|
else
|
|
{
|
|
fractionMonthAmount = this.GetSumOnRange(
|
|
employee.ID, GlobalFunctions.FirstDateOfMonth(fromDate), GlobalFunctions.LastDateOfMonth(toDate)
|
|
, groupCode, itemCode, itemId, payrollTypeId);
|
|
// Chenged by ashek 21 Sep 2014
|
|
if (employee.JoiningDate.Month == fromDate.Month && employee.JoiningDate.Year != fromDate.Year)
|
|
fractionMonthAmount = fractionMonthAmount * GlobalFunctions.GetFraction(fromDate, toDate);
|
|
}
|
|
return amount = amount + fractionMonthAmount;
|
|
|
|
}
|
|
public double GetAmountOnRange(Employee employee, DateTime fromDate, DateTime toDate,
|
|
EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int itemId, int supportid,
|
|
EmployeeGradeSalary gradeSalary, ADParameter apraram)
|
|
{
|
|
if (fromDate != Global.DateFunctions.FirstDateOfMonth(toDate))
|
|
{
|
|
//EmployeeGradeSalary oge = null;
|
|
//oge = new EmployeeGradeSalaryService().Get(employee.ID, fromDate, EnumArrearType.NotPresent);
|
|
|
|
if (gradeSalary != null)
|
|
{
|
|
if (itemCode == EnumSalaryItemCode.Allowance || itemCode == EnumSalaryItemCode.Deduction)
|
|
{
|
|
//ADParameter op = null;
|
|
//op = new ADParameterService().Get(supportid, payrolltypeid);
|
|
return this.GetAmountOnRangeintr( employee, fromDate, toDate, groupCode, itemCode, itemId, supportid, gradeSalary, apraram);
|
|
}
|
|
else return this.GetAmountOnRangeintr( employee, fromDate, toDate, groupCode, itemCode, itemId, supportid, gradeSalary, null);
|
|
}
|
|
return this.GetAmountOnRangeintr( employee, fromDate, toDate, groupCode, itemCode, itemId, supportid, null, null);
|
|
}
|
|
else return this.GetAmountOnRangeintr( employee, fromDate, toDate, groupCode, itemCode, itemId, supportid, null, null);
|
|
}
|
|
|
|
|
|
|
|
|
|
public double GetUnAuthorizeAmount(double nAmount, Employee employee, DateTime fromdate, DateTime toDate,
|
|
EnumSalaryItemCode itemCode, int itemId)
|
|
{
|
|
double uPaid = 0, uPayable = 0, totalUpayable = 0;
|
|
|
|
DateTime StartDate = GlobalFunctions.LastDateOfMonth(fromdate);
|
|
DateTime EndDate = GlobalFunctions.LastDateOfMonth(toDate);
|
|
|
|
double MonDays = 0;
|
|
int leaveDays = 0;
|
|
|
|
while (StartDate <= EndDate)
|
|
{
|
|
|
|
MonDays = (double)StartDate.Day;
|
|
leaveDays = new SalaryMonthlyService().GetUnAuthorizeDays(employee.ID, GlobalFunctions.LastDateOfMonth(StartDate));
|
|
if (leaveDays > 0)
|
|
{
|
|
uPaid = new SalaryMonthlyService().GetSumOnRange(employee.ID,
|
|
GlobalFunctions.FirstDateOfMonth(StartDate), GlobalFunctions.LastDateOfMonth(StartDate),
|
|
EnumSalaryGroup.UnauthLeave, itemCode, itemId, employee.PayrollTypeID);
|
|
uPayable = (nAmount / MonDays) * leaveDays;
|
|
totalUpayable = totalUpayable + (uPayable - uPaid);
|
|
}
|
|
StartDate = GlobalFunctions.LastDateOfMonth(StartDate.AddDays(1));
|
|
}
|
|
return totalUpayable;
|
|
}
|
|
|
|
|
|
public DataSet GetEmpSalaryDifference(DateTime fromDate, DateTime ToDate, string sEmpID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
Stopwatch stopwatch = new Stopwatch();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
stopwatch.Start();
|
|
tc.CommandTimeOut = 500000;
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetEmpSalaryDifference(tc, fromDate, ToDate, sEmpID);
|
|
stopwatch.Stop();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
TimeSpan transactionTime = stopwatch.Elapsed;
|
|
//int transactionTimeInt = (int)stopwatch.ElapsedMilliseconds;
|
|
//string time = $"Transaction Time: {transactionTime}";
|
|
|
|
return oSalaryMonthlys;
|
|
}
|
|
public double GetAmount(EnumSalaryGroup groupcode, EnumSalaryItemCode itemCode, SalaryMonthly salaryMonthly)
|
|
{
|
|
//SalaryMonthly salaryMonthly = new SalaryMonthlyService().GetbyId(id);
|
|
return salaryMonthly.Details
|
|
.Where(item => item.ItemCode == itemCode &&
|
|
item.itemGroupCode == groupcode)
|
|
.Sum(item => item.ChangedAmount);
|
|
}
|
|
public double GetAmount(EnumSalaryGroup groupcode, EnumSalaryItemCode itemCode, SalaryMonthly salaryMonthly, int itemId)
|
|
{
|
|
//SalaryMonthly salaryMonthly = new SalaryMonthlyService().GetbyId(id);
|
|
return salaryMonthly.Details
|
|
.Where(item => item.ItemCode == itemCode &&
|
|
item.itemGroupCode == groupcode &&
|
|
item.ItemID == itemId)
|
|
.Sum(item => item.ChangedAmount);
|
|
|
|
}
|
|
public double GetAmount(EnumSalaryGroup groupcode, EnumSalaryItemCode itemCode, SalaryMonthly salaryMonthly, string description)
|
|
{
|
|
return salaryMonthly.Details
|
|
.Where(item => item.ItemCode == itemCode &&
|
|
item.itemGroupCode == groupcode &&
|
|
item.Description.Trim().ToLower() == description.Trim().ToLower())
|
|
.Sum(item => item.ChangedAmount);
|
|
}
|
|
public double GetGrossAmount(EnumSalaryItemCode itemCode, int itemId, List<SalaryMonthlyDetail> Details)
|
|
{
|
|
double amount = 0;
|
|
foreach (SalaryMonthlyDetail item in Details)
|
|
{
|
|
if (item.ItemCode == itemCode && item.ItemID == itemId)
|
|
{
|
|
if (item.itemGroupCode == EnumSalaryGroup.Gross || item.itemGroupCode == EnumSalaryGroup.Arrear)
|
|
amount = amount + item.ChangedAmount;
|
|
else if (item.itemGroupCode == EnumSalaryGroup.UnauthLeave)
|
|
amount = amount - item.ChangedAmount;
|
|
}
|
|
}
|
|
return amount;
|
|
}
|
|
|
|
public double GetDeductAmount(EnumSalaryItemCode itemCode, int itemId, List<SalaryMonthlyDetail> Details)
|
|
{
|
|
double amount = 0;
|
|
foreach (SalaryMonthlyDetail item in Details)
|
|
{
|
|
if (item.ItemCode == itemCode && item.ItemID == itemId)
|
|
{
|
|
if (item.itemGroupCode == EnumSalaryGroup.Deductions || item.itemGroupCode == EnumSalaryGroup.Arrear)
|
|
amount = amount + item.ChangedAmount;
|
|
else if (item.itemGroupCode == EnumSalaryGroup.UnauthLeave)
|
|
amount = amount - item.ChangedAmount;
|
|
}
|
|
}
|
|
return amount;
|
|
}
|
|
public DataSet GetCCWiseOPISummary(DateTime dSMonthDate, int nID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetCCWiseOPISummary(tc, dSMonthDate, nID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
return oSalaryMonthlys;
|
|
}
|
|
public DataSet GetCCWiseOPI(DateTime dSMonthDate, int nID)
|
|
{
|
|
DataSet oSalaryMonthlys = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
oSalaryMonthlys = SalaryMonthlyDA.GetCCWiseOPI(tc, dSMonthDate, nID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
return oSalaryMonthlys;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
} |