รวม code แก้ issue #1

This commit is contained in:
Nakorn Rientrakrunchai
2020-02-21 00:16:37 +07:00
parent e4f3417bef
commit d9ca4b0aed
8 changed files with 106 additions and 12 deletions

View File

@@ -142,6 +142,14 @@ namespace TodoAPI2.Models
var entity = GetEntity(model); var entity = GetEntity(model);
entity.id = GetNewPrimaryKey(); 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)) if (!string.IsNullOrEmpty(model.thefile))
{ {
//Move file from temp to physical //Move file from temp to physical
@@ -157,6 +165,18 @@ namespace TodoAPI2.Models
public eva_evaluation_achievementViewModel Update(int id, eva_evaluation_achievementInputModel model) 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); var existingEntity = _repository.Get(id);
if (existingEntity != null) if (existingEntity != null)
{ {

View File

@@ -140,7 +140,13 @@ namespace TodoAPI2.Models
var entity = GetEntity(model); var entity = GetEntity(model);
entity.id = GetNewPrimaryKey(); 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); var inserted = _repository.Insert(entity);
@@ -149,6 +155,18 @@ namespace TodoAPI2.Models
public eva_evaluation_behaviorViewModel Update(int id, eva_evaluation_behaviorInputModel model) 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); var existingEntity = _repository.Get(id);
if (existingEntity != null) if (existingEntity != null)
{ {

View File

@@ -323,6 +323,9 @@
eva_create_evaluation_detail_summary1_SetEditForm(id); eva_create_evaluation_detail_summary1_SetEditForm(id);
eva_create_evaluation_detail_review01_SetEditForm(id); eva_create_evaluation_detail_review01_SetEditForm(id);
eva_create_evaluation_detail_status_SetEditForm(id); eva_create_evaluation_detail_status_SetEditForm(id);
setTimeout(Oneva_evaluation_achievement_process_scoreChange, 1000);
setTimeout(Oneva_evaluation_behavior_process_scoreChange, 1000);
} else { } else {
eva_create_evaluation_detail_process_SetCreateForm(); eva_create_evaluation_detail_process_SetCreateForm();
} }

View File

@@ -369,6 +369,10 @@
eva_create_evaluation_detail_review01_SetEditForm(id); eva_create_evaluation_detail_review01_SetEditForm(id);
eva_create_evaluation_detail_review02_SetEditForm(id); eva_create_evaluation_detail_review02_SetEditForm(id);
eva_create_evaluation_detail_status_SetEditForm(id); eva_create_evaluation_detail_status_SetEditForm(id);
setTimeout(Oneva_evaluation_achievement_process2_scoreChange, 1000);
setTimeout(Oneva_evaluation_behavior_process2_scoreChange, 1000);
} else { } else {
eva_create_evaluation_detail_process_SetCreateForm(); eva_create_evaluation_detail_process_SetCreateForm();
} }

View File

@@ -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); //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(){ function Oneva_evaluation_achievement_process_scoreChange(){
CheckValidValueachievement();
var total_achievement = 0; var total_achievement = 0;
var total_achievement_weight = 0; var total_achievement_weight = 0;
var total_achievement_score = 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_weight").text(total_achievement_weight.toFixed(2));
$("#h_eva_evaluation_achievement_process_score").text(total_achievement_score.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)); var w1 = parseFloat($("#w1").text());
$("#eva_create_evaluation_detail_summary1_Final_summary_chief").text(total_achievement_score.toFixed(2)); console.log(w1);
$("#eva_create_evaluation_detail_summary1_achievement_chief").text(total_achievement.toFixed(2));
$("#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(); calculationAllItem();
} }

View File

@@ -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(){ function Oneva_evaluation_achievement_process2_scoreChange(){
CheckValidValueachievement();
var total_achievement = 0; var total_achievement = 0;
var total_achievement_weight = 0; var total_achievement_weight = 0;
var total_achievement_score = 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_weight").text(total_achievement_weight.toFixed(2));
$("#h_eva_evaluation_achievement_process2_score2").text(total_achievement_score.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)); var w1 = parseFloat($("#w1").text());
$("#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)); $("#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(); calculationAllItem();
} }

View File

@@ -99,7 +99,17 @@ tag += '<td><input min="0" max="5" step=".01" onchange="Oneva_evaluation_behavio
} }
function CheckValidValuebehavior(){
$('#eva_evaluation_behavior_processBody tr').each(function () {
var i = $(this).find("#rowCount").text();
var score = $("#eva_evaluation_behavior_process_score_" + i).val();
if(score > 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(){ function Oneva_evaluation_behavior_process_scoreChange(){
CheckValidValuebehavior();
var total_behavior = 0; var total_behavior = 0;
var total_behavior_weight = 0; var total_behavior_weight = 0;
var total_behavior_score = 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_weight").text(total_behavior_weight.toFixed(2));
$("#h_eva_evaluation_behavior_process_score").text(total_behavior_score.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)); var w2 = parseFloat($("#w2").text());
$("#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)); $("#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(); calculationAllItem();
} }

View File

@@ -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(){ function Oneva_evaluation_behavior_process2_scoreChange(){
CheckValidValuebehavior();
var total_behavior = 0; var total_behavior = 0;
var total_behavior_weight = 0; var total_behavior_weight = 0;
var total_behavior_score = 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_weight").text(total_behavior_weight.toFixed(2));
$("#h_eva_evaluation_behavior_process2_score2").text(total_behavior_score.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)); var w2 = parseFloat($("#w2").text());
$("#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)); $("#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(); calculationAllItem();
} }