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

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