เพิ่ม source code แสดงรายงาน กรอบวงเงิน
This commit is contained in:
@@ -20,14 +20,17 @@ namespace TodoAPI2.Models
|
||||
public class eva_limit_frame_planService : Ieva_limit_frame_planService
|
||||
{
|
||||
private IBaseRepository2<eva_limit_frame_planEntity, Guid> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public eva_limit_frame_planService(IBaseRepository2<eva_limit_frame_planEntity, Guid> repository, IMyDatabase mydb, Iexternal_linkageService inext)
|
||||
public eva_limit_frame_planService(IBaseRepository2<eva_limit_frame_planEntity, Guid> repository, IMyDatabase mydb,
|
||||
Iexternal_linkageService inext, Iexternal_employeeService inemp)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
emp = inemp;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
@@ -47,7 +50,7 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
return Mapper.Map<List<eva_limit_frame_planViewModel>>(entities);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
@@ -94,12 +97,12 @@ namespace TodoAPI2.Models
|
||||
|
||||
public List<eva_limit_frame_planViewModel> GetListByexecuted_date(DateTime? executed_date)
|
||||
{
|
||||
var model = new eva_limit_frame_planSearchModel();
|
||||
var model = new eva_limit_frame_planSearchModel();
|
||||
model.executed_date = executed_date;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_limit_frame_planViewModel> GetListBySearch(eva_limit_frame_planSearchModel model)
|
||||
public List<eva_limit_frame_planViewModel> GetListBySearch(eva_limit_frame_planSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_limit_frame_plan in _repository.Context.eva_limit_frame_plan
|
||||
@@ -113,8 +116,8 @@ namespace TodoAPI2.Models
|
||||
from fk_external_linkageResult7 in external_linkageResult7.DefaultIfEmpty()
|
||||
|
||||
|
||||
where
|
||||
1 == 1
|
||||
where
|
||||
1 == 1
|
||||
&& (!model.executed_date.HasValue || m_eva_limit_frame_plan.executed_date == model.executed_date)
|
||||
|
||||
|
||||
@@ -158,9 +161,52 @@ namespace TodoAPI2.Models
|
||||
var entity = GetEntity(model);
|
||||
entity.id = Guid.NewGuid();
|
||||
|
||||
var all_group = (from i in _repository.Context.eva_evaluation_group
|
||||
select i);
|
||||
foreach(var x in all_group)
|
||||
{
|
||||
var all_emp = (from j in _repository.Context.eva_evaluation_group_detail
|
||||
join k in emp.GetAllEmployee() on j.employee_id equals k.id
|
||||
join m in ext.GetSortingDep() on k.department_id equals m.external_id
|
||||
where j.evaluation_group_id == x.id
|
||||
orderby m.external_code,
|
||||
k.hpt_position_type_id,
|
||||
k.hpl_position_level_id,
|
||||
k.employee_no
|
||||
select k);
|
||||
|
||||
var new_frame_group = new eva_limit_frame_groupEntity();
|
||||
new_frame_group.id = Guid.NewGuid();
|
||||
new_frame_group.frame_plan_guid = entity.id;
|
||||
new_frame_group.group_guid = x.id;
|
||||
new_frame_group.limit_frame_295 = (decimal?)2.95;
|
||||
new_frame_group.total_salary = all_emp.Sum(z => z.salary);
|
||||
new_frame_group.total_salary_limit = (new_frame_group.total_salary * new_frame_group.limit_frame_295 / 100);
|
||||
new_frame_group.total_salary_limit_rounded = new_frame_group.total_salary_limit;
|
||||
_repository.Context.Add(new_frame_group);
|
||||
|
||||
int i = 1;
|
||||
foreach (var y in all_emp)
|
||||
{
|
||||
var new_emp = new eva_limit_frame_employeeEntity();
|
||||
new_emp.id = Guid.NewGuid();
|
||||
new_emp.frame_group_guid = new_frame_group.id;
|
||||
new_emp.employee_id = y.id;
|
||||
new_emp.org_id = y.department_id;
|
||||
new_emp.position_text = y.position_name;
|
||||
new_emp.level_text = y.position_level_text;
|
||||
new_emp.salary = y.salary;
|
||||
new_emp.position_allowance = y.position_allowance;
|
||||
new_emp.monthly_remuneration = y.other_money;
|
||||
new_emp.cost_of_living = y.cost_of_living;
|
||||
new_emp.order_of_data = i;
|
||||
i++;
|
||||
_repository.Context.Add(new_emp);
|
||||
}
|
||||
}
|
||||
|
||||
entity.SetAutoField(_repository.Context);
|
||||
|
||||
entity.SetAutoField(_repository.Context);
|
||||
|
||||
if (is_force_save)
|
||||
{
|
||||
var inserted = _repository.Insert(entity);
|
||||
@@ -193,7 +239,7 @@ namespace TodoAPI2.Models
|
||||
existingEntity.limit_frame_005_total = model.limit_frame_005_total;
|
||||
existingEntity.limit_frame_005_total_rounded = model.limit_frame_005_total_rounded;
|
||||
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
|
||||
if (is_force_save)
|
||||
{
|
||||
@@ -209,32 +255,32 @@ namespace TodoAPI2.Models
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_limit_frame_planInputModel> model, bool is_force_save)
|
||||
public string UpdateMultiple(List<eva_limit_frame_planInputModel> model, bool is_force_save)
|
||||
{
|
||||
foreach(var i in model)
|
||||
foreach (var i in model)
|
||||
{
|
||||
if (i.active_mode == "1" && i.id.HasValue) // update
|
||||
{
|
||||
{
|
||||
var existingEntity = _repository.Get(i.id.Value);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.plan_guid = i.plan_guid;
|
||||
existingEntity.executed_date = i.executed_date;
|
||||
existingEntity.limit_frame_005 = i.limit_frame_005;
|
||||
existingEntity.status_self = i.status_self;
|
||||
existingEntity.status_chief = i.status_chief;
|
||||
existingEntity.supervisor1 = i.supervisor1;
|
||||
existingEntity.supervisor1_result = i.supervisor1_result;
|
||||
existingEntity.supervisor1_remark = i.supervisor1_remark;
|
||||
existingEntity.supervisor1_date = i.supervisor1_date;
|
||||
existingEntity.salary_adjustment_date = i.salary_adjustment_date;
|
||||
existingEntity.limit_frame_005_total = i.limit_frame_005_total;
|
||||
existingEntity.limit_frame_005_total_rounded = i.limit_frame_005_total_rounded;
|
||||
existingEntity.plan_guid = i.plan_guid;
|
||||
existingEntity.executed_date = i.executed_date;
|
||||
existingEntity.limit_frame_005 = i.limit_frame_005;
|
||||
existingEntity.status_self = i.status_self;
|
||||
existingEntity.status_chief = i.status_chief;
|
||||
existingEntity.supervisor1 = i.supervisor1;
|
||||
existingEntity.supervisor1_result = i.supervisor1_result;
|
||||
existingEntity.supervisor1_remark = i.supervisor1_remark;
|
||||
existingEntity.supervisor1_date = i.supervisor1_date;
|
||||
existingEntity.salary_adjustment_date = i.salary_adjustment_date;
|
||||
existingEntity.limit_frame_005_total = i.limit_frame_005_total;
|
||||
existingEntity.limit_frame_005_total_rounded = i.limit_frame_005_total_rounded;
|
||||
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
}
|
||||
}
|
||||
@@ -242,22 +288,22 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
var entity = GetEntity(i);
|
||||
entity.id = Guid.NewGuid();
|
||||
entity.SetAutoField(_repository.Context);
|
||||
entity.SetAutoField(_repository.Context);
|
||||
_repository.InsertWithoutCommit(entity);
|
||||
}
|
||||
else if (i.active_mode == "0" && i.id.HasValue) // remove
|
||||
{
|
||||
{
|
||||
_repository.DeleteWithoutCommit(i.id.Value);
|
||||
}
|
||||
else if (i.active_mode == "0" && !i.id.HasValue)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_force_save)
|
||||
{
|
||||
_repository.Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
return model.Count().ToString();
|
||||
}
|
||||
@@ -276,12 +322,25 @@ namespace TodoAPI2.Models
|
||||
}
|
||||
public void Delete(Guid id)
|
||||
{
|
||||
var all_group = (from i in _repository.Context.eva_limit_frame_group
|
||||
where i.frame_plan_guid == id
|
||||
select i);
|
||||
foreach (var x in all_group)
|
||||
{
|
||||
var all_emp = from i in _repository.Context.eva_limit_frame_employee
|
||||
where i.frame_group_guid == x.id
|
||||
select i;
|
||||
_repository.Context.RemoveRange(all_emp);
|
||||
}
|
||||
|
||||
_repository.Context.RemoveRange(all_group);
|
||||
|
||||
_repository.Delete(id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void RefreshAutoFieldOfAllData()
|
||||
public void RefreshAutoFieldOfAllData()
|
||||
{
|
||||
var all_items = from i in _repository.Context.eva_limit_frame_plan
|
||||
select i;
|
||||
@@ -292,7 +351,7 @@ namespace TodoAPI2.Models
|
||||
_repository.Context.SaveChanges();
|
||||
}
|
||||
|
||||
private Dictionary<string,string> GetLookupForLog()
|
||||
private Dictionary<string, string> GetLookupForLog()
|
||||
{
|
||||
var i = new Dictionary<string, string>();
|
||||
|
||||
@@ -313,7 +372,7 @@ namespace TodoAPI2.Models
|
||||
i.Add("salary_adjustment_date", "เลื่อนเงินเดือนวันที่");
|
||||
i.Add("txt_salary_adjustment_date", "เลื่อนเงินเดือนวันที่");
|
||||
i.Add("limit_frame_005_total", "กันวงเงินไว้");
|
||||
i.Add("limit_frame_005_total_rounded", "กันวงเงินใช้จริง");
|
||||
i.Add("limit_frame_005_total_rounded", "กันวงเงินใช้จริง");
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user