ปรับปรุงรายงานกรอบวงเงิน

This commit is contained in:
Nakorn Rientrakrunchai
2021-03-02 17:14:35 +07:00
parent a4e54a1179
commit ad14f4f664
77 changed files with 10782 additions and 4 deletions

View 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 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();
}
}

View File

@@ -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)
{
}
}
}

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

View File

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

View File

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

View File

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

View File

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

View File

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

View 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 Ieva_limit_frame_groupService : IBaseService2<Guid, eva_limit_frame_groupInputModel, eva_limit_frame_groupViewModel>
{
new eva_limit_frame_groupViewModel Insert(eva_limit_frame_groupInputModel model, bool is_force_save);
new eva_limit_frame_groupViewModel Update(Guid id, eva_limit_frame_groupInputModel model, bool is_force_save);
List<eva_limit_frame_groupViewModel> GetListBygroup_guid(Guid? group_guid);
List<eva_limit_frame_groupViewModel> GetListBySearch(eva_limit_frame_groupSearchModel model);
string UpdateMultiple(List<eva_limit_frame_groupInputModel> model, bool is_force_save);
eva_limit_frame_groupWithSelectionViewModel GetWithSelection(Guid id);
eva_limit_frame_groupWithSelectionViewModel GetBlankItem();
void RefreshAutoFieldOfAllData();
eva_limit_frame_groupEntity GetEntity(Guid id);
DataContext GetContext();
}
}

View File

@@ -0,0 +1,47 @@
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_groupEntity : BaseEntity2<Guid>
{
[ForeignKey("frame_plan_guid")]
public eva_limit_frame_planEntity eva_limit_frame_plan_frame_plan_guid { get; set; }
public Guid? frame_plan_guid { get; set; }
[ForeignKey("group_guid")]
public eva_evaluation_groupEntity eva_evaluation_group_group_guid { get; set; }
public Guid? group_guid { get; set; }
public decimal? limit_frame_295 { get; set; }
public decimal? total_salary { get; set; }
public decimal? total_salary_limit { get; set; }
public decimal? total_salary_limit_rounded { get; set; }
public void SetAutoField(DataContext context)
{
}
public void DoAfterInsertUpdate(DataContext context)
{
}
}
}

View File

@@ -0,0 +1,34 @@
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_groupInputModel
{
public Guid? id { get; set; }
public Guid? frame_plan_guid { get; set; }
public Guid? group_guid { get; set; }
public decimal? limit_frame_295 { get; set; }
public decimal? total_salary { get; set; }
public decimal? total_salary_limit { get; set; }
public decimal? total_salary_limit_rounded { get; set; }
public string active_mode { get; set; }
}
}

View File

@@ -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_groupReportRequestModel : eva_limit_frame_groupSearchModel
{
public string filetype { get; set; }
public string contentType { get { return MyHelper.GetContentType(filetype); } }
}
}

View File

@@ -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_groupSearchModel
{
public Guid id { get; set; }
public Guid? frame_plan_guid { get; set; }
public Guid? group_guid { get; set; }
}
}

View File

@@ -0,0 +1,301 @@
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_groupService : Ieva_limit_frame_groupService
{
private IBaseRepository2<eva_limit_frame_groupEntity, Guid> _repository;
private IMyDatabase db;
private Iexternal_linkageService ext;
public eva_limit_frame_groupService(IBaseRepository2<eva_limit_frame_groupEntity, Guid> repository, IMyDatabase mydb, Iexternal_linkageService inext)
{
_repository = repository;
db = mydb;
ext = inext;
}
#region Private Functions
private eva_limit_frame_groupEntity GetEntity(eva_limit_frame_groupInputModel model)
{
return Mapper.Map<eva_limit_frame_groupEntity>(model);
}
private List<eva_limit_frame_groupEntity> GetEntityList(List<eva_limit_frame_groupInputModel> models)
{
return Mapper.Map<List<eva_limit_frame_groupEntity>>(models);
}
private eva_limit_frame_groupViewModel GetDto(eva_limit_frame_groupEntity entity)
{
return Mapper.Map<eva_limit_frame_groupViewModel>(entity);
}
private List<eva_limit_frame_groupViewModel> GetDtoList(List<eva_limit_frame_groupEntity> entities)
{
return Mapper.Map<List<eva_limit_frame_groupViewModel>>(entities);
}
#endregion
#region Public Functions
#region Query Functions
public eva_limit_frame_groupViewModel Get(Guid id)
{
var entity = _repository.Get(id);
return GetDto(entity);
}
public eva_limit_frame_groupEntity GetEntity(Guid id)
{
var entity = _repository.Get(id);
return entity;
}
public DataContext GetContext()
{
return _repository.Context;
}
public eva_limit_frame_groupWithSelectionViewModel GetWithSelection(Guid id)
{
var entity = _repository.Get(id);
var i = Mapper.Map<eva_limit_frame_groupWithSelectionViewModel>(entity);
i.item_group_guid = (from x in _repository.Context.eva_evaluation_group select x).ToList();
return i;
}
public eva_limit_frame_groupWithSelectionViewModel GetBlankItem()
{
var i = new eva_limit_frame_groupWithSelectionViewModel();
i.item_group_guid = (from x in _repository.Context.eva_evaluation_group select x).ToList();
return i;
}
public List<eva_limit_frame_groupViewModel> GetListBygroup_guid(Guid? group_guid)
{
var model = new eva_limit_frame_groupSearchModel();
model.group_guid = group_guid;
return GetListBySearch(model);
}
public List<eva_limit_frame_groupViewModel> GetListBySearch(eva_limit_frame_groupSearchModel model)
{
var data = (
from m_eva_limit_frame_group in _repository.Context.eva_limit_frame_group
join fk_eva_limit_frame_plan1 in _repository.Context.eva_limit_frame_plan on m_eva_limit_frame_group.frame_plan_guid equals fk_eva_limit_frame_plan1.id
into eva_limit_frame_planResult1
from fk_eva_limit_frame_planResult1 in eva_limit_frame_planResult1.DefaultIfEmpty()
join fk_eva_evaluation_group2 in _repository.Context.eva_evaluation_group on m_eva_limit_frame_group.group_guid equals fk_eva_evaluation_group2.id
into eva_evaluation_groupResult2
from fk_eva_evaluation_groupResult2 in eva_evaluation_groupResult2.DefaultIfEmpty()
where
1 == 1
&& (!model.frame_plan_guid.HasValue || m_eva_limit_frame_group.frame_plan_guid == model.frame_plan_guid)
&& (!model.group_guid.HasValue || m_eva_limit_frame_group.group_guid == model.group_guid)
orderby m_eva_limit_frame_group.created descending
select new eva_limit_frame_groupViewModel()
{
id = m_eva_limit_frame_group.id,
frame_plan_guid = m_eva_limit_frame_group.frame_plan_guid,
group_guid = m_eva_limit_frame_group.group_guid,
limit_frame_295 = m_eva_limit_frame_group.limit_frame_295,
total_salary = m_eva_limit_frame_group.total_salary,
total_salary_limit = m_eva_limit_frame_group.total_salary_limit,
total_salary_limit_rounded = m_eva_limit_frame_group.total_salary_limit_rounded,
frame_plan_guid_eva_limit_frame_plan_executed_date = fk_eva_limit_frame_planResult1.executed_date,
group_guid_eva_evaluation_group_code = fk_eva_evaluation_groupResult2.code,
isActive = m_eva_limit_frame_group.isActive,
Created = m_eva_limit_frame_group.created,
Updated = m_eva_limit_frame_group.updated
}
).Take(1000).ToList();
return data;
}
#endregion
#region Manipulation Functions
public eva_limit_frame_groupViewModel Insert(eva_limit_frame_groupInputModel 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_groupViewModel>(entity);
}
}
public eva_limit_frame_groupViewModel Update(Guid id, eva_limit_frame_groupInputModel model, bool is_force_save)
{
var existingEntity = _repository.Get(id);
if (existingEntity != null)
{
existingEntity.frame_plan_guid = model.frame_plan_guid;
existingEntity.group_guid = model.group_guid;
existingEntity.limit_frame_295 = model.limit_frame_295;
existingEntity.total_salary = model.total_salary;
existingEntity.total_salary_limit = model.total_salary_limit;
existingEntity.total_salary_limit_rounded = model.total_salary_limit_rounded;
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_groupViewModel>(existingEntity);
}
}
else
throw new NotificationException("No data to update");
}
public string UpdateMultiple(List<eva_limit_frame_groupInputModel> 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_plan_guid = i.frame_plan_guid;
existingEntity.group_guid = i.group_guid;
existingEntity.limit_frame_295 = i.limit_frame_295;
existingEntity.total_salary = i.total_salary;
existingEntity.total_salary_limit = i.total_salary_limit;
existingEntity.total_salary_limit_rounded = i.total_salary_limit_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 eva_limit_frame_groupViewModel SetAsActive(Guid id)
{
var updated = _repository.SetAsActive(id);
return Get(updated.id);
}
public eva_limit_frame_groupViewModel 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_group
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_plan_guid", "frame_plan_guid");
i.Add("frame_plan_guid_eva_limit_frame_plan_executed_date", "frame_plan_guid");
i.Add("group_guid", "กลุ่มการประเมิน");
i.Add("group_guid_eva_evaluation_group_code", "กลุ่มการประเมิน");
i.Add("limit_frame_295", "กรอบวงเงินที่กันไว้");
i.Add("total_salary", "อัตราเงินเดือนรวม");
i.Add("total_salary_limit", "วงเงินในการเลื่อนเงินเดือน");
i.Add("total_salary_limit_rounded", "วงเงินในการเลื่อนเงินเดือน ที่ใช้จริง");
return i;
}
#endregion
#region Match Item
#endregion
#endregion
}
}

View File

@@ -0,0 +1,33 @@
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_groupViewModel : BaseViewModel2<Guid>
{
public Guid? frame_plan_guid { get; set; }
public Guid? group_guid { get; set; }
public decimal? limit_frame_295 { get; set; }
public decimal? total_salary { get; set; }
public decimal? total_salary_limit { get; set; }
public decimal? total_salary_limit_rounded { get; set; }
public DateTime? frame_plan_guid_eva_limit_frame_plan_executed_date { get; set; }
public string group_guid_eva_evaluation_group_code { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace TodoAPI2.Models
{
public class eva_limit_frame_groupWithSelectionViewModel: eva_limit_frame_groupViewModel
{
public List<eva_evaluation_groupEntity> item_group_guid { get; set; }
}
}

View 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 Ieva_limit_frame_planService : IBaseService2<Guid, eva_limit_frame_planInputModel, eva_limit_frame_planViewModel>
{
new eva_limit_frame_planViewModel Insert(eva_limit_frame_planInputModel model, bool is_force_save);
new eva_limit_frame_planViewModel Update(Guid id, eva_limit_frame_planInputModel model, bool is_force_save);
List<eva_limit_frame_planViewModel> GetListByexecuted_date(DateTime? executed_date);
List<eva_limit_frame_planViewModel> GetListBySearch(eva_limit_frame_planSearchModel model);
string UpdateMultiple(List<eva_limit_frame_planInputModel> model, bool is_force_save);
eva_limit_frame_planWithSelectionViewModel GetWithSelection(Guid id);
eva_limit_frame_planWithSelectionViewModel GetBlankItem();
void RefreshAutoFieldOfAllData();
eva_limit_frame_planEntity GetEntity(Guid id);
DataContext GetContext();
}
}

View File

@@ -0,0 +1,57 @@
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_planEntity : BaseEntity2<Guid>
{
[ForeignKey("plan_guid")]
public eva_performance_planEntity eva_performance_plan_plan_guid { get; set; }
public Guid? plan_guid { get; set; }
public DateTime? executed_date { get; set; }
public decimal? limit_frame_005 { get; set; }
[MaxLength(1)]
public string status_self { get; set; }
[MaxLength(1)]
public string status_chief { get; set; }
public int? supervisor1 { get; set; }
[MaxLength(1)]
public string supervisor1_result { get; set; }
[MaxLength(1000)]
public string supervisor1_remark { get; set; }
public DateTime? supervisor1_date { get; set; }
public DateTime? salary_adjustment_date { get; set; }
public void SetAutoField(DataContext context)
{
}
public void DoAfterInsertUpdate(DataContext context)
{
}
}
}

View File

@@ -0,0 +1,42 @@
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_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 string status_self { get; set; }
public string status_chief { get; set; }
public int? supervisor1 { get; set; }
public string supervisor1_result { get; set; }
public string supervisor1_remark { get; set; }
public DateTime? supervisor1_date { get; set; }
public DateTime? salary_adjustment_date { get; set; }
public string active_mode { get; set; }
}
}

View File

@@ -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_planReportRequestModel : eva_limit_frame_planSearchModel
{
public string filetype { get; set; }
public string contentType { get { return MyHelper.GetContentType(filetype); } }
}
}

View 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 eva_limit_frame_planSearchModel
{
public Guid id { get; set; }
public DateTime? executed_date { get; set; }
}
}

View File

@@ -0,0 +1,320 @@
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_planService : Ieva_limit_frame_planService
{
private IBaseRepository2<eva_limit_frame_planEntity, Guid> _repository;
private IMyDatabase db;
private Iexternal_linkageService ext;
public eva_limit_frame_planService(IBaseRepository2<eva_limit_frame_planEntity, Guid> repository, IMyDatabase mydb, Iexternal_linkageService inext)
{
_repository = repository;
db = mydb;
ext = inext;
}
#region Private Functions
private eva_limit_frame_planEntity GetEntity(eva_limit_frame_planInputModel model)
{
return Mapper.Map<eva_limit_frame_planEntity>(model);
}
private List<eva_limit_frame_planEntity> GetEntityList(List<eva_limit_frame_planInputModel> models)
{
return Mapper.Map<List<eva_limit_frame_planEntity>>(models);
}
private eva_limit_frame_planViewModel GetDto(eva_limit_frame_planEntity entity)
{
return Mapper.Map<eva_limit_frame_planViewModel>(entity);
}
private List<eva_limit_frame_planViewModel> GetDtoList(List<eva_limit_frame_planEntity> entities)
{
return Mapper.Map<List<eva_limit_frame_planViewModel>>(entities);
}
#endregion
#region Public Functions
#region Query Functions
public eva_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 eva_limit_frame_planWithSelectionViewModel GetWithSelection(Guid id)
{
var entity = _repository.Get(id);
var i = Mapper.Map<eva_limit_frame_planWithSelectionViewModel>(entity);
i.item_plan_guid = (from x in _repository.Context.eva_performance_plan select x).ToList();
//i.item_supervisor1_result = (from x in ext.GetDemoItem() select x).ToList();
return i;
}
public eva_limit_frame_planWithSelectionViewModel GetBlankItem()
{
var i = new eva_limit_frame_planWithSelectionViewModel();
i.item_plan_guid = (from x in _repository.Context.eva_performance_plan select x).ToList();
//i.item_supervisor1_result = (from x in ext.GetDemoItem() select x).ToList();
return i;
}
public List<eva_limit_frame_planViewModel> GetListByexecuted_date(DateTime? executed_date)
{
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)
{
var data = (
from m_eva_limit_frame_plan in _repository.Context.eva_limit_frame_plan
join fk_eva_performance_plan1 in _repository.Context.eva_performance_plan on m_eva_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()
//join fk_external_linkage7 in ext.GetDemoItem() on m_eva_limit_frame_plan.supervisor1_result equals fk_external_linkage7.external_code
//into external_linkageResult7
//from fk_external_linkageResult7 in external_linkageResult7.DefaultIfEmpty()
where
1 == 1
&& (!model.executed_date.HasValue || m_eva_limit_frame_plan.executed_date == model.executed_date)
orderby m_eva_limit_frame_plan.created descending
select new eva_limit_frame_planViewModel()
{
id = m_eva_limit_frame_plan.id,
plan_guid = m_eva_limit_frame_plan.plan_guid,
executed_date = m_eva_limit_frame_plan.executed_date,
limit_frame_005 = m_eva_limit_frame_plan.limit_frame_005,
status_self = m_eva_limit_frame_plan.status_self,
status_chief = m_eva_limit_frame_plan.status_chief,
supervisor1 = m_eva_limit_frame_plan.supervisor1,
supervisor1_result = m_eva_limit_frame_plan.supervisor1_result,
supervisor1_remark = m_eva_limit_frame_plan.supervisor1_remark,
supervisor1_date = m_eva_limit_frame_plan.supervisor1_date,
salary_adjustment_date = m_eva_limit_frame_plan.salary_adjustment_date,
plan_guid_eva_performance_plan_fiscal_year = fk_eva_performance_planResult1.fiscal_year,
//supervisor1_result_external_linkage_external_name = fk_external_linkageResult7.external_name,
isActive = m_eva_limit_frame_plan.isActive,
Created = m_eva_limit_frame_plan.created,
Updated = m_eva_limit_frame_plan.updated
}
).Take(1000).ToList();
return data;
}
#endregion
#region Manipulation Functions
public eva_limit_frame_planViewModel Insert(eva_limit_frame_planInputModel 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_planViewModel>(entity);
}
}
public eva_limit_frame_planViewModel Update(Guid id, eva_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.status_self = model.status_self;
existingEntity.status_chief = model.status_chief;
existingEntity.supervisor1 = model.supervisor1;
existingEntity.supervisor1_result = model.supervisor1_result;
existingEntity.supervisor1_remark = model.supervisor1_remark;
existingEntity.supervisor1_date = model.supervisor1_date;
existingEntity.salary_adjustment_date = model.salary_adjustment_date;
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_planViewModel>(existingEntity);
}
}
else
throw new NotificationException("No data to update");
}
public string UpdateMultiple(List<eva_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.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.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_planViewModel SetAsActive(Guid id)
{
var updated = _repository.SetAsActive(id);
return Get(updated.id);
}
public eva_limit_frame_planViewModel 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_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("status_self", "สถานะการส่ง กรอบวงเงิน");
i.Add("status_chief", "สถานะการตรวจ กรอบวงเงิน");
i.Add("supervisor1", "ผู้ตรวจกรอบวงเงิน");
i.Add("supervisor1_result", "ผลการตรวจ");
i.Add("supervisor1_result_external_linkage_external_name", "ผลการตรวจ");
i.Add("supervisor1_remark", "ความเห็นผู้ประเมิน");
i.Add("supervisor1_date", "วันที่ประเมิน");
i.Add("txt_supervisor1_date", "วันที่ประเมิน");
i.Add("txt_salary_adjustment_date", "เลื่อนเงินเดือนวันที่");
return i;
}
#endregion
#region Match Item
#endregion
#endregion
}
}

View File

@@ -0,0 +1,47 @@
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_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 string status_self { get; set; }
public string status_chief { get; set; }
public int? supervisor1 { get; set; }
public string supervisor1_result { get; set; }
public string supervisor1_remark { get; set; }
public DateTime? supervisor1_date { get; set; }
public string txt_supervisor1_date { get { return MyHelper.GetDateStringForReport(this.supervisor1_date); } }
public DateTime? salary_adjustment_date { get; set; }
public string txt_salary_adjustment_date { get { return MyHelper.GetDateStringForReport(this.salary_adjustment_date); } }
public int? plan_guid_eva_performance_plan_fiscal_year { get; set; }
public string supervisor1_result_external_linkage_external_name { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace TodoAPI2.Models
{
public class eva_limit_frame_planWithSelectionViewModel: eva_limit_frame_planViewModel
{
public List<eva_performance_planEntity> item_plan_guid { get; set; }
public List<external_linkageViewModel> item_supervisor1_result { get; set; }
}
}