2471 lines
80 KiB
C#
2471 lines
80 KiB
C#
|
using System;
|
|||
|
using System.Data;
|
|||
|
using System.Linq;
|
|||
|
using Ease.CoreV35;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using Ease.CoreV35.DataAccess;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Payroll.BO;
|
|||
|
using Ease.CoreV35.Caching;
|
|||
|
using System.Data.SqlClient;
|
|||
|
|
|||
|
namespace Payroll.Service
|
|||
|
{
|
|||
|
#region Employee Service
|
|||
|
[Serializable]
|
|||
|
public class EmployeeService : ServiceTemplate, IEmployeeService
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
Cache _cache = new Cache(typeof(Employee));
|
|||
|
|
|||
|
#endregion
|
|||
|
public EmployeeService() { }
|
|||
|
|
|||
|
private void MapObject(Employee oEmployee, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oEmployee, oReader.GetID("EmployeeID"));
|
|||
|
oEmployee.GlobalID = oReader.GetString("globalID");
|
|||
|
oEmployee.EmployeeNo = oReader.GetString("employeeNo");
|
|||
|
oEmployee.Name = oReader.GetString("name");
|
|||
|
oEmployee.Gender = (EnumGender)oReader.GetInt32("gender").Value;
|
|||
|
//oEmployee.IsManager = oReader.GetBoolean("IsManager").Value;
|
|||
|
oEmployee.BirthDate = oReader.GetDateTime("birthDate").Value;
|
|||
|
oEmployee.JoiningDate = oReader.GetDateTime("joiningDate").Value;
|
|||
|
oEmployee.EndOfContractDate = oReader.GetDateTime("endOfContractDate");// ? oReader.GetDateTime("endOfContractDate").Value : DateTime.MinValue;
|
|||
|
oEmployee.EmailAddress = oReader.GetString("emailAddress");
|
|||
|
oEmployee.MobileNo = oReader.GetString("mobileNo");
|
|||
|
oEmployee.TinNo = oReader.GetString("tinNo");
|
|||
|
oEmployee.CategoryID = oReader.GetID("categoryID");
|
|||
|
oEmployee.ForeignExPat = oReader.GetBoolean("foreignExPat").Value;
|
|||
|
oEmployee.ContinueGratuity = oReader.GetBoolean("continueGratuity").HasValue ? oReader.GetBoolean("continueGratuity").Value : false;
|
|||
|
oEmployee.DescriptionText = oReader.GetString("DESIGDESCRIPTION");
|
|||
|
//oEmployee.TaxCircle = (EnumTaxCircle)oReader.GetInt32("taxCircle").Value;
|
|||
|
oEmployee.TaxCircle = oReader.GetString("taxCircle");
|
|||
|
oEmployee.IsConfirmed = oReader.GetBoolean("isConfirmed").Value;
|
|||
|
oEmployee.Status = (EnumEmployeeStatus)oReader.GetInt32("status").Value;
|
|||
|
oEmployee.IsShownInTaxSheet = oReader.GetBoolean("isShownInTaxSheet").Value;
|
|||
|
oEmployee.PFMemberType = (EnumPFMembershipType)oReader.GetInt32("pFMemberType").Value;
|
|||
|
oEmployee.PFMemberShiptDate = oReader.GetDateTime("pfMemberShipDt").HasValue ? oReader.GetDateTime("pfMemberShipDt").Value : DateTime.Now;
|
|||
|
oEmployee.BranchID = oReader.GetID("branchID");
|
|||
|
oEmployee.AccountNo = oReader.GetString("accountNo");
|
|||
|
oEmployee.OutPayBranchID = oReader.GetID("OUTPAYBRANCHID");
|
|||
|
oEmployee.OutPayAccountNo = oReader.GetString("outPayAccountNo");
|
|||
|
oEmployee.DepartmentID = oReader.GetID("departmentID");
|
|||
|
oEmployee.LocationID = oReader.GetID("locationID");
|
|||
|
oEmployee.ReligionID = oReader.GetID("religionID");
|
|||
|
oEmployee.MaritalStatus = (EnumMaritalStatus)oReader.GetInt32("maritalStatusID").Value;
|
|||
|
oEmployee.DesignationID = oReader.GetID("designationID");
|
|||
|
oEmployee.GradeID = oReader.GetID("gradeID");
|
|||
|
oEmployee.BasicSalary = oReader.GetDouble("basicSalary").Value;
|
|||
|
oEmployee.PrevBasic = oReader.GetDouble("prevBasic").Value;
|
|||
|
oEmployee.PaymentMode = (EnumPaymentMode)oReader.GetInt32("paymentMode").Value;
|
|||
|
oEmployee.PaymentMode = (EnumPaymentMode)oReader.GetInt32("paymentMode").Value;
|
|||
|
oEmployee.PayrollTypeID = oReader.GetID("PayrollTypeID");
|
|||
|
try
|
|||
|
{
|
|||
|
oEmployee.OutPayPaymentMode = (EnumPaymentMode)oReader.GetInt32("OutPayPaymentMode").Value;
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
// if OutPayPaymentMode column does not exist
|
|||
|
//this error will be ignored.
|
|||
|
// Used for Navana do not delete
|
|||
|
}
|
|||
|
oEmployee.FatherName = oReader.GetString("fatherName");
|
|||
|
oEmployee.IsEligibleOT = oReader.GetBoolean("isEligibleOT").Value;
|
|||
|
oEmployee.DescriptionText = oReader.GetString("desigDescription");
|
|||
|
oEmployee.DesktopUserPass = oReader.GetString("desktopUserPass");
|
|||
|
oEmployee.PayrollTypeID = oReader.GetID("payrollTypeID");
|
|||
|
oEmployee.IsAutoProcess = oReader.GetBoolean("IsAutoProcess").Value;
|
|||
|
oEmployee.CardID = oReader.GetID("cardID");
|
|||
|
oEmployee.GrossSalary = oReader.GetDouble("grossSalary").Value;
|
|||
|
oEmployee.PhotoPath = oReader.GetString("PhotoPath");
|
|||
|
oEmployee.PayScaleId = oReader.GetID("payScaleId");
|
|||
|
oEmployee.TaxAmount = oReader.GetDouble("taxAmount").Value;
|
|||
|
oEmployee.CurrentHistoryID = oReader.GetID("EmpHistoryID");
|
|||
|
oEmployee.MonthStatusUpdate = oReader.GetInt32("MonthStatusUpdate").HasValue ? (EnumEmployeeStatus)oReader.GetInt32("MonthStatusUpdate") : EnumEmployeeStatus.Live;
|
|||
|
//Diu to few clients already gets 0 default values;
|
|||
|
if (oEmployee.MonthStatusUpdate == 0) oEmployee.MonthStatusUpdate = EnumEmployeeStatus.Live;
|
|||
|
oEmployee.ConfirDate = oReader.GetDateTime("dateOfConfirmation").HasValue ? oReader.GetDateTime("dateOfConfirmation").Value : DateTime.MinValue;
|
|||
|
//oEmployee.DiscontinueDate = oReader.GetDateTime("dateOfExpiry").HasValue ? oReader.GetDateTime("dateOfExpiry").Value : DateTime.MinValue;
|
|||
|
oEmployee.VendorCode = oReader.GetString("VendorCode");
|
|||
|
oEmployee.Role = (EnumRole)oReader.GetInt32("Role").Value;
|
|||
|
//oEmployee.Role = oReader.GetBoolean("Role").Value;
|
|||
|
oEmployee.CreatedBy = oReader.GetID("CreatedBy");
|
|||
|
oEmployee.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|||
|
oEmployee.ModifiedBy = oReader.GetID("ModifiedBy");
|
|||
|
oEmployee.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|||
|
oEmployee.PersonType = (EnumPersonType)oReader.GetInt32("PersonType").Value;
|
|||
|
this.SetObjectState(oEmployee, Ease.CoreV35.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
Employee oEmployee = new Employee();
|
|||
|
MapObject(oEmployee, oReader);
|
|||
|
return oEmployee as T;
|
|||
|
}
|
|||
|
|
|||
|
protected Employee CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
Employee oEmployee = new Employee();
|
|||
|
MapObject(oEmployee, oReader);
|
|||
|
return oEmployee;
|
|||
|
}
|
|||
|
|
|||
|
//protected ObjectsTemplate<Employee> CreateObjects(DataReader oDatareader)
|
|||
|
//{
|
|||
|
|
|||
|
//}
|
|||
|
|
|||
|
#region Service implementation
|
|||
|
public Employee Get(ID id)
|
|||
|
{
|
|||
|
Employee oEmployee = new Employee();
|
|||
|
#region Cache Header
|
|||
|
oEmployee = _cache["Get", id] as Employee;
|
|||
|
if (oEmployee != null)
|
|||
|
return oEmployee;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(EmployeeDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oEmployee = this.CreateObject<Employee>(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
|
|||
|
}
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oEmployee, "Get", id);
|
|||
|
#endregion
|
|||
|
return oEmployee;
|
|||
|
}
|
|||
|
|
|||
|
public Employee GetByCardID(ID id)
|
|||
|
{
|
|||
|
Employee oEmployee = new Employee();
|
|||
|
#region Cache Header
|
|||
|
oEmployee = _cache["GetByCardID", id] as Employee;
|
|||
|
if (oEmployee != null)
|
|||
|
return oEmployee;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(EmployeeDA.GetByCardID(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oEmployee = this.CreateObject<Employee>(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
|
|||
|
}
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oEmployee, "GetByCardID", id);
|
|||
|
#endregion
|
|||
|
return oEmployee;
|
|||
|
}
|
|||
|
public Employee GetParentEmployee(ID id)
|
|||
|
{
|
|||
|
Employee oEmployee = new Employee();
|
|||
|
#region Cache Header
|
|||
|
oEmployee = _cache["GetParentEmployee", id] as Employee;
|
|||
|
if (oEmployee != null)
|
|||
|
return oEmployee;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(EmployeeDA.GetParentEmployee(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oEmployee = this.CreateObject<Employee>(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
|
|||
|
}
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oEmployee, "GetParentEmployee", id);
|
|||
|
#endregion
|
|||
|
return oEmployee;
|
|||
|
}
|
|||
|
|
|||
|
public Employee Get(TransactionContext tc, ID id)
|
|||
|
{
|
|||
|
Employee oEmployee = new Employee();
|
|||
|
#region Cache Header
|
|||
|
oEmployee = _cache["Get", id] as Employee;
|
|||
|
if (oEmployee != null)
|
|||
|
return oEmployee;
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
DataReader oreader = new DataReader(EmployeeDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oEmployee = this.CreateObject<Employee>(oreader);
|
|||
|
}
|
|||
|
oreader.Close();
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oEmployee, "Get", id);
|
|||
|
#endregion
|
|||
|
return oEmployee;
|
|||
|
}
|
|||
|
public Employee GetwitoutchekPayrolltype(string employeeNo)
|
|||
|
{
|
|||
|
Employee oEmployee = new Employee();
|
|||
|
#region Cache Header
|
|||
|
oEmployee = _cache["GetwitoutchekPayrolltype", employeeNo] as Employee;
|
|||
|
if (oEmployee != null)
|
|||
|
return oEmployee;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(EmployeeDA.GetWithOutcheckPayrollType(tc, employeeNo));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oEmployee = this.CreateObject<Employee>(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
|
|||
|
}
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oEmployee, "GetwitoutchekPayrolltype", employeeNo);
|
|||
|
#endregion
|
|||
|
return oEmployee;
|
|||
|
}
|
|||
|
|
|||
|
public Employee GetByEmailAddress(string empEmail)
|
|||
|
{
|
|||
|
Employee oEmployee = new Employee();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(EmployeeDA.GetByEmailAddress(tc, empEmail));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oEmployee = this.CreateObject<Employee>(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 oEmployee;
|
|||
|
}
|
|||
|
|
|||
|
public Employee Get(string employeeNo, int payrollTypeID)
|
|||
|
{
|
|||
|
Employee oEmployee = new Employee();
|
|||
|
#region Cache Header
|
|||
|
oEmployee = _cache["Get", employeeNo] as Employee;
|
|||
|
if (oEmployee != null)
|
|||
|
return oEmployee;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(EmployeeDA.Get(tc, employeeNo, payrollTypeID));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oEmployee = this.CreateObject<Employee>(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
|
|||
|
}
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oEmployee, "Get", employeeNo);
|
|||
|
#endregion
|
|||
|
return oEmployee;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public ObjectsTemplate<Employee> Get(ObjectsTemplate<SearchEmployee> searchEmployees, int payrollTypeID)
|
|||
|
{
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = null;
|
|||
|
|
|||
|
string InEmps = "";
|
|||
|
foreach (SearchEmployee item in searchEmployees)
|
|||
|
{
|
|||
|
InEmps = InEmps + item.EmployeeID.ToString() + ", ";
|
|||
|
}
|
|||
|
if (InEmps.Length > 2) InEmps = InEmps.Substring(0, InEmps.Length - 2);
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.GetbyInSQL(tc, InEmps, payrollTypeID));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "Get");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
public ObjectsTemplate<Employee> GetByDeptIDs(string sIDs, int payrollTypeID)
|
|||
|
{
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.GetByDeptIDs(tc, sIDs, payrollTypeID));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "GetByDeptIDs");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<Employee> Get(int payrollTypeID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = _cache["Get"] as ObjectsTemplate<Employee>;
|
|||
|
if (employees != null)
|
|||
|
return employees;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.Get(tc, payrollTypeID));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "Get");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<Employee> GetForSuperUser()
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = _cache["Get"] as ObjectsTemplate<Employee>;
|
|||
|
if (employees != null)
|
|||
|
return employees;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.GetForSuperUser(tc));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "Get");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<Employee> GetAllEmps()
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = _cache["Get"] as ObjectsTemplate<Employee>;
|
|||
|
if (employees != null)
|
|||
|
return employees;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.GetAllEmps(tc));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "Get");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetCashAdvice(string sEmpIDs, string dSalDate)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = EmployeeDA.GetCashAdvice(tc, sEmpIDs, dSalDate);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<Employee> GetJoiningData(DateTime formDate)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = _cache["Get"] as ObjectsTemplate<Employee>;
|
|||
|
if (employees != null)
|
|||
|
return employees;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.GetJoiningData(tc, formDate));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "Get");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<Employee> GetWithDiscontinue(int payrollTypeID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = _cache["GetWithDiscontinue"] as ObjectsTemplate<Employee>;
|
|||
|
if (employees != null)
|
|||
|
return employees;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.GetWithDiscontinue(tc, payrollTypeID));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "GetWithDiscontinue");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
|
|||
|
//for Attendance Process
|
|||
|
public ObjectsTemplate<Employee> GetAbsentEmp(DateTime attnDate, EnumWorkPlanGroup wpGroup, int payrollTypeID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = _cache["GetAbsentEmp", attnDate, wpGroup] as ObjectsTemplate<Employee>;
|
|||
|
if (employees != null)
|
|||
|
return employees;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.GetAbsentEmp(tc, attnDate, wpGroup, payrollTypeID));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "GetAbsentEmp", attnDate, wpGroup);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<Employee> GetAttendaceEmp(EnumWorkPlanGroup wpGroup, int payrollTypeID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = _cache["GetAttendaceEmp", wpGroup] as ObjectsTemplate<Employee>;
|
|||
|
if (employees != null)
|
|||
|
return employees;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.GetAttendaceEmp(tc, wpGroup, payrollTypeID));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "GetAttendaceEmp", wpGroup);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<Employee> GetEmpExceptAutoWP(DateTime attnDate, int payrollTypeID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = _cache["GetEmpExceptAutoWP", attnDate] as ObjectsTemplate<Employee>;
|
|||
|
if (employees != null)
|
|||
|
return employees;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.GetEmpExceptAutoWP(tc, attnDate, payrollTypeID));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "GetEmpExceptAutoWP", attnDate);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<Employee> GetDiscontinueEmp(DateTime attnDate, DateTime currentDate, int payrollTypeID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = _cache["GetDiscontinueEmp", attnDate, currentDate] as ObjectsTemplate<Employee>;
|
|||
|
if (employees != null)
|
|||
|
return employees;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.GetDiscontinueEmp(tc, attnDate, currentDate, payrollTypeID));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "GetDiscontinueEmp", attnDate, currentDate);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
//
|
|||
|
|
|||
|
public ObjectsTemplate<Employee> Get(int status, DateTime lastDateOfYear)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = _cache["Get"] as ObjectsTemplate<Employee>;
|
|||
|
if (employees != null)
|
|||
|
return employees;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.Get(tc, status, lastDateOfYear));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "Get");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
|
|||
|
public DataTable GetEmpIDsOfManager(int status, DateTime lastDateOfYear)
|
|||
|
{
|
|||
|
DataTable dataTableOfEmployee = new DataTable("Employee");
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataSet dataSet = EmployeeDA.GetEmpIDsOfManager(tc, status, lastDateOfYear);
|
|||
|
dataTableOfEmployee = dataSet.Tables[0];
|
|||
|
dataSet.Dispose();
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return dataTableOfEmployee;
|
|||
|
}
|
|||
|
public List<EmployeesCurrentPosition> GetEmployeeCurrentPosition()
|
|||
|
{
|
|||
|
List<EmployeesCurrentPosition> oPositions = new List<EmployeesCurrentPosition>();
|
|||
|
|
|||
|
DataTable dataTableOfEmployee = new DataTable("EmployeeCurrentPosition");
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataSet dataSet = EmployeeDA.GetCurPos(tc);
|
|||
|
tc.End();
|
|||
|
|
|||
|
//SqlCommand command = new SqlCommand("sp_EmpCurrentPosition", connection);
|
|||
|
//command.CommandType = System.Data.CommandType.StoredProcedure;
|
|||
|
//connection.Open();
|
|||
|
dataTableOfEmployee = dataSet.Tables[0];
|
|||
|
//connection.Close();
|
|||
|
|
|||
|
foreach (DataRow dr in dataTableOfEmployee.Rows)
|
|||
|
{
|
|||
|
EmployeesCurrentPosition item = new EmployeesCurrentPosition();
|
|||
|
item.EmployeeID = Convert.ToInt32(dr[0].ToString());
|
|||
|
item.CurrentPosition = dr[1].ToString();
|
|||
|
item.Level1 = dr[1].ToString();
|
|||
|
item.Level2 = dr[1].ToString();
|
|||
|
item.Level3 = dr[1].ToString();
|
|||
|
item.Level4 = dr[1].ToString();
|
|||
|
item.Level5 = dr[1].ToString();
|
|||
|
item.Level6 = dr[1].ToString();
|
|||
|
oPositions.Add(item);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return oPositions;
|
|||
|
|
|||
|
}
|
|||
|
public DataTable GetOldEmp()
|
|||
|
{
|
|||
|
DataTable dataTableOfEmployee = new DataTable("Employee");
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataSet dataSet = EmployeeDA.GetOldEmp(tc);
|
|||
|
dataTableOfEmployee = dataSet.Tables[0];
|
|||
|
dataSet.Dispose();
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return dataTableOfEmployee;
|
|||
|
}
|
|||
|
public DataTable GetAllEmp()
|
|||
|
{
|
|||
|
DataTable dataTableOfEmployee = new DataTable("AllEmployee");
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataSet dataSet = EmployeeDA.GetAllEmp(tc);
|
|||
|
dataTableOfEmployee = dataSet.Tables[0];
|
|||
|
dataSet.Dispose();
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return dataTableOfEmployee;
|
|||
|
}
|
|||
|
public ObjectsTemplate<Employee> GetEmpsWithDiscontinue(string empIDs, int payrollTypeID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = _cache["GetEmpsWithDiscontinue", empIDs] as ObjectsTemplate<Employee>;
|
|||
|
if (employees != null)
|
|||
|
return employees;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.GetEmpsWithDiscontinue(tc, empIDs, payrollTypeID));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "GetEmpsWithDiscontinue", empIDs);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<Employee> GetByEmpIDs(string empIDs, int payrollTypeID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = _cache["GetByEmpIDs", empIDs] as ObjectsTemplate<Employee>;
|
|||
|
if (employees != null)
|
|||
|
return employees;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.GetByEmpIDs(tc, empIDs, payrollTypeID));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "GetByEmpIDs", empIDs);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
public ObjectsTemplate<Employee> GetNew(DateTime dt, int payrollTypeID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = _cache["Get"] as ObjectsTemplate<Employee>;
|
|||
|
if (employees != null)
|
|||
|
return employees;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.GetNew(tc, dt, payrollTypeID));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "Get");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
public ObjectsTemplate<Employee> GetFssEmp(string empIDs, int payrollTypeID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Employee> employees = _cache["GetFssEmp", empIDs] as ObjectsTemplate<Employee>;
|
|||
|
if (employees != null)
|
|||
|
return employees;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeDA.GetFssEmp(tc, empIDs, payrollTypeID));
|
|||
|
employees = this.CreateObjects<Employee>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(employees, "GetFssEmp", empIDs);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
|
|||
|
public string GenerateLoanNo(Employee oEmp, string sLoanName)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
int? nLoanID = 0;
|
|||
|
string sLoanNo = string.Empty;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(LoanIssueDA.GetMaxLoanIssueID(tc, oEmp.ID));
|
|||
|
if (dr.Read())
|
|||
|
{
|
|||
|
nLoanID = dr.GetInt32(0).HasValue ? dr.GetInt32(0).Value : 0;
|
|||
|
}
|
|||
|
dr.Close();
|
|||
|
|
|||
|
if (nLoanID == null)
|
|||
|
{
|
|||
|
nLoanID = 0;
|
|||
|
}
|
|||
|
|
|||
|
dr = new DataReader(LoanIssueDA.GetLoanNo(tc, oEmp.ID, nLoanID));
|
|||
|
if (dr.Read())
|
|||
|
{
|
|||
|
sLoanNo = dr.GetString(0);
|
|||
|
}
|
|||
|
nLoanID = 1;
|
|||
|
if (sLoanNo.Length > 3)
|
|||
|
{
|
|||
|
nLoanID = Convert.ToInt32(sLoanNo.Substring(sLoanNo.Length - 3, 3));
|
|||
|
}
|
|||
|
|
|||
|
dr.Close();
|
|||
|
nLoanID = nLoanID + 1;
|
|||
|
//sLoanName
|
|||
|
sLoanNo = "Loan" + "//" + oEmp.EmployeeNo + "/" + nLoanID.ToString().PadLeft(3, '0');
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return sLoanNo;
|
|||
|
}
|
|||
|
|
|||
|
//Save For Excel Data
|
|||
|
public void SaveBasicInfo(Employee oEmployee)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oEmployee.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("Employee", "EmployeeID");
|
|||
|
base.SetObjectID(oEmployee, ID.FromInteger(id));
|
|||
|
EmployeeDA.Insert(tc, oEmployee);
|
|||
|
tc.End();
|
|||
|
if (oEmployee.EmployeeGradeSalary != null)
|
|||
|
{
|
|||
|
oEmployee.EmployeeGradeSalary.EmployeeID = oEmployee.ID;
|
|||
|
oEmployee.EmployeeGradeSalary.GradeSalaryTypeID = ID.FromInteger(1);
|
|||
|
oEmployee.EmployeeGradeSalary.EffectDate = SystemInformation.CurrentSysInfo.LastPayProcessDate;
|
|||
|
|
|||
|
}
|
|||
|
if (oEmployee.EmployeeBankAccount != null)
|
|||
|
{
|
|||
|
oEmployee.EmployeeBankAccount.EmployeeID = oEmployee.ID;
|
|||
|
oEmployee.EmployeeBankAccount.EffectDate = SystemInformation.CurrentSysInfo.LastPayProcessDate;
|
|||
|
}
|
|||
|
if (oEmployee.EmployeePosting != null)
|
|||
|
{
|
|||
|
oEmployee.EmployeePosting.EmployeeID = oEmployee.ID;
|
|||
|
oEmployee.EmployeePosting.EffectDate = SystemInformation.CurrentSysInfo.LastPayProcessDate;
|
|||
|
}
|
|||
|
|
|||
|
oEmployee.EmployeeGradeSalary.Save();
|
|||
|
oEmployee.EmployeeBankAccount.Save();
|
|||
|
oEmployee.EmployeePosting.Save();
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmployeeDA.Update(tc, oEmployee);
|
|||
|
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 SaveShortInfo(ObjectsTemplate<Employee> items)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
foreach (Employee oEmployee in items)
|
|||
|
{
|
|||
|
EmployeeDA.UpdateShortInfo(tc, oEmployee);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public ID Save(Employee oEmployee)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oEmployee.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("Employee", "EmployeeID");
|
|||
|
base.SetObjectID(oEmployee, ID.FromInteger(id));
|
|||
|
EmployeeDA.Insert(tc, oEmployee);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmployeeDA.Update(tc, oEmployee);
|
|||
|
}
|
|||
|
tc.End();
|
|||
|
return oEmployee.ID;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
public void SaveIntegration(ObjectsTemplate<Employee> oEmps)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
int nn = 1;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
foreach (Employee oEmployee in oEmps)
|
|||
|
{
|
|||
|
//if (nn == 63)
|
|||
|
// nn = 63;
|
|||
|
if (oEmployee.EmployeeNo == "") continue;
|
|||
|
if (oEmployee.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("Employee", "EmployeeID");
|
|||
|
base.SetObjectID(oEmployee, ID.FromInteger(id));
|
|||
|
//oEmployee.PayrollTypeID = ID.FromInteger(1);
|
|||
|
EmployeeDA.Insert(tc, oEmployee);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmployeeDA.Update(tc, oEmployee);
|
|||
|
}
|
|||
|
//Save Life cycle
|
|||
|
EmpLifeCycleService lcService = new EmpLifeCycleService();
|
|||
|
oEmployee.EmpLifeCycle.EmployeeID = oEmployee.ID;
|
|||
|
oEmployee.EmpLifeCycle.CreatedBy = Payroll.BO.User.CurrentUser.ID;
|
|||
|
oEmployee.EmpLifeCycle.CreatedDate = DateTime.Now;
|
|||
|
lcService.SaveIntegration(oEmployee.EmpLifeCycle, tc,oEmployee);
|
|||
|
//Save Employee Account History
|
|||
|
if (oEmployee.EmployeeBankAccount.AccountNo != "")
|
|||
|
{
|
|||
|
EmployeeBankAccountService ebaService = new EmployeeBankAccountService();
|
|||
|
oEmployee.EmployeeBankAccount.EmployeeID = oEmployee.ID;
|
|||
|
oEmployee.EmployeeBankAccount.CreatedBy = Payroll.BO.User.CurrentUser.ID;
|
|||
|
oEmployee.EmployeeBankAccount.CreatedDate = DateTime.Now; ;
|
|||
|
oEmployee.EmployeeBankAccount.BranchID = oEmployee.BranchID;
|
|||
|
if (oEmployee.EmployeeBankAccount.EffectDate != DateTime.MinValue)
|
|||
|
ebaService.SaveIntegration(oEmployee.EmployeeBankAccount, tc);
|
|||
|
}
|
|||
|
nn++;
|
|||
|
}
|
|||
|
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 BulkSave(List<SuccessorErrorList> items)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataTable processTable = new DataTable("SuccessorErrorList");
|
|||
|
processTable.Columns.Add(new DataColumn("RowNo", typeof(Int32)));
|
|||
|
processTable.Columns.Add(new DataColumn("EmployeeNo", typeof(string)));
|
|||
|
processTable.Columns.Add(new DataColumn("Message", typeof(string)));
|
|||
|
processTable.Columns.Add(new DataColumn("Status", typeof(string)));
|
|||
|
processTable.Columns.Add(new DataColumn("UploadDate", typeof(DateTime)));
|
|||
|
|
|||
|
|
|||
|
foreach (SuccessorErrorList item in items)
|
|||
|
{
|
|||
|
processTable.Rows.Add(item.RowNo.Integer,item.EmployeeNo,item.Message,item.Status.ToString(),item.UploadDate);
|
|||
|
}
|
|||
|
|
|||
|
using (SqlBulkCopy bulkCopy = new SqlBulkCopy((SqlConnection)tc.Connection))
|
|||
|
{
|
|||
|
bulkCopy.BulkCopyTimeout = 600; // in seconds
|
|||
|
|
|||
|
bulkCopy.DestinationTableName = "SuccessorErrorList";
|
|||
|
bulkCopy.WriteToServer(processTable);
|
|||
|
}
|
|||
|
tc.End();
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
}
|
|||
|
}
|
|||
|
public void Delete(ID id)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
EmployeeDA.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
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DeleteAll()
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
EmployeeDA.DeleteAll(tc);
|
|||
|
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 UpdateStatus(ID employeeID, ID historyID, DateTime effectDate, EnumEmployeeStatus status)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
EmployeeDA.UpdateStatus(tc, employeeID, historyID, effectDate, status);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
public void UpdateCardInformation(ID employeeID, ID CardID, bool IsAutoProcess)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
EmployeeDA.UpdateCardInformation(tc, employeeID, CardID, IsAutoProcess);
|
|||
|
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 UpdateCardInformation(TransactionContext tc, ID employeeID, ID CardID, bool IsAutoProcess)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
EmployeeDA.UpdateCardInformation(tc, employeeID, CardID, IsAutoProcess);
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void UpdatePFMemship(ID empID, EnumPFMembershipType PFType, DateTime dPFEffectDate)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
EmployeeDA.UpdatePFMemship(tc, empID, PFType, dPFEffectDate);
|
|||
|
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 UpdateTaxAmount(ID employeeID, double TaxAmount)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
EmployeeDA.UpdateTaxAmount(tc, employeeID, TaxAmount);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
public void UpdateEmpRole(Employee oEmp)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
EmployeeDA.UpdateEmpRole(tc, oEmp);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
public void DoConfirm(ID employeeID, DateTime confirmDate, DateTime pfMShipDate, bool IsConfirm, bool IsPFMember)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
EmployeeDA.DoConfirm(tc, employeeID, confirmDate, pfMShipDate, IsConfirm, IsPFMember);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
public void UndoConfirm(ID employeeID, bool IsConfirm)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
EmployeeDA.UndoConfirm(tc, employeeID, IsConfirm);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
public void UpdatePayrollType(ID employeeID, ID payrollTypeID, DateTime dEffectDate)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
EmployeeDA.UpdatePayrollType(tc, employeeID, payrollTypeID, dEffectDate);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public void UpdateBankAcc(TransactionContext tc, ID employeeID, ID branchid, string accountNo, EnumPaymentMode paymentMode)
|
|||
|
{
|
|||
|
EmployeeDA.UpdateBankAcc(tc, employeeID, branchid, accountNo, paymentMode);
|
|||
|
}
|
|||
|
|
|||
|
public void UpdateOPIBankAcc(TransactionContext tc, ID employeeID, ID branchid, string accountNo, EnumPaymentMode paymentMode)
|
|||
|
{
|
|||
|
EmployeeDA.UpdateOPIBankAcc(tc, employeeID, branchid, accountNo, paymentMode);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public DataSet GetEmpBasicInfo(string sEmpID)
|
|||
|
{
|
|||
|
DataSet oEmpBasicInfos = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oEmpBasicInfos = EmployeeDA.GetEmpBasicInfo(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 oEmpBasicInfos;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetLineManager(int sEmpID)
|
|||
|
{
|
|||
|
DataSet oLineManager = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oLineManager = EmployeeDA.GetLineManager(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 oLineManager;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetDivision(int nEmpID)
|
|||
|
{
|
|||
|
DataSet oEmpBasicInfos = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oEmpBasicInfos = EmployeeDA.GetDivision(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 oEmpBasicInfos;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetEmpDetails(string sEmpID)
|
|||
|
{
|
|||
|
DataSet oEmpDetails = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oEmpDetails = EmployeeDA.GetEmpDetails(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 oEmpDetails;
|
|||
|
}
|
|||
|
|
|||
|
//public DataSet GetEmployeeCV(string sEmpID)
|
|||
|
//{
|
|||
|
// DataSet oEmpCV = new DataSet();
|
|||
|
// TransactionContext tc = null;
|
|||
|
// try
|
|||
|
// {
|
|||
|
// tc = TransactionContext.Begin();
|
|||
|
// oEmpCV = EmployeeDA.GetEmployeeCV(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 oEmpCV;
|
|||
|
//}
|
|||
|
|
|||
|
public DataSet GetEmpForLetterOfIntroDuction(string sEmpID, DateTime month)
|
|||
|
{
|
|||
|
DataSet oEmpDetails = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oEmpDetails = EmployeeDA.GetEmpForLetterOfIntroduction(tc, sEmpID, month);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return oEmpDetails;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetEmpPosting(string sEmpID)
|
|||
|
{
|
|||
|
DataSet oEmpPostings = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oEmpPostings = EmployeeDA.GetEmpPosting(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 oEmpPostings;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetEmpBasicInfoForPSlip(string sEmpID)
|
|||
|
{
|
|||
|
DataSet empBasicInfoForPSlipDSet = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
empBasicInfoForPSlipDSet = EmployeeDA.GetEmpBasicInfoForPSlip(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 empBasicInfoForPSlipDSet;
|
|||
|
}
|
|||
|
public DataSet GetEmpBasicInfoForPSlipNew(string sEmpID,DateTime dt)
|
|||
|
{
|
|||
|
DataSet empBasicInfoForPSlipDSet = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
empBasicInfoForPSlipDSet = EmployeeDA.GetEmpBasicInfoForPSlip(tc, sEmpID, dt);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return empBasicInfoForPSlipDSet;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetEmpConfirmHis(DateTime dEffectDate, DateTime dEffectDate2, int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet oEmpConfirms = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oEmpConfirms = EmployeeDA.GetEmpConfirmHis(tc, dEffectDate, dEffectDate2, 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 oEmpConfirms;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetEmpPFHis(DateTime dEffectDate)
|
|||
|
{
|
|||
|
DataSet oEmpConfirms = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oEmpConfirms = EmployeeDA.GetEmpPFHis(tc, dEffectDate);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return oEmpConfirms;
|
|||
|
}
|
|||
|
public DataSet GetEmpGradeSalaryChangeInfo(DateTime datefrom, DateTime dateTo, string selection)
|
|||
|
{
|
|||
|
DataSet changedinfo = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
changedinfo = EmployeeDA.GetEmpGradeSalaryChangeInfo(tc, datefrom, dateTo, selection);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
throw new Exception(ex.Message);
|
|||
|
}
|
|||
|
return changedinfo;
|
|||
|
|
|||
|
}
|
|||
|
public DataSet GetEmpJoining(DateTime dEffectDate, DateTime dEffectDate2)
|
|||
|
{
|
|||
|
DataSet oEmpConfirms = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oEmpConfirms = EmployeeDA.GetEmpJoining(tc, dEffectDate, dEffectDate2);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return oEmpConfirms;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetEmpJoining4Novartis(DateTime dEffectDate, int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet oEmpJoining = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oEmpJoining = EmployeeDA.GetEmpJoining4Novartis(tc, dEffectDate, 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 oEmpJoining;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public int GetDays(int nPayrollTypeID)
|
|||
|
{
|
|||
|
int nDays = 0;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
nDays = EmployeeDA.GetDays(tc, nPayrollTypeID);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return nDays;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
public DataSet GetByMonthStartMonthEndForContinueFromDiscontinue(DateTime startmonth, DateTime endmonth, int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet allData = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
allData = EmployeeDA.GetByMonthStartMonthEndForContinueFromDiscontinue(tc, startmonth, endmonth, 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 allData;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public DataSet GetITAndBasic(DateTime startmonth, DateTime endmonth)
|
|||
|
{
|
|||
|
DataSet allData = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
allData = EmployeeDA.GetITAndBasic(tc, startmonth, endmonth);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return allData;
|
|||
|
}
|
|||
|
|
|||
|
//For Excel Upload
|
|||
|
public static void SaveForUpload(TransactionContext tc, ObjectsTemplate<Employee> employees)
|
|||
|
{
|
|||
|
string empNo = "";
|
|||
|
try
|
|||
|
{
|
|||
|
foreach (Employee oEmployee in employees)
|
|||
|
{
|
|||
|
empNo = oEmployee.EmployeeNo;
|
|||
|
if (oEmployee.IsNew)
|
|||
|
{
|
|||
|
|
|||
|
oEmployee.CreatedBy = User.CurrentUser.ID;
|
|||
|
oEmployee.CreatedDate = DateTime.Today;
|
|||
|
EmployeeDA.Insert(tc, oEmployee);
|
|||
|
|
|||
|
foreach (EmployeeGradeSalary item in oEmployee.EmployeeGradeSalarys)
|
|||
|
{
|
|||
|
item.EmployeeID = oEmployee.ID;
|
|||
|
item.CreatedBy = User.CurrentUser.ID;
|
|||
|
item.CreatedDate = DateTime.Today;
|
|||
|
EmployeeGradeSalaryDA.Insert(tc, item);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
if (oEmployee.BranchID != null)
|
|||
|
{
|
|||
|
(new EmployeeService()).SetObjectID(oEmployee.EmployeeBankAccount, ID.FromInteger(tc.GenerateID("BANKACCOUNTHISTORY", "EmpBankAccountID")));
|
|||
|
oEmployee.EmployeeBankAccount.EmployeeID = oEmployee.ID;
|
|||
|
oEmployee.EmployeeBankAccount.CreatedBy = User.CurrentUser.ID;
|
|||
|
oEmployee.EmployeeBankAccount.CreatedDate = DateTime.Today;
|
|||
|
EmployeeBankAccountDA.Insert(tc, oEmployee.EmployeeBankAccount);
|
|||
|
}
|
|||
|
|
|||
|
if (oEmployee.OutPayBranchID != null)
|
|||
|
{
|
|||
|
(new EmployeeService()).SetObjectID(oEmployee.EmployeeOPIBankAccount, ID.FromInteger(tc.GenerateID("BANKACCOUNTHISTORY", "EmpBankAccountID")));
|
|||
|
oEmployee.EmployeeOPIBankAccount.EmployeeID = oEmployee.ID;
|
|||
|
oEmployee.EmployeeOPIBankAccount.CreatedBy = User.CurrentUser.ID;
|
|||
|
oEmployee.EmployeeOPIBankAccount.CreatedDate = DateTime.Today;
|
|||
|
EmployeeBankAccountDA.Insert(tc, oEmployee.EmployeeOPIBankAccount);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmployeeDA.Update(tc, oEmployee);
|
|||
|
}
|
|||
|
EmployeeDA.UpdateOTFlag(tc,oEmployee.ID.Integer);
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message + " Employee ID:" + empNo, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<Employee> GetEmployeesYetNotAssigned()
|
|||
|
{
|
|||
|
ObjectsTemplate<Employee> notAssignedEmployees = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(EmployeeDA.GetEmployeesYetNotAssigned(tc));
|
|||
|
//if (oreader.Read())
|
|||
|
//{
|
|||
|
notAssignedEmployees = this.CreateObjects<Employee>(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 notAssignedEmployees;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<Employee> GetSubordinates(ID employeeID)
|
|||
|
{
|
|||
|
ObjectsTemplate<Employee> oEmployees = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
|
|||
|
DataReader oreader = new DataReader(EmployeeDA.GetSubordinates(tc, employeeID));
|
|||
|
|
|||
|
oEmployees = this.CreateObjects<Employee>(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 oEmployees;
|
|||
|
|
|||
|
}
|
|||
|
private string recure(string subQuery, int level)
|
|||
|
{
|
|||
|
if (level == 0)
|
|||
|
{
|
|||
|
return subQuery;
|
|||
|
}
|
|||
|
return "Select OrganogramID From Organogram Where ParentID IN ("
|
|||
|
+ recure(subQuery + "", level - 1) + ")";
|
|||
|
}
|
|||
|
public ObjectsTemplate<Employee> GetAllSubordinates(ID nodeID)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
ObjectsTemplate<Employee> employees = null;
|
|||
|
string sql = string.Empty;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
OrganogramBasic ogBasic = OrganogramBasic.Get(nodeID);
|
|||
|
OrganogramService osv = new OrganogramService();
|
|||
|
int maxLevel = osv.GetMaxTier(tc);
|
|||
|
|
|||
|
if (ogBasic != null)
|
|||
|
{
|
|||
|
string subQuery = "Select OrganogramID From Organogram Where ParentID=" + nodeID.ToString();
|
|||
|
for (int i = 0; i <= maxLevel - ogBasic.Tier; i++)
|
|||
|
{
|
|||
|
if (sql.Length > 0) sql += " UNION ";
|
|||
|
sql = sql + recure(subQuery, i);
|
|||
|
}
|
|||
|
sql = "Select Employee.* From OrganEmployee , Employee Where OrganEmployee.NodeID In " +
|
|||
|
"(" + sql + ")" +
|
|||
|
"AND OrganEmployee.EmployeeID IS NOT NULL AND OrganEmployee.EmployeeID = Employee.EmployeeID AND Employee.Status =1";
|
|||
|
|
|||
|
|
|||
|
DataReader oreader = new DataReader(EmployeeDA.GetSubordinates(tc, sql));
|
|||
|
employees = this.CreateObjects<Employee>(oreader);
|
|||
|
oreader.Close();
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
|
|||
|
return employees;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException("Failed to Get Subordinates", e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
public string GetQueryForAllSubordinates(ID nodeID)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
string query = null;
|
|||
|
string sql = string.Empty;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
OrganogramBasic ogBasic = OrganogramBasic.Get(nodeID);
|
|||
|
OrganogramService osv = new OrganogramService();
|
|||
|
int maxLevel = osv.GetMaxTier(tc);
|
|||
|
|
|||
|
if (ogBasic != null)
|
|||
|
{
|
|||
|
string subQuery = "Select OrganogramID From Organogram Where ParentID=" + nodeID.ToString();
|
|||
|
for (int i = 0; i <= maxLevel - ogBasic.Tier; i++)
|
|||
|
{
|
|||
|
if (sql.Length > 0) sql += " UNION ";
|
|||
|
sql = sql + recure(subQuery, i);
|
|||
|
}
|
|||
|
sql = "Select Employee.EmployeeID From OrganEmployee , Employee Where OrganEmployee.NodeID In " +
|
|||
|
"(" + sql + ")" +
|
|||
|
"AND OrganEmployee.EmployeeID IS NOT NULL AND OrganEmployee.EmployeeID = Employee.EmployeeID AND Employee.Status =1";
|
|||
|
|
|||
|
|
|||
|
|
|||
|
query = sql;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
|
|||
|
return query;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException("Failed to Get Subordinates", e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<Employee> GetEmployeesByJoiningMonth(DateTime fromDate, DateTime toDate)
|
|||
|
{
|
|||
|
ObjectsTemplate<Employee> oEmployeesByJoiningMonth = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(EmployeeDA.GetEmployeesByJoiningMonth(tc, fromDate, toDate));
|
|||
|
|
|||
|
oEmployeesByJoiningMonth = this.CreateObjects<Employee>(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 oEmployeesByJoiningMonth;
|
|||
|
}
|
|||
|
|
|||
|
public DataTable GetDesignationWiseEmployeeCountsByDepartmentID(ID departmentID)
|
|||
|
{
|
|||
|
DataSet designationWiseCountDS = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
designationWiseCountDS = EmployeeDA.GetDesignationWiseEmployeeCountsByDepartmentID(tc, departmentID.Integer);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return designationWiseCountDS.Tables[0];
|
|||
|
}
|
|||
|
public DataTable GetDFSL()
|
|||
|
{
|
|||
|
DataSet designationWiseCountDS = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
designationWiseCountDS = EmployeeDA.GetDFSL(tc);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return designationWiseCountDS.Tables[0];
|
|||
|
}
|
|||
|
|
|||
|
public DataTable GetGradeWiseEmployeeCountsByDepartmentID(ID departmentID)
|
|||
|
{
|
|||
|
DataSet gradeWiseCountDS = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
gradeWiseCountDS = EmployeeDA.GetGradeWiseEmployeeCountsByDepartmentID(tc, departmentID.Integer);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return gradeWiseCountDS.Tables[0];
|
|||
|
}
|
|||
|
|
|||
|
public DataTable GetGradeWiseEmployeeCounts()
|
|||
|
{
|
|||
|
DataSet gradeWiseCountDS = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
gradeWiseCountDS = EmployeeDA.GetGradeWiseEmployeeCounts(tc);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return gradeWiseCountDS.Tables[0];
|
|||
|
}
|
|||
|
public Employee Get4Web(string employeeNo)
|
|||
|
{
|
|||
|
Employee oEmployee = new Employee();
|
|||
|
#region Cache Header
|
|||
|
oEmployee = _cache["Get", employeeNo] as Employee;
|
|||
|
if (oEmployee != null)
|
|||
|
return oEmployee;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(EmployeeDA.Get4Web(tc, employeeNo));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oEmployee = this.CreateObject<Employee>(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
|
|||
|
}
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oEmployee, "Get", employeeNo);
|
|||
|
#endregion
|
|||
|
return oEmployee;
|
|||
|
}
|
|||
|
|
|||
|
public Employee GetDepartmentHead(EnumOGPositionType type, ID departmentID)
|
|||
|
{
|
|||
|
Employee oEmployee = new Employee();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(EmployeeDA.GetDepartmentHead(tc, type, departmentID));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oEmployee = this.CreateObject<Employee>(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 oEmployee;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
public DataSet GetRCAssignedEmp()
|
|||
|
{
|
|||
|
DataSet allData = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
allData = EmployeeDA.GetRCAssignedEmp(tc);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return allData;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public DataSet GetRCNotAssignedEmp()
|
|||
|
{
|
|||
|
DataSet allData = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
allData = EmployeeDA.GetRCNotAssignedEmp(tc);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return allData;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetUploadedComponents(DateTime firstDate, DateTime lastDate)
|
|||
|
{
|
|||
|
DataSet allData = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
allData = EmployeeDA.GetUploadedComponents(tc, firstDate, lastDate);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return allData;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetUploadedComponentDetails(int uploadedComponentId)
|
|||
|
{
|
|||
|
DataSet allData = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
allData = EmployeeDA.GetUploadedComponentDetails(tc, uploadedComponentId);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return allData;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|