ปรับปรุงรายงานกรอบวงเงิน
This commit is contained in:
@@ -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 Ieva_limit_frame_employeeService : IBaseService2<Guid, eva_limit_frame_employeeInputModel, eva_limit_frame_employeeViewModel>
|
||||
{
|
||||
new eva_limit_frame_employeeViewModel Insert(eva_limit_frame_employeeInputModel model, bool is_force_save);
|
||||
new eva_limit_frame_employeeViewModel Update(Guid id, eva_limit_frame_employeeInputModel model, bool is_force_save);
|
||||
List<eva_limit_frame_employeeViewModel> GetListByemployee_id(int? employee_id);
|
||||
List<eva_limit_frame_employeeViewModel> GetListBySearch(eva_limit_frame_employeeSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_limit_frame_employeeInputModel> model, bool is_force_save);
|
||||
eva_limit_frame_employeeWithSelectionViewModel GetWithSelection(Guid id);
|
||||
eva_limit_frame_employeeWithSelectionViewModel GetBlankItem();
|
||||
|
||||
void RefreshAutoFieldOfAllData();
|
||||
eva_limit_frame_employeeEntity GetEntity(Guid id);
|
||||
DataContext GetContext();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
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;
|
||||
using System.IO;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_limit_frame_employeeEntity : BaseEntity2<Guid>
|
||||
{
|
||||
|
||||
|
||||
[ForeignKey("frame_group_guid")]
|
||||
public eva_limit_frame_groupEntity eva_limit_frame_group_frame_group_guid { get; set; }
|
||||
public Guid? frame_group_guid { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public int? org_id { get; set; }
|
||||
|
||||
public int? position_id { get; set; }
|
||||
|
||||
public int? level_id { get; set; }
|
||||
|
||||
public decimal? salary { get; set; }
|
||||
|
||||
public decimal? position_allowance { get; set; }
|
||||
|
||||
public decimal? monthly_remuneration { get; set; }
|
||||
|
||||
|
||||
public void SetAutoField(DataContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void DoAfterInsertUpdate(DataContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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 eva_limit_frame_employeeInputModel
|
||||
{
|
||||
|
||||
public Guid? id { get; set; }
|
||||
|
||||
public Guid? frame_group_guid { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public int? org_id { get; set; }
|
||||
|
||||
public int? position_id { get; set; }
|
||||
|
||||
public int? level_id { get; set; }
|
||||
|
||||
public decimal? salary { get; set; }
|
||||
|
||||
public decimal? position_allowance { get; set; }
|
||||
|
||||
public decimal? monthly_remuneration { 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 eva_limit_frame_employeeReportRequestModel : eva_limit_frame_employeeSearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
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 eva_limit_frame_employeeSearchModel
|
||||
{
|
||||
|
||||
public Guid id { get; set; }
|
||||
|
||||
public Guid? frame_group_guid { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,338 @@
|
||||
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 eva_limit_frame_employeeService : Ieva_limit_frame_employeeService
|
||||
{
|
||||
private IBaseRepository2<eva_limit_frame_employeeEntity, Guid> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public eva_limit_frame_employeeService(IBaseRepository2<eva_limit_frame_employeeEntity, 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_employeeEntity GetEntity(eva_limit_frame_employeeInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_limit_frame_employeeEntity>(model);
|
||||
}
|
||||
private List<eva_limit_frame_employeeEntity> GetEntityList(List<eva_limit_frame_employeeInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_limit_frame_employeeEntity>>(models);
|
||||
}
|
||||
private eva_limit_frame_employeeViewModel GetDto(eva_limit_frame_employeeEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_limit_frame_employeeViewModel>(entity);
|
||||
}
|
||||
private List<eva_limit_frame_employeeViewModel> GetDtoList(List<eva_limit_frame_employeeEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_limit_frame_employeeViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_limit_frame_employeeViewModel Get(Guid id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
|
||||
public eva_limit_frame_employeeEntity GetEntity(Guid id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public DataContext GetContext()
|
||||
{
|
||||
return _repository.Context;
|
||||
}
|
||||
|
||||
public eva_limit_frame_employeeWithSelectionViewModel GetWithSelection(Guid id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_limit_frame_employeeWithSelectionViewModel>(entity);
|
||||
i.item_employee_id = (from x in emp.GetAllEmployee() select x).ToList();
|
||||
i.item_org_id = (from x in ext.GetSortingDep() select x).ToList();
|
||||
i.item_position_id = (from x in ext.GetPositionForReport() select x).ToList();
|
||||
i.item_level_id = (from x in ext.Gethrm_position_levels() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_limit_frame_employeeWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_limit_frame_employeeWithSelectionViewModel();
|
||||
i.item_employee_id = (from x in emp.GetAllEmployee() select x).ToList();
|
||||
i.item_org_id = (from x in ext.GetSortingDep() select x).ToList();
|
||||
i.item_position_id = (from x in ext.GetPositionForReport() select x).ToList();
|
||||
i.item_level_id = (from x in ext.Gethrm_position_levels() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_limit_frame_employeeViewModel> GetListByemployee_id(int? employee_id)
|
||||
{
|
||||
var model = new eva_limit_frame_employeeSearchModel();
|
||||
model.employee_id = employee_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_limit_frame_employeeViewModel> GetListBySearch(eva_limit_frame_employeeSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_limit_frame_employee in _repository.Context.eva_limit_frame_employee
|
||||
|
||||
join fk_eva_limit_frame_group1 in _repository.Context.eva_limit_frame_group on m_eva_limit_frame_employee.frame_group_guid equals fk_eva_limit_frame_group1.id
|
||||
into eva_limit_frame_groupResult1
|
||||
from fk_eva_limit_frame_groupResult1 in eva_limit_frame_groupResult1.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage2 in emp.GetAllEmployee() on m_eva_limit_frame_employee.employee_id equals fk_external_linkage2.id
|
||||
into external_linkageResult2
|
||||
from fk_external_linkageResult2 in external_linkageResult2.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage3 in ext.GetSortingDep() on m_eva_limit_frame_employee.org_id equals fk_external_linkage3.id
|
||||
into external_linkageResult3
|
||||
from fk_external_linkageResult3 in external_linkageResult3.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage4 in ext.GetPositionForReport() on m_eva_limit_frame_employee.position_id equals fk_external_linkage4.id
|
||||
into external_linkageResult4
|
||||
from fk_external_linkageResult4 in external_linkageResult4.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage5 in ext.Gethrm_position_levels() on m_eva_limit_frame_employee.level_id equals fk_external_linkage5.id
|
||||
into external_linkageResult5
|
||||
from fk_external_linkageResult5 in external_linkageResult5.DefaultIfEmpty()
|
||||
|
||||
|
||||
where
|
||||
1 == 1
|
||||
&& (!model.frame_group_guid.HasValue || m_eva_limit_frame_employee.frame_group_guid == model.frame_group_guid)
|
||||
&& (!model.employee_id.HasValue || m_eva_limit_frame_employee.employee_id == model.employee_id)
|
||||
|
||||
|
||||
orderby m_eva_limit_frame_employee.created descending
|
||||
select new eva_limit_frame_employeeViewModel()
|
||||
{
|
||||
id = m_eva_limit_frame_employee.id,
|
||||
frame_group_guid = m_eva_limit_frame_employee.frame_group_guid,
|
||||
employee_id = m_eva_limit_frame_employee.employee_id,
|
||||
org_id = m_eva_limit_frame_employee.org_id,
|
||||
position_id = m_eva_limit_frame_employee.position_id,
|
||||
level_id = m_eva_limit_frame_employee.level_id,
|
||||
salary = m_eva_limit_frame_employee.salary,
|
||||
position_allowance = m_eva_limit_frame_employee.position_allowance,
|
||||
monthly_remuneration = m_eva_limit_frame_employee.monthly_remuneration,
|
||||
|
||||
frame_group_guid_eva_limit_frame_group_group_guid = fk_eva_limit_frame_groupResult1.group_guid,
|
||||
employee_id_external_linkage_external_name = fk_external_linkageResult2.fullname,
|
||||
org_id_external_linkage_external_name = fk_external_linkageResult3.external_name,
|
||||
position_id_external_linkage_external_name = fk_external_linkageResult4.external_name,
|
||||
level_id_external_linkage_external_name = fk_external_linkageResult5.external_name,
|
||||
|
||||
isActive = m_eva_limit_frame_employee.isActive,
|
||||
Created = m_eva_limit_frame_employee.created,
|
||||
Updated = m_eva_limit_frame_employee.updated
|
||||
}
|
||||
).Take(1000).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
|
||||
|
||||
public eva_limit_frame_employeeViewModel Insert(eva_limit_frame_employeeInputModel model, bool is_force_save)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = Guid.NewGuid();
|
||||
|
||||
|
||||
entity.SetAutoField(_repository.Context);
|
||||
|
||||
if (is_force_save)
|
||||
{
|
||||
var inserted = _repository.Insert(entity);
|
||||
entity.DoAfterInsertUpdate(_repository.Context);
|
||||
return Get(inserted.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
_repository.InsertWithoutCommit(entity);
|
||||
entity.DoAfterInsertUpdate(_repository.Context);
|
||||
return Mapper.Map<eva_limit_frame_employeeViewModel>(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public eva_limit_frame_employeeViewModel Update(Guid id, eva_limit_frame_employeeInputModel model, bool is_force_save)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.frame_group_guid = model.frame_group_guid;
|
||||
existingEntity.employee_id = model.employee_id;
|
||||
existingEntity.org_id = model.org_id;
|
||||
existingEntity.position_id = model.position_id;
|
||||
existingEntity.level_id = model.level_id;
|
||||
existingEntity.salary = model.salary;
|
||||
existingEntity.position_allowance = model.position_allowance;
|
||||
existingEntity.monthly_remuneration = model.monthly_remuneration;
|
||||
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
|
||||
if (is_force_save)
|
||||
{
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
existingEntity.DoAfterInsertUpdate(_repository.Context);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
_repository.UpdateWithoutCommit(id, existingEntity);
|
||||
existingEntity.DoAfterInsertUpdate(_repository.Context);
|
||||
return Mapper.Map<eva_limit_frame_employeeViewModel>(existingEntity);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_limit_frame_employeeInputModel> 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.frame_group_guid = i.frame_group_guid;
|
||||
existingEntity.employee_id = i.employee_id;
|
||||
existingEntity.org_id = i.org_id;
|
||||
existingEntity.position_id = i.position_id;
|
||||
existingEntity.level_id = i.level_id;
|
||||
existingEntity.salary = i.salary;
|
||||
existingEntity.position_allowance = i.position_allowance;
|
||||
existingEntity.monthly_remuneration = i.monthly_remuneration;
|
||||
|
||||
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 eva_limit_frame_employeeViewModel SetAsActive(Guid id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_limit_frame_employeeViewModel SetAsInactive(Guid id)
|
||||
{
|
||||
var updated = _repository.SetAsInActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public void Delete(Guid id)
|
||||
{
|
||||
_repository.Delete(id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void RefreshAutoFieldOfAllData()
|
||||
{
|
||||
var all_items = from i in _repository.Context.eva_limit_frame_employee
|
||||
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("frame_group_guid", "frame_plan_guid");
|
||||
i.Add("frame_group_guid_eva_limit_frame_group_group_guid", "frame_plan_guid");
|
||||
i.Add("employee_id", "พนักงาน");
|
||||
i.Add("employee_id_external_linkage_external_name", "พนักงาน");
|
||||
i.Add("org_id", "หน่วยงาน");
|
||||
i.Add("org_id_external_linkage_external_name", "หน่วยงาน");
|
||||
i.Add("position_id", "ตำแหน่ง");
|
||||
i.Add("position_id_external_linkage_external_name", "ตำแหน่ง");
|
||||
i.Add("level_id", "ระดับ");
|
||||
i.Add("level_id_external_linkage_external_name", "ระดับ");
|
||||
i.Add("salary", "เงินเดือน");
|
||||
i.Add("position_allowance", "เงินประจำตำแหน่ง");
|
||||
i.Add("monthly_remuneration", "ค่าตอบแทนรายเดือน");
|
||||
i.Add("limit_frame_group_id", "limit_frame_group_id");
|
||||
i.Add("limit_frame_group_id_eva_limit_frame_group_group_guid", "limit_frame_group_id");
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Match Item
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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 eva_limit_frame_employeeViewModel : BaseViewModel2<Guid>
|
||||
{
|
||||
|
||||
public Guid? frame_group_guid { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public int? org_id { get; set; }
|
||||
|
||||
public int? position_id { get; set; }
|
||||
|
||||
public int? level_id { get; set; }
|
||||
|
||||
public decimal? salary { get; set; }
|
||||
|
||||
public decimal? position_allowance { get; set; }
|
||||
|
||||
public decimal? monthly_remuneration { get; set; }
|
||||
|
||||
public Guid? frame_group_guid_eva_limit_frame_group_group_guid { get; set; }
|
||||
public string employee_id_external_linkage_external_name { get; set; }
|
||||
public string org_id_external_linkage_external_name { get; set; }
|
||||
public string position_id_external_linkage_external_name { get; set; }
|
||||
public string level_id_external_linkage_external_name { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_limit_frame_employeeWithSelectionViewModel: eva_limit_frame_employeeViewModel
|
||||
{
|
||||
public List<external_employeeViewModel> item_employee_id { get; set; }
|
||||
public List<external_linkageViewModel> item_org_id { get; set; }
|
||||
public List<external_linkageViewModel> item_position_id { get; set; }
|
||||
public List<external_linkageViewModel> item_level_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user