ปรับปรุงหน้า โควต้า เพิ่มเติม

This commit is contained in:
Nakorn Rientrakrunchai
2020-02-28 18:36:54 +07:00
parent 1ca6d4955d
commit 8c3ec683bf
8 changed files with 58 additions and 19 deletions

View File

@@ -30,6 +30,8 @@ namespace TodoAPI2.Models
public int? managed_by { get; set; }
public decimal? limit { get; set; }
public string active_mode { get; set; }
public List<eva_adjust_postponement_detail_quota_02InputModel> adjust_postponement_detail_quota_02_model;

View File

@@ -118,6 +118,7 @@ namespace TodoAPI2.Models
limit_frame_quota = m_eva_adjust_postponement_quota.limit_frame_quota,
command_no = m_eva_adjust_postponement_quota.command_no,
managed_by = m_eva_adjust_postponement_quota.managed_by,
limit = m_eva_adjust_postponement_quota.limit,
managed_by_external_linkage_external_name = fk_external_linkageResult7.fullname,
@@ -170,25 +171,30 @@ namespace TodoAPI2.Models
{
var entity = GetEntity(model);
entity.id = GetNewPrimaryKey();
entity.limit_quota = 0;
entity.limit_frame_quota = 0;
var all_emp = (from i in emp.GetListByemployee_type(null, null) select i.id).ToList();
AddMultipleDetail(entity.id, all_emp, entity.fiscal_year, entity.theRound);
var all_emp = emp.GetListByemployee_type(null, null);
var all_emp_id_list = (from i in all_emp select i.id).ToList();
entity.limit = AddMultipleDetail(entity.id, all_emp_id_list, entity.fiscal_year, entity.theRound, all_emp);
var inserted = _repository.Insert(entity);
return Get(inserted.id);
}
public string AddMultipleDetail(int? adjust_postponement_quota_id, List<int> model, int? fiscal_year, int? theRound)
public decimal AddMultipleDetail(int? adjust_postponement_quota_id, List<int> model, int? fiscal_year, int? theRound,
List<external_employeeViewModel> all_emp)
{
decimal sum_salary = 0;
if (!adjust_postponement_quota_id.HasValue)
{
return "0";
return sum_salary;
}
else
{
int k = 0;
var all_emp = emp.GetListByemployee_type(null, null);
var cylinder = (from z in _repository.Context.eva_salary_cylinder
select z).ToList();
int newkey = GetNewPrimaryKeyDetail();
@@ -197,7 +203,7 @@ namespace TodoAPI2.Models
where x.adjust_postponement_quota_id == adjust_postponement_quota_id
select x.employee_id).ToList();
decimal sum_salary = 0;
foreach (var i in model)
{
@@ -205,6 +211,12 @@ namespace TodoAPI2.Models
{
if (!checkExistEmployeeInInternal(i, ex))
{
var theemp = (from x in all_emp where x.id == i select x).FirstOrDefault();
if (theemp.salary.HasValue)
{
sum_salary += theemp.salary.Value;
}
var q = (from p in _repository.Context.eva_adjust_postponement_detail
where p.employee_id == i
&& p.eva_adjust_postponement.fiscal_year == fiscal_year
@@ -220,8 +232,6 @@ namespace TodoAPI2.Models
}
else
{
var theemp = (from x in all_emp where x.id == i select x).FirstOrDefault();
var r = new eva_adjust_postponement_detailEntity();
r.id = newkey;
r.adjust_postponement_id = null;
@@ -270,8 +280,7 @@ namespace TodoAPI2.Models
}
}
//_repository.Context.SaveChanges();
return k.ToString();
return sum_salary;
}
}
@@ -315,6 +324,7 @@ namespace TodoAPI2.Models
existingEntity.limit_frame_quota = model.limit_frame_quota;
existingEntity.command_no = model.command_no;
existingEntity.managed_by = model.managed_by;
// limit
quota02.UpdateMultiple(model.adjust_postponement_detail_quota_02_model);
@@ -341,7 +351,7 @@ namespace TodoAPI2.Models
existingEntity.limit_frame_quota = i.limit_frame_quota;
existingEntity.command_no = i.command_no;
existingEntity.managed_by = i.managed_by;
// limit
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
}
@@ -385,6 +395,15 @@ namespace TodoAPI2.Models
select i;
_repository.Context.RemoveRange(data);
var data2 = from i in _repository.Context.eva_adjust_postponement_detail
where i.adjust_postponement_quota_id == id && i.adjust_postponement_id != null
select i;
foreach(var i in data2)
{
i.adjust_postponement_quota_id = null;
}
_repository.Delete(id);
return;

View File

@@ -30,6 +30,8 @@ namespace TodoAPI2.Models
public int? managed_by { get; set; }
public decimal? limit { get; set; }
public string managed_by_external_linkage_external_name { get; set; }
}

View File

@@ -30,6 +30,7 @@
<div class="row">
<div class="col-md-12">
<input class="form-control" type="hidden" id="eva_adjust_postponement_quota_id" />
<input class="form-control" type="hidden" id="eva_adjust_postponement_quota_limit" />
<div class='row'>
<div class="form-group col-md-6">
@@ -56,12 +57,12 @@
<div class='row'>
<div class="form-group col-md-6">
<label id="lab_eva_adjust_postponement_quota_limit_frame_quota" for="eva_adjust_postponement_quota_limit_frame_quota">กรอบโควต้าพิเศษร้อยละ</label>
<input class="form-control" type="number" id="eva_adjust_postponement_quota_limit_frame_quota" iLabel="กรอบโควต้าพิเศษร้อยละ" iRequire="true" iGroup="eva_adjust_postponement_quota" />
<input onchange="Oneva_adjust_postponement_quota_limit_frame_quotaChange();" class="form-control" type="number" id="eva_adjust_postponement_quota_limit_frame_quota" iLabel="กรอบโควต้าพิเศษร้อยละ" iRequire="true" iGroup="eva_adjust_postponement_quota" />
</div>
<div class="form-group col-md-6">
<label id="lab_eva_adjust_postponement_quota_limit_quota" for="eva_adjust_postponement_quota_limit_quota">จำนวนเงินที่สามารถบริหารวงเงินโควต้าพิเศษ</label>
<input class="form-control" type="number" id="eva_adjust_postponement_quota_limit_quota" iLabel="จำนวนเงินที่สามารถบริหารวงเงินโควต้าพิเศษ" iRequire="true" iGroup="eva_adjust_postponement_quota" />
<input disabled class="form-control" type="number" id="eva_adjust_postponement_quota_limit_quota" iLabel="จำนวนเงินที่สามารถบริหารวงเงินโควต้าพิเศษ" iRequire="true" iGroup="eva_adjust_postponement_quota" />
</div>
</div>
<div class='row'>
@@ -69,6 +70,11 @@
<label id="lab_eva_adjust_postponement_quota_command_no" for="eva_adjust_postponement_quota_command_no">เลขที่คำสั่ง</label>
<input class="form-control" type="text" id="eva_adjust_postponement_quota_command_no" iLabel="เลขที่คำสั่ง" iRequire="true" iGroup="eva_adjust_postponement_quota" />
</div>
<div class="form-group col-md-6">
<label for="remain_quota">จำนวนเงินโควต้าพิเศษคงเหลือ</label>
<input class="form-control" type="text" id="remain_quota" iLabel="เลขที่คำสั่ง" iRequire="false" iGroup="eva_adjust_postponement_quota" />
</div>
</div>

View File

@@ -18,7 +18,7 @@ $("#eva_adjust_postponement_detail_quota_02_emp_fullname_" + i).text("");
$("#eva_adjust_postponement_detail_quota_02_emp_position_" + i).text("");
$("#eva_adjust_postponement_detail_quota_02_emp_level_" + i).text("");
$("#eva_adjust_postponement_detail_quota_02_total_score_" + i).text("");
$("#eva_adjust_postponement_detail_quota_02_eva_result_" + i).val("");
$("#eva_adjust_postponement_detail_quota_02_eva_result_" + i).text("");
}
@@ -41,7 +41,7 @@ $("#eva_adjust_postponement_detail_quota_02_emp_fullname_" + i).text(data.emp_fu
$("#eva_adjust_postponement_detail_quota_02_emp_position_" + i).text(data.emp_position);
$("#eva_adjust_postponement_detail_quota_02_emp_level_" + i).text(data.emp_level);
$("#eva_adjust_postponement_detail_quota_02_total_score_" + i).text(data.total_score);
$("#eva_adjust_postponement_detail_quota_02_eva_result_" + i).val(data.eva_result);
$("#eva_adjust_postponement_detail_quota_02_eva_result_" + i).text(data.eva_result);
}
@@ -65,7 +65,7 @@ eva_adjust_postponement_detail_quota_02Object.emp_fullname = obj.find("#eva_adju
eva_adjust_postponement_detail_quota_02Object.emp_position = obj.find("#eva_adjust_postponement_detail_quota_02_emp_position_" + i).text();
eva_adjust_postponement_detail_quota_02Object.emp_level = obj.find("#eva_adjust_postponement_detail_quota_02_emp_level_" + i).text();
eva_adjust_postponement_detail_quota_02Object.total_score = obj.find("#eva_adjust_postponement_detail_quota_02_total_score_" + i).text();
eva_adjust_postponement_detail_quota_02Object.eva_result = obj.find("#eva_adjust_postponement_detail_quota_02_eva_result_" + i).val();
eva_adjust_postponement_detail_quota_02Object.eva_result = obj.find("#eva_adjust_postponement_detail_quota_02_eva_result_" + i).text();
eva_adjust_postponement_detail_quota_02Object.active_mode = obj.find("#isActive_" + i + "_eva_adjust_postponement_detail_quota_02").val();
return eva_adjust_postponement_detail_quota_02Object;
@@ -103,7 +103,7 @@ function eva_adjust_postponement_detail_quota_02_Get(a, blankItem) {
tag += '<td><p id="eva_adjust_postponement_detail_quota_02_emp_position_' + (i + 1)+'" /></td>';
tag += '<td><p id="eva_adjust_postponement_detail_quota_02_emp_level_' + (i + 1)+'" /></td>';
tag += '<td><p id="eva_adjust_postponement_detail_quota_02_total_score_' + (i + 1)+'" /></td>';
tag += '<td><input class="form-control" type="text" id="eva_adjust_postponement_detail_quota_02_eva_result_' + (i + 1)+'" /></td>';
tag += '<td><p id="eva_adjust_postponement_detail_quota_02_eva_result_' + (i + 1)+'" /></td>';
tag += '<td><p id="eva_adjust_postponement_detail_quota_02_sarary_' + (i + 1)+'" /></td>';
tag += '<td><p id="eva_adjust_postponement_detail_quota_02_cost_living_' + (i + 1)+'" /></td>';

View File

@@ -11,8 +11,9 @@ $("#eva_adjust_postponement_quota_theRound").val(data.theRound);
$("#eva_adjust_postponement_quota_limit_quota").val(data.limit_quota);
$("#eva_adjust_postponement_quota_limit_frame_quota").val(data.limit_frame_quota);
$("#eva_adjust_postponement_quota_command_no").val(data.command_no);
$("#eva_adjust_postponement_quota_limit").val(data.limit);
DropDownClearFormAndFeedWithData($("#eva_adjust_postponement_quota_managed_by"), data, "id", "fullname", "item_managed_by", data.managed_by);
console.log($("#eva_adjust_postponement_quota_limit").val());
}
function eva_adjust_postponement_quota_GetFromForm() {
@@ -25,6 +26,7 @@ function eva_adjust_postponement_quota_GetFromForm() {
eva_adjust_postponement_quotaObject.limit_frame_quota = $("#eva_adjust_postponement_quota_limit_frame_quota").val();
eva_adjust_postponement_quotaObject.command_no = $("#eva_adjust_postponement_quota_command_no").val();
eva_adjust_postponement_quotaObject.managed_by = $("#eva_adjust_postponement_quota_managed_by").val();
eva_adjust_postponement_quotaObject.limit = $("#eva_adjust_postponement_quota_limit").val();
var eva_adjust_postponement_detail_quota_02 = [];
$('#eva_adjust_postponement_detail_quota_02Body tr').each(function () {
@@ -113,6 +115,14 @@ function eva_adjust_postponement_quota_GoDelete(a) {
//================= Multi-Selection Function =========================================
//================= Control Function =========================================
function Oneva_adjust_postponement_quota_limit_frame_quotaChange()
{
var limit_frame_quota = parseFloat($("#eva_adjust_postponement_quota_limit_frame_quota").val());
var limit = parseFloat($("#eva_adjust_postponement_quota_limit").val());
limit_quota = limit_frame_quota * limit / 100;
$("#eva_adjust_postponement_quota_limit_quota").val(limit_quota);
}