From 78747c06746afc30a7e6aa6463a951778fd59380 Mon Sep 17 00:00:00 2001 From: Mohaimen Hasan Date: Mon, 9 Nov 2026 12:39:38 +0600 Subject: [PATCH] Previous --- HRM.BO/Employee/Employee.cs | 1 - HRM.DA/DA/Employee/EmployeeDA.cs | 12 ---- HRM.DA/Service/Employee/EmployeeService.cs | 31 --------- .../Employee/EmployeeController.cs | 69 ------------------- 4 files changed, 113 deletions(-) diff --git a/HRM.BO/Employee/Employee.cs b/HRM.BO/Employee/Employee.cs index 25e8573..4ddf416 100644 --- a/HRM.BO/Employee/Employee.cs +++ b/HRM.BO/Employee/Employee.cs @@ -522,7 +522,6 @@ namespace HRM.BO List GetAllEmps(); void UpdateLM2(List emps); List GetWithDiscontinue(int payrollTypeID); - List GetDiscontinuedInRange(DateTime fromDate, DateTime toDate, int payrollTypeID); List GetSubordinates(int employeeID); //List GetAllSubordinates(int nodeID); List GetByDeptShiftGFType(string deptIDs, int shiftID, string GFType, int payrollTypeID); diff --git a/HRM.DA/DA/Employee/EmployeeDA.cs b/HRM.DA/DA/Employee/EmployeeDA.cs index 27d205e..6adbd52 100644 --- a/HRM.DA/DA/Employee/EmployeeDA.cs +++ b/HRM.DA/DA/Employee/EmployeeDA.cs @@ -663,18 +663,6 @@ namespace HRM.DA return tc.ExecuteReader(sql); } - // Discontinue Employee Details report: employees discontinued (Status = Discontinued) - // whose discontinue date (ENDOFCONTRACTDATE) falls inside the date range. - internal static IDataReader GetDiscontinuedInRange(TransactionContext tc, DateTime fromDate, DateTime toDate, - int payrollTypeID) - { - string sql = SQLParser.MakeSQL( - "SELECT * FROM Employee WHERE STATUS = %n AND ENDOFCONTRACTDATE IS NOT NULL " - + "AND CAST(ENDOFCONTRACTDATE AS DATE) BETWEEN %d AND %d AND PAYROLLTYPEID = %n order by EmployeeNo", - (int)EnumEmployeeStatus.Discontinued, fromDate, toDate, payrollTypeID); - return tc.ExecuteReader(sql); - } - internal static IDataReader GetAllSubordinatesNew(TransactionContext tc, int employeeID) { //For Oracle diff --git a/HRM.DA/Service/Employee/EmployeeService.cs b/HRM.DA/Service/Employee/EmployeeService.cs index 5b368ad..f0d72a9 100644 --- a/HRM.DA/Service/Employee/EmployeeService.cs +++ b/HRM.DA/Service/Employee/EmployeeService.cs @@ -1482,37 +1482,6 @@ namespace HRM.DA return employees; } - public List GetDiscontinuedInRange(DateTime fromDate, DateTime toDate, int payrollTypeID) - { - List employees = new List(); - - TransactionContext tc = null; - try - { - tc = TransactionContext.Begin(); - - DataReader dr = new DataReader(EmployeeDA.GetDiscontinuedInRange(tc, fromDate, toDate, 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 GetWithDiscontinue(int payrollTypeID) { List employees = new List(); diff --git a/HRM.UI/Controllers/Employee/EmployeeController.cs b/HRM.UI/Controllers/Employee/EmployeeController.cs index fe3b1a4..9dd96d8 100644 --- a/HRM.UI/Controllers/Employee/EmployeeController.cs +++ b/HRM.UI/Controllers/Employee/EmployeeController.cs @@ -2213,75 +2213,6 @@ namespace HRM.UI.Controllers return Ok(items); } - public class DiscontinueEmpDetailRequest - { - public string FromDate { get; set; } // yyyy-MM-dd - public string ToDate { get; set; } // yyyy-MM-dd - } - - /// - /// Discontinue Employee Details report: the same columns as Employee Details (getEmpDetailInfo), - /// but only for employees discontinued between FromDate and ToDate (by discontinue date), - /// in the current payroll type, plus their Discontinue Date. Reuses GetEmpDetailInfo unchanged. - /// - [HttpPost("getDiscontinueEmpDetailInfo")] - public ActionResult GetDiscontinueEmpDetailInfo(DiscontinueEmpDetailRequest request) - { - DateTime fromDate, toDate; - if (request == null - || !DateTime.TryParseExact(request.FromDate, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture, - System.Globalization.DateTimeStyles.None, out fromDate) - || !DateTime.TryParseExact(request.ToDate, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture, - System.Globalization.DateTimeStyles.None, out toDate)) - return BadRequest("Please select a valid From Date and To Date."); - if (fromDate > toDate) - return BadRequest("From Date cannot be after To Date."); - - List discontinued; - try - { - CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); - discontinued = _EmployeeService.GetDiscontinuedInRange(fromDate, toDate, (int)currentUser.PayrollTypeID); - } - catch (Exception e) - { - return StatusCode(StatusCodes.Status500InternalServerError, e.Message); - } - - if (discontinued.Count == 0) - return Ok(new List()); - - // Built here rather than with Employee.getSearchEmp, which casts DepartmentID for - // LocationID/GradeID and throws when an employee has no department. - List selected = discontinued - .Select(x => new SearchEmployee { ID = x.ID, EmployeeID = x.ID, EmployeeNo = x.EmployeeNo, Name = x.Name }) - .ToList(); - ActionResult detailResult = GetEmpDetailInfo(selected); - if (!(detailResult is OkObjectResult ok) || !(ok.Value is List details)) - return detailResult; - - var serializer = JsonSerializer.Create(new JsonSerializerSettings - { - ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() - }); - var discontinueDates = discontinued - .GroupBy(x => x.EmployeeNo) - .ToDictionary(g => g.Key, g => g.First().EndOfContractDate); - - var rows = new List(); - foreach (EmployeeDetailInfo item in details) - { - var row = Newtonsoft.Json.Linq.JObject.FromObject(item, serializer); - DateTime? discontinueDate = null; - if (item.EmployeeNo != null && discontinueDates.TryGetValue(item.EmployeeNo, out DateTime? d)) - discontinueDate = d; - row["discontinueDate"] = discontinueDate; - rows.Add(row); - } - - return Ok(rows); - } - //[HttpPost("getEmpApiResponse")] //[AllowAnonymous]