รวม code แก้ issue #1
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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(){
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user