From 4623ca3ff3238621800738c3abbb044c5ffcc15d Mon Sep 17 00:00:00 2001 From: "LAPTOP-KB8JC2K2\\acer" Date: Tue, 6 Apr 2021 21:46:39 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=E0=B8=9B?= =?UTF-8?q?=E0=B8=A3=E0=B8=B8=E0=B8=87=E0=B9=80=E0=B8=89=E0=B8=9E=E0=B8=B2?= =?UTF-8?q?=E0=B8=B0=E0=B8=AA=E0=B9=88=E0=B8=A7=E0=B8=99=E0=B8=97=E0=B8=B5?= =?UTF-8?q?=E0=B9=88=E0=B9=80=E0=B8=81=E0=B8=B5=E0=B9=88=E0=B8=A2=E0=B8=A7?= =?UTF-8?q?=E0=B8=81=E0=B8=B1=E0=B8=9A=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=87?= =?UTF-8?q?=E0=B8=B2=E0=B8=99=20=E0=B9=81=E0=B8=A5=E0=B8=B0=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A1=E0=B8=A7?= =?UTF-8?q?=E0=B8=A5=E0=B8=9C=E0=B8=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rep_eva_limit_frame_planControllers.cs | 6 ++++ .../eva_limit_frame_groupService.cs | 36 +++++++++++++++++-- .../vw_limit_frame_planService.cs | 30 ++++++++++++++++ .../eva_limit_frame_group_d.js | 1 + 4 files changed, 71 insertions(+), 2 deletions(-) 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();