From dc1309640fdfb629c2332c009c00f45811664173 Mon Sep 17 00:00:00 2001 From: mashfiq Date: Sun, 27 Apr 2025 11:13:48 +0600 Subject: [PATCH] manual entry --- HRM.BO/Attendance/DailyAttnProcess.cs | 28 +++--- HRM.DA/DA/Attendance/DailyAttnProcessDA.cs | 5 ++ .../Attendance/DailyAttnProcessService.cs | 27 +++++- .../Attendance/AttendanceController.cs | 87 +++++++++++++++++++ 4 files changed, 133 insertions(+), 14 deletions(-) diff --git a/HRM.BO/Attendance/DailyAttnProcess.cs b/HRM.BO/Attendance/DailyAttnProcess.cs index 276aebe..1efed3a 100644 --- a/HRM.BO/Attendance/DailyAttnProcess.cs +++ b/HRM.BO/Attendance/DailyAttnProcess.cs @@ -441,20 +441,21 @@ namespace HRM.BO } } - public bool OnlyManualInTime - { - get { - return (this.IsManualEntry == true && this.ActualInTime != null) ? true : false;} + //public bool OnlyManualInTime + //{ + // get { + // return (this.IsManualEntry == true && this.ActualInTime != null) ? true : false;} - } - public bool OnlyManualOutTime - { - get - { - return (this.IsManualEntry == true && this.ActualOutTime != null) ? true : false; - } - } - + //} + //public bool OnlyManualOutTime + //{ + // get + // { + // return (this.IsManualEntry == true && this.ActualOutTime != null) ? true : false; + // } + //} + public bool OnlyManualInTime { get; set; } + public bool OnlyManualOutTime { get; set; } @@ -3382,6 +3383,7 @@ namespace HRM.BO DataTable getTopEmpAbsentData(Employee oEmp, EnumAttendanceType type); DataTable getcorehrAbsentData(Employee oEmp, EnumAttendanceType type); DataSet AttnDaysSummaryForSalaryProcess(DateTime FromDate, DateTime ToDate); + List GetByEmployees(DateTime attnDate, string employeeIDs); } #endregion diff --git a/HRM.DA/DA/Attendance/DailyAttnProcessDA.cs b/HRM.DA/DA/Attendance/DailyAttnProcessDA.cs index 6e1c3db..d60c7d2 100644 --- a/HRM.DA/DA/Attendance/DailyAttnProcessDA.cs +++ b/HRM.DA/DA/Attendance/DailyAttnProcessDA.cs @@ -4092,6 +4092,11 @@ namespace HRM.DA return ds.Tables[0]; } + internal static IDataReader GetByEmployees(TransactionContext tc, DateTime attnDate, string employeeIDs) + { + return tc.ExecuteReader("SELECT * FROM DailyAttnProcess WHERE AttnDate=%d And employeeid in (%q)", attnDate, employeeIDs); + + } } #endregion diff --git a/HRM.DA/Service/Attendance/DailyAttnProcessService.cs b/HRM.DA/Service/Attendance/DailyAttnProcessService.cs index 14f6208..c75ebb9 100644 --- a/HRM.DA/Service/Attendance/DailyAttnProcessService.cs +++ b/HRM.DA/Service/Attendance/DailyAttnProcessService.cs @@ -46,7 +46,9 @@ namespace HRM.DA oDailyAttnProcess.AttenType = (EnumAttendanceType)oReader.GetInt32("AttenType").Value; oDailyAttnProcess.Comments = oReader.GetString("Comments") == null ? "" : oReader.GetString("Comments"); oDailyAttnProcess.Reason = oReader.GetString("Reason") == null ? "" : oReader.GetString("Reason"); - oDailyAttnProcess.IsManualEntry = oReader.GetBoolean("IsManualEntry").Value; + oDailyAttnProcess.IsManualEntry = oReader.GetBoolean("IsManualEntry", false); + oDailyAttnProcess.OnlyManualInTime = oReader.GetBoolean("OnlyManualInTime", false); + oDailyAttnProcess.OnlyManualOutTime = oReader.GetBoolean("OnlyManualOutTime").Value; oDailyAttnProcess.IsFromMobile = (EnumIsFromMobile)oReader.GetInt32("IsFromMobile").Value; oDailyAttnProcess.InTimeLatitude = oReader.GetString("InTimeLatitude") == null ? 0.0m : Convert.ToDecimal(oReader.GetString("InTimeLatitude")); oDailyAttnProcess.OutTimeLatitude = oReader.GetString("OutTimeLatitude") == null ? 0.0m : Convert.ToDecimal(oReader.GetString("OutTimeLatitude")); @@ -4807,6 +4809,29 @@ namespace HRM.DA return dt; } + public List GetByEmployees(DateTime attnDate, string employeeIDs) + { + List dailyAttnProcesses = new List(); + TransactionContext tc = null; + try + { + tc = TransactionContext.Begin(); + DataReader dr = new DataReader(DailyAttnProcessDA.GetByEmployees(tc, attnDate, employeeIDs)); + dailyAttnProcesses = 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 dailyAttnProcesses; + } } diff --git a/HRM.UI/Controllers/Attendance/AttendanceController.cs b/HRM.UI/Controllers/Attendance/AttendanceController.cs index 9387ff3..a5a45cd 100644 --- a/HRM.UI/Controllers/Attendance/AttendanceController.cs +++ b/HRM.UI/Controllers/Attendance/AttendanceController.cs @@ -1331,6 +1331,93 @@ namespace HRM.UI.Controllers.Attendance return Ok(attnProcesses); } + [HttpPost("getDailyAttnProcessByEmpForManualEntry")] + public ActionResult getDailyAttnProcessByEmpForManualEntry(dynamic data) + { + List _dAttnProcessess = new List(); + DailyAttnProcess _dAttnProcess = new DailyAttnProcess(); + try + { + var items = Newtonsoft.Json.JsonConvert.DeserializeObject(Convert.ToString(data)); + string empids = ""; + DateTime attnDate = DateTime.Today; + List empIdList = new List(); + foreach (var item in items) + { + int empID = (int)item["employeeid"].ToObject(); + empids = empids + empID.ToString() + ","; + attnDate = (DateTime)item["attnDate"].ToObject(); + empIdList.Add(empID); + } + + if (empids.Length > 0) + { + empids = empids.Substring(0, empids.Length - 1); + } + + attnDate = new DateTime(attnDate.Year, attnDate.Month, attnDate.Day); + List dAttnProcessess = this._dailyAttnProcessService.GetByEmployees(attnDate, empids); + + + //List DailyAttnProcesses = new List(); + + foreach (var empid in empIdList) + { + bool existInList = false; + foreach (DailyAttnProcess dattnPs in _dAttnProcessess) + { + if (dattnPs.EmployeeID == empid) + { + existInList = true; + } + } + if (!existInList) + { + bool ExistInSavedData = false; + if (dAttnProcessess != null && dAttnProcessess.Count > 0) + { + foreach (DailyAttnProcess dAttnProcess in dAttnProcessess) + { + if (dAttnProcess.EmployeeID == empid) + { + ExistInSavedData = true; + _dAttnProcessess.Add(dAttnProcess); + } + } + } + + if (!ExistInSavedData) + { + _dAttnProcess = new DailyAttnProcess(); + + _dAttnProcess.EmployeeID = empid; + //_dAttnProcess.Employee.EmployeeNo = sEmp.Employee.EmployeeNo; + //_dAttnProcess.Employee.Name = sEmp.Employee.Name; + _dAttnProcessess.Add(_dAttnProcess); + } + } + } + + + if (_dAttnProcessess != null && _dAttnProcessess.Count > 0) + { + int serial = 1; + foreach (DailyAttnProcess dAttnProcess in _dAttnProcessess) + { + if (dAttnProcess.IsNew) + { + + } + } + } + } + catch (Exception e) + { + return StatusCode(StatusCodes.Status500InternalServerError, e.Message); + } + + return Ok(_dAttnProcessess); + } // DailyAttnProcess [HttpGet("getDailyAttnProcessByEmployeeId/{employeeId}")]