รวมหน้าจอ วงเงินที่ใช้ในการเลื่อนเงินเดือน
This commit is contained in:
32
Models/vw_limit_frame_plan/Ivw_limit_frame_planService.cs
Normal file
32
Models/vw_limit_frame_plan/Ivw_limit_frame_planService.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TTSW.EF;
|
||||
using TTSW.Utils;
|
||||
using TTSW.Constant;
|
||||
using TTSW.Common;
|
||||
using TodoAPI2.Models;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public interface Ivw_limit_frame_planService : IBaseService2<Guid, vw_limit_frame_planInputModel, vw_limit_frame_planViewModel>
|
||||
{
|
||||
new vw_limit_frame_planViewModel Insert(vw_limit_frame_planInputModel model, bool is_force_save);
|
||||
new vw_limit_frame_planViewModel Update(Guid id, vw_limit_frame_planInputModel model, bool is_force_save);
|
||||
List<vw_limit_frame_planViewModel> GetListByexecuted_date(DateTime? executed_date);
|
||||
List<vw_limit_frame_planViewModel> GetListBySearch(vw_limit_frame_planSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<vw_limit_frame_planInputModel> model, bool is_force_save);
|
||||
vw_limit_frame_planWithSelectionViewModel GetWithSelection(Guid id);
|
||||
vw_limit_frame_planWithSelectionViewModel GetBlankItem();
|
||||
|
||||
void RefreshAutoFieldOfAllData();
|
||||
eva_limit_frame_planEntity GetEntity(Guid id);
|
||||
DataContext GetContext();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
36
Models/vw_limit_frame_plan/vw_limit_frame_planInputModel.cs
Normal file
36
Models/vw_limit_frame_plan/vw_limit_frame_planInputModel.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TTSW.EF;
|
||||
using TTSW.Utils;
|
||||
using TTSW.Constant;
|
||||
using TTSW.Common;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class vw_limit_frame_planInputModel
|
||||
{
|
||||
|
||||
public Guid? id { get; set; }
|
||||
|
||||
public Guid? plan_guid { get; set; }
|
||||
|
||||
public DateTime? executed_date { get; set; }
|
||||
|
||||
public decimal? limit_frame_005 { get; set; }
|
||||
|
||||
public DateTime? salary_adjustment_date { get; set; }
|
||||
|
||||
public decimal? total_salary { get; set; }
|
||||
|
||||
public decimal? limit_frame_005_total { get; set; }
|
||||
|
||||
public decimal? limit_frame_005_total_rounded { get; set; }
|
||||
|
||||
public string active_mode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TTSW.EF;
|
||||
using TTSW.Utils;
|
||||
using TTSW.Constant;
|
||||
using TTSW.Common;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class vw_limit_frame_planReportRequestModel : vw_limit_frame_planSearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
23
Models/vw_limit_frame_plan/vw_limit_frame_planSearchModel.cs
Normal file
23
Models/vw_limit_frame_plan/vw_limit_frame_planSearchModel.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TTSW.EF;
|
||||
using TTSW.Utils;
|
||||
using TTSW.Constant;
|
||||
using TTSW.Common;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class vw_limit_frame_planSearchModel
|
||||
{
|
||||
|
||||
public Guid id { get; set; }
|
||||
|
||||
public DateTime? executed_date { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
363
Models/vw_limit_frame_plan/vw_limit_frame_planService.cs
Normal file
363
Models/vw_limit_frame_plan/vw_limit_frame_planService.cs
Normal file
@@ -0,0 +1,363 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TTSW.EF;
|
||||
using TTSW.Utils;
|
||||
using TTSW.Constant;
|
||||
using TTSW.Common;
|
||||
using TodoAPI2.Models;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Net;
|
||||
using TTSW.Configure;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Data;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class vw_limit_frame_planService : Ivw_limit_frame_planService
|
||||
{
|
||||
private IBaseRepository2<eva_limit_frame_planEntity, Guid> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public vw_limit_frame_planService(IBaseRepository2<eva_limit_frame_planEntity, Guid> repository, IMyDatabase mydb,
|
||||
Iexternal_linkageService inext, Iexternal_employeeService inemp)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
emp = inemp;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_limit_frame_planEntity GetEntity(vw_limit_frame_planInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_limit_frame_planEntity>(model);
|
||||
}
|
||||
private List<eva_limit_frame_planEntity> GetEntityList(List<vw_limit_frame_planInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_limit_frame_planEntity>>(models);
|
||||
}
|
||||
private vw_limit_frame_planViewModel GetDto(eva_limit_frame_planEntity entity)
|
||||
{
|
||||
return Mapper.Map<vw_limit_frame_planViewModel>(entity);
|
||||
}
|
||||
private List<vw_limit_frame_planViewModel> GetDtoList(List<eva_limit_frame_planEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<vw_limit_frame_planViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public vw_limit_frame_planViewModel Get(Guid id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
|
||||
public eva_limit_frame_planEntity GetEntity(Guid id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public DataContext GetContext()
|
||||
{
|
||||
return _repository.Context;
|
||||
}
|
||||
|
||||
public vw_limit_frame_planWithSelectionViewModel GetWithSelection(Guid id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<vw_limit_frame_planWithSelectionViewModel>(entity);
|
||||
i.item_plan_guid = (from x in _repository.Context.eva_performance_plan select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public vw_limit_frame_planWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new vw_limit_frame_planWithSelectionViewModel();
|
||||
i.item_plan_guid = (from x in _repository.Context.eva_performance_plan select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<vw_limit_frame_planViewModel> GetListByexecuted_date(DateTime? executed_date)
|
||||
{
|
||||
var model = new vw_limit_frame_planSearchModel();
|
||||
model.executed_date = executed_date;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<vw_limit_frame_planViewModel> GetListBySearch(vw_limit_frame_planSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_vw_limit_frame_plan in _repository.Context.eva_limit_frame_plan
|
||||
|
||||
join fk_eva_performance_plan1 in _repository.Context.eva_performance_plan on m_vw_limit_frame_plan.plan_guid equals fk_eva_performance_plan1.id
|
||||
into eva_performance_planResult1
|
||||
from fk_eva_performance_planResult1 in eva_performance_planResult1.DefaultIfEmpty()
|
||||
|
||||
|
||||
where
|
||||
1 == 1
|
||||
&& (!model.executed_date.HasValue || m_vw_limit_frame_plan.executed_date == model.executed_date)
|
||||
|
||||
|
||||
orderby m_vw_limit_frame_plan.created descending
|
||||
select new vw_limit_frame_planViewModel()
|
||||
{
|
||||
id = m_vw_limit_frame_plan.id,
|
||||
plan_guid = m_vw_limit_frame_plan.plan_guid,
|
||||
executed_date = m_vw_limit_frame_plan.executed_date,
|
||||
limit_frame_005 = m_vw_limit_frame_plan.limit_frame_005,
|
||||
salary_adjustment_date = m_vw_limit_frame_plan.salary_adjustment_date,
|
||||
total_salary = m_vw_limit_frame_plan.total_salary,
|
||||
limit_frame_005_total = m_vw_limit_frame_plan.limit_frame_005_total,
|
||||
limit_frame_005_total_rounded = m_vw_limit_frame_plan.limit_frame_005_total_rounded,
|
||||
|
||||
plan_guid_eva_performance_plan_fiscal_year = fk_eva_performance_planResult1.display_text,
|
||||
|
||||
isActive = m_vw_limit_frame_plan.isActive,
|
||||
Created = m_vw_limit_frame_plan.created,
|
||||
Updated = m_vw_limit_frame_plan.updated
|
||||
}
|
||||
).Take(1000).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
|
||||
|
||||
public vw_limit_frame_planViewModel Insert(vw_limit_frame_planInputModel model, bool is_force_save)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = Guid.NewGuid();
|
||||
entity.limit_frame_005 = (decimal?)0.05;
|
||||
|
||||
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 = MyHelper.RoundOff(new_frame_group.total_salary_limit.Value, 10);
|
||||
_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);
|
||||
|
||||
if (is_force_save)
|
||||
{
|
||||
var inserted = _repository.Insert(entity);
|
||||
entity.DoAfterInsertUpdate(_repository.Context);
|
||||
_repository.Context.SaveChanges();
|
||||
return Get(inserted.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
_repository.InsertWithoutCommit(entity);
|
||||
entity.DoAfterInsertUpdate(_repository.Context);
|
||||
return Mapper.Map<vw_limit_frame_planViewModel>(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public vw_limit_frame_planViewModel Update(Guid id, vw_limit_frame_planInputModel model, bool is_force_save)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.plan_guid = model.plan_guid;
|
||||
existingEntity.executed_date = model.executed_date;
|
||||
existingEntity.limit_frame_005 = model.limit_frame_005;
|
||||
existingEntity.salary_adjustment_date = model.salary_adjustment_date;
|
||||
existingEntity.total_salary = model.total_salary;
|
||||
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);
|
||||
|
||||
if (is_force_save)
|
||||
{
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
existingEntity.DoAfterInsertUpdate(_repository.Context);
|
||||
_repository.Context.SaveChanges();
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
_repository.UpdateWithoutCommit(id, existingEntity);
|
||||
existingEntity.DoAfterInsertUpdate(_repository.Context);
|
||||
return Mapper.Map<vw_limit_frame_planViewModel>(existingEntity);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<vw_limit_frame_planInputModel> model, bool is_force_save)
|
||||
{
|
||||
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.salary_adjustment_date = i.salary_adjustment_date;
|
||||
existingEntity.total_salary = i.total_salary;
|
||||
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);
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
}
|
||||
}
|
||||
else if (i.active_mode == "1" && !i.id.HasValue) // add
|
||||
{
|
||||
var entity = GetEntity(i);
|
||||
entity.id = Guid.NewGuid();
|
||||
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();
|
||||
}
|
||||
|
||||
public vw_limit_frame_planViewModel SetAsActive(Guid id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public vw_limit_frame_planViewModel SetAsInactive(Guid id)
|
||||
{
|
||||
var updated = _repository.SetAsInActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
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()
|
||||
{
|
||||
var all_items = from i in _repository.Context.eva_limit_frame_plan
|
||||
select i;
|
||||
foreach (var item in all_items)
|
||||
{
|
||||
item.SetAutoField(_repository.Context);
|
||||
}
|
||||
_repository.Context.SaveChanges();
|
||||
}
|
||||
|
||||
private Dictionary<string, string> GetLookupForLog()
|
||||
{
|
||||
var i = new Dictionary<string, string>();
|
||||
|
||||
|
||||
i.Add("plan_guid", "แผนการประเมิน");
|
||||
i.Add("plan_guid_eva_performance_plan_fiscal_year", "แผนการประเมิน");
|
||||
i.Add("executed_date", "วันที่ตั้งกรอบวงเงิน");
|
||||
i.Add("txt_executed_date", "วันที่ตั้งกรอบวงเงิน");
|
||||
i.Add("limit_frame_005", "กรอบวงเงินที่กันไว้");
|
||||
i.Add("salary_adjustment_date", "เลื่อนเงินเดือนวันที่");
|
||||
i.Add("txt_salary_adjustment_date", "เลื่อนเงินเดือนวันที่");
|
||||
i.Add("total_salary", "รวมอัตราเงินเดือน");
|
||||
i.Add("limit_frame_005_total", "กันวงเงินไว้");
|
||||
i.Add("limit_frame_005_total_rounded", "กันวงเงินใช้จริง");
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Match Item
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
38
Models/vw_limit_frame_plan/vw_limit_frame_planViewModel.cs
Normal file
38
Models/vw_limit_frame_plan/vw_limit_frame_planViewModel.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TTSW.EF;
|
||||
using TTSW.Utils;
|
||||
using TTSW.Constant;
|
||||
using TTSW.Common;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class vw_limit_frame_planViewModel : BaseViewModel2<Guid>
|
||||
{
|
||||
|
||||
public Guid? plan_guid { get; set; }
|
||||
|
||||
public DateTime? executed_date { get; set; }
|
||||
|
||||
public string txt_executed_date { get { return MyHelper.GetDateStringForReport(this.executed_date); } }
|
||||
|
||||
public decimal? limit_frame_005 { get; set; }
|
||||
|
||||
public DateTime? salary_adjustment_date { get; set; }
|
||||
|
||||
public string txt_salary_adjustment_date { get { return MyHelper.GetDateStringForReport(this.salary_adjustment_date); } }
|
||||
|
||||
public decimal? total_salary { get; set; }
|
||||
|
||||
public decimal? limit_frame_005_total { get; set; }
|
||||
|
||||
public decimal? limit_frame_005_total_rounded { get; set; }
|
||||
|
||||
public string plan_guid_eva_performance_plan_fiscal_year { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class vw_limit_frame_planWithSelectionViewModel: vw_limit_frame_planViewModel
|
||||
{
|
||||
public List<eva_performance_planEntity> item_plan_guid { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user