ทำหน้าจอพิเศษ นำเข้าข้อมูลเงินเดือนย้อนหลัง
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_adjust_postponement_detail_migrationService : IBaseService<int, eva_adjust_postponement_detail_migrationInputModel, eva_adjust_postponement_detail_migrationViewModel>
|
||||
{
|
||||
new eva_adjust_postponement_detail_migrationViewModel Insert(eva_adjust_postponement_detail_migrationInputModel model);
|
||||
new eva_adjust_postponement_detail_migrationViewModel Update(int id, eva_adjust_postponement_detail_migrationInputModel model);
|
||||
List<eva_adjust_postponement_detail_migrationViewModel> GetListByadjust_postponement_id(int? adjust_postponement_id);
|
||||
List<eva_adjust_postponement_detail_migrationViewModel> GetListBySearch(eva_adjust_postponement_detail_migrationSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_adjust_postponement_detail_migrationInputModel> model);
|
||||
eva_adjust_postponement_detail_migrationWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_adjust_postponement_detail_migrationWithSelectionViewModel GetBlankItem();
|
||||
|
||||
void RefreshAutoFieldOfAllData();
|
||||
eva_adjust_postponement_detailEntity GetEntity(int id);
|
||||
DataContext GetContext();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
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_adjust_postponement_detail_migrationInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? adjust_postponement_id { get; set; }
|
||||
|
||||
public int? adjust_postponement_quota_id { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public decimal? sarary { get; set; }
|
||||
|
||||
public decimal? cost_living { get; set; }
|
||||
|
||||
public decimal? middle { get; set; }
|
||||
|
||||
public decimal? promoted_percentage { get; set; }
|
||||
|
||||
public decimal? total_promote { get; set; }
|
||||
|
||||
public decimal? new_sarary { get; set; }
|
||||
|
||||
public decimal? new_cost_living { get; set; }
|
||||
|
||||
public string remark { get; set; }
|
||||
|
||||
public decimal? receive_quota { get; set; }
|
||||
|
||||
public decimal? new_sarary_with_quota { get; set; }
|
||||
|
||||
public string position_this_time { get; set; }
|
||||
|
||||
public string level_this_time { 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_adjust_postponement_detail_migrationReportRequestModel : eva_adjust_postponement_detail_migrationSearchModel
|
||||
{
|
||||
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_adjust_postponement_detail_migrationSearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? adjust_postponement_id { get; set; }
|
||||
|
||||
public int? adjust_postponement_quota_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,337 @@
|
||||
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_adjust_postponement_detail_migrationService : Ieva_adjust_postponement_detail_migrationService
|
||||
{
|
||||
private IBaseRepository2<eva_adjust_postponement_detailEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public eva_adjust_postponement_detail_migrationService(IBaseRepository2<eva_adjust_postponement_detailEntity, int> repository,
|
||||
IMyDatabase mydb, Iexternal_linkageService inext, Iexternal_employeeService inemp)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
emp = inemp;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_adjust_postponement_detailEntity GetEntity(eva_adjust_postponement_detail_migrationInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponement_detailEntity>(model);
|
||||
}
|
||||
private List<eva_adjust_postponement_detailEntity> GetEntityList(List<eva_adjust_postponement_detail_migrationInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponement_detailEntity>>(models);
|
||||
}
|
||||
private eva_adjust_postponement_detail_migrationViewModel GetDto(eva_adjust_postponement_detailEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponement_detail_migrationViewModel>(entity);
|
||||
}
|
||||
private List<eva_adjust_postponement_detail_migrationViewModel> GetDtoList(List<eva_adjust_postponement_detailEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponement_detail_migrationViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_adjust_postponement_detail_migrationViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
|
||||
public eva_adjust_postponement_detailEntity GetEntity(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public DataContext GetContext()
|
||||
{
|
||||
return _repository.Context;
|
||||
}
|
||||
|
||||
public eva_adjust_postponement_detail_migrationWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_adjust_postponement_detail_migrationWithSelectionViewModel>(entity);
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_employee_id = all_emp.ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_adjust_postponement_detail_migrationWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_adjust_postponement_detail_migrationWithSelectionViewModel();
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_employee_id = all_emp.ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponement_detail_migrationViewModel> GetListByadjust_postponement_id(int? adjust_postponement_id)
|
||||
{
|
||||
var model = new eva_adjust_postponement_detail_migrationSearchModel();
|
||||
model.adjust_postponement_id = adjust_postponement_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponement_detail_migrationViewModel> GetListBySearch(eva_adjust_postponement_detail_migrationSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_adjust_postponement_detail_migration in _repository.Context.eva_adjust_postponement_detail
|
||||
|
||||
join fk_eva_adjust_postponement1 in _repository.Context.eva_adjust_postponement on m_eva_adjust_postponement_detail_migration.adjust_postponement_id equals fk_eva_adjust_postponement1.id
|
||||
into eva_adjust_postponementResult1
|
||||
from fk_eva_adjust_postponementResult1 in eva_adjust_postponementResult1.DefaultIfEmpty()
|
||||
|
||||
join fk_eva_adjust_postponement2 in _repository.Context.eva_adjust_postponement on m_eva_adjust_postponement_detail_migration.adjust_postponement_quota_id equals fk_eva_adjust_postponement2.id
|
||||
into eva_adjust_postponementResult2
|
||||
from fk_eva_adjust_postponementResult2 in eva_adjust_postponementResult2.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage3 in emp.GetListByemployee_type(null, null) on m_eva_adjust_postponement_detail_migration.employee_id equals fk_external_linkage3.id
|
||||
into external_linkageResult3
|
||||
from fk_external_linkageResult3 in external_linkageResult3.DefaultIfEmpty()
|
||||
|
||||
|
||||
where
|
||||
(m_eva_adjust_postponement_detail_migration.id == model.id)
|
||||
|| (model.adjust_postponement_id.HasValue && m_eva_adjust_postponement_detail_migration.adjust_postponement_id == model.adjust_postponement_id)
|
||||
|| (model.adjust_postponement_quota_id.HasValue && m_eva_adjust_postponement_detail_migration.adjust_postponement_quota_id == model.adjust_postponement_quota_id)
|
||||
|
||||
|
||||
orderby m_eva_adjust_postponement_detail_migration.created descending
|
||||
select new eva_adjust_postponement_detail_migrationViewModel()
|
||||
{
|
||||
id = m_eva_adjust_postponement_detail_migration.id,
|
||||
adjust_postponement_id = m_eva_adjust_postponement_detail_migration.adjust_postponement_id,
|
||||
adjust_postponement_quota_id = m_eva_adjust_postponement_detail_migration.adjust_postponement_quota_id,
|
||||
employee_id = m_eva_adjust_postponement_detail_migration.employee_id,
|
||||
sarary = m_eva_adjust_postponement_detail_migration.sarary,
|
||||
cost_living = m_eva_adjust_postponement_detail_migration.cost_living,
|
||||
middle = m_eva_adjust_postponement_detail_migration.middle,
|
||||
promoted_percentage = m_eva_adjust_postponement_detail_migration.promoted_percentage,
|
||||
total_promote = m_eva_adjust_postponement_detail_migration.total_promote,
|
||||
new_sarary = m_eva_adjust_postponement_detail_migration.new_sarary,
|
||||
new_cost_living = m_eva_adjust_postponement_detail_migration.new_cost_living,
|
||||
remark = m_eva_adjust_postponement_detail_migration.remark,
|
||||
receive_quota = m_eva_adjust_postponement_detail_migration.receive_quota,
|
||||
new_sarary_with_quota = m_eva_adjust_postponement_detail_migration.new_sarary_with_quota,
|
||||
position_this_time = m_eva_adjust_postponement_detail_migration.position_this_time,
|
||||
level_this_time = m_eva_adjust_postponement_detail_migration.level_this_time,
|
||||
|
||||
adjust_postponement_id_eva_adjust_postponement_fiscal_year = fk_eva_adjust_postponementResult1.fiscal_year,
|
||||
adjust_postponement_quota_id_eva_adjust_postponement_fiscal_year = fk_eva_adjust_postponementResult2.fiscal_year,
|
||||
employee_id_external_linkage_external_name = fk_external_linkageResult3.fullname,
|
||||
|
||||
isActive = m_eva_adjust_postponement_detail_migration.isActive,
|
||||
Created = m_eva_adjust_postponement_detail_migration.created,
|
||||
Updated = m_eva_adjust_postponement_detail_migration.updated
|
||||
}
|
||||
).Take(1000).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
|
||||
public int GetNewPrimaryKey()
|
||||
{
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_adjust_postponement_detail
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if (x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
|
||||
return newkey.Value;
|
||||
}
|
||||
|
||||
|
||||
public eva_adjust_postponement_detail_migrationViewModel Insert(eva_adjust_postponement_detail_migrationInputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_adjust_postponement_detail_migrationViewModel Update(int id, eva_adjust_postponement_detail_migrationInputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.adjust_postponement_id = model.adjust_postponement_id;
|
||||
existingEntity.adjust_postponement_quota_id = model.adjust_postponement_quota_id;
|
||||
existingEntity.employee_id = model.employee_id;
|
||||
existingEntity.sarary = model.sarary;
|
||||
existingEntity.cost_living = model.cost_living;
|
||||
existingEntity.middle = model.middle;
|
||||
existingEntity.promoted_percentage = model.promoted_percentage;
|
||||
existingEntity.total_promote = model.total_promote;
|
||||
existingEntity.new_sarary = model.new_sarary;
|
||||
existingEntity.new_cost_living = model.new_cost_living;
|
||||
existingEntity.remark = model.remark;
|
||||
existingEntity.receive_quota = model.receive_quota;
|
||||
existingEntity.new_sarary_with_quota = model.new_sarary_with_quota;
|
||||
existingEntity.position_this_time = model.position_this_time;
|
||||
existingEntity.level_this_time = model.level_this_time;
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_adjust_postponement_detail_migrationInputModel> 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.adjust_postponement_id = i.adjust_postponement_id;
|
||||
existingEntity.adjust_postponement_quota_id = i.adjust_postponement_quota_id;
|
||||
existingEntity.employee_id = i.employee_id;
|
||||
existingEntity.sarary = i.sarary;
|
||||
existingEntity.cost_living = i.cost_living;
|
||||
existingEntity.middle = i.middle;
|
||||
existingEntity.promoted_percentage = i.promoted_percentage;
|
||||
existingEntity.total_promote = i.total_promote;
|
||||
existingEntity.new_sarary = i.new_sarary;
|
||||
existingEntity.new_cost_living = i.new_cost_living;
|
||||
existingEntity.remark = i.remark;
|
||||
existingEntity.receive_quota = i.receive_quota;
|
||||
existingEntity.new_sarary_with_quota = i.new_sarary_with_quota;
|
||||
existingEntity.position_this_time = i.position_this_time;
|
||||
existingEntity.level_this_time = i.level_this_time;
|
||||
|
||||
//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 = GetNewPrimaryKey();
|
||||
//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
|
||||
}
|
||||
}
|
||||
_repository.Context.SaveChanges();
|
||||
|
||||
return model.Count().ToString();
|
||||
}
|
||||
|
||||
public eva_adjust_postponement_detail_migrationViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_adjust_postponement_detail_migrationViewModel SetAsInactive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsInActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public void Delete(int id)
|
||||
{
|
||||
_repository.Delete(id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void RefreshAutoFieldOfAllData()
|
||||
{
|
||||
var all_items = from i in _repository.Context.eva_adjust_postponement_detail
|
||||
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("adjust_postponement_id", "รหัสอ้างอิงตาราง eva_adjust_postponement");
|
||||
i.Add("adjust_postponement_id_eva_adjust_postponement_fiscal_year", "รหัสอ้างอิงตาราง eva_adjust_postponement");
|
||||
i.Add("adjust_postponement_quota_id", "รหัสอ้างอิงตาราง eva_adjust_postponement");
|
||||
i.Add("adjust_postponement_quota_id_eva_adjust_postponement_fiscal_year", "รหัสอ้างอิงตาราง eva_adjust_postponement");
|
||||
i.Add("employee_id", "ผู้รับการประเมิน");
|
||||
i.Add("employee_id_external_linkage_external_name", "ผู้รับการประเมิน");
|
||||
i.Add("sarary", "เงินเดือน ก่อนปรับเลื่อน");
|
||||
i.Add("cost_living", "ค่าครองชีพ ก่อนปรับเลื่อน");
|
||||
i.Add("middle", "ค่ากลางฐานในการคำนวณ");
|
||||
i.Add("promoted_percentage", "ร้อยละที่ได้เลื่อน");
|
||||
i.Add("total_promote", "จำนวนเงินที่ได้เลื่อน");
|
||||
i.Add("new_sarary", "เงินเดือนใหม่");
|
||||
i.Add("new_cost_living", "ค่าครองชีพใหม่");
|
||||
i.Add("remark", "หมายเหตุ");
|
||||
i.Add("receive_quota", "ได้รับเงินโควต้าพิเศษ");
|
||||
i.Add("new_sarary_with_quota", "เงินเดือนใหม่ (รวมโควต้า)");
|
||||
i.Add("position_this_time", "ตำแหน่ง (ณ วันปรับเลื่อน)");
|
||||
i.Add("level_this_time", "ระดับ (ณ วันปรับเลื่อน)");
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Match Item
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
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_adjust_postponement_detail_migrationViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? adjust_postponement_id { get; set; }
|
||||
|
||||
public int? adjust_postponement_quota_id { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public decimal? sarary { get; set; }
|
||||
|
||||
public decimal? cost_living { get; set; }
|
||||
|
||||
public decimal? middle { get; set; }
|
||||
|
||||
public decimal? promoted_percentage { get; set; }
|
||||
|
||||
public decimal? total_promote { get; set; }
|
||||
|
||||
public decimal? new_sarary { get; set; }
|
||||
|
||||
public decimal? new_cost_living { get; set; }
|
||||
|
||||
public string remark { get; set; }
|
||||
|
||||
public decimal? receive_quota { get; set; }
|
||||
|
||||
public decimal? new_sarary_with_quota { get; set; }
|
||||
|
||||
public string position_this_time { get; set; }
|
||||
|
||||
public string level_this_time { get; set; }
|
||||
|
||||
public int? adjust_postponement_id_eva_adjust_postponement_fiscal_year { get; set; }
|
||||
public int? adjust_postponement_quota_id_eva_adjust_postponement_fiscal_year { get; set; }
|
||||
public string employee_id_external_linkage_external_name { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_adjust_postponement_detail_migrationWithSelectionViewModel: eva_adjust_postponement_detail_migrationViewModel
|
||||
{
|
||||
public List<external_employeeViewModel> item_employee_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user