本文整理汇总了C#中CustomBaseRepository.Add方法的典型用法代码示例。如果您正苦于以下问题:C# CustomBaseRepository.Add方法的具体用法?C# CustomBaseRepository.Add怎么用?C# CustomBaseRepository.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CustomBaseRepository
的用法示例。
在下文中一共展示了CustomBaseRepository.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveEvalutionData
public string SaveEvalutionData(int year, Guid? TimesGetDataID, string orgStructureID, DateTime? _dateStart, DateTime? _dateEnd,string userLogin)
{
using (var context = new VnrHrmDataContext())
{
var evaServices = new Eva_ReportServices();
List<Eva_EvalutionDataEntity> lstEvalutionDataEntity = new List<Eva_EvalutionDataEntity>();
lstEvalutionDataEntity = evaServices.SummaryEvalutionData(year, TimesGetDataID, orgStructureID, _dateStart, _dateEnd,userLogin);
var unitOfWork = (IUnitOfWork)new UnitOfWork(context);
var repoEva_EvalutionData = new CustomBaseRepository<Eva_EvalutionData>(unitOfWork);
List<Eva_EvalutionData> lstEvalutionData = new List<Eva_EvalutionData>();
lstEvalutionData = lstEvalutionDataEntity.Translate<Eva_EvalutionData>();
if (lstEvalutionData != null)
{
int _total = lstEvalutionData.Count;
int _totalPage = _total / 200 + 1;
int _pageSize = 200;
for (int _page = 1; _page <= _totalPage; _page++)
{
int _skip = _pageSize * (_page - 1);
var _listCurrenPage = lstEvalutionData.Skip(_skip).Take(_pageSize).ToList();
foreach (var item in _listCurrenPage)
{
repoEva_EvalutionData.Add(item);
}
unitOfWork.SaveChanges();
}
}
return "SaveSuccess";
// #endregion
}
}
示例2: ComputeBonusUnusualAllowance
public Guid ComputeBonusUnusualAllowance(Sal_UnusualAllowanceEntity model)
{
using (var context = new VnrHrmDataContext())
{
var unitOfWork = (IUnitOfWork)new UnitOfWork(context);
var repoSys_AsynTask = new CustomBaseRepository<Sys_AsynTask>(unitOfWork);
var repoCat_Element = new CustomBaseRepository<Cat_Element>(unitOfWork);
//tạo asynTask
Sys_AsynTask asynTask = new Sys_AsynTask()
{
ID = Guid.NewGuid(),
Summary = "Tính thưởng : " + model.MonthStart.Value.ToString("dd/MM/yyyy"),
Type = AsynTask.Payroll_Compute_BonusUnusualAllowance.ToString(),
Status = AsynTaskStatus.Doing.ToString(),
TimeStart = DateTime.Now,
PercentComplete = 0.01,
};
repoSys_AsynTask.Add(asynTask);
unitOfWork.SaveChanges();
Thread threadCompute = new Thread(() => ComputeBonusUnusualAllowance_Progress(asynTask.ID, model));
threadCompute.Start();
return asynTask.ID;
}
}
示例3: SaveList
public string SaveList(List<Att_RosterEntity> lstModel)
{
using (var context = new VnrHrmDataContext())
{
List<Att_Roster> lstSave = new List<Att_Roster>();
lstSave = lstModel.Translate<Att_Roster>();
var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
var repo = new CustomBaseRepository<Att_Roster>(unitOfWork);
//int count = 0;
foreach (var item in lstSave)
{
//count += 1;
item.ID = Guid.NewGuid();
repo.Add(item);
}
try
{
repo.SaveChanges();
return "Success";
}
catch (Exception)
{
return "Error";
}
}
}
示例4: AddList
public bool AddList(List<Att_AnnualLeaveDetailEntity> models)
{
bool isSuccess = false;
var leaveType = string.Empty;
var status = string.Empty;
var year = 2013;
if (models != null && models.FirstOrDefault() != null && models.FirstOrDefault().Year != null)
{
year = Convert.ToInt32(models.FirstOrDefault().Year);
leaveType = models.FirstOrDefault().Type;
}
using (var context = new VnrHrmDataContext())
{
var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
var repo = new CustomBaseRepository<Att_AnnualLeaveDetail>(unitOfWork);
try
{
var annualLeaveDetails = GetAllUseEntity<Att_AnnualLeaveDetail>(ref status).Where(p => p.Type == leaveType && p.Year == year).ToList().AsQueryable();
foreach (var attAnnualLeaveDetail in models)
{
var addSuccess = false;
var existAnnualDetail = annualLeaveDetails.Where(p => p.ProfileID == attAnnualLeaveDetail.ProfileID ).FirstOrDefault();
if (existAnnualDetail != null)
{
existAnnualDetail.Month1 = attAnnualLeaveDetail.Month1;
existAnnualDetail.Month2 = attAnnualLeaveDetail.Month1;
existAnnualDetail.Month3 = attAnnualLeaveDetail.Month1;
existAnnualDetail.Month4 = attAnnualLeaveDetail.Month1;
existAnnualDetail.Month5 = attAnnualLeaveDetail.Month1;
existAnnualDetail.Month6 = attAnnualLeaveDetail.Month1;
existAnnualDetail.Month7 = attAnnualLeaveDetail.Month1;
existAnnualDetail.Month8 = attAnnualLeaveDetail.Month1;
existAnnualDetail.Month9 = attAnnualLeaveDetail.Month1;
existAnnualDetail.Month10 = attAnnualLeaveDetail.Month1;
existAnnualDetail.Month11 = attAnnualLeaveDetail.Month1;
existAnnualDetail.Month12 = attAnnualLeaveDetail.Month1;
repo.Edit(existAnnualDetail);
}
else
{
Att_AnnualLeaveDetail temp = new Att_AnnualLeaveDetail();
temp = attAnnualLeaveDetail.CopyData<Att_AnnualLeaveDetail>();
repo.Add(temp);
}
}
repo.SaveChanges();
return true;
}
catch
{
return false;
}
}
}
示例5: SaveUnusualAllowance
public void SaveUnusualAllowance(List<Sal_UnusualAllowanceEntity> model)
{
using (var context = new VnrHrmDataContext())
{
string status = string.Empty;
var unitOfWork = (IUnitOfWork)new UnitOfWork(context);
var repoUnusualAllowance = new CustomBaseRepository<Sal_UnusualAllowance>(unitOfWork);
repoUnusualAllowance.Add(model.Translate<Sal_UnusualAllowance>());
unitOfWork.SaveChanges();
}
}
示例6: CreateFormulaTemplate
public void CreateFormulaTemplate(List<Cat_FormulaTemplateEntity> listFormulaTemplate,Guid GradeID)
{
using (var context = new VnrHrmDataContext())
{
var unitOfWork = (IUnitOfWork)new UnitOfWork(context);
var repoCat_FormulaTemplate = new CustomBaseRepository<Cat_FormulaTemplate>(unitOfWork);
var repoCat_Element = new CustomBaseRepository<Cat_Element>(unitOfWork);
#region Xử lý bảng template
//lấy các phần tử template trong grade
List<Cat_FormulaTemplate> listFormulaTemplateByGrade = repoCat_FormulaTemplate.FindBy(m => m.IsDelete != true && m.GradeID != null && m.GradeID == GradeID).ToList();
//xóa các phần tử đó
repoCat_FormulaTemplate.Delete(listFormulaTemplateByGrade);
//insert lại các phần tử mới
List<Cat_FormulaTemplate> listFormulaTemplateModel = listFormulaTemplate.Translate<Cat_FormulaTemplate>();
listFormulaTemplateModel.ForEach(m => m.GradeID = GradeID);
repoCat_FormulaTemplate.Add(listFormulaTemplateModel);
#endregion
#region Xử lý bảng cat_element
//lấy các phần tử có cùng mã code với template
List<Cat_Element> listElement = repoCat_Element.FindBy(m => m.IsDelete != true && m.GradePayrollID == GradeID).ToList();
listElement = listElement.Where(m => listFormulaTemplate.Any(t => t.ElementCode.ReplaceSpace() == m.ElementCode.ReplaceSpace())).ToList();
//xóa các phần tử đó đi
repoCat_Element.Delete(listElement);
//tạo ra các element
List<Cat_Element> listElementModel = new List<Cat_Element>();
Cat_Element item = new Cat_Element();
foreach (var template in listFormulaTemplate)
{
item = new Cat_Element();
item.GradePayrollID = GradeID;
item.ElementCode = template.ElementCode.ReplaceSpace();
item.ElementName = template.ElementName;
item.Formula = template.Formula;
item.IsBold = template.IsBold;
item.Invisible = template.Invisible;
item.Description = template.Description;
item.TabType = CatElementType.Payroll.ToString();
item.MethodPayroll = MethodPayroll.E_NORMAL.ToString();
item.ElementType = CatElementType.Payroll.ToString();
item.Type = EnumDropDown.ElementDataType.Double.ToString();
listElementModel.Add(item);
}
repoCat_Element.Add(listElementModel);
unitOfWork.SaveChanges();
#endregion
}
}
示例7: SetCompensationLeaveBeginYear
public void SetCompensationLeaveBeginYear(List<Guid> lstProfileIDs, double? limitMaximum, int Year, int? MonthResetANL, Guid? AllowanceTypeID, Guid? CuttOffDurationID)
{
using (var context = new VnrHrmDataContext())
{
var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
var repoAtt_CompensationConfig = new CustomBaseRepository<Att_CompensationConfig>(unitOfWork);
DateTime EndLastYear = new DateTime(Year - 1, 12, 1);
List<Att_CompensationDetail> lstCompensationDetail = unitOfWork.CreateQueryable<Att_CompensationDetail>(m => m.MonthYear == EndLastYear
&& m.ProfileID != null
&& lstProfileIDs.Contains(m.ProfileID.Value)).ToList();
var lstCompensationLeaveInDB = unitOfWork.CreateQueryable<Att_CompensationConfig>(m => m.Year == Year && m.ProfileID != null && lstProfileIDs.Contains(m.ProfileID.Value)).ToList();
List<Att_CompensationConfig> lstNewData = new List<Att_CompensationConfig>();
List<Att_CompensationConfig> lstEditData = new List<Att_CompensationConfig>();
foreach (var ProfileID in lstProfileIDs)
{
Att_CompensationConfig CompensationLeaveConfigByProfile = lstCompensationLeaveInDB.Where(m => m.ProfileID == ProfileID).FirstOrDefault();
bool IsNew = false;
if (CompensationLeaveConfigByProfile == null)
{
IsNew = true;
CompensationLeaveConfigByProfile = new Att_CompensationConfig();
CompensationLeaveConfigByProfile.ID = Guid.NewGuid();
CompensationLeaveConfigByProfile.ProfileID = ProfileID;
CompensationLeaveConfigByProfile.Year = Year;
}
CompensationLeaveConfigByProfile.MonthResetInitAvailable = MonthResetANL;
double RemainLastYear = lstCompensationDetail.Where(m => m.ProfileID == ProfileID).Select(m => m.Remain ?? 0).FirstOrDefault();
if (limitMaximum != null)
{
CompensationLeaveConfigByProfile.InitAvailable = RemainLastYear > limitMaximum.Value ? limitMaximum.Value : RemainLastYear;
}
else
{
CompensationLeaveConfigByProfile.InitAvailable = RemainLastYear;
}
if (IsNew)
{
lstNewData.Add(CompensationLeaveConfigByProfile);
}
else
{
lstEditData.Add(CompensationLeaveConfigByProfile);
}
//Sửa lại theo phần tử mới mà Sơn build
}
repoAtt_CompensationConfig.Add(lstNewData);
repoAtt_CompensationConfig.Edit(lstEditData);
unitOfWork.SaveChanges();
}
}
示例8: AddDataForGrade
public void AddDataForGrade(string ProfileIDs, Guid GradePayrollID, DateTime DateHire)
{
using (var context = new VnrHrmDataContext())
{
var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
var repoGrade = new CustomBaseRepository<Sal_Grade>(unitOfWork);
List<Guid> lstProfileIDs = ProfileIDs.Split(',').Select(x => Guid.Parse(x)).ToList();
List<Sal_Grade> lstGrade = new List<Sal_Grade>();
foreach (var item in lstProfileIDs)
{
Sal_Grade Grade = new Sal_Grade();
Grade.ProfileID = item;
Grade.GradePayrollID = GradePayrollID;
Grade.MonthStart = DateHire;
lstGrade.Add(Grade);
}
repoGrade.Add(lstGrade);
repoGrade.SaveChanges();
}
}
示例9: SaveLeaveDay
public string SaveLeaveDay(Att_Workday Workday, string LeaveTypeCode, string UserLogin)
{
if (Workday == null)
return string.Empty;
using (var context = new VnrHrmDataContext())
{
var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
var repoCat_Shift = new CustomBaseRepository<Cat_Shift>(unitOfWork);
var repoCat_LeaveDayType = new CustomBaseRepository<Cat_LeaveDayType>(unitOfWork);
var repoAtt_LeaveDay = new CustomBaseRepository<Att_LeaveDay>(unitOfWork);
var repoHre_Profile = new CustomBaseRepository<Hre_Profile>(unitOfWork);
var repoAtt_Grade = new CustomBaseRepository<Att_Grade>(unitOfWork);
var repoCat_GradeAttendance = new CustomBaseRepository<Cat_GradeAttendance>(unitOfWork);
var repoHre_WorkHistory = new CustomBaseRepository<Hre_WorkHistory>(unitOfWork);
var repoAtt_Roster = new CustomBaseRepository<Att_Roster>(unitOfWork);
var repoAtt_RosterGroup = new CustomBaseRepository<Att_RosterGroup>(unitOfWork);
var repoCat_DayOff = new CustomBaseRepository<Cat_DayOff>(unitOfWork);
var shifts = repoCat_Shift.FindBy(s => s.IsDelete == null).ToList();
Att_LeavedayServices leavedayServices = new Att_LeavedayServices();
LeaveTypeCode = LeaveTypeCode.Replace("...", string.Empty);
Guid? ShiftID = Workday.ShiftApprove ?? Workday.ShiftID;
double DurationHour = 8;
var shift = repoCat_Shift.FindBy(m => m.ID == ShiftID).FirstOrDefault();
//Cat_Shift shift = EntityService.CreateQueryable<Cat_Shift>(false, GuidContext, Guid.Empty, m => m.ID == ShiftID).FirstOrDefault();
if (shift != null)
DurationHour = shift.WorkHours ?? 8;
var leaveType = new List<Cat_LeaveDayType>().Select(m => new { m.ID, m.Code, m.CodeStatistic }).FirstOrDefault();
if (!string.IsNullOrEmpty(LeaveTypeCode))
{
leaveType = repoCat_LeaveDayType.FindBy(m => m.Code == LeaveTypeCode).Select(m => new { m.ID, m.Code, m.CodeStatistic }).FirstOrDefault();
//leaveType = EntityService.CreateQueryable<Cat_LeaveDayType>(false, GuidContext, Guid.Empty, m => m.CodeStatistic == LeaveTypeCode).Select(m => new { m.ID, m.Code, m.CodeStatistic }).FirstOrDefault();
}
DateTime workday = Workday.WorkDate;
DateTime beginDate = workday.Date;
DateTime endDate = beginDate.AddDays(1).AddMinutes(-1);
DateTime beginShift = workday.AddHours(shift.InTime.Hour).AddMinutes(shift.InTime.Minute);
DateTime endShift = beginShift.AddHours(shift.CoOut);
string E_APPROVED = LeaveDayStatus.E_APPROVED.ToString();
string E_REJECTED = LeaveDayStatus.E_REJECTED.ToString();
List<Att_LeaveDay> lstLeaveDayInDbUpdate = repoAtt_LeaveDay.FindBy(m => m.DateStart <= endDate && m.DateEnd >= beginDate && m.ProfileID == Workday.ProfileID && m.Status != E_REJECTED).ToList<Att_LeaveDay>();
List<Att_LeaveDay> lstLeaveDayInsert = new List<Att_LeaveDay>();
if (lstLeaveDayInDbUpdate.Count > 0)
{
if (!lstLeaveDayInDbUpdate.Any(m => m.Status == LeaveDayStatus.E_APPROVED.ToString()))
{
if (leaveType != null)
{
lstLeaveDayInDbUpdate.ForEach(m => m.LeaveDayTypeID = leaveType.ID);
}
else
{
lstLeaveDayInDbUpdate.ForEach(m => m.IsDelete = true);
}
}
else
lstLeaveDayInDbUpdate = new List<Att_LeaveDay>();
}
else
{
if (leaveType != null)
{
Att_LeaveDay LeavedayInsert = new Att_LeaveDay();
LeavedayInsert.ID = Guid.Empty;
LeavedayInsert.ProfileID = Workday.ProfileID;
LeavedayInsert.TotalDuration = 1;
LeavedayInsert.LeaveDays = 1;
LeavedayInsert.Duration = shift.WorkHours ?? 8;
LeavedayInsert.LeaveHours = shift.WorkHours ?? 8;
LeavedayInsert.DurationType = LeaveDayDurationType.E_FULLSHIFT.ToString();
LeavedayInsert.DateStart = workday;
LeavedayInsert.DateEnd = workday;
LeavedayInsert.LeaveDayTypeID = leaveType.ID;
LeavedayInsert.Status = LeaveDayStatus.E_SUBMIT.ToString();
lstLeaveDayInsert.Add(LeavedayInsert);
}
}
//Cap nhat leavedayID cho workday o day
if (lstLeaveDayInsert.Count > 0)
{
if (lstLeaveDayInsert.Count > 1)
{
Workday.LeaveDayID1 = lstLeaveDayInsert[0].ID;
Workday.LeaveDayID2 = lstLeaveDayInsert[1].ID;
//Workday.udLeavedayCode1 = LeaveTypeCode;
//Workday.udLeavedayCode2 = LeaveTypeCode;
//Workday.udLeavedayStatus1 = lstLeaveDayInsert.FirstOrDefault().Status.TranslateString();
//Workday.udLeavedayStatus2 = lstLeaveDayInsert.FirstOrDefault().Status.TranslateString();
}
else
{
Workday.LeaveDayID1 = lstLeaveDayInsert[0].ID;
//Workday.udLeavedayCode1 = LeaveTypeCode;
//Workday.udLeavedayStatus1 = lstLeaveDayInsert.FirstOrDefault().Status.TranslateString();
}
}
//else if (lstLeaveDayInDbUpdate.Count > 0)
//.........这里部分代码省略.........
示例10: CalNonAllowOvertime
/// <summary>
/// [Hien.Nguyen] - Chức năng không tính tăng ca - màng hình Phân Tích Tăng Ca
/// </summary>
/// <param name="lstOvertimeEntity"></param>
public void CalNonAllowOvertime(List<Att_OvertimeEntity> lstOvertime, string userLogin)
{
using (var context = new VnrHrmDataContext())
{
var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
var repoAtt_workday = new CustomBaseRepository<Att_Workday>(unitOfWork);
var repoAtt_NoneOvertime = new CustomBaseRepository<Att_NonOverTime>(unitOfWork);
if (lstOvertime.Count == 0 || lstOvertime.Where(m => m.WorkDateRoot != null).Count() == 0)
{
return;
}
DateTime minDate = lstOvertime.Min(m => m.WorkDateRoot.Value);
DateTime maxDate = lstOvertime.Max(m => m.WorkDateRoot.Value);
List<Guid> lstProfileID = lstOvertime.Select(m => m.ProfileID).Distinct().ToList();
string E_REJECTED = OverTimeStatus.E_REJECTED.ToString();
// List<ProfileDateTime> lstWorkdayNotOT = new List<ProfileDateTime>();
List<Guid> lstOvertimeIDChange = new List<Guid>();
foreach (var item in lstOvertime)
{
if (item.WorkDateRoot == null)
continue;
if (item.IsNonOvertime == true)
continue;
if (string.IsNullOrEmpty(item.udOvertimeStatus))
{
//ProfileDateTime workdayNotOt = new ProfileDateTime();
//workdayNotOt.ProfileID = item.ProfileID;
//workdayNotOt.WorkDate = item.WorkDateRoot.Value;
//workdayNotOt.OvertimeID = item.ID;
//lstWorkdayNotOT.Add(workdayNotOt);
lstOvertimeIDChange.Add(item.ID);
}
}
List<Att_OvertimeEntity> lstOvertimeInCache = lstOvertime;
List<Att_OvertimeEntity> lstOvertimeInCache_Profile = lstOvertimeInCache.Where(m => lstOvertimeIDChange.Contains(m.ID)).ToList();
List<Att_OvertimeEntity> lstOvertimeNonBe_Insert = new List<Att_OvertimeEntity>();
foreach (var item in lstOvertimeInCache_Profile)
{
//if (lstWorkdayNotOT.Any(m => m.ProfileID == item.ProfileID && m.WorkDate == item.WorkDateRoot))
//{
item.IsNonOvertime = true;
lstOvertimeNonBe_Insert.Add(item);
// }
}
lstOvertimeInCache.RemoveRange(lstOvertimeInCache_Profile);
//Để tính lại lũy kế sau khi xong
OvertimePermitEntity overtimePermit = getOvertimePermit(userLogin);
List<WorkdayCustom> lstWorkday = new List<WorkdayCustom>();
if (lstProfileID.Count < 2000)
{
lstWorkday = repoAtt_workday
.FindBy(m => m.IsDelete == null && m.WorkDate >= minDate && m.WorkDate <= maxDate && lstProfileID.Contains(m.ProfileID))
.Select(m => new WorkdayCustom() { ID = m.ID, ProfileID = m.ProfileID, ShiftID = m.ShiftID, ShiftApprove = m.ShiftApprove, WorkDate = m.WorkDate, Status = m.Status, InTime1 = m.InTime1, InTime2 = m.InTime2, OutTime1 = m.OutTime1, OutTime2 = m.OutTime2 })
.ToList<WorkdayCustom>();
}
else
{
lstWorkday = repoAtt_workday
.FindBy(m => m.IsDelete == null && m.WorkDate >= minDate && m.WorkDate <= maxDate)
.Select(m => new WorkdayCustom() { ID = m.ID, ProfileID = m.ProfileID, ShiftID = m.ShiftID, ShiftApprove = m.ShiftApprove, WorkDate = m.WorkDate, Status = m.Status, InTime1 = m.InTime1, InTime2 = m.InTime2, OutTime1 = m.OutTime1, OutTime2 = m.OutTime2 })
.ToList<WorkdayCustom>();
}
FillterAllowOvertime(context, lstOvertimeInCache_Profile, overtimePermit, lstWorkday);
lstOvertimeInCache.AddRange(lstOvertimeInCache_Profile);
lstOvertimeInCache = lstOvertimeInCache.OrderBy(m => m.WorkDate.Date).ThenBy(m => m.ProfileID).ToList();
lstOvertimeCache = lstOvertimeInCache;
List<Att_NonOverTime> LstNonOTInsert = new List<Att_NonOverTime>();
foreach (var item in lstOvertimeNonBe_Insert)
{
Att_NonOverTime nonOT = new Att_NonOverTime();
nonOT.ID = Guid.NewGuid();
nonOT.ProfileID = item.ProfileID;
nonOT.WorkDay = item.WorkDateRoot.Value;
nonOT.OvertimeTypeID = item.OvertimeTypeID;
nonOT.Type = item.udTypeBeginOTWithShift;
LstNonOTInsert.Add(nonOT);
repoAtt_NoneOvertime.Add(nonOT);
}
unitOfWork.SaveChanges();
}
//BindToGrid(lstOvertimeCache);
}
示例11: SaveOvertimePermitConfig
public string SaveOvertimePermitConfig(OvertimePermitEntity entity, string userLogin)
{
using (var context = new VnrHrmDataContext())
{
var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
var repoSys_AllSetting = new CustomBaseRepository<Sys_AllSetting>(unitOfWork);
Sys_AllSetting sys = new Sys_AllSetting();
string HRM_ATT_OT_OTPERMIT_ = AppConfig.HRM_ATT_OT_OTPERMIT_.ToString();
string status = string.Empty;
List<object> lstO = new List<object>();
lstO.Add(HRM_ATT_OT_OTPERMIT_);
lstO.Add(null);
lstO.Add(null);
var config = GetData<Sys_AllSetting>(lstO, ConstantSql.hrm_sys_sp_get_AllSetting, userLogin, ref status);
if (config != null)
{
if (entity.limitHour_ByDay.HasValue)
{
var objConfig = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_OTPERMIT_LIMITHOUR_BYDAY.ToString()).FirstOrDefault();
if (objConfig != null)
{
if (objConfig.Value1 != entity.limitHour_ByDay.Value.ToString())
{
objConfig.Value1 = entity.limitHour_ByDay.Value.ToString();
repoSys_AllSetting.Edit(objConfig);
}
}
else
{
objConfig.ID = Guid.NewGuid();
objConfig.Name = AppConfig.HRM_ATT_OT_OTPERMIT_LIMITHOUR_BYDAY.ToString();
objConfig.Value1 = entity.limitHour_ByDay.Value.ToString();
repoSys_AllSetting.Add(objConfig);
}
}
if (entity.limitHour_ByDay_Lev1.HasValue)
{
var objConfig = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_OTPERMIT_LIMITHOUR_BYDAY_LEV1.ToString()).FirstOrDefault();
if (objConfig != null)
{
if (objConfig.Value1 != entity.limitHour_ByDay_Lev1.Value.ToString())
{
objConfig.Value1 = entity.limitHour_ByDay_Lev1.Value.ToString();
repoSys_AllSetting.Edit(objConfig);
}
}
else
{
objConfig.ID = Guid.NewGuid();
objConfig.Name = AppConfig.HRM_ATT_OT_OTPERMIT_LIMITHOUR_BYDAY_LEV1.ToString();
objConfig.Value1 = entity.limitHour_ByDay_Lev1.Value.ToString();
repoSys_AllSetting.Add(objConfig);
}
}
if (entity.limitHour_ByDay_Lev2.HasValue)
{
var objConfig = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_OTPERMIT_LIMITHOUR_BYDAY_LEV2.ToString()).FirstOrDefault();
if (objConfig != null)
{
if (objConfig.Value1 != entity.limitHour_ByDay_Lev2.Value.ToString())
{
objConfig.Value1 = entity.limitHour_ByDay_Lev2.Value.ToString();
repoSys_AllSetting.Edit(objConfig);
}
}
else
{
objConfig.ID = Guid.NewGuid();
objConfig.Name = AppConfig.HRM_ATT_OT_OTPERMIT_LIMITHOUR_BYDAY_LEV2.ToString();
objConfig.Value1 = entity.limitHour_ByDay_Lev2.Value.ToString();
repoSys_AllSetting.Add(objConfig);
}
}
if (entity.limitHour_ByWeek.HasValue)
{
var objConfig = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_OTPERMIT_LIMITHOUR_BYWEEK.ToString()).FirstOrDefault();
if (objConfig != null)
{
if (objConfig.Value1 != entity.limitHour_ByWeek.Value.ToString())
{
objConfig.Value1 = entity.limitHour_ByWeek.Value.ToString();
repoSys_AllSetting.Edit(objConfig);
}
}
else
{
objConfig.ID = Guid.NewGuid();
objConfig.Name = AppConfig.HRM_ATT_OT_OTPERMIT_LIMITHOUR_BYWEEK.ToString();
objConfig.Value1 = entity.limitHour_ByWeek.Value.ToString();
repoSys_AllSetting.Add(objConfig);
}
}
if (entity.limitHour_ByWeek_Lev1.HasValue)
{
var objConfig = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_OTPERMIT_LIMITHOUR_BYWEEK_LEV1.ToString()).FirstOrDefault();
if (objConfig != null)
{
if (objConfig.Value1 != entity.limitHour_ByWeek_Lev1.Value.ToString())
//.........这里部分代码省略.........
示例12: SaveChangeHoldSalary
public ResultsObject SaveChangeHoldSalary(List<Sal_HoldSalaryEntity> ListEntity)
{
try
{
using (var context = new VnrHrmDataContext())
{
var unitOfWork = (IUnitOfWork)new UnitOfWork(context);
var repoSal_HoldSalary = new CustomBaseRepository<Sal_HoldSalary>(unitOfWork);
List<Sal_HoldSalary> TotalHoldSalary = repoSal_HoldSalary.FindBy(m => m.IsDelete != true).ToList();
foreach (var i in ListEntity)
{
#region Kiểm tra nhân viên đã có dữ liệu giữ lương hay chưa
Sal_HoldSalary HoldSalaryByProfile = TotalHoldSalary.FirstOrDefault(m => m.ProfileID == i.ProfileID && m.MonthSalary != null && m.MonthSalary.Value.Day == i.MonthSalary.Value.Day && m.TimeAnalyzeID != null && m.TimeAnalyzeID == i.TimeAnalyzeID);
if (HoldSalaryByProfile != null)
{
if (HoldSalaryByProfile.Status == EnumDropDown.HoldSalaryStatus.E_APPROVED.ToString())
{
continue;
}
else
{
HoldSalaryByProfile.AmountSalary = i.AmountSalary;
HoldSalaryByProfile.IsLeaveContinuous = i.IsLeaveContinuous;
HoldSalaryByProfile.IsLeaveM = i.IsLeaveM;
HoldSalaryByProfile.Terminate = i.Terminate;
HoldSalaryByProfile.TimeAnalyzeID = i.TimeAnalyzeID;
}
}
else
{
Sal_HoldSalary HoldSalary = i.Copy<Sal_HoldSalary>();
repoSal_HoldSalary.Add(HoldSalary);
}
#endregion
}
unitOfWork.SaveChanges();
return new ResultsObject();
}
}
catch (Exception ex)
{
return new ResultsObject() { Success = false, Messenger = ex.Message };
}
}
示例13: CreateComputeOvertime
//.........这里部分代码省略.........
List<Att_OvertimeEntity> LimitOTByYear = ValidateLimitOTByYear(lstOvertimeInsert, lisProfileAllowLimitOvertime, overtimePermit);
if (LimitOTByYear.Count > 0)
{
List<Guid> lstProfileID = LimitOTByYear.Select(m => m.ProfileID).Distinct().ToList();
var lstProfile = lstHre.Where(m => lstProfileID.Contains(m.ID)).Select(m => new { m.ID, m.ProfileName, m.CodeEmp });
string lstCodeEmpErr = string.Empty;
foreach (var item in lstProfile)
{
lstCodeEmpErr += item.CodeEmp + "; ";
}
if (lstCodeEmpErr.Length > 0)
{
lstCodeEmpErr = lstCodeEmpErr.Substring(0, lstCodeEmpErr.Length - 2);
}
// errorMessage = string.Format("Nhân viên {0} đã vượt trần", lstCodeEmpErr);
return false;
}
#endregion
List<Att_TimeOffInLieu> lstTimeOffInLieu = new List<Att_TimeOffInLieu>();
string Att_Overtime = "Att_Overtime";
string E_OVERTIME = "E_OVERTIME";
Cat_EntityLabel EntityLabel = repoCat_EntityLabel.FindBy(m => m.UserID == UserId && m.EntityName == Att_Overtime && m.EntityLabelName == E_OVERTIME).FirstOrDefault();
if (EntityLabel == null)
{
EntityLabel = new Cat_EntityLabel();
EntityLabel.ID = Guid.NewGuid();
EntityLabel.UserID = UserId;
EntityLabel.EntityName = Att_Overtime;
EntityLabel.EntityLabelName = E_OVERTIME;
repoCat_EntityLabel.Add(EntityLabel);
repoCat_EntityLabel.SaveChanges();
}
Sys_GroupLabel GroupLable = repoSys_GroupLabel.FindBy(m => m.EntityLabelID == EntityLabel.ID).FirstOrDefault();
if (GroupLable == null)
{
GroupLable = new Sys_GroupLabel();
GroupLable.ID = Guid.NewGuid();
GroupLable.EntityLabelID = EntityLabel.ID;
GroupLable.EntityItems = string.Empty;
repoSys_GroupLabel.Add(GroupLable);
repoSys_GroupLabel.SaveChanges();
}
string EntityItems = GroupLable.EntityItems;
List<Att_Overtime> save = new List<Att_Overtime>();
List<Att_Overtime> saveAdd = new List<Att_Overtime>();
List<Att_Overtime> saveEdit = new List<Att_Overtime>();
Att_Overtime saveModel = null;
foreach (Att_OvertimeEntity Ot in lstOvertimeInsert)
{
bool InsertToTimeOffInlieu = false;
Ot.Status = strOvertimeStatus;//OverTimeStatus.E_APPROVED.ToString();
Ot.udOvertimeStatus = strOvertimeStatus.TranslateString();
if (strOvertimeStatus == OverTimeStatus.E_APPROVED.ToString())
{
Ot.ApproveHours = Ot.RegisterHours;
if (Ot.MethodPayment == EnumDropDown.PaymentType.E_TIMEOFF.ToString() || Ot.MethodPayment == EnumDropDown.PaymentType.E_CASHOUT_TIMEOFF.ToString())
InsertToTimeOffInlieu = true;
}
else if (strOvertimeStatus == OverTimeStatus.E_CONFIRM.ToString())
{
示例14: ComputeBonusUnusualAllowance_Progress
public void ComputeBonusUnusualAllowance_Progress(Guid AsynTaskID, Sal_UnusualAllowanceEntity model, bool AllowanceEvaluationYear = false)
{
using (var context = new VnrHrmDataContext())
{
var unitOfWork = (IUnitOfWork)new UnitOfWork(context);
var repoSys_AsynTask = new CustomBaseRepository<Sys_AsynTask>(unitOfWork);
var repoCat_Element = new CustomBaseRepository<Cat_Element>(unitOfWork);
var repoCat_UnusualAllowanceCfg = new CustomBaseRepository<Cat_UnusualAllowanceCfg>(unitOfWork);
var repoUnusualAllowance = new CustomBaseRepository<Sal_UnusualAllowance>(unitOfWork);
Sys_AsynTask asynTask = repoSys_AsynTask.GetById(AsynTaskID);
Sal_ComputePayrollServices CumputePayrollServices = new Sal_ComputePayrollServices();
List<object> listModel = new List<object>();
string status = string.Empty;
Sal_ComputePayrollServices Services = new Sal_ComputePayrollServices();
List<Sal_UnusualAllowanceEntity> ListResult = new List<Sal_UnusualAllowanceEntity>();
List<ElementFormula> listElementFormula = new List<ElementFormula>();
Sal_UnusualAllowanceServices UnusualAllowanceServices = new Sal_UnusualAllowanceServices();
Att_CutOffDurationEntity CutOffDuration = new Att_CutOffDurationEntity();
if (model.MonthEnd != null)
{
CutOffDuration.MonthYear = model.MonthStart.Value;
CutOffDuration.DateStart = model.MonthStart.Value;
CutOffDuration.DateEnd = model.MonthEnd.Value;
}
else
{
CutOffDuration.MonthYear = new DateTime(model.MonthStart.Value.Year, model.MonthStart.Value.Month, 1);
CutOffDuration.DateStart = new DateTime(model.MonthStart.Value.Year, model.MonthStart.Value.Month, 1);
CutOffDuration.DateEnd = new DateTime(model.MonthStart.Value.Year, model.MonthStart.Value.Month, 1).AddMonths(1).AddDays(-1);
}
List<Hre_ProfileEntity> ListProfile = new List<Hre_ProfileEntity>();
if (model.OrgStructureIDs != null && model.OrgStructureIDs != string.Empty)
{
listModel = new List<object>();
listModel.AddRange(new object[18]);
listModel[2] = model.OrgStructureIDs;
listModel[16] = 1;
listModel[17] = Int32.MaxValue - 1;
ListProfile = GetData<Hre_ProfileEntity>(listModel, ConstantSql.hrm_hr_sp_get_Profile, ref status);
if (model.ExProfileIDs != null)
{
string[] ExProfile = model.ExProfileIDs.Split(',');
ListProfile = ListProfile.Where(m => ExProfile.Contains(m.ID.ToString())).ToList();
}
}
else if (model.ProfileIDs != null && model.ProfileIDs != string.Empty)
{
ListProfile = GetData<Hre_ProfileEntity>(Common.DotNetToOracle(model.ProfileIDs), ConstantSql.hrm_hr_sp_get_ProfileByIds, ref status);
}
//lọc profile theo workplace
if (model.WorkingPlaceID != null)
{
string[] listWorkPlare = model.WorkingPlaceID.Split(',');
ListProfile = ListProfile.Where(m => listWorkPlare.Contains(m.WorkPlaceID.ToString())).ToList();
}
List<Cat_UnusualAllowanceCfg> listUnusualAllowanceCfg = new List<Cat_UnusualAllowanceCfg>();
listUnusualAllowanceCfg = repoCat_UnusualAllowanceCfg.FindBy(m => m.IsDelete != true).ToList();
#region Delete các phụ cấp trong năm đã có
List<Sal_UnusualAllowance> listUnusualAllowance = repoUnusualAllowance.FindBy(m => m.IsDelete != true && m.MonthStart != null && model.MonthStart != null && m.MonthStart.Value.Year == model.MonthStart.Value.Year && m.Status != WorkHistoryStatus.E_APPROVED.ToString()).ToList();
//nếu là tính phép năm sức khỏe tốt thì delete thêm loại GoodHealth
if (AllowanceEvaluationYear)
{
var _tmp = listUnusualAllowanceCfg.FirstOrDefault(m => m.Code == "GoodHealth");
listUnusualAllowance = listUnusualAllowance.Where(m => (m.UnusualEDTypeID == model.UnusualEDTypeID || m.UnusualEDTypeID == _tmp.ID) && ListProfile.Any(t => t.ID == m.ProfileID)).ToList();
}
else
{
listUnusualAllowance = listUnusualAllowance.Where(m => m.UnusualEDTypeID == model.UnusualEDTypeID && ListProfile.Any(t => t.ID == m.ProfileID)).ToList();
}
//update isdelete is true
listUnusualAllowance.ForEach(m => m.IsDelete = true);
#endregion
//Cat_ElementEntity ElementItem = repoCat_Element.GetById((Guid)model.Element).Copy<Cat_ElementEntity>();
Cat_ElementEntity ElementItem = repoCat_Element.FindBy(m => m.ID == (Guid)model.Element).FirstOrDefault().Copy<Cat_ElementEntity>();
ComputePayrollDataModel TotalData = Services.GetDataForComputeSalary(CutOffDuration);
List<Cat_ElementEntity> listElementAll = new List<Cat_ElementEntity>();
listElementAll = TotalData.listElement_All;
#region Xử lý cho tính phép năm, sức khỏe tốt
List<Cat_UnusualAllowanceCfg> ListUnusualAllowanceCfg = new List<Cat_UnusualAllowanceCfg>();
Cat_UnusualAllowanceCfg PaidLeave = null;
Cat_UnusualAllowanceCfg GoodHealth = null;
ElementFormula FormulaValue = new ElementFormula();
if (AllowanceEvaluationYear)
{
ListUnusualAllowanceCfg = repoCat_UnusualAllowanceCfg.FindBy(m => m.IsDelete != true).ToList();
//.........这里部分代码省略.........
示例15: ComputeAnnualSickLeaveDetail
/// <summary>
/// Button Tính Phép Bệnh
/// </summary>
/// <param name="Year"></param>
/// <param name="orgStructure"></param>
/// <param name="LstProfileStatus"></param>
/// <returns></returns>
public bool ComputeAnnualSickLeaveDetail(int Year, string orgStructure, string LstProfileStatus, string UserLogin)
{
var result = false;
using (var context = new VnrHrmDataContext())
{
string status = string.Empty;
var unitOfWork = (IUnitOfWork)new UnitOfWork(context);
var repoAtt_AnnualLeaveDetail = new CustomBaseRepository<Att_AnnualLeaveDetail>(unitOfWork);
var repoHre_Profile = new CustomBaseRepository<Hre_Profile>(unitOfWork);
var repoHre_HDTJob = new CustomBaseRepository<Hre_HDTJob>(unitOfWork);
var repoCat_DayOff = new CustomBaseRepository<Cat_DayOff>(unitOfWork);
var repoCat_LeaveDayType = new CustomBaseRepository<Cat_LeaveDayType>(unitOfWork);
var repoAtt_LeaveDay = new CustomBaseRepository<Att_LeaveDay>(unitOfWork);
var repoCat_JobTitle = new CustomBaseRepository<Cat_JobTitle>(unitOfWork);
#region FilterInfo
string E_SICK_LEAVE = AnnualLeaveDetailType.E_SICK_LEAVE.ToString();
Att_AnnualLeaveDetail AnnualLeaveDetailTop = repoAtt_AnnualLeaveDetail
.FindBy(m => m.IsDelete == null && m.Type == E_SICK_LEAVE && m.Year == Year).FirstOrDefault();
DateTime beginyear = (AnnualLeaveDetailTop == null || AnnualLeaveDetailTop.MonthStart == null) ? new DateTime(Year, 1, 1) : AnnualLeaveDetailTop.MonthStart.Value;
DateTime endYear = beginyear.AddYears(1).AddMinutes(-1);
List<object> lstObj = new List<object>();
lstObj.Add(orgStructure);
lstObj.Add(null);
lstObj.Add(null);
var lstProfileQuery = GetData<Hre_ProfileEntity>(lstObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, UserLogin, ref status).ToList();
if (LstProfileStatus != null)
{
if (LstProfileStatus == StatusEmpLeaveDetail.E_NEWEMPINYEAR.ToString())
{
lstProfileQuery = lstProfileQuery.Where(m => m.DateHire != null && m.DateHire >= beginyear && m.DateHire <= endYear).ToList();
}
if (LstProfileStatus == StatusEmpLeaveDetail.E_RESIGNEMPINYEAR.ToString())
{
lstProfileQuery = lstProfileQuery.Where(m => m.DateQuit != null && m.DateQuit >= beginyear && m.DateQuit <= endYear).ToList();
}
if (LstProfileStatus == StatusEmpLeaveDetail.E_EMPOFHDT4.ToString())
{
string Job4 = HDTJobType.E_Four.ToString();
List<Guid> lstprofileHDT4 = repoHre_HDTJob
.FindBy(m => m.IsDelete == null && m.Type == Job4 && m.DateFrom <= endYear && m.DateTo >= beginyear && m.ProfileID != null)
.Select(m => m.ProfileID.Value).ToList<Guid>();
lstProfileQuery = lstProfileQuery.Where(m => lstprofileHDT4.Contains(m.ID)).ToList();
}
if (LstProfileStatus == StatusEmpLeaveDetail.E_EMPOFHDT5.ToString())
{
string Job5 = HDTJobType.E_Five.ToString();
List<Guid> lstprofileHDT5 = repoHre_HDTJob
.FindBy(m => m.IsDelete == null && m.Type == Job5 && m.DateFrom <= endYear && m.DateTo >= beginyear && m.ProfileID != null)
.Select(m => m.ProfileID.Value).ToList<Guid>();
lstProfileQuery = lstProfileQuery.Where(m => lstprofileHDT5.Contains(m.ID)).ToList();
}
}
List<Guid> lstProfileID = lstProfileQuery.Select(m => m.ID).Distinct().ToList<Guid>();
#endregion
#region get Data
//string E_STANDARD_WORKDAY = AppConfig.E_STANDARD_WORKDAY.ToString();
//Sys_AppConfig appconfig = EntityService.CreateQueryable<Sys_AppConfig>(false, GuidContext, Guid.Empty, m => m.Info == E_STANDARD_WORKDAY).FirstOrDefault();
//if (appconfig == null || string.IsNullOrEmpty(appconfig.Value76) || string.IsNullOrEmpty(appconfig.Value77))
//{
// Common.MessageBoxs(Messages.Msg, Messages.PleaseConfigSickLeaveAtTotalConfig, MessageBox.Icon.WARNING, string.Empty);
// return;
//}
string HRM_ATT_ANNUALSICKLEAVE_ = AppConfig.HRM_ATT_ANNUALSICKLEAVE_.ToString();
List<object> lstO = new List<object>();
lstO.Add(HRM_ATT_ANNUALSICKLEAVE_);
lstO.Add(null);
lstO.Add(null);
var config = GetData<Sys_AllSettingEntity>(lstO, ConstantSql.hrm_sys_sp_get_AllSetting, UserLogin, ref status);
var formular1 = config.Where(s => s.Name == AppConfig.HRM_ATT_ANNUALSICKLEAVE_FORMULARCONFIG.ToString()).FirstOrDefault();
var formular2 = config.Where(s => s.Name == AppConfig.HRM_ATT_ANNUALSICKLEAVE_FORMULARCOMPUTE.ToString()).FirstOrDefault();
if (config == null || string.IsNullOrEmpty(formular1.Value1) || string.IsNullOrEmpty(formular2.Value1))
{
//Common.MessageBoxs(Messages.Msg, Messages.PleaseConfigAnnualLeaveAtTotalConfig, MessageBox.Icon.WARNING, string.Empty);
return result;
}
string formularConfig = formular1.Value1;
string formularCompute = formular2.Value1;
ParamGetConfigANL configAnl = new ParamGetConfigANL();
(new Att_AttendanceServices()).GetConfigANL(formularConfig, out configAnl);
int MonthBegin = 1;
//.........这里部分代码省略.........