diff --git a/Models/eva_evaluation_achievement/eva_evaluation_achievementService.cs b/Models/eva_evaluation_achievement/eva_evaluation_achievementService.cs index 4b67fba..6977732 100644 --- a/Models/eva_evaluation_achievement/eva_evaluation_achievementService.cs +++ b/Models/eva_evaluation_achievement/eva_evaluation_achievementService.cs @@ -142,6 +142,14 @@ namespace TodoAPI2.Models var entity = GetEntity(model); entity.id = GetNewPrimaryKey(); + var current_sum = (from i in _repository.Context.eva_evaluation_achievement + select i.weight).Sum(); + + if (current_sum + model.weight > 100) + { + throw new Exception("ไม่สามารถบันทึกค่าน้ำหนักในส่วนผลสัมฤทธิ์ของงาน ได้เกิน 100"); + } + if (!string.IsNullOrEmpty(model.thefile)) { //Move file from temp to physical @@ -157,6 +165,18 @@ namespace TodoAPI2.Models public eva_evaluation_achievementViewModel Update(int id, eva_evaluation_achievementInputModel model) { + var current_sum = (from i in _repository.Context.eva_evaluation_achievement + select i.weight).Sum(); + + var current_item_weight = (from i in _repository.Context.eva_evaluation_achievement + where i.id==id + select i.weight).Sum(); + + if (current_sum - current_item_weight + model.weight > 100) + { + throw new Exception("ไม่สามารถบันทึกค่าน้ำหนักในส่วนผลสัมฤทธิ์ของงาน ได้เกิน 100"); + } + var existingEntity = _repository.Get(id); if (existingEntity != null) { diff --git a/Models/eva_evaluation_behavior/eva_evaluation_behaviorService.cs b/Models/eva_evaluation_behavior/eva_evaluation_behaviorService.cs index b3c7c90..f7f4d94 100644 --- a/Models/eva_evaluation_behavior/eva_evaluation_behaviorService.cs +++ b/Models/eva_evaluation_behavior/eva_evaluation_behaviorService.cs @@ -140,7 +140,13 @@ namespace TodoAPI2.Models var entity = GetEntity(model); entity.id = GetNewPrimaryKey(); + var current_sum = (from i in _repository.Context.eva_evaluation_behavior + select i.weight).Sum(); + if (current_sum + model.weight > 100) + { + throw new Exception("ไม่สามารถบันทึกค่าน้ำหนักในส่วนผลสัมฤทธิ์ของงาน ได้เกิน 100"); + } var inserted = _repository.Insert(entity); @@ -149,6 +155,18 @@ namespace TodoAPI2.Models public eva_evaluation_behaviorViewModel Update(int id, eva_evaluation_behaviorInputModel model) { + var current_sum = (from i in _repository.Context.eva_evaluation_behavior + select i.weight).Sum(); + + var current_item_weight = (from i in _repository.Context.eva_evaluation_behavior + where i.id == id + select i.weight).Sum(); + + if (current_sum - current_item_weight + model.weight > 100) + { + throw new Exception("ไม่สามารถบันทึกค่าน้ำหนักในส่วนพฤติกรรมการปฏิบัติงาน ได้เกิน 100"); + } + var existingEntity = _repository.Get(id); if (existingEntity != null) { diff --git a/Views/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d.cshtml b/Views/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d.cshtml index 5dd090c..760b9d5 100644 --- a/Views/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d.cshtml +++ b/Views/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d.cshtml @@ -323,6 +323,9 @@ eva_create_evaluation_detail_summary1_SetEditForm(id); eva_create_evaluation_detail_review01_SetEditForm(id); eva_create_evaluation_detail_status_SetEditForm(id); + + setTimeout(Oneva_evaluation_achievement_process_scoreChange, 1000); + setTimeout(Oneva_evaluation_behavior_process_scoreChange, 1000); } else { eva_create_evaluation_detail_process_SetCreateForm(); } diff --git a/Views/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d2.cshtml b/Views/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d2.cshtml index c2797e4..48de5d5 100644 --- a/Views/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d2.cshtml +++ b/Views/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d2.cshtml @@ -369,6 +369,10 @@ eva_create_evaluation_detail_review01_SetEditForm(id); eva_create_evaluation_detail_review02_SetEditForm(id); eva_create_evaluation_detail_status_SetEditForm(id); + + setTimeout(Oneva_evaluation_achievement_process2_scoreChange, 1000); + setTimeout(Oneva_evaluation_behavior_process2_scoreChange, 1000); + } else { eva_create_evaluation_detail_process_SetCreateForm(); } diff --git a/wwwroot/js/eva_evaluation_achievement_process/eva_evaluation_achievement_process_inline.js b/wwwroot/js/eva_evaluation_achievement_process/eva_evaluation_achievement_process_inline.js index c1c3718..1a053fa 100644 --- a/wwwroot/js/eva_evaluation_achievement_process/eva_evaluation_achievement_process_inline.js +++ b/wwwroot/js/eva_evaluation_achievement_process/eva_evaluation_achievement_process_inline.js @@ -96,7 +96,17 @@ function eva_evaluation_achievement_process_Get(a, blankItem) { //AjaxGetRequest(apisite + '/api/eva_evaluation_achievement_process/GetListBycreate_evaluation_detail_id/' + a, successFunc, AlertDanger); } +function CheckValidValueachievement(){ + $('#eva_evaluation_achievement_processBody tr').each(function () { + var i = $(this).find("#rowCount").text(); + var score = $("#eva_evaluation_achievement_process_score_" + i).val(); + if(score > 5) $("#eva_evaluation_achievement_process_score_" + i).val(5); + if(score < 0) $("#eva_evaluation_achievement_process_score_" + i).val(0); + }); +} + function Oneva_evaluation_achievement_process_scoreChange(){ + CheckValidValueachievement(); var total_achievement = 0; var total_achievement_weight = 0; var total_achievement_score = 0; @@ -114,9 +124,12 @@ function Oneva_evaluation_achievement_process_scoreChange(){ $("#h_eva_evaluation_achievement_process_weight").text(total_achievement_weight.toFixed(2)); $("#h_eva_evaluation_achievement_process_score").text(total_achievement_score.toFixed(2)); - $("#eva_create_evaluation_detail_summary1_total_summary_chief").text(total_achievement.toFixed(2)); - $("#eva_create_evaluation_detail_summary1_Final_summary_chief").text(total_achievement_score.toFixed(2)); - $("#eva_create_evaluation_detail_summary1_achievement_chief").text(total_achievement.toFixed(2)); + var w1 = parseFloat($("#w1").text()); +console.log(w1); + + $("#eva_create_evaluation_detail_summary1_total_summary_chief").text((total_achievement * 20).toFixed(2)); + $("#eva_create_evaluation_detail_summary1_Final_summary_chief").text((total_achievement * 20).toFixed(2)); + $("#eva_create_evaluation_detail_summary1_achievement_chief").text((total_achievement_score * w1/10).toFixed(2)); calculationAllItem(); } diff --git a/wwwroot/js/eva_evaluation_achievement_process2/eva_evaluation_achievement_process2_inline.js b/wwwroot/js/eva_evaluation_achievement_process2/eva_evaluation_achievement_process2_inline.js index 503949a..7fce365 100644 --- a/wwwroot/js/eva_evaluation_achievement_process2/eva_evaluation_achievement_process2_inline.js +++ b/wwwroot/js/eva_evaluation_achievement_process2/eva_evaluation_achievement_process2_inline.js @@ -106,7 +106,17 @@ Oneva_evaluation_achievement_process2_scoreChange(); } +function CheckValidValueachievement(){ + $('#eva_evaluation_achievement_process2Body tr').each(function () { + var i = $(this).find("#rowCount").text(); + var score = $("#eva_evaluation_achievement_process2_score2_" + i).val(); + if(score > 5) $("#eva_evaluation_achievement_process2_score2_" + i).val(5); + if(score < 0) $("#eva_evaluation_achievement_process2_score2_" + i).val(0); + }); +} + function Oneva_evaluation_achievement_process2_scoreChange(){ + CheckValidValueachievement(); var total_achievement = 0; var total_achievement_weight = 0; var total_achievement_score = 0; @@ -123,9 +133,11 @@ function Oneva_evaluation_achievement_process2_scoreChange(){ $("#h_eva_evaluation_achievement_process2_weight").text(total_achievement_weight.toFixed(2)); $("#h_eva_evaluation_achievement_process2_score2").text(total_achievement_score.toFixed(2)); - $("#eva_create_evaluation_detail_summary2_total_summary_supervisor").text(total_achievement.toFixed(2)); - $("#eva_create_evaluation_detail_summary2_Final_summary_supervisor").text(total_achievement_score.toFixed(2)); - $("#eva_create_evaluation_detail_summary2_achievement_supervisor").text(total_achievement.toFixed(2)); + var w1 = parseFloat($("#w1").text()); + + $("#eva_create_evaluation_detail_summary2_total_summary_supervisor").text((total_achievement*20).toFixed(2)); + $("#eva_create_evaluation_detail_summary2_Final_summary_supervisor").text((total_achievement*20).toFixed(2)); + $("#eva_create_evaluation_detail_summary2_achievement_supervisor").text((total_achievement_score*w1/10).toFixed(2)); calculationAllItem(); } diff --git a/wwwroot/js/eva_evaluation_behavior_process/eva_evaluation_behavior_process_inline.js b/wwwroot/js/eva_evaluation_behavior_process/eva_evaluation_behavior_process_inline.js index 5da8034..5f8f8ae 100644 --- a/wwwroot/js/eva_evaluation_behavior_process/eva_evaluation_behavior_process_inline.js +++ b/wwwroot/js/eva_evaluation_behavior_process/eva_evaluation_behavior_process_inline.js @@ -99,7 +99,17 @@ tag += ' 5) $("#eva_evaluation_behavior_process_score_" + i).val(5); + if(score < 0) $("#eva_evaluation_behavior_process_score_" + i).val(0); + }); +} + function Oneva_evaluation_behavior_process_scoreChange(){ + CheckValidValuebehavior(); var total_behavior = 0; var total_behavior_weight = 0; var total_behavior_score = 0; @@ -117,9 +127,11 @@ function Oneva_evaluation_behavior_process_scoreChange(){ $("#h_eva_evaluation_behavior_process_weight").text(total_behavior_weight.toFixed(2)); $("#h_eva_evaluation_behavior_process_score").text(total_behavior_score.toFixed(2)); - $("#eva_create_evaluation_detail_summary1_total_summary_competency_chief").text(total_behavior.toFixed(2)); - $("#eva_create_evaluation_detail_summary1_Final_summary_competency_chief").text(total_behavior_score.toFixed(2)); - $("#eva_create_evaluation_detail_summary1_competency_chief").text(total_behavior.toFixed(2)); + var w2 = parseFloat($("#w2").text()); + + $("#eva_create_evaluation_detail_summary1_total_summary_competency_chief").text((total_behavior * 20).toFixed(2)); + $("#eva_create_evaluation_detail_summary1_Final_summary_competency_chief").text((total_behavior * 20).toFixed(2)); + $("#eva_create_evaluation_detail_summary1_competency_chief").text((total_behavior_score * w2 /10).toFixed(2)); calculationAllItem(); } diff --git a/wwwroot/js/eva_evaluation_behavior_process2/eva_evaluation_behavior_process2_inline.js b/wwwroot/js/eva_evaluation_behavior_process2/eva_evaluation_behavior_process2_inline.js index cf621f5..ccc7037 100644 --- a/wwwroot/js/eva_evaluation_behavior_process2/eva_evaluation_behavior_process2_inline.js +++ b/wwwroot/js/eva_evaluation_behavior_process2/eva_evaluation_behavior_process2_inline.js @@ -102,7 +102,17 @@ Oneva_evaluation_behavior_process2_scoreChange(); } +function CheckValidValuebehavior(){ + $('#eva_evaluation_behavior_process2Body tr').each(function () { + var i = $(this).find("#rowCount").text(); + var score = $("#eva_evaluation_behavior_process2_score2_" + i).val(); + if(score > 5) $("#eva_evaluation_behavior_process2_score2_" + i).val(5); + if(score < 0) $("#eva_evaluation_behavior_process2_score2_" + i).val(0); + }); +} + function Oneva_evaluation_behavior_process2_scoreChange(){ + CheckValidValuebehavior(); var total_behavior = 0; var total_behavior_weight = 0; var total_behavior_score = 0; @@ -119,9 +129,11 @@ function Oneva_evaluation_behavior_process2_scoreChange(){ $("#h_eva_evaluation_behavior_process2_weight").text(total_behavior_weight.toFixed(2)); $("#h_eva_evaluation_behavior_process2_score2").text(total_behavior_score.toFixed(2)); - $("#eva_create_evaluation_detail_summary2_total_summary_competency_supervisor").text(total_behavior.toFixed(2)); - $("#eva_create_evaluation_detail_summary2_Final_summary_competency_supervisor").text(total_behavior_score.toFixed(2)); - $("#eva_create_evaluation_detail_summary2_competency_supervisor").text(total_behavior.toFixed(2)); + var w2 = parseFloat($("#w2").text()); + + $("#eva_create_evaluation_detail_summary2_total_summary_competency_supervisor").text((total_behavior*20).toFixed(2)); + $("#eva_create_evaluation_detail_summary2_Final_summary_competency_supervisor").text((total_behavior*20).toFixed(2)); + $("#eva_create_evaluation_detail_summary2_competency_supervisor").text((total_behavior_score*w2/10).toFixed(2)); calculationAllItem(); }