using HRM.BO; using Ease.Core.DataAccess; using Ease.Core.Model; using Ease.Core.Utility; using System; using System.Collections.Generic; using System.Linq; using HRM.Service; using System.Data; namespace HRM.DA { #region EmpLeaveStatus Service public class EmpLeaveStatusService : ServiceTemplate//, ILeaveProcessService { public EmpLeaveStatusService() { } //#region Private functions and declaration ////Cache _cache = new Cache(typeof(EmpLeaveStatus)); private void MapObject(EmpLeaveStatus oEmpLeaveStatus, DataReader oReader) { //this.SetObjectID(oEmpLeaveStatus,ID.FromInteger(oReader.GetInt32("TranId"))); base.SetObjectID(oEmpLeaveStatus, oReader.GetInt32("TranId").Value); oEmpLeaveStatus.ProcessId = oReader.GetInt32("ProcessId").Value; oEmpLeaveStatus.EmpId = oReader.GetInt32("EmpId").Value; oEmpLeaveStatus.LeaveYearID = oReader.GetInt32("LEAVEYEARID").Value; oEmpLeaveStatus.LeaveId = oReader.GetInt32("LeaveId").Value; //oEmpLeaveStatus.GradeId = oReader.GetInt32("GradeId"); //oEmpLeaveStatus.ParamId = oReader.GetInt32("ParamId"); oEmpLeaveStatus.CarryFromPrvYear = oReader.GetDouble("CarryFromPrvYear").Value; oEmpLeaveStatus.CFDays = oReader.GetDouble("CFDays").Value; oEmpLeaveStatus.EncashDays = oReader.GetDouble("EncashDays").Value; oEmpLeaveStatus.EncashAmount = oReader.GetDouble("EncashAmount").Value; oEmpLeaveStatus.NormalLeaveDays = oReader.GetDouble("NormalLeaveDays").Value; oEmpLeaveStatus.YearEndBalance = oReader.GetDouble("YearEndBalance").Value; oEmpLeaveStatus.LeaveAvailed = oReader.GetDouble("LEAVEAVAILED").Value; oEmpLeaveStatus.OpeningBalance = oReader.GetDouble("OPENINGBALANCE").Value; oEmpLeaveStatus.ForfitedDays = oReader.GetDouble("FORFITEDDAYS").Value; //this.SetObjectState(oEmpLeaveStatus, ObjectState.Saved); this.SetObjectState(oEmpLeaveStatus, Ease.Core.ObjectState.Saved); } //private EmpLeaveStatus CreateObject(NullHandler oReader) protected override T CreateObject(DataReader oReader) { EmpLeaveStatus oEmpLeaveStatus = new EmpLeaveStatus(); MapObject(oEmpLeaveStatus, oReader); return oEmpLeaveStatus as T; } protected EmpLeaveStatus CreateObject(DataReader oReader) { EmpLeaveStatus oEmpLeaveStatus = new EmpLeaveStatus(); MapObject(oEmpLeaveStatus, oReader); return oEmpLeaveStatus; } //#endregion //#region Service implementation private List CurrentYearStatusOptimized(Employee oEmployee, DateTime operationDate, int presentAttnCount, List oAppLeaveParams, LeaveYear oCurrYear, List oLeaveEntries, EnumLeaveStatus enumLeaveStatus, List oPrevStatuses, List ParamDetails, List oExceptions, List oNationalHolidays, DateTime NextPayProcessDate) { try { DateTime dCurrentDate = operationDate; DateTime from_Date = DateTime.MinValue; DateTime to_Date = DateTime.MinValue; List oCurrYearBalance = new List(); LeaveParameterDetail oDetail = null; foreach (LeaveParameter oItem in oAppLeaveParams) { EmpLeaveStatus oPrevStatus = null; EmpLeaveStatus oCurrStatus = new EmpLeaveStatus(); oCurrStatus.EmpId = oEmployee.ID; oCurrStatus.LeaveId = oItem.LeaveId; oCurrStatus.LeaveYearID = oCurrYear.ID; // int empId = oEmployee.ID; from_Date = Global.DateFunctions.FirstDateOfYear(operationDate); to_Date = Global.DateFunctions.LastDateOfYear(operationDate); if (oItem.LeaveId == 5) { DateTime SelectedMonth = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).LastDateOfMonth(); from_Date = new DateTime(to_Date.Year - 2, oEmployee.JoiningDate.Month, oEmployee.JoiningDate.Day); DataSet ds = new DailyAttnProcessService().GetEarnedLeaveOpening(oEmployee.ID, oItem.LeaveId, from_Date, to_Date); int dCurrectedDay = 0; if (DateTime.DaysInMonth(SelectedMonth.Year, SelectedMonth.Month) < oEmployee.JoiningDate.Day) dCurrectedDay = DateTime.DaysInMonth(SelectedMonth.Year, SelectedMonth.Month); else dCurrectedDay = oEmployee.JoiningDate.Day; DateTime JoiningDateBefore2YearsFromCurrentYear = new DateTime(SelectedMonth.Year, SelectedMonth.Month, dCurrectedDay).AddYears(-2);// new DateTime(DateTime.Today.Year- 2, item.JoiningDate.Month, item.JoiningDate.Day);// SelectedMonth.FirstDateOfMonth().AddYears(-2); DateTime FirstYearStartDate = JoiningDateBefore2YearsFromCurrentYear; DateTime FirstYearEndDate = JoiningDateBefore2YearsFromCurrentYear.AddYears(1).AddDays(-1); DateTime LastYearStartDate = JoiningDateBefore2YearsFromCurrentYear.AddYears(1); DateTime LastYearEndDate = JoiningDateBefore2YearsFromCurrentYear.AddYears(2).AddDays(-1); double secondYearLeaveAvailed = new LeaveEntryService().Get(oEmployee.ID, LastYearStartDate, LastYearEndDate, EnumLeaveStatus.Approved).Sum(x => x.ApprovedTotalDays); //ObjectsTemplate les = LeaveEncashment.GetByEmpIDs(oEmployee.ID.Integer.ToString(), FirstYearStartDate, FirstYearEndDate); if (ds != null && ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { oCurrStatus.OpeningBalance = Convert.ToDouble(dr[0].ToString()); oCurrStatus.LeaveAvailed = Convert.ToDouble(dr[1].ToString()); //secondYearLeaveAvailed; oCurrStatus.EncashDays = 0;// les==null?0:les.Sum(x=> Math.Round(x.EncashmentDays)); oCurrStatus.YearEndBalance = oCurrStatus.OpeningBalance - (oCurrStatus.LeaveAvailed + oCurrStatus.EncashDays); } } oCurrYearBalance.Add(oCurrStatus); } else { //ObjectsTemplate les = LeaveEntry.GetByLeaveID(oItem.LeaveId, empId, from_Date, to_Date); List les = oLeaveEntries.Where(le => le.LeaveID == oItem.LeaveId && le.EmpID == empId && le.ApprovedFromDate >= from_Date && le.ApprovedFromDate <= to_Date && le.ApprovedTotalDays > 0) .OrderByDescending(x => x.ApprovedFromDate) .ToList(); //double countDays = 0; //foreach (LeaveEntry le in les) //{ // countDays += le.AppliedTotalDays; //} //oCurrStatus.ApplyDays = countDays; oCurrStatus.ApplyDays = les.Sum(x => x.AppliedTotalDays); // if (oPrevStatuses != null) { oPrevStatus = oPrevStatuses.FirstOrDefault(el => el.LeaveId == oItem.LeaveId && el.EmpId == oEmployee.ID); //EmpLeaveStatus.GetPrvYearStatus(oCurrYear.ID.Integer, oItem.LeaveId, oEmployee.ID.Integer); } oDetail = new LeaveParameterService().GetApplicableForEmployee2(oEmployee, operationDate, ParamDetails, oItem.ID); //LeaveException oLeaveEx = oExceptions.Find(delegate(LeaveException el) { return el.LeaveID == oItem.LeaveId && el.EmployeeID == oEmployee.ID.Integer; }); //EmpLeaveStatus.GetPrvYearStatus(oCurrYear.ID.Integer, oItem.LeaveId, oEmployee.ID.Integer); LeaveException oLeaveEx = oExceptions.FirstOrDefault(el => el.LeaveID == oItem.LeaveId && el.EmployeeID == oEmployee.ID); //EmpLeaveStatus.GetPrvYearStatus(oCurrYear.ID.Integer, oItem.LeaveId, oEmployee.ID.Integer); if (oLeaveEx != null) { oCurrStatus.LeaveAvailed = oLeaveEntries.Where(le => le.LeaveID == oItem.LeaveId && le.EmpID == empId && le.LeaveYearId == oCurrYear.ID && le.ApprovedTotalDays > 0 && le.LeaveStatus == EnumLeaveStatus.Approved) .Sum(x => x.ApprovedTotalDays); oCurrStatus.OpeningBalance = oLeaveEx.OpeningBalance + oLeaveEx.MaxDays; oCurrStatus.YearEndBalance = oCurrStatus.OpeningBalance - oCurrStatus.LeaveAvailed; } else { if (oDetail != null) oCurrStatus.NormalLeaveDays = 0; else continue; //oItem.Details = new ObjectsTemplate(); //oItem.Details.Add(oDetail); #region calculate the current year balance if (oItem.ApplicableFor == LeaveApplicableType.Confirmed) { // No Fraction For Echo if (oEmployee.IsConfirmed == true) { oCurrStatus.CurrentYearBalance = Math.Round(GetOptimizedCurrentYearDays(oItem.CalculationType, oEmployee, dCurrentDate, presentAttnCount, oDetail, oCurrYear), 0); } else oCurrStatus.CurrentYearBalance = 0; } else { // No Fraction For Echo oCurrStatus.CurrentYearBalance = Math.Round(GetOptimizedCurrentYearDays(oItem.CalculationType, oEmployee, dCurrentDate, presentAttnCount, oDetail, oCurrYear), 0); } #endregion #region calculate leave availed in current year if (oLeaveEntries == null) oCurrStatus.LeaveAvailed = 0; else { var itemsInCart = from o in oLeaveEntries where o.EmpID == oEmployee.ID && o.LeaveID == oItem.LeaveId && o.LeaveYearId == oCurrYear.ID && (o.LeaveStatus == enumLeaveStatus || o.LeaveStatus == EnumLeaveStatus.Cancel_Request) select new { o.ApprovedTotalDays }; oCurrStatus.LeaveAvailed = itemsInCart.ToList().Select(c => c.ApprovedTotalDays).Sum(); } #endregion #region calculate the opening balance new //oCurrStatus.CurrentYearOpening = oPrevStatus == null ? 0 : oPrevStatus.YearEndBalance; oCurrStatus.CurrentYearOpening = oPrevStatus == null ? 0 : Math.Round(oPrevStatus.CFDays); oCurrStatus.OpeningBalance = oCurrStatus.CurrentYearBalance + oCurrStatus.CurrentYearOpening; if (oItem.MaxAccumulatedDays > 0) { // No Fraction For Echo oCurrStatus.OpeningBalance = Math.Round(oCurrStatus.OpeningBalance > oItem.MaxAccumulatedDays ? oItem.MaxAccumulatedDays : oCurrStatus.OpeningBalance, 0); //,1); } #endregion #region Calculate Year-End Balance oCurrStatus.YearEndBalance = 0; #region COMPENSATORY LEAVE based on Nation Holiday if (oItem.LeaveId == 7) { List oEmpDailAttnProcesses = new DailyAttnProcessService().Get(oEmployee.ID, NextPayProcessDate.FirstDateOfMonth(), NextPayProcessDate.LastDateOfMonth()); double nDays = 0; foreach (DailyAttnProcess dp in oEmpDailAttnProcesses) { if (dp.InTime != DateTime.MinValue) { AttnNationalHoliday nh = oNationalHolidays.Find(x => dp.AttnDate >= x.FromDate && dp.AttnDate <= x.ToDate); if (nh != null) nDays++; } } oCurrStatus.OpeningBalance = nDays; } #endregion if (oItem.Leave.IsBalanceCalculationNeeded == false) { oCurrStatus.NormalLeaveDays = 0; oCurrStatus.OpeningBalance = 0; } else { // No Fraction For Echo oCurrStatus.YearEndBalance = Math.Round(oCurrStatus.OpeningBalance - (oCurrStatus.ForfitedDays + oCurrStatus.LeaveAvailed), 0); // 1); } #endregion } if (oItem.Leave.IsBalanceCalculationNeeded) { if (oDetail.MaxCF > 0) { oCurrStatus.CFDays = oCurrStatus.YearEndBalance > oDetail.MaxCF ? oDetail.MaxCF : oCurrStatus.YearEndBalance; } oCurrYearBalance.Add(oCurrStatus); } } } return oCurrYearBalance; } catch (Exception exp) { //MessageBox.Show(oEmployee.EmployeeNo); throw new Exception(exp.Message); } } private static double GetOptimizedCurrentYearDays(EnumLeaveCalculationType eType, Employee emp, DateTime dCurrentDate, int presentAttnCount, LeaveParameterDetail oDetail, LeaveYear oCurrentYear) { double nTotalDays = 0; TimeSpan ts = new TimeSpan(); if (eType == EnumLeaveCalculationType.Yearly) { if (presentAttnCount > 0) { nTotalDays = (double)presentAttnCount / 18; } } else if (eType == EnumLeaveCalculationType.Yearly) { ts = (dCurrentDate - ((emp.JoiningDate > oCurrentYear.StartDate) ? emp.JoiningDate : Global.DateFunctions.FirstDateOfYear(dCurrentDate))) .Add(TimeSpan.FromDays(1)); nTotalDays = (oDetail.MaxDays * ts.Days) / 365; } else if (eType == EnumLeaveCalculationType.Yearly) { ts = (dCurrentDate - ((emp.JoiningDate > oCurrentYear.StartDate) ? emp.JoiningDate : Global.DateFunctions.FirstDateOfYear(dCurrentDate))) .Add(TimeSpan.FromDays(1)); if (ts.Days > 365) { nTotalDays = (double)oDetail.MaxDays; } // Else '0' , What?????????????????? } else if (eType == EnumLeaveCalculationType.Yearly) { ts = (Global.DateFunctions.LastDateOfYear(dCurrentDate) - Global.DateFunctions.FirstDateOfYear(dCurrentDate)).Add(TimeSpan.FromDays(1)); nTotalDays = (oDetail.MaxDays * ts.Days) / 365; } else if (eType == EnumLeaveCalculationType.Yearly) { ts = (Global.DateFunctions.LastDateOfYear(dCurrentDate) - ((emp.JoiningDate > oCurrentYear.StartDate) ? emp.JoiningDate : Global.DateFunctions.FirstDateOfYear(dCurrentDate))) .Add(TimeSpan.FromDays(1)); nTotalDays = (oDetail.MaxDays * ts.Days) / 365; } return Math.Round(nTotalDays, 0); } public List CurrentYearStatus(List oEmployees, LeaveYear lYear, DateTime operationDate, EnumLeaveStatus eStatus, DateTime NextPayProcessDate) { try { //UpdateprocessStatus("Collecting Leave Information ...."); if (operationDate.Date > lYear.EndDate) operationDate = lYear.EndDate.Date; DateTime oEmpOperationDate; List oCurrYearBalance = null; List oAllEmpsCurrYearBalance = new List(); LeaveYear oCurrYear = lYear; LeaveYear oPrvYear = new LeaveYearService().LastLeaveYear(oCurrYear); List setupTypes = new SetupDetailService().GetTypes(EnumParameterSetup.Leave); List setupDetails = new SetupDetailService().GetParameters(EnumParameterSetup.Leave); List leaveParamss = new LeaveParameterService().Get(); List leaveParamDetails = new LeaveParameterService().GetDetails(); List oLs = new LeaveEntryService().Get(oEmployees.CommaSeparatedIDs(), oCurrYear.ID, EnumLeaveStatus.Approved);// LeaveEntry.GetByLeaveYear(oCurrYear.ID.Integer); List oPrevStatuses = new LeaveProcessService().GetByYear(oPrvYear.ID); List oExceptions = new LeaveExceptionService().Get(lYear.StartDate, lYear.EndDate); DataTable oYearlyDailyAttnProcess = new DailyAttnProcessService().GetTypeWiseAttnCount(oEmployees.CommaSeparatedIDs(), Global.DateFunctions.FirstDateOfYear(operationDate), Global.DateFunctions.LastDateOfYear(operationDate), EnumAttendanceType.Present, EnumAttendanceType.Early, EnumAttendanceType.Late, EnumAttendanceType.Delay, EnumAttendanceType.OutSideDuty, EnumAttendanceType.HalfDay); List oNationalHolidays = new AttnNationalHolidayService().GetByMonth(oCurrYear.StartDate, oCurrYear.EndDate); DataRow dRow = null; int presentCount = 0; int nMax = oEmployees.Count; int ncc = 0; //UpdateProgressStatus(EnumProcessStatus.Start); foreach (Employee oEmp in oEmployees) { //UpdateProgressStatus(EnumProcessStatus.PerformStep); int nCount = ++ncc; if (nCount == 98) nCount = 98; //UpdateprocessStatus("Collecting Leave Information " + (nCount).ToString() + "/" + nMax); oEmpOperationDate = operationDate; if (oEmp.EndOfContractDate != null) { if (oEmp.EndOfContractDate < lYear.StartDate) continue; if (oEmp.EndOfContractDate.Value < operationDate) { oEmpOperationDate = oEmp.EndOfContractDate.Value; } } dRow = oYearlyDailyAttnProcess.AsEnumerable().FirstOrDefault(x => Convert.ToInt32(x["EmployeeID"].ToString()) == oEmp.ID); presentCount = dRow != null ? Convert.ToInt32(dRow["Count"].ToString()) : 0; List oAppLeaveParams = new LeaveParameterService().ApplicableParamsForReport(oEmp, setupTypes, setupDetails, leaveParamss); oCurrYearBalance = new EmpLeaveStatusService().CurrentYearStatusOptimized(oEmp, operationDate, presentCount, oAppLeaveParams, oCurrYear, oLs, eStatus, oPrevStatuses, leaveParamDetails, oExceptions, oNationalHolidays , NextPayProcessDate); foreach (EmpLeaveStatus eSts in oCurrYearBalance) { oAllEmpsCurrYearBalance.Add(eSts); } } //UpdateProgressStatus(EnumProcessStatus.End); //ProcessStatus = null; //ProgressStatus = null; return oAllEmpsCurrYearBalance; } catch (Exception exp) { // Nothing } return new List(); } //public EmpLeaveStatus Get(int id) //{ // EmpLeaveStatus oEmpLeaveStatus = new EmpLeaveStatus(); // #region Cache Header // oEmpLeaveStatus = (EmpLeaveStatus)_cache["Get", id]; // if (oEmpLeaveStatus != null) // return oEmpLeaveStatus; // #endregion // TransactionContext tc = null; // try // { // tc = TransactionContext.Begin(); // DataReader oreader = new DataReader(EmpLeaveStatusDA.Get(tc, id)); // if (oreader.Read()) // { // oEmpLeaveStatus = CreateObject(oreader); // } // oreader.Close(); // tc.End(); // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException("Failed to Get Employee Leave Status", e); // #endregion // } // #region Cache Footer // _cache.Add(oEmpLeaveStatus, "Get", id); // #endregion // return oEmpLeaveStatus; //} //public EmpLeaveStatus GetStatus(int empid, int leaveID, int leaveYearID) //{ // EmpLeaveStatus oEmpLeaveStatus = new EmpLeaveStatus(); // #region Cache Header // oEmpLeaveStatus = (EmpLeaveStatus)_cache["Get", empid, leaveID, leaveYearID]; // if (oEmpLeaveStatus != null) // return oEmpLeaveStatus; // #endregion // TransactionContext tc = null; // try // { // tc = TransactionContext.Begin(); // DataReader oreader = new DataReader(EmpLeaveStatusDA.GetStatus(tc, empid, leaveID, leaveYearID)); // if (oreader.Read()) // { // oEmpLeaveStatus = CreateObject(oreader); // } // oreader.Close(); // tc.End(); // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException("Failed to Get Employee Leave Status", e); // #endregion // } // #region Cache Footer // _cache.Add(oEmpLeaveStatus, "Get", empid, leaveID, leaveYearID); // #endregion // return oEmpLeaveStatus; //} //public EmpLeaveStatus GetByYear(int leaveyearID, int LeaveId, int EmpId) //{ // EmpLeaveStatus oEmpLeaveStatus = null; // TransactionContext tc = null; // try // { // tc = TransactionContext.Begin(); // DataReader oreader = new DataReader(EmpLeaveStatusDA.GetByYear(tc, leaveyearID, LeaveId, EmpId)); // if (oreader.Read()) // { // oEmpLeaveStatus = CreateObject(oreader); // } // oreader.Close(); // tc.End(); // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException("Failed to Get Employee Leave Status", e); // #endregion // } // return oEmpLeaveStatus; //} //public List GetByYear(int leaveyearID) //{ // #region Cache Header // List empLeaveStatuss = _cache["Get", leaveyearID] as List; // if (empLeaveStatuss != null) // return empLeaveStatuss; // #endregion // TransactionContext tc = null; // try // { // tc = TransactionContext.Begin(); // DataReader oreader = new DataReader(EmpLeaveStatusDA.GetByYear(tc, leaveyearID)); // empLeaveStatuss = this.CreateObjects(oreader); // oreader.Close(); // tc.End(); // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException("Failed to Get Employee Leave Status", e); // #endregion // } // #region Cache Footer // _cache.Add(empLeaveStatuss, "Get", leaveyearID); // #endregion // return empLeaveStatuss; //} //public List Get(int nProcessId) //{ // #region Cache Header // List empLeaveStatuss = _cache["Get", nProcessId] as List; // if (empLeaveStatuss != null) // return empLeaveStatuss; // #endregion // TransactionContext tc = null; // try // { // tc = TransactionContext.Begin(); // DataReader oReader = new DataReader(EmpLeaveStatusDA.GetByProcessId(tc, nProcessId)); // empLeaveStatuss = this.CreateObjects(oReader); // oReader.Close(); // tc.End(); // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException("Failed to Get Employee Leave Status", e); // #endregion // } // #region Cache Footer // _cache.Add(empLeaveStatuss, "Get", nProcessId); // #endregion // return empLeaveStatuss; //} //public List GetAllStatus(int empId) //{ // #region Cache Header // List empLeaveStatuss = _cache["Get", empId] as List; // if (empLeaveStatuss != null) // return empLeaveStatuss; // #endregion // TransactionContext tc = null; // try // { // tc = TransactionContext.Begin(); // DataReader oReader = new DataReader(EmpLeaveStatusDA.GetAllStatus(tc, empId)); // empLeaveStatuss = this.CreateObjects(oReader); // oReader.Close(); // tc.End(); // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException("Failed to Get Employee Leave Status", e); // #endregion // } // #region Cache Footer // _cache.Add(empLeaveStatuss, "Get", empId); // #endregion // return empLeaveStatuss; //} //public ID Insert(EmpLeaveStatus oEmpLeaveStatus) //{ // TransactionContext tc = null; // try // { // tc = TransactionContext.Begin(true); // if (oEmpLeaveStatus.IsNew) // { // int id = tc.GenerateID("EmpLeaveStatus", "TranId"); // base.SetObjectID(oEmpLeaveStatus, ID.FromInteger(id)); // EmpLeaveStatusDA.Insert(tc, oEmpLeaveStatus); // } // else // EmpLeaveStatusDA.Update(tc, oEmpLeaveStatus); // tc.End(); // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException("Failed to Insert Employee Leave Status", e); // #endregion // } // return oEmpLeaveStatus.ID; //} //public void SaveStatus(EmpLeaveStatus oEmpLeaveStatus) //{ // TransactionContext tc = null; // try // { // tc = TransactionContext.Begin(true); // if (oEmpLeaveStatus.IsNew) // { // // this.SetObjectID(oEmpLeaveStatus, ID.FromInteger(EmpLeaveStatusDA.GetNewID(tc))); // EmpLeaveStatusDA.Insert(tc, oEmpLeaveStatus); // } // //else // // EmpLeaveStatusDA.Update(tc, oEmpLeaveStatus); // tc.End(); // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException("Failed to Insert Employee Leave Status", e); // #endregion // } //} //internal void SaveAtProcessing(bool IsUpdate, int ProcessId, List oEmpLeaveStatuss, TransactionContext tc) //{ // foreach (EmpLeaveStatus oItem in oEmpLeaveStatuss) // { // if (IsUpdate) EmpLeaveStatusDA.Update(tc, oItem); // else // { // this.SetObjectID(oItem, ID.FromInteger(EmpLeaveStatusDA.GetNewID(tc))); // oItem.ProcessId = ProcessId; // EmpLeaveStatusDA.Insert(tc, oItem); // } // } //} //public void Delete(int id) //{ // TransactionContext tc = null; // try // { // tc = TransactionContext.Begin(true); // EmpLeaveStatusDA.Delete(tc, id); // tc.End(); // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException("Failed to Delete Employee Leave Status", e); // #endregion // } //} //public void Delete(int nProcessId) //{ // TransactionContext tc = null; // try // { // tc = TransactionContext.Begin(true); // EmpLeaveStatusDA.DeleteByProcessId(tc, nProcessId); // tc.End(); // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException("Failed to Delete Employee Leave Status", e); // #endregion // } //} //#endregion } #endregion }