using Ease.Core.DataAccess; using Ease.Core.Model; using Ease.Core.Utility; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Linq.Expressions; using HRM.BO; using System.ComponentModel.DataAnnotations; using static iTextSharp.text.pdf.AcroFields; namespace HRM.DA { public class EmployeeService : ServiceTemplate, IEmployeeService { public EmployeeService() { } private void MapObject(Employee oEmployee, DataReader oReader) { try { base.SetObjectID(oEmployee, oReader.GetInt32("EmployeeID").Value); 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; //DateTime? RetirementDateValue = oReader.GetDateTime("RetirementDate"); //oEmployee.RetirementDate = RetirementDateValue.HasValue ? RetirementDateValue.Value : null; oEmployee.EndOfContractDate = oReader.GetDateTime("endOfContractDate"); // ? oReader.GetDateTime("endOfContractDate").Value : DateTime.MinValue; oEmployee.CardDate = oReader.GetDateTime("CardDate"); oEmployee.EmailAddress = oReader.GetString("emailAddress"); oEmployee.MobileNo = oReader.GetString("mobileNo"); oEmployee.TinNo = oReader.GetString("tinNo"); oEmployee.CategoryID = oReader.GetInt32("categoryID").Value; oEmployee.ForeignExPat = oReader.GetBoolean("foreignExPat").Value; //oEmployee.TaxCircle = (EnumTaxCircle)oReader.GetInt32("taxCircle", true, 0); //oEmployee.TaxCircle = oReader.GetString("taxCircle"); oEmployee.IsConfirmed = oReader.GetBoolean("isConfirmed").Value; oEmployee.Status = (EnumEmployeeStatus)oReader.GetInt32("status").Value; /*oEmployee.ProfileStatus = oReader.GetInt32("ProfileStatus") != null ? (EnumProfileStatus)oReader.GetInt32("ProfileStatus").Value : EnumProfileStatus.Inserted_By_Employee;*/ //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.GetInt32("branchID"); oEmployee.AccountNo = oReader.GetString("accountNo"); oEmployee.OutPayBranchID = oReader.GetInt32("OUTPAYBRANCHID"); oEmployee.OutPayAccountNo = oReader.GetString("outPayAccountNo"); oEmployee.DepartmentID = oReader.GetInt32("departmentID"); oEmployee.LocationID = oReader.GetInt32("locationID"); oEmployee.ReligionID = oReader.GetInt32("religionID").Value; oEmployee.MaritalStatus = (EnumMaritalStatus)oReader.GetInt32("maritalStatusID").Value; oEmployee.DesignationID = oReader.GetInt32("designationID"); oEmployee.GradeID = oReader.GetInt32("gradeID"); oEmployee.BasicSalary = oReader.GetDouble("basicSalary").Value; oEmployee.PrevBasic = oReader.GetDouble("prevBasic").Value; oEmployee.PaymentMode = (EnumPaymentMode)oReader.GetInt32("paymentMode").Value; oEmployee.OutPayPaymentMode = (EnumPaymentMode)oReader.GetInt32("OutPayPaymentMode").Value; oEmployee.FatherName = oReader.GetString("fatherName"); oEmployee.MotherName = oReader.GetString("MOTHERNAME"); oEmployee.FatherOccupationId = oReader.GetInt32("FATHEROCCUPATIONID", 0); oEmployee.MotherOccupationId = oReader.GetInt32("MOTHEROCCUPATIONID", 0); oEmployee.IsEligibleOT = oReader.GetBoolean("isEligibleOT").Value; oEmployee.DescriptionText = oReader.GetString("desigDescription"); oEmployee.DesktopUserPass = oReader.GetString("desktopUserPass"); oEmployee.PayrollTypeID = oReader.GetInt32("payrollTypeID").Value; //oEmployee.IsAutoProcess = oReader.GetBoolean("IsAutoProcess").Value; oEmployee.CardID = oReader.GetInt32("cardID"); oEmployee.GrossSalary = oReader.GetDouble("grossSalary").Value; //oEmployee.PhotoPath = oReader.GetString("PhotoPath"); oEmployee.PayScaleId = oReader.GetInt32("payScaleId"); oEmployee.TaxAmount = oReader.GetDouble("taxAmount").Value; oEmployee.CurrentHistoryID = oReader.GetInt32("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"); oEmployee.DiscontinueDate = oReader.GetDateTime("dateOfExpiry") != null ? 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.GetInt32("CreatedBy").Value; oEmployee.CreatedDate = oReader.GetDateTime("CreationDate").Value; oEmployee.ModifiedBy = oReader.GetInt32("ModifiedBy"); oEmployee.ModifiedDate = oReader.GetDateTime("ModifiedDate"); oEmployee.PersonType = (EnumPersonType)oReader.GetInt32("PersonType", true, 0); oEmployee.LineManagerID = oReader.GetInt32("LineManagerID").HasValue ? oReader.GetInt32("LineManagerID").Value : null; oEmployee.SecondLineManagerID = oReader.GetInt32("SecondLineManagerID").HasValue ? oReader.GetInt32("SecondLineManagerID").Value : null; oEmployee.MobileNo = oReader.GetString("MobileNo"); oEmployee.GeId = oReader.GetString("GeId", true, string.Empty); oEmployee.ExtraField1 = oReader.GetString("ExtraField1", true, string.Empty); oEmployee.ExtraField2 = (EnumBaseStation)oReader.GetInt32("ExtraField2", true, 0); oEmployee.ExtraField3 = oReader.GetString("ExtraField3", true, string.Empty); oEmployee.ExtraField4 = oReader.GetString("ExtraField4", true, string.Empty); oEmployee.ExtraField5 = oReader.GetString("ExtraField5", true, string.Empty); oEmployee.FirstName = oReader.GetString("FirstName", true, string.Empty); oEmployee.LastName = oReader.GetString("LastName", true, string.Empty); oEmployee.CrgId = oReader.GetInt32("CrgId"); oEmployee.NationalityID = oReader.GetInt32("NATIONALITYID", true, 0); oEmployee.ProfileCompletionPercent = oReader.GetInt32("ProfileComplitionPercent", true, 0); oEmployee.InsuranceId = oReader.GetString("InsuranceId", true, string.Empty); oEmployee.InclusionDate = oReader.GetDateTime("InclusionDate", true, DateTime.MinValue); oEmployee.IsFixedLocation = oReader.GetBoolean("IsFixedLocation", true, false); oEmployee.HasDisableChildren = oReader.GetBoolean("HasDisableChildren", true, false); oEmployee.IsSalaryWithHeld = oReader.GetBoolean("IsSalaryWithHeld", true, false); oEmployee.NationalId = oReader.GetString("NATIONALID", true, string.Empty); oEmployee.PassportNo = oReader.GetString("PASSPORTNO", true, string.Empty); oEmployee.Address = oReader.GetString("Address", true, string.Empty); //oEmployee.SBU = oReader.GetString("SBU", true, string.Empty); this.SetObjectState(oEmployee, Ease.Core.ObjectState.Saved); } catch (Exception e) { ExceptionLog.Write(e); throw new ServiceException(e.Message, e); } } protected override T CreateObject(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 List CreateObjects(DataReader oDatareader) //{ //} #region Service implementation public Employee Get(TransactionContext tc, int id) { Employee oEmployee = null; try { DataReader oreader = new DataReader(EmployeeDA.Get(tc, id)); if (oreader.Read()) { oEmployee = this.CreateObject(oreader); } oreader.Close(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oEmployee; } public List GetAbsentEmployees(DateTime fromDate, DateTime toDate) { TransactionContext tc = null; List employees = new List(); try { DataReader dr = new DataReader(EmployeeDA.GetAbsentEmployees(tc, fromDate, toDate)); employees = this.CreateObjects(dr); dr.Close(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetAllLive() { TransactionContext tc = null; List employees = new List(); try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetAllLive(tc)); employees = this.CreateObjects(dr); dr.Close(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public Employee Get(int id) { Employee oEmployee = null; //Employee oLMEmployee = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.Get(tc, id)); if (oreader.Read()) { oEmployee = this.CreateObject(oreader); } oreader.Close(); tc.End(); //if (oEmployee != null && // oEmployee.LineManagerID != null && // oEmployee.LineManagerID != 0) //{ // DataReader oreaderLM = new DataReader(EmployeeDA.Get(tc, (int)oEmployee.LineManagerID)); // if (oreaderLM.Read()) // { // oLMEmployee = this.CreateObject(oreaderLM); // } // oreaderLM.Close(); //} //tc.End(); //if (oEmployee != null) //{ // Grade grade = oEmployee.GradeID != null ? new GradeService().Get(oEmployee.GradeID.GetValueOrDefault()) : null; // Department department = oEmployee.DepartmentID != null ? new DepartmentService().Get((int)oEmployee.DepartmentID) : null; // Designation designation = oEmployee.DesignationID != null ? new DesignationService().Get((int)oEmployee.DesignationID) : null; // oEmployee.GradeName = grade != null ? grade.Name : string.Empty; // oEmployee.DepartmentName = department != null ? department.Name : string.Empty; // oEmployee.DesignationName = designation != null ? designation.Name : string.Empty; // oEmployee.LineManager = oLMEmployee != null ? oLMEmployee.Name + " (" + oLMEmployee.EmployeeNo + ")" : string.Empty; // Category category = oEmployee.CategoryID != 0 // ? new CategoryService().Get(oEmployee.CategoryID) // : null; // oEmployee.CategoryName = category != null ? category.Name : string.Empty; //} } 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 GetEmployeeForHnm(int id) { Employee oEmployee = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetEmpForHNM(tc, id)); if (oreader.Read()) { oEmployee = this.CreateObject(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 List Get(string id) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetEmployeeByIDs(tc, id)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetMaternityLeaveEmployee(DateTime formDate, DateTime toDate) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetMaternityLeaveEmployee(tc, formDate, toDate)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public bool GetIsFixedPositionForMobile(int employeeid) { #region WF Movements TransactionContext tc = null; bool IsFixedPosition = false; try { tc = TransactionContext.Begin(); IsFixedPosition = EmployeeDA.GetIsFixedPositionForMobile(tc, employeeid); tc.End(); } catch (ServiceException ex) { #region Handle Error if (tc != null) tc.HandleError(); ExceptionLog.Write(ex); throw new ServiceException(ex.Message); #endregion } #endregion return IsFixedPosition; } public DataTable GetEmployeeForDashboard(int ID) { TransactionContext tc = null; DataTable dt = null; try { tc = TransactionContext.Begin(); dt = EmployeeDA.GetEmployeeForDashboard(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 } return dt; } public DataTable getNameAndEmail(int empid) { TransactionContext tc = null; DataTable dt = null; try { tc = TransactionContext.Begin(); dt = EmployeeDA.GetNameAndMail(tc, empid); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dt; } public DataTable GetNameAndMailWithNoLock(int empid) { TransactionContext tc = null; DataTable dt = null; try { tc = TransactionContext.Begin(); dt = EmployeeDA.GetNameAndMailWithNoLock(tc, empid); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dt; } public DataTable GetUserForLandingPage(int userId) { TransactionContext tc = null; DataTable dt = null; try { tc = TransactionContext.Begin(); dt = EmployeeDA.GetUserForLandingPage(tc, userId); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dt; } public DataSet GetAbsentEmployeesForLM(DateTime fromDate, DateTime toDate, EnumAttendanceType attnType) { TransactionContext tc = null; DataSet employees = null; try { tc = TransactionContext.Begin(); employees = EmployeeDA.GetAbsentEmployeesForLM(tc, fromDate, toDate, attnType); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public DataSet GetLinemanagerPendingList() { TransactionContext tc = null; DataSet employees = null; try { employees = EmployeeDA.GetLinemanagerPendingList(tc); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetAllHREmpsWorkAniversary(string payrollTypeId) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetAllHREmpsWorkAniversary(tc, payrollTypeId)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetAllHREmpsBirthday(string payrollTypeId) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetAllHREmpsBirthday(tc, payrollTypeId)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public DataTable GetMaternityLeaveEmployeeBasicInfo(int empID) { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetMaternityLeaveEmployeeBasicInfo(tc, empID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return ds.Tables[0]; } public List GetAllAbsentOnYesterdayEmps(string payrollTypeId) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetAllAbsentOnYesterdayEmps(tc, payrollTypeId)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } internal List GetByEmpNos(TransactionContext tc, string sEmpIDs) { List employees = new List(); try { DataReader dr = new DataReader(EmployeeDA.GetByEmpNos(tc, sEmpIDs)); employees = this.CreateObjects(dr); dr.Close(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetByEmpNos(string sEmpIDs) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetByEmpNos(tc, sEmpIDs)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public Employee GetByCardID(int id) { Employee oEmployee = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetByCardID(tc, id)); if (oreader.Read()) { oEmployee = this.CreateObject(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 GetParentEmployee(int id) { Employee oEmployee = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetParentEmployee(tc, id)); if (oreader.Read()) { oEmployee = this.CreateObject(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 GetLineManager(int empId) { Employee item = new Employee(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetLineManager(tc, empId)); if (oreader.Read()) { item = this.CreateObject(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 item; } public Employee GetwitoutchekPayrolltype(string employeeNo) { Employee oEmployee = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetWithOutcheckPayrollType(tc, employeeNo)); if (oreader.Read()) { oEmployee = this.CreateObject(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 = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.Get(tc, employeeNo, payrollTypeID)); if (oreader.Read()) { oEmployee = this.CreateObject(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 GetByEmail(string email) { Employee oEmployee = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetbyEmail(tc, email)); if (oreader.Read()) { oEmployee = this.CreateObject(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 GetFromAll(string employeeNo, int payrollTypeID) { Employee oEmployee = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetFromAll(tc, employeeNo, payrollTypeID)); if (oreader.Read()) { oEmployee = this.CreateObject(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 List Get(List searchEmployees, int payrollTypeID) //{ // List employees = new List(); // 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(dr); // dr.Close(); // tc.End(); // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException(e.Message, e); // #endregion // } // return employees; //} public List GetByDeptIDs(string sIDs, int payrollTypeID) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetByDeptIDs(tc, sIDs, payrollTypeID)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public DataSet GetAllEmpBasicInfo(string empIDs) { DataSet designationWiseCountDS = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); designationWiseCountDS = EmployeeDA.GetAllEmpBasicInfo(tc, empIDs); 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; } public List GetByDeptShiftGFType(string deptIDs, int shiftID, string GFType, int payrollTypeID) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetByDeptShiftGFType(tc, deptIDs, shiftID, GFType, payrollTypeID)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } //Previously Get public List GetWithPayrollType(int payrollTypeID) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetWithPayrollType(tc, payrollTypeID)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetForSuperUser() { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetForSuperUser(tc)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetAllEmps() { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetAllEmps(tc)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetAllEmps(int payrollTypeid) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetAllEmps(tc, payrollTypeid)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetAllEmps(TransactionContext tc) { List employees = new List(); try { DataReader dr = new DataReader(EmployeeDA.GetAllEmps(tc)); employees = this.CreateObjects(dr); dr.Close(); } catch (Exception e) { #region Handle Exception ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public DataSet GetEmployeeIncrement(string empIDs) { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetEmployeeIncrement(tc, empIDs); } catch (Exception e) { throw new ServiceException(e.Message, e); } return ds; } public void UpdateLM2(List emps) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); foreach (Employee item in emps) { EmployeeDA.UpdateLM(tc, item.ID, (int)item.LineManagerID, item.SecondLineManagerID); } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public DataSet 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 List GetJoiningData(DateTime formDate) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetJoiningData(tc, formDate)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetWithDiscontinue(int payrollTypeID) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetWithDiscontinue(tc, payrollTypeID)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } //for Attendance Process public List GetAbsentEmp(DateTime attnDate, EnumWorkPlanGroup wpGroup, int payrollTypeID) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetAbsentEmp(tc, attnDate, wpGroup, payrollTypeID)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetAttendaceEmp(EnumWorkPlanGroup wpGroup, int payrollTypeID) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetAttendaceEmp(tc, wpGroup, payrollTypeID)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetEmpExceptAutoWP(DateTime attnDate, int payrollTypeID) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetEmpExceptAutoWP(tc, attnDate, payrollTypeID)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetDiscontinueEmp(DateTime attnDate, DateTime currentDate, int payrollTypeID) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetDiscontinueEmp(tc, attnDate, currentDate, payrollTypeID)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } // public List Get(int status, DateTime lastDateOfYear) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.Get(tc, status, lastDateOfYear)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List Get(EnumEmployeeStatus status, int payrollTypeID) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.Get(tc, status, payrollTypeID)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return 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 DataSet GetEncashmentReport(string sEmpIDs, string leaveYear) { DataSet oDataSet = null; TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); oDataSet = EmployeeDA.GetEncashmentReport(tc, sEmpIDs, leaveYear); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } return oDataSet; } public List GetEmpsWithDiscontinue(string empIDs, int payrollTypeID) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetEmpsWithDiscontinue(tc, empIDs, payrollTypeID)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); List designations = new DesignationService().GetAll(); List departments = new DepartmentService().GetAll(); List locations = new LocationService().GetLocations(); employees.ForEach(emp => { if (emp.DesignationID != null) { //emp.Designation = new DesignationService().Get(emp.DesignationID.Value); emp.Designation = designations.Where(x => x.ID == emp.DesignationID.Value).FirstOrDefault(); } else { emp.Designation = new Designation(); } if (emp.DepartmentID != null) { emp.Department = departments.Where(x => x.ID == emp.DepartmentID.Value).FirstOrDefault(); //emp.Department = new DepartmentService().Get(emp.DepartmentID.Value); } else { emp.Department = new Department(); } if (emp.LocationID != null) { emp.Location = locations.Where(x => x.ID == emp.LocationID.Value).FirstOrDefault(); //emp.Location = new LocationService().Get(emp.LocationID.Value); } else { emp.Location = new Location(); } }); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetByEmpIDs(string empIDs, int payrollTypeID) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetByEmpIDs(tc, empIDs, payrollTypeID)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetByEmpIDs(string empIDs) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetByEmpIDs(tc, empIDs)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public void UpdateBanglaInformation(List employeBanglaInfo) { TransactionContext tc = null; try { tc = TransactionContext.Begin(); EmployeeDA.UpdateBanglaInformation(tc, employeBanglaInfo); 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 UpdateBanglaContactInformation(List employeBanglaInfo) { TransactionContext tc = null; try { tc = TransactionContext.Begin(); EmployeeDA.UpdateBanglaContactInformation(tc, employeBanglaInfo); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public List GetNew(DateTime dt, int payrollTypeID) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetNew(tc, dt, payrollTypeID)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetFssEmp(string empIDs, int payrollTypeID) { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetFssEmp(tc, empIDs, payrollTypeID)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetTopMostEmployees() { List employees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetTopMostEmployees(tc)); employees = this.CreateObjects(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 employees; } //Insert 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); // EmployeeDA.Insert(tc, oEmployee); // tc.End(); // if (oEmployee.EmployeeGradeSalary != null) // { // oEmployee.EmployeeGradeSalary.EmployeeID = oEmployee.ID; // oEmployee.EmployeeGradeSalary.GradeSalaryTypeID = 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.Insert(); // //oEmployee.EmployeeBankAccount.Insert(); // (new EmployeeBankAccountService()).Insert(oEmployee.EmployeeGradeSalary); // oEmployee.EmployeePosting.Insert(); // } // 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 int Save(Employee oEmployee) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); if (oEmployee.IsNew) { int id = tc.GenerateID("Employee", "EmployeeID"); base.SetObjectID(oEmployee, 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 int SaveHnmEmployee(List employeeData) { TransactionContext tc = null; Employee oEmployee = null; EmpContact empContact = null; int id = 0; try { foreach (var item in employeeData) { if (item is Employee) { oEmployee = (Employee)item; } if (item is EmpContact) { empContact = (EmpContact)item; } } tc = TransactionContext.Begin(true); if (oEmployee != null && oEmployee.IsNew) { id = tc.GenerateID("Employee", "EmployeeID"); base.SetObjectID(oEmployee, id); EmployeeDA.Insert(tc, oEmployee); } else { EmployeeDA.Update(tc, oEmployee); } EmployeeDA.DeleteEmpContact(tc, oEmployee.ID); if (empContact != null) { empContact.EmployeeID = oEmployee.ID; var iD = tc.GenerateID("EMPCONTACT", "ContactID"); base.SetObjectID(empContact, iD); EmployeeDA.InsertEmpContact(tc, empContact); } 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(List oEmps) //{ // TransactionContext tc = null; // try // { // tc = TransactionContext.Begin(true); // EmpLifeCycleService lcService = null; // EmployeeBankAccountService ebaService = null; // foreach (HREmployee oEmployee in oEmps) // { // if (string.IsNullOrEmpty(oEmployee.EmployeeNo)) continue; // if (oEmployee.IsNew) // { // int id = tc.GenerateID("Employee", "EmployeeID"); // base.SetObjectID(oEmployee, ID.FromInteger(id)); // oEmployee.CreatedBy = User.CurrentUser.ID; // oEmployee.CreatedDate = DateTime.Today; // HREmployeeDA.InsertForIntegration(tc, oEmployee); // } // else // { // oEmployee.ModifiedBy = User.CurrentUser.ID; // oEmployee.ModifiedDate = DateTime.Today; // HREmployeeDA.UpdateForIntegration(tc, oEmployee); // } // //Insert Life cycle // if (oEmployee.EmpLifeCycle != null && oEmployee.EmpLifeCycle.StatusDetailID != null && !oEmployee.EmpLifeCycle.StatusDetailID.IsUnassigned) // { // lcService = new EmpLifeCycleService(); // oEmployee.EmpLifeCycle.EmployeeID = oEmployee.ID; // oEmployee.EmpLifeCycle.CreatedBy = User.CurrentUser.ID; // oEmployee.EmpLifeCycle.CreatedDate = DateTime.Now; // lcService.SaveIntegration(oEmployee.EmpLifeCycle, tc, oEmployee); // } // //Insert Employee Account History // if (oEmployee.EmployeeBankAccount != null) // { // ebaService = new EmployeeBankAccountService(); // oEmployee.EmployeeBankAccount.EmployeeID = oEmployee.ID; // oEmployee.EmployeeBankAccount.CreatedBy = User.CurrentUser.ID; // oEmployee.EmployeeBankAccount.CreatedDate = DateTime.Now; ; // if (oEmployee.EmployeeBankAccount.EffectDate != DateTime.MinValue) // ebaService.SaveIntegration(oEmployee.EmployeeBankAccount, tc); // } // //Insert Employee Contacts // if (oEmployee.Contacts != null && oEmployee.Contacts.Count > 0) // { // if (!oEmployee.IsNew) // HREmployeeDA.Delete(tc, "EmpContact", "EmployeeID", oEmployee.ID); // foreach (EmpContact item in oEmployee.Contacts) // { // item.EmployeeID = oEmployee.ID; // this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpContact", "ContactID"))); // HREmployeeDA.Insert(tc, item); // } // } // //Insert Employee Spoused // if (oEmployee.Spouses != null && oEmployee.Spouses.Count > 0) // { // //if (!oEmployee.IsNew) // // HREmployeeDA.Delete(tc, "EmpSpouse", "EmployeeID", oEmployee.ID); // foreach (EmpSpouse item in oEmployee.Spouses) // { // item.EmployeeID = oEmployee.ID; // this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpSpouse", "SpouseID"))); // HREmployeeDA.Insert(tc, item); // } // } // //Insert Employee Child // if (oEmployee.ChildrenList != null && oEmployee.ChildrenList.Count > 0) // { // //if (!oEmployee.IsNew) // // HREmployeeDA.Delete(tc, "EmpChildren", "EmployeeID", oEmployee.ID); // foreach (EmpChildren item in oEmployee.ChildrenList) // { // item.EmployeeID = oEmployee.ID; // this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpChildren", "ChildID"))); // HREmployeeDA.Insert(tc, item); // } // } // //Insert Employee Costcenter // if (oEmployee.EmployeeCostCenters != null && oEmployee.EmployeeCostCenters.Count > 0) // { // //if (!oEmployee.IsNew) // // HREmployeeDA.Delete(tc, "EMPCOSTCENTER", "EmployeeID", oEmployee.ID); // oEmployee.EmployeeCostCenters.ForEach(x => x.EmployeeID = oEmployee.ID); // EmployeeCostCenterService ocda = new EmployeeCostCenterService(); // ocda.Insert(tc, oEmployee.EmployeeCostCenters); // //foreach (EmployeeCostCenter item in oEmployee.EmployeeCostCenters) // //{ // // item.EmployeeID = oEmployee.ID; // // this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EMPCOSTCENTER", "CostCenterID"))); // // HREmployeeDA.Insert(tc, item); // //} // } // //Update AuroraEmployee // AuroraEmployeeCompositeTypeDA.UpdateForProcess(tc, DateTime.Today, User.CurrentUser.ID.ToString(), oEmployee.EmployeeNo, oEmployee.GlobalID); // } // tc.End(); // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException(e.Message, e); // #endregion // } //} public int GetCurrentHeadCount(int departmentId, int designationId, int gradeId) { TransactionContext tc = null; int? empCount = 0; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetCurrentHeadCount(tc, departmentId, designationId, gradeId)); if (dr.Read()) { empCount = dr.GetInt32(0); } dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return empCount ?? 0; } public void UpdateLineManager(List employees) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); foreach (Employee item in employees) { EmployeeDA.UpdateLineManager(tc, item); } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void Delete(int id, int UserID) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); EmployeeDA.Delete(tc, id, UserID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void DeleteAll(int UserID) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); EmployeeDA.DeleteAll(tc, UserID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void UpdateStatus(int employeeID, int historyID, DateTime effectDate, EnumEmployeeStatus status) { TransactionContext tc = null; tc = TransactionContext.Begin(true); EmployeeDA.UpdateStatus(tc, employeeID, historyID, effectDate, status); tc.End(); } public void UpdateCardInformation(int employeeID, int 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 UpdateEmpCardHistory(int employeeID, int CardID, DateTime cardDate, string cardNumber) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); EmployeeDA.UpdateEmpCardHistory(tc, employeeID, CardID, cardDate, cardNumber); 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 UpdateEmpCardHistory(TransactionContext tc, int employeeID, int CardID, DateTime cardDate, string cardNumber) { try { EmployeeDA.UpdateEmpCardHistory(tc, employeeID, CardID, cardDate, cardNumber); } 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, int employeeID, int 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(int 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(int 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(int 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(int employeeID, bool IsConfirm) { TransactionContext tc = null; tc = TransactionContext.Begin(true); EmployeeDA.UndoConfirm(tc, employeeID, IsConfirm); tc.End(); } public void UpdatePayrollType(int employeeID, int payrollTypeID, DateTime dEffectDate) { TransactionContext tc = null; tc = TransactionContext.Begin(true); EmployeeDA.UpdatePayrollType(tc, employeeID, payrollTypeID, dEffectDate); tc.End(); } public void UpdatePayrollType(TransactionContext tc, int employeeID, int payrollTypeID) { EmployeeDA.UpdatePayrollType(tc, employeeID, payrollTypeID); } public void UpdateBankAcc(TransactionContext tc, int employeeID, int branchid, string accountNo, EnumPaymentMode paymentMode) { EmployeeDA.UpdateBankAcc(tc, employeeID, branchid, accountNo, paymentMode); } public void UpdateOPIBankAcc(TransactionContext tc, int employeeID, int 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 GetEmpBasicInfoForReport(string sEmpID) { DataSet oEmpBasicInfos = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oEmpBasicInfos = EmployeeDA.GetEmpBasicInfoForReport(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 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 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 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 GetEmpDetailsView(string sEmpID) { DataSet oEmpDetails = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oEmpDetails = EmployeeDA.GetEmpDetailsView(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 GetEmpDetailsView() { DataSet oEmpDetails = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oEmpDetails = EmployeeDA.GetEmpDetailsView(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 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 GetLineManagerFromOrg(int sEmpID) { DataSet oLineManager = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oLineManager = EmployeeDA.GetLineManagerFromOrg(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 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 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 List Get() { TransactionContext tc = null; List users = new List(); try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.Get(tc)); users = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return users; } public DataTable GetOtEligibleEmployees(int payrolltypeid) { DataTable dt = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); dt = EmployeeDA.GetOtEligibleEmployees(tc, payrolltypeid); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dt; } public List GetEmployeesForPicker(string employeeCode, string employeeName) { TransactionContext tc = null; List users = new List(); try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetEmployeesForPicker(tc, employeeCode, employeeName)); users = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return users; } 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 DataTable GetShortInformation(string empID) { DataTable dataTableOfEmployee = new DataTable("GetShortInformation"); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataSet dataSet = EmployeeDA.GetShortInformation(tc, empID); 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 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 SaveDepartment(TransactionContext tc, List employees) { try { foreach (Employee oEmployee in employees) { EmployeeDA.UpdateDepartment(tc, oEmployee); } } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } //Data Integration public void SaveIntegration(List oEmps, int currentUserId, DateTime NextPayProcessDate, DateTime LastPayProcessDate) { TransactionContext tc = null; int nn = 1; string empNo = ""; string Errmsg = ""; try { tc = TransactionContext.Begin(true); foreach (Employee oEmployee in oEmps) { empNo = oEmployee.EmployeeNo; Errmsg = "Error during updateting/Inserting employee"; if (oEmployee.IsNew) { int id = tc.GenerateID("Employee", "EmployeeID"); base.SetObjectID(oEmployee, id); EmployeeDA.Insert(tc, oEmployee); } else { EmployeeDA.Update(tc, oEmployee); } Errmsg = "Error during life-cycle update "; EmpLifeCycleService lcService = new EmpLifeCycleService(); oEmployee.EmpLifeCycle.EmployeeID = oEmployee.ID; oEmployee.EmpLifeCycle.CreatedBy = currentUserId; oEmployee.EmpLifeCycle.CreatedDate = DateTime.Now; lcService.SaveIntegration(oEmployee.EmpLifeCycle, tc, oEmployee, NextPayProcessDate, currentUserId, LastPayProcessDate); //Save Employee Account History Errmsg = "Error during Bank Account"; if (oEmployee.EmployeeBankAccount.AccountNo != "") { EmployeeBankAccountService ebaService = new EmployeeBankAccountService(); oEmployee.EmployeeBankAccount.EmployeeID = oEmployee.ID; oEmployee.EmployeeBankAccount.CreatedBy = currentUserId; oEmployee.EmployeeBankAccount.CreatedDate = DateTime.Now; ; oEmployee.EmployeeBankAccount.BranchID = (int)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(Errmsg + " from employee:" + empNo + " " + e.Message, e); #endregion } } public static void SaveForUpload(TransactionContext tc, List employees, EnumRegularDataUpload uploadtype) { List empstatuss = new EmployeeStatusService().Get(tc, EnumStatus.Regardless); PayrollType opayrolltype = new PayrollTypeService().Get(tc, employees[0].PayrollTypeID); EmployeeStatus joiningEmpstatu = empstatuss.FirstOrDefault(x => x.IsJoining == true); if (joiningEmpstatu == null) throw new Exception("Joing Life-cycle status not found in the system"); string empNo = ""; try { foreach (Employee oEmployee in employees) { oEmployee.EmployeeNo = oEmployee.EmployeeNo.Trim('`'); empNo = oEmployee.EmployeeNo; oEmployee.CreatedDate = DateTime.Today; oEmployee.Name = oEmployee.Name == "" ? "Employee-" + oEmployee.EmployeeNo : oEmployee.Name; EmployeeDA.Insert(tc, oEmployee); int id = tc.GenerateID("GRADESALARYASSIGNMENT", "EmpGradeSalaryID"); (new EmployeeService()).SetObjectID(oEmployee.EmployeeGradeSalary, id); oEmployee.EmployeeGradeSalary.EmployeeID = oEmployee.ID; oEmployee.EmployeeGradeSalary.GradeSalaryTypeID = joiningEmpstatu.ID; oEmployee.EmployeeGradeSalary.GradeID = (int)oEmployee.GradeID; oEmployee.EmployeeGradeSalary.CreatedBy = oEmployee.CreatedBy; oEmployee.EmployeeGradeSalary.CreatedDate = DateTime.Today; oEmployee.EmployeeGradeSalary.EffectDate = oEmployee.JoiningDate; // // Create Arrear, it is for regular upload only if (uploadtype == EnumRegularDataUpload.EmployeeRegularUpload) { if (oEmployee.JoiningDate < GlobalFunctions.FirstDateOfMonth(opayrolltype.NextPayProcessDate)) { (new EmployeeService()).SetObjectID(oEmployee.EmployeeGradeSalary, id); oEmployee.EmployeeGradeSalary.TillDate = opayrolltype.LastPayProcessDate; oEmployee.EmployeeGradeSalary.ArrearType = EnumArrearType.ToCalculate; EmployeeGradeSalaryDA.Insert(tc, oEmployee.EmployeeGradeSalary); oEmployee.EmployeeGradeSalary.EffectDate = GlobalFunctions.FirstDateOfMonth(opayrolltype.NextPayProcessDate); oEmployee.EmployeeGradeSalary.ArrearType = EnumArrearType.NotPresent; oEmployee.EmployeeGradeSalary.TillDate = null; id = id + 1; EmployeeGradeSalaryDA.Insert(tc, oEmployee.EmployeeGradeSalary); } else EmployeeGradeSalaryDA.Insert(tc, oEmployee.EmployeeGradeSalary); } else EmployeeGradeSalaryDA.Insert(tc, oEmployee.EmployeeGradeSalary); if (oEmployee.BranchID != null) { (new EmployeeService()).SetObjectID(oEmployee.EmployeeBankAccount, tc.GenerateID("BANKACCOUNTHISTORY", "EmpBankAccountID")); oEmployee.EmployeeBankAccount.EmployeeID = oEmployee.ID; oEmployee.EmployeeBankAccount.CreatedBy = oEmployee.CreatedBy; oEmployee.EmployeeBankAccount.CreatedDate = DateTime.Today; oEmployee.EmployeeBankAccount.BranchID = (int)oEmployee.BranchID; oEmployee.EmployeeBankAccount.AccountNo = oEmployee.EmployeeBankAccount.AccountNo; // == "" ? "1234" : oEmployee.EmployeeBankAccount.AccountNo; EmployeeBankAccountDA.Insert(tc, oEmployee.EmployeeBankAccount); } if (oEmployee.OutPayBranchID != null) { (new EmployeeService()).SetObjectID(oEmployee.EmployeeOPIBankAccount, tc.GenerateID("BANKACCOUNTHISTORY", "EmpBankAccountID")); oEmployee.EmployeeOPIBankAccount.EmployeeID = oEmployee.ID; oEmployee.EmployeeOPIBankAccount.CreatedBy = oEmployee.CreatedBy; oEmployee.EmployeeOPIBankAccount.CreatedDate = DateTime.Today; oEmployee.EmployeeOPIBankAccount.AccountNo = oEmployee.EmployeeOPIBankAccount.AccountNo;// == "" ? "1234" : oEmployee.EmployeeOPIBankAccount.AccountNo; EmployeeBankAccountDA.Insert(tc, oEmployee.EmployeeOPIBankAccount); } #region Emplifecycle id = tc.GenerateID("EmpLifecycle", "EmpLifecycleID"); oEmployee.EmpLifeCycle = new EmpLifeCycle(); (new EmployeeService()).SetObjectID(oEmployee.EmpLifeCycle, (tc.GenerateID("EmpLifecycle", "EmpLifecycleID"))); oEmployee.EmpLifeCycle.EmployeeGradeSalary = oEmployee.EmployeeGradeSalary; oEmployee.EmpLifeCycle.Description = joiningEmpstatu.Description; oEmployee.EmpLifeCycle.EmployeeID = oEmployee.ID; oEmployee.EmpLifeCycle.BasicSalary = oEmployee.BasicSalary; oEmployee.EmpLifeCycle.EffectDate = oEmployee.JoiningDate; oEmployee.EmpLifeCycle.GradeID = oEmployee.GradeID; oEmployee.EmpLifeCycle.DepartmentID = oEmployee.DepartmentID; oEmployee.EmpLifeCycle.DesignationID = oEmployee.DesignationID; oEmployee.EmpLifeCycle.StatusDetailID = joiningEmpstatu.ID; oEmployee.EmpLifeCycle.Status = EnumStatus.Active; oEmployee.EmpLifeCycle.EmployeeStatus = EnumEmployeeStatus.Live; oEmployee.EmpLifeCycle.LocationID = oEmployee.LocationID; oEmployee.EmpLifeCycle.CategoryID = oEmployee.CategoryID; oEmployee.EmpLifeCycle.IsConfirm = (oEmployee.IsConfirmed == true) ? true : false; oEmployee.EmpLifeCycle.CreatedBy = oEmployee.CreatedBy; oEmployee.EmpLifeCycle.CreatedDate = oEmployee.CreatedDate; oEmployee.EmpLifeCycle.GradeSalaryAssesmentID = oEmployee.EmployeeGradeSalary.ID; new EmpLifeCycleService().Insert(tc, oEmployee.EmpLifeCycle); #endregion } foreach (Employee oEmployee in employees) { #region Line Manager if (oEmployee.LineManagerNo != null && oEmployee.LineManagerNo != string.Empty) EmployeeDA.UpdateLineManager(tc, oEmployee.ID, oEmployee.LineManagerNo); #endregion } } 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 static void SaveForIntegration(TransactionContext tc, List employees, EnumRegularDataUpload uploadtype) { List empstatuss = new EmployeeStatusService().Get(tc, EnumStatus.Regardless); PayrollType opayrolltype = new PayrollTypeService().Get(tc, employees[0].PayrollTypeID); //EmployeeStatus joiningEmpstatu = empstatuss.FirstOrDefault(x => x.IsJoining == true); //if (joiningEmpstatu == null) throw new Exception("Joing Life-cycle status not found in the system"); int maxEmpID = tc.GenerateID("Employee", "EmployeeID"); string empNo = ""; try { foreach (Employee oEmployee in employees) { oEmployee.EmployeeNo = oEmployee.EmployeeNo.Trim('`'); empNo = oEmployee.EmployeeNo; oEmployee.CreatedDate = DateTime.Today; oEmployee.Name = oEmployee.Name == "" ? "Employee-" + oEmployee.EmployeeNo : oEmployee.Name; if (maxEmpID <= oEmployee.ID) EmployeeDA.Insert(tc, oEmployee); else EmployeeDA.IntegrationUpdate(tc, oEmployee); //EmployeeStatus joiningEmpstatu = empstatuss.FirstOrDefault(x => x.Description == oEmployee.EmpLifeCycle.Description); //if (joiningEmpstatu == null) throw new Exception("Joing Life-cycle status not found in the system"); //int id = tc.GenerateID("GRADESALARYASSIGNMENT", "EmpGradeSalaryID"); //(new EmployeeService()).SetObjectID(oEmployee.EmployeeGradeSalary, id); //oEmployee.EmployeeGradeSalary.EmployeeID = oEmployee.ID; //oEmployee.EmployeeGradeSalary.GradeSalaryTypeID = joiningEmpstatu.ID; //oEmployee.EmployeeGradeSalary.GradeID = (int)oEmployee.GradeID; //oEmployee.EmployeeGradeSalary.CreatedBy = oEmployee.CreatedBy; //oEmployee.EmployeeGradeSalary.CreatedDate = DateTime.Today; //oEmployee.EmployeeGradeSalary.EffectDate = oEmployee.JoiningDate; //// // Create Arrear, it is for regular upload only //if (oEmployee.EmployeeGradeSalary != null) //{ // if (oEmployee.EmployeeGradeSalary.EffectDate < GlobalFunctions.FirstDateOfMonth(opayrolltype.NextPayProcessDate)) // { // (new EmployeeService()).SetObjectID(oEmployee.EmployeeGradeSalary, id); // oEmployee.EmployeeGradeSalary.TillDate = opayrolltype.LastPayProcessDate; // oEmployee.EmployeeGradeSalary.ArrearType = EnumArrearType.ToCalculate; // EmployeeGradeSalaryDA.Insert(tc, oEmployee.EmployeeGradeSalary); // oEmployee.EmployeeGradeSalary.EffectDate = GlobalFunctions.FirstDateOfMonth(opayrolltype.NextPayProcessDate); // oEmployee.EmployeeGradeSalary.ArrearType = EnumArrearType.NotPresent; // oEmployee.EmployeeGradeSalary.TillDate = null; // id = id + 1; // EmployeeGradeSalaryDA.Insert(tc, oEmployee.EmployeeGradeSalary); // } // else EmployeeGradeSalaryDA.Insert(tc, oEmployee.EmployeeGradeSalary); //} if (oEmployee.EmployeeBankAccount != null) { (new EmployeeService()).SetObjectID(oEmployee.EmployeeBankAccount, tc.GenerateID("BANKACCOUNTHISTORY", "EmpBankAccountID")); EmployeeBankAccountDA.Insert(tc, oEmployee.EmployeeBankAccount); EmployeeDA.UpdateBankAcc(tc, oEmployee.ID, oEmployee.EmployeeBankAccount.BranchID , oEmployee.EmployeeBankAccount.AccountNo, EnumPaymentMode.BankTransfer); } if (oEmployee.OutPayBranchID != null) { (new EmployeeService()).SetObjectID(oEmployee.EmployeeOPIBankAccount, tc.GenerateID("BANKACCOUNTHISTORY", "EmpBankAccountID")); oEmployee.EmployeeOPIBankAccount.EmployeeID = oEmployee.ID; oEmployee.EmployeeOPIBankAccount.CreatedBy = oEmployee.CreatedBy; oEmployee.EmployeeOPIBankAccount.CreatedDate = DateTime.Today; oEmployee.EmployeeOPIBankAccount.AccountNo = oEmployee.EmployeeOPIBankAccount.AccountNo;// == "" ? "1234" : oEmployee.EmployeeOPIBankAccount.AccountNo; EmployeeBankAccountDA.Insert(tc, oEmployee.EmployeeOPIBankAccount); } #region Emplifecycle // int id = tc.GenerateID("EmpLifecycle", "EmpLifecycleID"); oEmployee.EmpLifeCycle.SalaryMonth = opayrolltype.NextPayProcessDate; new EmpLifeCycleService().Save(tc, oEmployee.EmpLifeCycle, opayrolltype.NextPayProcessDate, opayrolltype.ID); #endregion } foreach (Employee oEmployee in employees) { #region Line Manager if (oEmployee.LineManagerNo != null && oEmployee.LineManagerNo != string.Empty) EmployeeDA.UpdateLineManager(tc, oEmployee.ID, oEmployee.LineManagerNo); #endregion } } 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 void UpdateCardInformation(TransactionContext tc, int employeeID, int CardID, DateTime cardDate, EnumCardStatus cardStatus, bool IsAutoProcess) { try { EmployeeDA.UpdateCardInformation(tc, employeeID, CardID, cardDate, cardStatus, IsAutoProcess); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public List GetEmployeesYetNotAssigned() { List notAssignedEmployees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetEmployeesYetNotAssigned(tc)); //if (oreader.Read()) //{ notAssignedEmployees = this.CreateObjects(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 List GetSubordinates(int employeeID) { List oEmployees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetSubordinates(tc, employeeID)); oEmployees = this.CreateObjects(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; } public List GetMonthlyAttnEmployee(DateTime fromDate, DateTime toDate, int payrollTypeID) { List oEmployees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetMonthlyAttnEmployee(tc, fromDate, toDate, payrollTypeID)); oEmployees = this.CreateObjects(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; } public DataTable GetDepartmentName(int empID, bool banglaDescriptionExits) { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetDepartmentName(tc, empID, banglaDescriptionExits); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return ds.Tables[0]; } public List NotYetAssigned(int payrollTypeID) { TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeWorkPlanSetupDA.NotYetAssigned(tc, payrollTypeID)); var totalEmployee = this.CreateObjects(dr); dr.Close(); tc.End(); return totalEmployee; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } 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 List GetAllSubordinates(int nodeID) //{ // TransactionContext tc = null; // List employees = new List(); // 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(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 List GetGrandChilds(int employeeID) { List oEmployees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetGrandChilds(tc, employeeID)); oEmployees = this.CreateObjects(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; } public List GetbyDepartment(int deptId) { List oEmployees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetbyDepartment(tc, deptId)); oEmployees = this.CreateObjects(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; } public DataSet GetEmpDashBoardInfo(int empID) { DataSet dsetDashBoard = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); dsetDashBoard = EmployeeDA.GetEmpDashBoardInfo(tc, empID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dsetDashBoard; } public List GetAllSubordinatesNew(int employeeID) { List oEmployees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetAllSubordinatesNew(tc, employeeID)); oEmployees = this.CreateObjects(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; } public List GetGrandChilds(string sEmpNos) { List oEmployees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetGrandChilds(tc, sEmpNos)); oEmployees = this.CreateObjects(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; } public List GetAssignedEmployees(int nPMPYearID, int nEmpID) { List oEmployees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetAssignedEmployees(tc, nPMPYearID, nEmpID)); oEmployees = this.CreateObjects(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; } public List GetEmployeesByJoiningMonth(DateTime fromDate, DateTime toDate) { List oEmployeesByJoiningMonth = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetEmployeesByJoiningMonth(tc, fromDate, toDate)); oEmployeesByJoiningMonth = this.CreateObjects(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(int departmentID) { DataSet designationWiseCountDS = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); designationWiseCountDS = EmployeeDA.GetDesignationWiseEmployeeCountsByDepartmentID(tc, departmentID); 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 DataSet GetEmpBasicInfoForPSlip(string sEmpID, DateTime dMonth) { DataSet empBasicInfoForPSlipDSet = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); empBasicInfoForPSlipDSet = EmployeeDA.GetEmpBasicInfoForPSlip(tc, sEmpID, dMonth); 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 DataTable GetGradeWiseEmployeeCountsByDepartmentID(int departmentID) { DataSet gradeWiseCountDS = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); gradeWiseCountDS = EmployeeDA.GetGradeWiseEmployeeCountsByDepartmentID(tc, departmentID); 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 = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.Get4Web(tc, employeeNo)); if (oreader.Read()) { oEmployee = this.CreateObject(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 GetDepartmentHead(EnumOGPositionType type, int 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(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 GetAllGeneralInfo(string sEmpIDs) { DataSet allData = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); allData = EmployeeDA.GetAllGeneralInfo(tc, sEmpIDs); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return allData; } public DataSet GetAllContactInfo(string sEmpIDs) { DataSet allData = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); allData = EmployeeDA.GetAllContactInfo(tc, sEmpIDs); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return allData; } public DataSet GetSpouseInfo(string sEmpIDs) { DataSet allData = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); allData = EmployeeDA.GetSpouseInfo(tc, sEmpIDs); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return allData; } public DataSet GetChildInfo(string sEmpIDs) { DataSet allData = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); allData = EmployeeDA.GetChildInfo(tc, sEmpIDs); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return allData; } public DataSet GetEmpExperienceInfo(string sEmpIDs) { DataSet allData = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); allData = EmployeeDA.GetEmpExperienceInfo(tc, sEmpIDs); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return allData; } public DataSet GetEmpTrainingInfo(string sEmpIDs) { DataSet allData = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); allData = EmployeeDA.GetEmpTrainingInfo(tc, sEmpIDs); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return allData; } public DataSet GetEmpAcademicInfo(string sEmpIDs) { DataSet allData = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); allData = EmployeeDA.GetEmpAcademicInfo(tc, sEmpIDs); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return allData; } public DataSet GetEmpReferenceInfo(string sEmpIDs) { DataSet allData = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); allData = EmployeeDA.GetEmpReferenceInfo(tc, sEmpIDs); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return allData; } public DataSet GetEmpPublicationInfo(string sEmpIDs) { DataSet allData = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); allData = EmployeeDA.GetEmpPublicationInfo(tc, sEmpIDs); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return allData; } public DataTable GetBasicSalary() { DataTable allData = new DataTable(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); allData = EmployeeDA.GetBasicSalary(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 DataTable GetBasicSalaryWithDiscontinue(DateTime salaryMonth) { DataTable allData = new DataTable(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); allData = EmployeeDA.GetBasicSalaryWithDiscontinue(tc, salaryMonth); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return allData; } public string GetBasicSalary(int id) { string currentBasic = ""; DataTable allData = new DataTable(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); allData = EmployeeDA.GetBasicSalary(tc, id); //currentBasic = allData[BASICSALARY]; tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return currentBasic; } public DataSet GetEmpNomineeInfo(string sEmpIDs) { DataSet allData = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); allData = EmployeeDA.GetEmpNomineeInfo(tc, sEmpIDs); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return allData; } public DataSet GetEmployeeGeneralData() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetEmployeeGeneralData(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 ds; } public DataSet GetEmployeeContactData() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetEmployeeContactData(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 ds; } public DataSet GetEmployeeSpouseData() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetEmployeeSpouseData(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 ds; } public DataSet GetEmployeeChildrenData() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetEmployeeChildrenData(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 ds; } public DataSet GetEmployeeAcademicData() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetEmployeeAcademicData(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 ds; } public DataSet GetEmployeeTrainingData() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetEmployeeTrainingData(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 ds; } public DataSet GetEmployeeExperienceData() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetEmployeeExperienceData(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 ds; } public DataSet GetEmployeeNomineeData() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetEmployeeNomineeData(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 ds; } public DataSet GetListOfPromotion() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetListOfPromotion(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 ds; } public DataSet GetListOfTransfer() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetListOfTransfer(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 ds; } public DataSet GetJobSeparationList() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetJobSeparationList(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 ds; } public DataSet GetConfirmedEmployeeList() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetConfirmedEmployeeList(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 ds; } public DataTable GetEmpFromView(string empNo) { DataTable dtEmpInfo = new DataTable(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); DataSet ds = EmployeeDA.GetEmpFromView(tc, empNo); if (ds != null || (ds.Tables.Count > 0)) dtEmpInfo = ds.Tables[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 dtEmpInfo; } public void Get(TransactionContext tc, out Employee emp, string employeeNo) { emp = new Employee(); DataReader reader = new DataReader(EmployeeDA.Get(tc, employeeNo)); if (reader.Read()) emp = this.CreateObject(reader); reader.Close(); } //public void GetLoggedUserCredentials(out Employee emp, out SystemInformation sysInfo, out DataSet dsNotiAndPendi, string logInID) //{ // TransactionContext tc = null; // try // { // tc = TransactionContext.Begin(); // this.Get(tc, out emp, logInID); // if (emp != null || emp.ID == 0) // { // WFMovementTranService wfService = new WFMovementTranService(); // dsNotiAndPendi = wfService.GetNotificationAndPendingJobCount(tc, emp.ID); // SystemInformationService sys = new SystemInformationService(); // sys.Get(tc, out sysInfo); // } // else // { // if (tc != null) // tc.HandleError(); // throw new ServiceException("Employee not found"); // } // tc.End(); // } // catch (Exception e) // { // #region Handle Exception // if (tc != null) // tc.HandleError(); // ExceptionLog.Write(e); // throw new ServiceException(e.Message, e); // #endregion // } //} 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 DataSet GetEmployeeGenderRatio() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetEmployeeGenderRatio(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 ds; } public DataSet GetEmployeeSummaryData() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetEmployeeSummaryData(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 ds; } public DataSet GetEmployeeAttritionData() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetEmployeeAttritionData(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 ds; } public DataSet GetDashBoardGraphData() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetDashBoardGraphData(tc); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return ds; } public DataSet GetEmployeeSummaryDataByDepartment(Employee emp) { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetEmployeeSummaryDataByDepartment(tc, emp); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return ds; } public Employee GetByName(string EmpName) { Employee oEmployee = new Employee(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetByName(tc, EmpName)); if (oreader.Read()) { oEmployee = this.CreateObject(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 List GetByPrimaryLMID(int employeeID) { List employees = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetByPrimaryLMID(tc, employeeID)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public List GetFirstLMTeamMembers(int employeeID) { List oEmployees = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetFirstLMTeamMembers(tc, employeeID)); oEmployees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oEmployees; } public List GetSubordinatesByLineManager(int employeeID) { List oEmployees = null; TransactionContext sc = null; try { sc = TransactionContext.Begin(); DataReader oreader = new DataReader(EmployeeDA.GetSubordinatesByLineManager(sc, employeeID)); oEmployees = this.CreateObjects(oreader); oreader.Close(); sc.End(); } catch (Exception e) { #region Handle Exception if (sc != null) sc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oEmployees; } public DataTable GetSubordinatesByLineManagerForMobile(int employeeID) { TransactionContext sc = null; try { sc = TransactionContext.Begin(); return EmployeeDA.GetsubordinateforMobile(sc, employeeID); sc.End(); } catch (Exception e) { #region Handle Exception if (sc != null) sc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public DataTable GetSubordinatesByLineManagerForMobileWithNoLock(int employeeID) { TransactionContext sc = null; try { sc = TransactionContext.Begin(); return EmployeeDA.GetSubordinatesByLineManagerForMobileWithNoLock(sc, employeeID); sc.End(); } catch (Exception e) { #region Handle Exception if (sc != null) sc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public DataSet GetEstimatedConfirmationReport() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetEstimatedConfirmationReport(tc); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return ds; } public DataSet GetEstimatedRetirementReport() { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetEstimatedRetirementReport(tc); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return ds; } public DataSet GetSelfServiceBasicData(int employeeId) { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetSelfServiceBasicData(tc, employeeId); ds.Tables[0].Columns.Add("ServiceTenure"); ds.Tables[0].Columns.Add("Age"); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { ds.Tables[0].Rows[0]["ServiceTenure"] = GlobalFunctions.AgeCalculate(Convert.ToDateTime(ds.Tables[0].Rows[0]["JoiningDate"]), DateTime.Today); ds.Tables[0].Rows[0]["Age"] = GlobalFunctions.AgeCalculate(Convert.ToDateTime(ds.Tables[0].Rows[0]["BirthDate"]), DateTime.Today); } } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return ds; } public DataSet GetSelfServiceContactData(int employeeId) { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetSelfServiceContactData(tc, employeeId); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return ds; } public DataTable GetBasic(string sEmpIDs) { DataSet gradeWiseCountDS = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); gradeWiseCountDS = EmployeeDA.GetBasic(tc, sEmpIDs); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return gradeWiseCountDS.Tables[0]; } public List GetEmployeesRequisitionID(int requisitionID) { List oEmployees = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(InternalRecruitmentDA.GetEmployeesRequisitionID(tc, requisitionID)); oEmployees = this.CreateObjects(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; } public DataSet GetLandingPageData(int isEmployee, int isLeave, int isAttendance, int payrollTypeId) { TransactionContext tc = null; DataSet ds = new DataSet(); try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetLandingPageData(tc, isEmployee, isLeave, isAttendance, 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 ds; } public DataSet GetHolidayInfoForDashboard() { TransactionContext tc = null; DataSet ds = new DataSet(); try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetHolidayInfoForDashboard(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 ds; } public DataSet GetBankAdviceReport(string sEmpIDs, string leaveYear) { DataSet oDataSet = null; TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); oDataSet = EmployeeDA.GetBankAdviceReport(tc, sEmpIDs, leaveYear); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } return oDataSet; } public DataSet GetEncashPayslip(string sEmpIDs, string leaveYear) { DataSet oDataSet = null; TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); oDataSet = EmployeeDA.GetEncashPayslip(tc, sEmpIDs, leaveYear); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } return oDataSet; } public DataSet GetLeaveCashAdvice(string sEmpIDs, string leaveYear) { DataSet oDataSet = null; TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); oDataSet = EmployeeDA.GetLeaveCashAdvice(tc, sEmpIDs, leaveYear); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } return oDataSet; } public DataSet GetEmpDigitalServiceBook(int empID) { DataSet dsetDSB = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(true); dsetDSB = EmployeeDA.GetEmpDigitalServiceBook(tc, empID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dsetDSB; } public bool IsCCApplicable(int empid, string companyCode, string salesEmail) { TransactionContext tc = null; bool isApplicable = false; try { tc = TransactionContext.Begin(); isApplicable = EmployeeDA.IsCCApplicable(tc, empid, companyCode, salesEmail); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return isApplicable; } public DataTable GetRegularizableEmail(string regularizableEmployeeIds) { TransactionContext tc = null; DataTable oDataTable = null; try { #region Retrieving data tc = TransactionContext.Begin(); oDataTable = EmployeeDA.GetRegularizableEmail(tc, regularizableEmployeeIds); tc.End(); #endregion } catch (Exception e) { #region Handle Exception tc?.HandleError(); throw new ServiceException(e.Message, e); #endregion } return oDataTable; } public DataSet GetMobileProfile(int EmpID) { TransactionContext tc = null; DataSet ds = new DataSet(); try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetMobileProfile(tc, EmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return ds; } public DataSet GetMobileProfileNew(int EmpID) { TransactionContext tc = null; DataSet ds = new DataSet(); try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetMobileProfileNew(tc, EmpID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return ds; } public DataTable GetMyTeam(Employee oEmp) { DataTable dt = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(true); dt = EmployeeDA.GetMyTeam(tc, oEmp); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dt; } public DataTable GetCordinatorTeam(Employee oEmp) { DataTable dt = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(true); dt = EmployeeDA.GetCordinatorTeam(tc, oEmp); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dt; } public DataTable GetEmployeeCount(Employee oEmp) { DataTable dt = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(true); dt = EmployeeDA.GetEmployeeCount(tc, oEmp); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dt; } public DataTable getEmpInfoForGateman(int empid) { DataTable dt = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(true); dt = EmployeeDA.getEmpInfoForGateman(tc, empid); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dt; } public DataTable GetEmpOrganogramInfo(Employee oEmp) { DataTable dt = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(true); dt = EmployeeDA.GetEmpOrganogramInfo(tc, oEmp); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dt; } public DataTable GetCostCenterInfo(string empID) { DataSet ds = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); ds = EmployeeDA.GetCostCenterInfo(tc, empID); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return ds.Tables[0]; } public List GetEmployeeByCoordinator(int corID) { TransactionContext tc = null; List employees = new List(); try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(EmployeeDA.GetEmployeeByCoordinator(tc, corID)); employees = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return employees; } public string GetNextCode(int payrollTypeId) { TransactionContext tc = null; string _code = ""; try { tc = TransactionContext.Begin(); _code = GlobalFunctionDA.GetMaxCode(tc, "employee", "employeeno"); tc.End(); int newCode = 0; int.TryParse(_code, out newCode); newCode = newCode + 1; _code = newCode.ToString(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return _code; } public DataSet GetPFLedger(string sEmpID, DateTime FromDate, DateTime toDate) { DataSet oGrossPay = new DataSet(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); oGrossPay = EmployeeDA.GetPFLedger(tc, sEmpID, FromDate, toDate); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oGrossPay; } public DataTable GetEmployeeNameAndNo(int payrolltypeid) { DataTable dt = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); dt = EmployeeDA.GetEmployeeNameAndNo(tc, payrolltypeid); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return dt; } } }