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

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; }
}