เพิ่มหน้าจอบันทึกผลการตรวจข้อตกลงการประเมิน
This commit is contained in:
@@ -164,6 +164,16 @@ namespace TodoAPI2.Models
|
||||
|
||||
[MaxLength(255)]
|
||||
public string level_score_supervisor2A { get; set; }
|
||||
|
||||
public int? chief_a { get; set; }
|
||||
|
||||
[MaxLength(1)]
|
||||
public string chief_a_result { get; set; }
|
||||
|
||||
[MaxLength(1000)]
|
||||
public string chief_a_remark { get; set; }
|
||||
|
||||
public DateTime? chief_a_date { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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_create_evaluation_detail_review0AService : IBaseService2<int, eva_create_evaluation_detail_review0AInputModel, eva_create_evaluation_detail_review0AViewModel>
|
||||
{
|
||||
new eva_create_evaluation_detail_review0AViewModel Insert(eva_create_evaluation_detail_review0AInputModel model, bool is_force_save);
|
||||
new eva_create_evaluation_detail_review0AViewModel Update(int id, eva_create_evaluation_detail_review0AInputModel model, bool is_force_save);
|
||||
List<eva_create_evaluation_detail_review0AViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id);
|
||||
List<eva_create_evaluation_detail_review0AViewModel> GetListBySearch(eva_create_evaluation_detail_review0ASearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_create_evaluation_detail_review0AInputModel> model, bool is_force_save);
|
||||
eva_create_evaluation_detail_review0AWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_create_evaluation_detail_review0AWithSelectionViewModel GetBlankItem();
|
||||
|
||||
void RefreshAutoFieldOfAllData();
|
||||
eva_create_evaluation_detailEntity GetEntity(int id);
|
||||
DataContext GetContext();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
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_create_evaluation_detail_review0AInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? chief_a { get; set; }
|
||||
|
||||
public string chief_a_result { get; set; }
|
||||
|
||||
public string chief_a_remark { get; set; }
|
||||
|
||||
public DateTime? chief_a_date { 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_create_evaluation_detail_review0AReportRequestModel : eva_create_evaluation_detail_review0ASearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_create_evaluation_detail_review0ASearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,316 @@
|
||||
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_create_evaluation_detail_review0AService : Ieva_create_evaluation_detail_review0AService
|
||||
{
|
||||
private IBaseRepository2<eva_create_evaluation_detailEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_create_evaluation_detail_review0AService(IBaseRepository2<eva_create_evaluation_detailEntity, int> repository, IMyDatabase mydb, Iexternal_linkageService inext)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_create_evaluation_detailEntity GetEntity(eva_create_evaluation_detail_review0AInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detailEntity>(model);
|
||||
}
|
||||
private List<eva_create_evaluation_detailEntity> GetEntityList(List<eva_create_evaluation_detail_review0AInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detailEntity>>(models);
|
||||
}
|
||||
private eva_create_evaluation_detail_review0AViewModel GetDto(eva_create_evaluation_detailEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detail_review0AViewModel>(entity);
|
||||
}
|
||||
private List<eva_create_evaluation_detail_review0AViewModel> GetDtoList(List<eva_create_evaluation_detailEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detail_review0AViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_create_evaluation_detail_review0AViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detailEntity GetEntity(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public DataContext GetContext()
|
||||
{
|
||||
return _repository.Context;
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_review0AWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_create_evaluation_detail_review0AWithSelectionViewModel>(entity);
|
||||
i.item_chief_a_result = (from x in ext.GetAgreeDisagree2() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_create_evaluation_detail_review0AWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_create_evaluation_detail_review0AWithSelectionViewModel();
|
||||
i.item_chief_a_result = (from x in ext.GetAgreeDisagree2() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_review0AViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id)
|
||||
{
|
||||
var model = new eva_create_evaluation_detail_review0ASearchModel();
|
||||
model.create_evaluation_id = create_evaluation_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_review0AViewModel> GetListBySearch(eva_create_evaluation_detail_review0ASearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_create_evaluation_detail_review0A in _repository.Context.eva_create_evaluation_detail
|
||||
|
||||
join fk_external_linkage3 in ext.GetAgreeDisagree2() on m_eva_create_evaluation_detail_review0A.chief_a_result equals fk_external_linkage3.external_code
|
||||
into external_linkageResult3
|
||||
from fk_external_linkageResult3 in external_linkageResult3.DefaultIfEmpty()
|
||||
|
||||
|
||||
where 1 == 1
|
||||
//&& (m_eva_create_evaluation_detail_review01.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_create_evaluation_detail_review0A.create_evaluation_id == model.create_evaluation_id || !model.create_evaluation_id.HasValue)
|
||||
|
||||
|
||||
orderby m_eva_create_evaluation_detail_review0A.created descending
|
||||
select new eva_create_evaluation_detail_review0AViewModel()
|
||||
{
|
||||
id = m_eva_create_evaluation_detail_review0A.id,
|
||||
create_evaluation_id = m_eva_create_evaluation_detail_review0A.create_evaluation_id,
|
||||
chief_a = m_eva_create_evaluation_detail_review0A.chief_a,
|
||||
chief_a_result = m_eva_create_evaluation_detail_review0A.chief_a_result,
|
||||
chief_a_remark = m_eva_create_evaluation_detail_review0A.chief_a_remark,
|
||||
chief_a_date = m_eva_create_evaluation_detail_review0A.chief_a_date,
|
||||
|
||||
chief_a_result_external_linkage_external_name = fk_external_linkageResult3.external_name,
|
||||
|
||||
isActive = m_eva_create_evaluation_detail_review0A.isActive,
|
||||
Created = m_eva_create_evaluation_detail_review0A.created,
|
||||
Updated = m_eva_create_evaluation_detail_review0A.updated
|
||||
}
|
||||
).Take(1000).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
|
||||
public int GetNewPrimaryKey()
|
||||
{
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_create_evaluation_detail
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if (x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
|
||||
return newkey.Value;
|
||||
}
|
||||
|
||||
|
||||
public eva_create_evaluation_detail_review0AViewModel Insert(eva_create_evaluation_detail_review0AInputModel model, bool is_force_save)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
//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_create_evaluation_detail_review0AViewModel>(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_review0AViewModel Update(int id, eva_create_evaluation_detail_review0AInputModel model, bool is_force_save)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
var current_detail = (from k in _repository.Context.eva_create_evaluation_detail
|
||||
where k.id == model.id
|
||||
select k).FirstOrDefault();
|
||||
|
||||
if (current_detail.status_chief_a == "Y")
|
||||
{
|
||||
throw new Exception("ผู้ประเมิน อนุมัติข้อตกลงไปแล้ว บันทึกไม่ได้");
|
||||
}
|
||||
|
||||
existingEntity.create_evaluation_id = model.create_evaluation_id;
|
||||
existingEntity.chief_a = model.chief_a;
|
||||
existingEntity.chief_a_result = model.chief_a_result;
|
||||
existingEntity.chief_a_remark = model.chief_a_remark;
|
||||
existingEntity.chief_a_date = model.chief_a_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_create_evaluation_detail_review0AViewModel>(existingEntity);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_create_evaluation_detail_review0AInputModel> 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.create_evaluation_id = i.create_evaluation_id;
|
||||
existingEntity.chief_a = i.chief_a;
|
||||
existingEntity.chief_a_result = i.chief_a_result;
|
||||
existingEntity.chief_a_remark = i.chief_a_remark;
|
||||
existingEntity.chief_a_date = i.chief_a_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 = 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
|
||||
}
|
||||
}
|
||||
if (is_force_save)
|
||||
{
|
||||
_repository.Context.SaveChanges();
|
||||
}
|
||||
|
||||
return model.Count().ToString();
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_review0AViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_create_evaluation_detail_review0AViewModel 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_create_evaluation_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("create_evaluation_id", "แบบประเมิน");
|
||||
i.Add("chief_a", "ผู้ประเมิน");
|
||||
i.Add("chief_a_result", "ผลการประเมิน");
|
||||
i.Add("chief_a_result_external_linkage_external_name", "ผลการประเมิน");
|
||||
i.Add("chief_a_remark", "ความเห็นผู้ประเมินสูงสุด");
|
||||
i.Add("chief_a_date", "วันที่ประเมิน");
|
||||
i.Add("txt_chief_a_date", "วันที่ประเมิน");
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Match Item
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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_create_evaluation_detail_review0AViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? chief_a { get; set; }
|
||||
|
||||
public string chief_a_result { get; set; }
|
||||
|
||||
public string chief_a_remark { get; set; }
|
||||
|
||||
public DateTime? chief_a_date { get; set; }
|
||||
|
||||
public string txt_chief_a_date { get { return MyHelper.GetDateStringForReport(this.chief_a_date); } }
|
||||
|
||||
public string chief_a_result_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_create_evaluation_detail_review0AWithSelectionViewModel: eva_create_evaluation_detail_review0AViewModel
|
||||
{
|
||||
public List<external_linkageViewModel> item_chief_a_result { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ namespace TodoAPI2.Models
|
||||
List<external_linkageViewModel> Getevaluation_status();
|
||||
List<external_linkageViewModel> Getevaluation_accept();
|
||||
List<external_linkageViewModel> GetAgreeDisagree();
|
||||
List<external_linkageViewModel> GetAgreeDisagree2();
|
||||
List<external_linkageViewModel> GetDepartmentData();
|
||||
List<external_linkageViewModel> GetDepartmentDataForReport();
|
||||
List<external_linkageViewModel> GetPositionForReport();
|
||||
|
||||
@@ -266,6 +266,24 @@ namespace TodoAPI2.Models
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<external_linkageViewModel> GetAgreeDisagree2()
|
||||
{
|
||||
var result = new List<external_linkageViewModel>();
|
||||
var i = new external_linkageViewModel();
|
||||
i.external_id = 1;
|
||||
i.external_code = "Y";
|
||||
i.external_name = "เห็นด้วยกับข้อตกลงการประเมิน";
|
||||
result.Add(i);
|
||||
|
||||
var j = new external_linkageViewModel();
|
||||
j.external_id = 2;
|
||||
j.external_code = "N";
|
||||
j.external_name = "ไม่เห็นด้วยและมีความเห็นต่าง";
|
||||
result.Add(j);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<external_linkageViewModel> GetDepartmentData()
|
||||
{
|
||||
var sql = string.Format("select * from public.{0}DepartmentData{0} where department_name != '' and deleted_at is null order by department_name; ", '"'.ToString());
|
||||
|
||||
Reference in New Issue
Block a user