รวม code จากทุกคน ที่แก้ไข op ล่าสุด

This commit is contained in:
Nakorn Rientrakrunchai
2020-04-05 22:57:02 +07:00
parent 6135a2ec09
commit 9ffe9c30d3
46 changed files with 2636 additions and 529 deletions

View File

@@ -254,6 +254,8 @@ namespace TodoAPI2.Models
if (theemp.salary.HasValue)
{
n.sarary = theemp.salary;
if (n.sarary < 13285) n.cost_living = 1000;
else n.cost_living = 0;
sum_salary += n.sarary.Value;
}
else
@@ -262,21 +264,23 @@ namespace TodoAPI2.Models
}
var c = getCylinderForEmployee(theemp, cylinder);
n.cost_living = 0;
n.middle = 0;
n.middle = 0;
if (c != null)
{
n.middle = c.middle;
n.cost_living = c.cost_living;
}
n.promoted_percentage = 0;
n.total_promote = 0;
n.promoted_percentage = 0; // ร้อยละที่ได้เลื่อน
n.total_promote = 0; // จำนวนเงินที่ได้เลื่อน
n.new_sarary = n.sarary;
n.new_cost_living = n.cost_living;
n.remark = null;
if(theemp.worked_month < 4)
{
n.remark = "ปฏิบัติงานไม่ครบ 4 เดือน";
}
n.receive_quota = 0;
n.new_sarary_with_quota = n.sarary;

View File

@@ -108,7 +108,7 @@ namespace TodoAPI2.Models
where 1==1
//&& (m_eva_adjust_postponement_detail_normal_02.id == model.id || !model.id.HasValue)
&& (m_eva_adjust_postponement_detail_normal_02.adjust_postponement_id == model.adjust_postponement_id || !model.adjust_postponement_id.HasValue)
&& fk_create_detailResult.employee_id == m_eva_adjust_postponement_detail_normal_02.employee_id
//&& fk_create_detailResult.employee_id == m_eva_adjust_postponement_detail_normal_02.employee_id
orderby m_eva_adjust_postponement_detail_normal_02.created descending
select new eva_adjust_postponement_detail_normal_02ViewModel()

View File

@@ -96,19 +96,23 @@ namespace TodoAPI2.Models
into eva_adjust_postponementResult1
from fk_eva_adjust_postponementResult1 in eva_adjust_postponementResult1.DefaultIfEmpty()
join fk_eva_adjust_postponement1A in _repository.Context.eva_adjust_postponement on m_eva_adjust_postponement_detail_quota_02.adjust_postponement_id equals fk_eva_adjust_postponement1A.id
into eva_adjust_postponementResult1A
from fk_eva_adjust_postponementResult1A in eva_adjust_postponementResult1A.DefaultIfEmpty()
join fk_external_linkage2 in all_emp on m_eva_adjust_postponement_detail_quota_02.employee_id equals fk_external_linkage2.id
into external_linkageResult2
from fk_external_linkageResult2 in external_linkageResult2.DefaultIfEmpty()
join create_detail in _repository.Context.eva_create_evaluation_detail
on fk_eva_adjust_postponementResult1.create_evaluation_id equals create_detail.create_evaluation_id
on fk_eva_adjust_postponementResult1A.create_evaluation_id equals create_detail.create_evaluation_id
into create_detailResult
from fk_create_detailResult in create_detailResult.DefaultIfEmpty()
where 1==1
//&& (m_eva_adjust_postponement_detail_quota_02.id == model.id || !model.id.HasValue)
&& (m_eva_adjust_postponement_detail_quota_02.adjust_postponement_quota_id == model.adjust_postponement_quota_id || !model.adjust_postponement_quota_id.HasValue)
&& (fk_create_detailResult.employee_id == m_eva_adjust_postponement_detail_quota_02.employee_id || fk_create_detailResult == null)
orderby m_eva_adjust_postponement_detail_quota_02.created descending
select new eva_adjust_postponement_detail_quota_02ViewModel()

View File

@@ -22,15 +22,18 @@ namespace TodoAPI2.Models
private IBaseRepository2<eva_create_evaluationEntity, int> _repository;
private IMyDatabase db;
private Iexternal_linkageService ext;
Iexternal_employeeService emp;
private Iexternal_employeeService emp;
private Ieva_create_evaluation_detailService create_detail;
public eva_create_evaluationService(IBaseRepository2<eva_create_evaluationEntity, int> repository, IMyDatabase mydb,
Iexternal_linkageService inext, Iexternal_employeeService inemp)
Iexternal_linkageService inext, Iexternal_employeeService inemp,
Ieva_create_evaluation_detailService in_create_detail)
{
_repository = repository;
db = mydb;
ext = inext;
emp = inemp;
create_detail = in_create_detail;
}
#region Private Functions
@@ -183,10 +186,14 @@ namespace TodoAPI2.Models
var entity = GetEntity(model);
entity.id = GetNewPrimaryKey();
var inserted = _repository.Insert(entity);
var selected_emp = (from i in _repository.Context.eva_evaluation_group_detail
where i.evaluation_group_id == model.evaluation_group_id
select i.employee_id.Value).ToList();
create_detail.AddMultiple(entity.id, selected_emp);
return Get(inserted.id);
}
@@ -266,6 +273,39 @@ namespace TodoAPI2.Models
}
public void Delete(int id)
{
var p = from i in _repository.Context.eva_adjust_postponement
where i.create_evaluation_id == id
select i;
foreach(var j in p)
{
var p2 = from i in _repository.Context.eva_adjust_postponement_detail
where i.adjust_postponement_id == j.id
select i;
_repository.Context.eva_adjust_postponement_detail.RemoveRange(p2);
}
_repository.Context.eva_adjust_postponement.RemoveRange(p);
var p3 = from i in _repository.Context.eva_create_evaluation_detail
where i.create_evaluation_id == id
select i;
foreach(var k in p3)
{
var p4 = from i in _repository.Context.eva_evaluation_behavior
where i.create_evaluation_detail_id == k.id
select i;
_repository.Context.eva_evaluation_behavior.RemoveRange(p4);
var p5 = from i in _repository.Context.eva_evaluation_achievement
where i.create_evaluation_detail_id == k.id
select i;
_repository.Context.eva_evaluation_achievement.RemoveRange(p5);
}
_repository.Context.eva_create_evaluation_detail.RemoveRange(p3);
_repository.Delete(id);
return;

View File

@@ -162,6 +162,9 @@ namespace TodoAPI2.Models
supervisor1_result_external_linkage_external_name = fk_external_linkageResult21.external_name,
supervisor2_result_external_linkage_external_name = fk_external_linkageResult25.external_name,
position_level_text = fk_external_linkageResult2.position_level_text,
position_type_text = fk_external_linkageResult2.position_type_name,
isActive = m_eva_create_evaluation_detail.isActive,
Created = m_eva_create_evaluation_detail.created,
Updated = m_eva_create_evaluation_detail.updated

View File

@@ -87,5 +87,7 @@ namespace TodoAPI2.Models
public string supervisor1_result_external_linkage_external_name { get; set; }
public string supervisor2_result_external_linkage_external_name { get; set; }
public string position_type_text { get; set; }
public string position_level_text { get; set; }
}
}

View File

@@ -85,7 +85,7 @@ namespace TodoAPI2.Models
employee_code = fk_external_employee.employee_no,
employee_fullname = fk_external_employee.fullname,
employee_position = fk_external_employee.position_name,
employee_position_type = fk_external_employee.employee_type_name,
employee_position_type = fk_external_employee.position_type_name,
employee_position_level = fk_external_employee.position_level_text,
employee_org = fk_external_employee.department_name,
chief_fullname = fk_external_chief.fullname,
@@ -195,8 +195,8 @@ namespace TodoAPI2.Models
employee_code = fk_external_employee.employee_no,
employee_fullname = fk_external_employee.fullname,
employee_position = fk_external_employee.position_name,
employee_position_type = null,
employee_position_level = null,
employee_position_type = fk_external_employee.position_type_name,
employee_position_level = fk_external_employee.position_level_text,
employee_org = fk_external_employee.department_name,
chief_fullname = fk_external_chief.fullname,
chief_position = fk_external_chief.position_name,

View File

@@ -0,0 +1,28 @@
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_idp_planService : IBaseService<int, eva_idp_planInputModel, eva_idp_planViewModel>
{
new eva_idp_planViewModel Insert(eva_idp_planInputModel model);
new eva_idp_planViewModel Update(int id, eva_idp_planInputModel model);
List<eva_idp_planViewModel> GetListBycreate_evaluation_detail_id(int? create_evaluation_detail_id);
List<eva_idp_planViewModel> GetListBySearch(eva_idp_planSearchModel model);
string UpdateMultiple(List<eva_idp_planInputModel> model);
eva_idp_planWithSelectionViewModel GetWithSelection(int id);
eva_idp_planWithSelectionViewModel GetBlankItem();
}
}

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;
using System.IO;
namespace TodoAPI2.Models
{
public class eva_idp_planEntity : BaseEntity2<int>
{
public int? create_evaluation_detail_id { get; set; }
[MaxLength(1000)]
public string develop { get; set; }
[MaxLength(1000)]
public string development_method { get; set; }
public DateTime? start_date { get; set; }
public DateTime? end_date { get; set; }
}
}

View File

@@ -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_idp_planInputModel
{
public int? id { get; set; }
public int? create_evaluation_detail_id { get; set; }
public string develop { get; set; }
public string development_method { get; set; }
public DateTime? start_date { get; set; }
public DateTime? end_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_idp_planReportRequestModel : eva_idp_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_idp_planSearchModel
{
public int id { get; set; }
public int? create_evaluation_detail_id { get; set; }
}
}

View File

@@ -0,0 +1,232 @@
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_idp_planService : Ieva_idp_planService
{
private IBaseRepository2<eva_idp_planEntity, int> _repository;
private IMyDatabase db;
private Iexternal_linkageService ext;
public eva_idp_planService(IBaseRepository2<eva_idp_planEntity, int> repository, IMyDatabase mydb, Iexternal_linkageService inext)
{
_repository = repository;
db = mydb;
ext = inext;
}
#region Private Functions
private eva_idp_planEntity GetEntity(eva_idp_planInputModel model)
{
return Mapper.Map<eva_idp_planEntity>(model);
}
private List<eva_idp_planEntity> GetEntityList(List<eva_idp_planInputModel> models)
{
return Mapper.Map<List<eva_idp_planEntity>>(models);
}
private eva_idp_planViewModel GetDto(eva_idp_planEntity entity)
{
return Mapper.Map<eva_idp_planViewModel>(entity);
}
private List<eva_idp_planViewModel> GetDtoList(List<eva_idp_planEntity> entities)
{
return Mapper.Map<List<eva_idp_planViewModel>>(entities);
}
#endregion
#region Public Functions
#region Query Functions
public eva_idp_planViewModel Get(int id)
{
var entity = _repository.Get(id);
return GetDto(entity);
}
public eva_idp_planWithSelectionViewModel GetWithSelection(int id)
{
var entity = _repository.Get(id);
var i = Mapper.Map<eva_idp_planWithSelectionViewModel>(entity);
return i;
}
public eva_idp_planWithSelectionViewModel GetBlankItem()
{
var i = new eva_idp_planWithSelectionViewModel();
return i;
}
public List<eva_idp_planViewModel> GetListBycreate_evaluation_detail_id(int? create_evaluation_detail_id)
{
var model = new eva_idp_planSearchModel();
model.create_evaluation_detail_id = create_evaluation_detail_id;
return GetListBySearch(model);
}
public List<eva_idp_planViewModel> GetListBySearch(eva_idp_planSearchModel model)
{
var data = (
from m_eva_idp_plan in _repository.Context.eva_idp_plan
where 1==1
//&& (m_eva_idp_plan.id == model.id || !model.id.HasValue)
&& (m_eva_idp_plan.create_evaluation_detail_id == model.create_evaluation_detail_id || !model.create_evaluation_detail_id.HasValue)
orderby m_eva_idp_plan.created descending
select new eva_idp_planViewModel()
{
id = m_eva_idp_plan.id,
create_evaluation_detail_id = m_eva_idp_plan.create_evaluation_detail_id,
develop = m_eva_idp_plan.develop,
development_method = m_eva_idp_plan.development_method,
start_date = m_eva_idp_plan.start_date,
end_date = m_eva_idp_plan.end_date,
isActive = m_eva_idp_plan.isActive,
Created = m_eva_idp_plan.created,
Updated = m_eva_idp_plan.updated
}
).Take(100).ToList();
return data;
}
#endregion
#region Manipulation Functions
public int GetNewPrimaryKey()
{
int? newkey = 0;
var x = (from i in _repository.Context.eva_idp_plan
orderby i.id descending
select i).Take(1).ToList();
if(x.Count > 0)
{
newkey = x[0].id + 1;
}
return newkey.Value;
}
public eva_idp_planViewModel Insert(eva_idp_planInputModel model)
{
var entity = GetEntity(model);
entity.id = GetNewPrimaryKey();
var inserted = _repository.Insert(entity);
return Get(inserted.id);
}
public eva_idp_planViewModel Update(int id, eva_idp_planInputModel model)
{
var existingEntity = _repository.Get(id);
if (existingEntity != null)
{
existingEntity.create_evaluation_detail_id = model.create_evaluation_detail_id;
existingEntity.develop = model.develop;
existingEntity.development_method = model.development_method;
existingEntity.start_date = model.start_date;
existingEntity.end_date = model.end_date;
var updated = _repository.Update(id, existingEntity);
return Get(updated.id);
}
else
throw new NotificationException("No data to update");
}
public string UpdateMultiple(List<eva_idp_planInputModel> 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.create_evaluation_detail_id = i.create_evaluation_detail_id;
existingEntity.develop = i.develop;
existingEntity.development_method = i.development_method;
existingEntity.start_date = i.start_date;
existingEntity.end_date = i.end_date;
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
}
}
else if (i.active_mode == "1" && !i.id.HasValue) // add
{
var entity = GetEntity(i);
entity.id = GetNewPrimaryKey();
_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_idp_planViewModel SetAsActive(int id)
{
var updated = _repository.SetAsActive(id);
return Get(updated.id);
}
public eva_idp_planViewModel SetAsInactive(int id)
{
var updated = _repository.SetAsInActive(id);
return Get(updated.id);
}
public void Delete(int id)
{
_repository.Delete(id);
return;
}
#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_idp_planViewModel : BaseViewModel2<int>
{
public int? create_evaluation_detail_id { get; set; }
public string develop { get; set; }
public string development_method { get; set; }
public DateTime? start_date { get; set; }
public string txt_start_date { get { return MyHelper.GetDateStringForReport(this.start_date); } }
public DateTime? end_date { get; set; }
public string txt_end_date { get { return MyHelper.GetDateStringForReport(this.end_date); } }
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace TodoAPI2.Models
{
public class eva_idp_planWithSelectionViewModel: eva_idp_planViewModel
{
}
}

View File

@@ -70,8 +70,10 @@ select he.employee_id as id, mpn.position_number,he.employee_no,he.position_no,
CONCAT(htm.title_name,' ',he.firstname,' ',he.lastname) as fullname,opd.position_name,
orgdata.id as department_id,orgdata.department_name,orgdata.department_code,he.salary,
he.employee_type_id, het.employee_type_name,opd.position_id as position_id,
u.email as user_email, u.id as user_id,hpl.position_level_name,hpl.position_level_id
u.email as user_email, u.id as user_id,hpl.position_level_name,he.position_level_id,
he.position_type_id,hpt.position_type_name,he.packing_date
from public.hrm_employees as he
left join public.hrm_position_types as hpt on he.position_type_id=hpt.id
left join public.hrm_position_levels as hpl on he.position_level_id = hpl.id
left join public.mpp_position_numbers as mpn on he.position_no = mpn.id
left join public.org_position_datas as opd on opd.position_id = mpn.position_id
@@ -98,7 +100,12 @@ order by he.firstname,he.lastname;
i.employee_type_id = Convert.ToInt32(dr["employee_type_id"]);
i.employee_type_name = dr["employee_type_name"].ToString();
}
i.position_type_id = null;
if (dr["position_type_id"] != DBNull.Value)
{
i.position_type_id = Convert.ToInt32(dr["position_type_id"]);
i.position_type_name = dr["position_type_name"].ToString();
}
if (dr["position_id"] != DBNull.Value)
{
@@ -130,6 +137,10 @@ order by he.firstname,he.lastname;
{
i.salary = Convert.ToDecimal(dr["salary"]);
}
if (dr["packing_date"] != DBNull.Value)
{
i.packing_date = Convert.ToDateTime(dr["packing_date"]);
}
result.Add(i);
}
@@ -141,7 +152,7 @@ order by he.firstname,he.lastname;
var sql = @"
select he.employee_id as id, mpn.position_number, opd.position_name,
CONCAT(htm.title_name,' ',he.firstname,' ',he.lastname) as fullname,
u.email as user_email, u.id as user_id
u.email as user_email, u.id as user_id,u.name as fullname2
from public.hrm_employees as he
left join public.mpp_position_numbers as mpn on he.position_no = mpn.id
left join public.org_position_datas as opd on opd.position_id = mpn.position_id
@@ -164,14 +175,14 @@ and u.id=@user_id;
i.id = Convert.ToInt32(dr["id"]);
i.position_number = dr["position_number"].ToString();
i.position_name = dr["position_name"].ToString();
i.fullname = dr["fullname"].ToString();
i.fullname = dr["fullname2"].ToString();
i.employee_type_id = null;
i.position_type_id = null;
if(dr["user_id"] != DBNull.Value)
if (dr["user_id"] != DBNull.Value)
{
i.user_email = dr["user_email"].ToString();
i.user_id = Convert.ToInt32(dr["user_id"]);
}
}
result.Add(i);
}

View File

@@ -26,6 +26,7 @@ namespace TodoAPI2.Models
public int? position_id { get; set; }
public int? position_type_id { get; set; }
public string position_type_name { get; set; }
public string user_email { get; set; }
@@ -40,5 +41,27 @@ namespace TodoAPI2.Models
public int? position_level_id { get; set; }
public string position_level_text { get; set; }
public DateTime? packing_date { get; set; }
public int? worked_month // ทำงานมาแล้วกี่เดือน
{
get
{
if (packing_date.HasValue)
{
DateTime startDate = packing_date.Value;
DateTime endDate = DateTime.Now;
int monthsApart = 12 * (startDate.Year - endDate.Year) + startDate.Month - endDate.Month;
return Math.Abs(monthsApart);
}
else
{
return 0;
}
}
}
}
}
}