diff --git a/ApiControllers/rep_eva_limit_frame_planControllers.cs b/ApiControllers/rep_eva_limit_frame_planControllers.cs index 7abfaf8..6483992 100644 --- a/ApiControllers/rep_eva_limit_frame_planControllers.cs +++ b/ApiControllers/rep_eva_limit_frame_planControllers.cs @@ -138,7 +138,13 @@ namespace TodoAPI2.Controllers reader.Close(); var all_group = (from t in _repository.GetContext().eva_limit_frame_group + + join fk_eva_evaluation_group2 in _repository.GetContext().eva_evaluation_group on t.group_guid equals fk_eva_evaluation_group2.id + into eva_evaluation_groupResult2 + from fk_eva_evaluation_groupResult2 in eva_evaluation_groupResult2.DefaultIfEmpty() + where t.frame_plan_guid == model.frame_plan_guid + orderby fk_eva_evaluation_groupResult2.code select t); foreach(var u in all_group) { diff --git a/Models/eva_limit_frame_group/eva_limit_frame_groupService.cs b/Models/eva_limit_frame_group/eva_limit_frame_groupService.cs index d0f4ed7..17d2d9b 100644 --- a/Models/eva_limit_frame_group/eva_limit_frame_groupService.cs +++ b/Models/eva_limit_frame_group/eva_limit_frame_groupService.cs @@ -22,12 +22,15 @@ namespace TodoAPI2.Models private IBaseRepository2 _repository; private IMyDatabase db; private Iexternal_linkageService ext; + private Iexternal_employeeService emp; - public eva_limit_frame_groupService(IBaseRepository2 repository, IMyDatabase mydb, Iexternal_linkageService inext) + public eva_limit_frame_groupService(IBaseRepository2 repository, + IMyDatabase mydb, Iexternal_linkageService inext, Iexternal_employeeService inemp) { _repository = repository; db = mydb; ext = inext; + emp = inemp; } #region Private Functions @@ -172,6 +175,18 @@ namespace TodoAPI2.Models public eva_limit_frame_groupViewModel Update(Guid id, eva_limit_frame_groupInputModel model, bool is_force_save) { var existingEntity = _repository.Get(id); + + var plan = (from i in _repository.Context.eva_limit_frame_plan where i.plan_guid == existingEntity.frame_plan_guid select i).FirstOrDefault(); + + var all_all_emp = emp.GetAllEmployee(); + var mapping_dept = emp.GetDeptMapping(); + var working_record = from i in emp.GetWorkingRecord() +// where +//plan.executed_date.HasValue +//&& i.start_date <= plan.executed_date +//&& i.end_date >= plan.executed_date + select i; + if (existingEntity != null) { existingEntity.frame_plan_guid = model.frame_plan_guid; @@ -182,7 +197,24 @@ namespace TodoAPI2.Models existingEntity.total_salary_limit_rounded = model.total_salary_limit_rounded; existingEntity.remark = model.remark; - existingEntity.SetAutoField(_repository.Context); + foreach (var y in from z in _repository.Context.eva_limit_frame_employee where z.frame_group_guid == model.id orderby z.order_of_data select z) + { + int j = 1; + if (y.help_org_id.HasValue) + { + var theemp = (from q in all_all_emp where q.id == y.employee_id select q).FirstOrDefault(); + var thedetail = (from r in working_record where r.employee_id == y.employee_id select r).FirstOrDefault(); + var help_at = (from s in mapping_dept where s.id == thedetail.place select s).FirstOrDefault(); + if (theemp != null && thedetail != null && help_at != null) + { + if (model.remark != "") existingEntity.remark += "\n"; + existingEntity.remark += $"{j}.ในลำดับที่ {y.order_of_data} {theemp.fullname} ตำแหน่ง{theemp.position_name} {theemp.department_name} \nมาช่วยปฏิบัติงานที่{help_at.department_name} ตั้งแต่วันที่ {MyHelper.GetDateStringForReport(thedetail.start_date)} - {MyHelper.GetDateStringForReport(thedetail.end_date)} \nตาม{thedetail.subject}"; + } + j++; + } + } + + existingEntity.SetAutoField(_repository.Context); if (is_force_save) { diff --git a/Models/vw_limit_frame_plan/vw_limit_frame_planService.cs b/Models/vw_limit_frame_plan/vw_limit_frame_planService.cs index 2195ba6..354cbe9 100644 --- a/Models/vw_limit_frame_plan/vw_limit_frame_planService.cs +++ b/Models/vw_limit_frame_plan/vw_limit_frame_planService.cs @@ -276,6 +276,15 @@ namespace TodoAPI2.Models public vw_limit_frame_planViewModel Update(Guid id, vw_limit_frame_planInputModel model, bool is_force_save) { var existingEntity = _repository.Get(id); + var all_all_emp = emp.GetAllEmployee(); + var mapping_dept = emp.GetDeptMapping(); + var working_record = from i in emp.GetWorkingRecord() + where +model.executed_date.HasValue +&& i.start_date <= model.executed_date +&& i.end_date >= model.executed_date + select i; + if (existingEntity != null) { existingEntity.plan_guid = model.plan_guid; @@ -286,6 +295,27 @@ namespace TodoAPI2.Models existingEntity.limit_frame_005_total = model.limit_frame_005_total; existingEntity.limit_frame_005_total_rounded = model.limit_frame_005_total_rounded; + foreach (var x in from i in _repository.Context.eva_limit_frame_group where i.frame_plan_guid == id select i) + { + x.remark = ""; + foreach (var y in from z in _repository.Context.eva_limit_frame_employee where z.frame_group_guid == x.id orderby z.order_of_data select z) + { + int j = 1; + if (y.help_org_id.HasValue) + { + var theemp = (from q in all_all_emp where q.id == y.employee_id select q).FirstOrDefault(); + var thedetail = (from r in working_record where r.employee_id == y.employee_id select r).FirstOrDefault(); + var help_at = (from s in mapping_dept where s.id == thedetail.place select s).FirstOrDefault(); + if (theemp != null && thedetail != null && help_at != null) + { + if (x.remark != "") x.remark += "\n"; + x.remark += $"{j}.ในลำดับที่ {y.order_of_data} {theemp.fullname} ตำแหน่ง{theemp.position_name} {theemp.department_name} \nมาช่วยปฏิบัติงานที่{help_at.department_name} ตั้งแต่วันที่ {MyHelper.GetDateStringForReport(thedetail.start_date)} - {MyHelper.GetDateStringForReport(thedetail.end_date)} \nตาม{thedetail.subject}"; + } + j++; + } + } + } + existingEntity.SetAutoField(_repository.Context); if (is_force_save) diff --git a/wwwroot/js/eva_limit_frame_group/eva_limit_frame_group_d.js b/wwwroot/js/eva_limit_frame_group/eva_limit_frame_group_d.js index a8d7cb7..a728452 100644 --- a/wwwroot/js/eva_limit_frame_group/eva_limit_frame_group_d.js +++ b/wwwroot/js/eva_limit_frame_group/eva_limit_frame_group_d.js @@ -72,6 +72,7 @@ function eva_limit_frame_group_PutUpdate() { if (eva_limit_frame_group_editMode === "UPDATE") { var successFunc1 = function (result) { AlertSuccess(result.code + " " + result.message); + window.location.reload(); endLoad(); }; startLoad();