本文整理汇总了C#中CustomBaseRepository.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# CustomBaseRepository.SaveChanges方法的具体用法?C# CustomBaseRepository.SaveChanges怎么用?C# CustomBaseRepository.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CustomBaseRepository
的用法示例。
在下文中一共展示了CustomBaseRepository.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ActionApproved
public void ActionApproved(List<Guid> lstId, string status, Guid userId)
{
var statusMes = string.Empty;
var objTravelRequest = new List<object>();
string UserLogin = string.Empty;
using (var context = new VnrHrmDataContext())
{
var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
var repoTravelRequestItem = new CustomBaseRepository<FIN_ClaimItem>(unitOfWork);
var lstTravelRequestItem = repoTravelRequestItem.GetAll().Where(s => s.IsDelete == null).ToList();
if(status == "E_APPROVED")
{
var objApprovedClaim = new List<object>();
objApprovedClaim.AddRange(new object[6]);
objApprovedClaim[4] = 1;
objApprovedClaim[5] = int.MaxValue - 1;
var lstApprovedClaim = GetData<FIN_ApproverECLAIMEntity>(objApprovedClaim, ConstantSql.hrm_fin_sp_get_ApproverECLAIM, UserLogin, ref statusMes).ToList();
var approvedType1 = FinApproverType.FIN_Claim_Profile.ToString();
var approvedType2 = FinApproverType.FIN_Claim_Manufacture.ToString();
var approvedEntity = lstApprovedClaim.Where(s => s.ApprovedID != null && s.ApprovedID.Value == userId && (s.ApprovedType == approvedType1 || s.ApprovedType == approvedType2)).FirstOrDefault();
if (lstId.Count > 0)
{
if (approvedEntity != null)
{
lstTravelRequestItem = lstTravelRequestItem.Where(s => lstId.Contains(s.ID)).ToList();
foreach (var item in lstTravelRequestItem)
{
item.Description2 = status;
}
repoTravelRequestItem.SaveChanges();
}
}
}
if(status == "E_REJECTED")
{
if (lstId.Count > 0)
{
lstTravelRequestItem = lstTravelRequestItem.Where(s => lstId.Contains(s.ID)).ToList();
foreach (var item in lstTravelRequestItem)
{
item.Description2 = status;
}
repoTravelRequestItem.SaveChanges();
}
}
}
}
示例2: 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";
}
}
}
示例3: 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();
}
}
示例4: SaveConfig
/// <summary>
/// Lấy tất cả các bản ghi
/// Get by key
/// </summary>
/// <returns></returns>
public void SaveConfig(List<Dictionary<string,string>> lstModel)
{
using (var context = new VnrHrmDataContext())
{
IUnitOfWork unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
var repo = new CustomBaseRepository<Sys_AllSetting>(unitOfWork);
string status = string.Empty;
List<Dictionary<Guid, string>> lstUpdate = new List<Dictionary<Guid, string>>();
var valueTemp = new Sys_AllSetting();
var modelTemp = new Sys_AllSetting();
List<Guid> lstConfigIds = new List<Guid>();
List<Sys_AllSetting> lstAdd = new List<Sys_AllSetting>();
List<Sys_AllSetting> lstEdit = new List<Sys_AllSetting>();
List<Sys_AllSetting> lstDel = new List<Sys_AllSetting>();
var getdata = repo.FindBy(s => s.IsDelete == null).ToList();
if (lstModel[0].FirstOrDefault().Value.Length > 0)
{
var lstStr = lstModel.FirstOrDefault()["lstConfigIds"].Split(',');
lstConfigIds = lstStr.Select(Guid.Parse).ToList();
}
foreach (var item in lstConfigIds)
{
modelTemp = GetById<Sys_AllSetting>(item, ref status);
lstUpdate.Add(new Dictionary<Guid, string>() { { modelTemp.ID, modelTemp.Name } });
}
for (int i = 1; i < lstModel.Count; i++)
{
var lstEntity = getdata.Where(s => s.Name == lstModel[i].FirstOrDefault().Key).ToList();
if (lstEntity.Count == 0)
{
valueTemp = new Sys_AllSetting();
valueTemp.ID = Guid.NewGuid();
valueTemp.Name = lstModel[i].FirstOrDefault().Key;
valueTemp.Value1 = lstModel[i].FirstOrDefault().Value;
lstAdd.Add(valueTemp);
continue;
}
if (lstEntity.Count > 0)
{
valueTemp = new Sys_AllSetting();
foreach (var item in lstEntity)
{
item.IsDelete = true;
lstDel.Add(item);
//repo.Edit(item);
}
var isUpdate = lstUpdate.Where(s => s.FirstOrDefault().Value == lstModel[i].FirstOrDefault().Key).FirstOrDefault();
if (isUpdate != null)
{
valueTemp.ID = lstEntity.FirstOrDefault().ID;
valueTemp.Name = lstModel[i].FirstOrDefault().Key;
valueTemp.Value1 = lstModel[i].FirstOrDefault().Value;
valueTemp.IsDelete = null;
lstEdit.Add(valueTemp);
}
else
{
valueTemp.ID = Guid.NewGuid();
valueTemp.Name = lstModel[i].FirstOrDefault().Key;
valueTemp.Value1 = lstModel[i].FirstOrDefault().Value;
lstAdd.Add(valueTemp);
}
}
}
repo.Edit(lstDel);
repo.Add(lstAdd);
repo.Edit(lstEdit);
repo.SaveChanges();
}
}
示例5: ComputeAnnualSickLeaveDetail
//.........这里部分代码省略.........
lstCodeLeaveTypeNonAnl = configAnl.lstCodeLeaveNonANL;
}
DateTime BeginYear = new DateTime(Year, MonthBegin, 1);
DateTime EndYear = BeginYear.AddYears(1).AddMinutes(-1);
string E_APPROVED = LeaveDayStatus.E_APPROVED.ToString();
List<DateTime> lstDayOff = repoCat_DayOff
.FindBy(m => m.IsDelete == null && m.DateOff > BeginYear && m.DateOff <= EndYear)
.Select(m => m.DateOff).Distinct().ToList<DateTime>();
List<Hre_ProfileEntity> lstprofile = lstProfileQuery
.Where(m => m.DateQuit == null || (m.DateQuit != null && m.DateQuit > BeginYear))
.ToList<Hre_ProfileEntity>();
List<Guid> lstLeavedayTypeNonAnl = repoCat_LeaveDayType
.FindBy(m => m.IsDelete == null && lstCodeLeaveTypeNonAnl.Contains(m.Code)).Select(m => m.ID).ToList<Guid>();
List<Att_LeaveDay> lstleavedayNonANl = repoAtt_LeaveDay
.FindBy(m => m.IsDelete == null && m.Status == E_APPROVED && lstLeavedayTypeNonAnl.Contains(m.LeaveDayTypeID)
&& lstProfileID.Contains(m.ProfileID)).ToList<Att_LeaveDay>();
List<Att_LeaveDay> lstleavedayNonANlInYear = lstleavedayNonANl.Where(m => m.DateStart <= EndYear && m.DateEnd >= BeginYear).ToList<Att_LeaveDay>();
List<Hre_HDTJob> lstHDTJob = repoHre_HDTJob
.FindBy(m => m.IsDelete == null && m.ProfileID != null && lstProfileID.Contains(m.ProfileID.Value)).ToList<Hre_HDTJob>();
List<Cat_JobTitle> lstJobtitle = repoCat_JobTitle.FindBy(s => s.IsDelete == null).ToList();
#endregion
List<Att_AnnualLeaveDetail> lstAnnualDetail = new List<Att_AnnualLeaveDetail>();
foreach (var item in lstprofile)
{
List<Att_LeaveDay> lstLeavedayNonAnlByProfile = lstleavedayNonANl.Where(m => m.ProfileID == item.ID).ToList();
List<Att_LeaveDay> lstLeavedayNonAnlByProfileInYear = lstleavedayNonANlInYear.Where(m => m.ProfileID == item.ID).ToList();
List<Hre_HDTJob> lstHDTJobByProfile = lstHDTJob.Where(m => m.ProfileID == item.ID).ToList();
double AvailabelInYear = (new Att_AttendanceServices()).GetAnnualLeaveAvailableAllYear(Year, null, item.DateHire,
item.DateEndProbation, item.DateQuit, formularConfig,
formularCompute, lstLeavedayNonAnlByProfileInYear, lstJobtitle, lstDayOff, lstHDTJobByProfile, lstLeavedayNonAnlByProfile);
Att_AnnualLeaveDetail annualProfile = new Att_AnnualLeaveDetail();
annualProfile.ID = Guid.NewGuid();
annualProfile.ProfileID = item.ID;
annualProfile.MonthStart = BeginYear;
annualProfile.MonthEnd = EndYear;
annualProfile.Year = Year;
annualProfile.Type = E_SICK_LEAVE;
annualProfile.Month1 = AvailabelInYear;
annualProfile.Month2 = AvailabelInYear;
annualProfile.Month3 = AvailabelInYear;
annualProfile.Month4 = AvailabelInYear;
annualProfile.Month5 = AvailabelInYear;
annualProfile.Month6 = AvailabelInYear;
annualProfile.Month7 = AvailabelInYear;
annualProfile.Month8 = AvailabelInYear;
annualProfile.Month9 = AvailabelInYear;
annualProfile.Month10 = AvailabelInYear;
annualProfile.Month11 = AvailabelInYear;
annualProfile.Month12 = AvailabelInYear;
lstAnnualDetail.Add(annualProfile);
}
DataErrorCode DataErr = DataErrorCode.Unknown;
if (lstAnnualDetail.Count > 0)
{
#region lấy dữ liệu dưới DB xóa đi
List<Guid> lstProfileID_InDB = lstAnnualDetail.Where(m => m.ProfileID != null).Select(m => m.ProfileID.Value).ToList();
List<Att_AnnualLeaveDetail> lstAnnualLeaveDetail_InDB = repoAtt_AnnualLeaveDetail
.FindBy(m => m.IsDelete == null && m.Year == Year && m.Type == E_SICK_LEAVE && m.ProfileID != null && lstProfileID_InDB.Contains(m.ProfileID.Value)).ToList<Att_AnnualLeaveDetail>();
foreach (var item in lstAnnualLeaveDetail_InDB)
{
item.IsDelete = true;
}
#endregion
repoAtt_AnnualLeaveDetail.Add(lstAnnualDetail);
try
{
repoAtt_AnnualLeaveDetail.SaveChanges();
}
catch (Exception)
{
return false;
}
//EntityService.AddEntity<Att_AnnualLeaveDetail>(GuidContext, lstAnnualDetail.ToArray());
//DataErr = EntityService.SubmitChanges(GuidContext, LoginUserID);
//if (DataErr == DataErrorCode.Success)
//{
// Common.MessageBoxs(Messages.Msg, Messages.SaveSuccess, MessageBox.Icon.INFO, string.Empty);
//}
//else
//{
// Common.MessageBoxs(Messages.Msg, Messages.SaveUnSuccess, MessageBox.Icon.INFO, string.Empty);
//}
}
//else
//{
// Common.MessageBoxs(Messages.Msg, Messages.NoDataToCompute, MessageBox.Icon.WARNING, string.Empty);
//}
result = true;
}
return result;
}
示例6: ActionSubmit
public void ActionSubmit(List<Guid> lstId, string status, Guid userId)
{
var statusMes = string.Empty;
var objTravelRequest = new List<object>();
var UserLogin = string.Empty;
using (var context = new VnrHrmDataContext())
{
var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
var repoTravelRequestItem = new CustomBaseRepository<Fin_CashAdvanceItem>(unitOfWork);
var lstTravelRequestItem = repoTravelRequestItem.GetAll().Where(s => s.IsDelete == null).ToList();
var cashAdvanceID = lstTravelRequestItem.Where(s => s.CashAdvanceID != null && lstId.Contains(s.ID)).Select(s => s.CashAdvanceID).Distinct().FirstOrDefault();
var userEntity = GetData<Sys_UserInfoEntity>(userId, ConstantSql.hrm_sys_sp_get_UserbyId, UserLogin, ref statusMes).FirstOrDefault();
var cashAdvanceEntity = new Fin_CashAdvanceEntity();
if (cashAdvanceID != null)
{
cashAdvanceEntity = GetData<Fin_CashAdvanceEntity>(cashAdvanceID.Value, ConstantSql.hrm_hr_sp_get_CashAdvanceById, UserLogin, ref statusMes).FirstOrDefault();
}
if (lstId.Count > 0)
{
if (userEntity != null && cashAdvanceEntity != null)
{
if (userEntity.ProfileID.Value == cashAdvanceEntity.ProfileID.Value)
{
lstTravelRequestItem = lstTravelRequestItem.Where(s => lstId.Contains(s.ID)).ToList();
foreach (var item in lstTravelRequestItem)
{
item.Status = status;
}
repoTravelRequestItem.SaveChanges();
}
}
}
}
}
示例7: ProcessReject
/// <summary>
/// [Hieu.Van]
/// Xử lý Từ Chối
/// </summary>
/// <param name="LoginID"></param>
/// <param name="userApprovedID"></param>
/// <param name="recordID"></param>
/// <param name="type"></param>
/// <returns></returns>
public string ProcessReject(string host, Guid LoginID, Guid recordID, string type)
{
DataErrorCode status = DataErrorCode.Success;
using (var context = new VnrHrmDataContext())
{
var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
var repoFIN_PurchaseRequest = new CustomBaseRepository<FIN_PurchaseRequest>(unitOfWork);
var repoSys_UserApprove = new CustomBaseRepository<Sys_UserApprove>(unitOfWork);
var repoSys_UserInfo = new CustomBaseRepository<Sys_UserInfo>(unitOfWork);
var record = repoFIN_PurchaseRequest.FindBy(s => s.ID == recordID).FirstOrDefault();
if (record.Status == EnumDropDown.Status.E_REJECTED.ToString())
{
return DataErrorCode.Error_Reject.ToString();
}
var userApproved = repoSys_UserApprove.FindBy(s => s.ID == record.UserApproveID).FirstOrDefault();
// Kiểm tra tài khoản login có được phép Duyệt hay ko?
if (LoginID == Guid.Empty || userApproved.UserApproveID != LoginID)
{
// kiểm tra nếu bản ghi có tk duyệt trống (tức bản ghi mới tạo) và tk login = tk tạo thì cho duyệt tiếp tục
if (record.UserApproveID == null && record.UserCreateID == LoginID)
{
}
else
{
return DataErrorCode.NoPermission.ToString();
}
}
record.Status = EnumDropDown.Status.E_REJECTED.ToString();
repoFIN_PurchaseRequest.Edit(record);
status = repoFIN_PurchaseRequest.SaveChanges();
return status.ToString();
}
}
示例8: 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;
}
}
}
示例9: Set_ApproveLeaveDay_ByModuleApprove
public string Set_ApproveLeaveDay_ByModuleApprove(string host, List<Guid> lstLeaveDay, Guid UserLoginID, string userLogin)
{
using (var context = new VnrHrmDataContext())
{
string status = string.Empty;
string statusSendMail = DataErrorCode.Error.ToString();
var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
BaseService service = new BaseService();
var repoAtt_LeaveDay = new CustomBaseRepository<Att_LeaveDay>(unitOfWork);
#region getdata
List<object> lstParamUser = new List<object>();
lstParamUser.AddRange(new object[4]);
lstParamUser[3] = Int32.MaxValue;
var lstUserAll = service.GetData<Sys_UserInfo>(lstParamUser, ConstantSql.hrm_sys_sp_get_users, userLogin, ref status);
var lstUser = lstUserAll.Where(m => !string.IsNullOrEmpty(m.Email)).Select(m => new { m.ID, m.Email }).ToList();
//Step1 : Check 1 Approve or 2 approve
DateTime today = DateTime.Today;
string E_LEAVEDAY = DelegateApproveType.E_LEAVE_DAY.ToString();
List<object> lstParam = new List<object>();
lstParam.AddRange(new object[10]);
var lstDelegateApproveAll = service.GetData<Sys_DelegateApprove>(lstParam, ConstantSql.hrm_sys_sp_get_DelegateApprove, userLogin, ref status);
var lstDelegateApprove = lstDelegateApproveAll.Where(m => m.UserID != null
&& m.UserDelegateID != null
&& m.DataTypeDelegate == E_LEAVEDAY
&& m.DateFrom <= today
&& m.DateTo >= today).ToList();
List<Guid> lstUserCanView = lstDelegateApprove.Where(m => m.UserDelegateID == UserLoginID).Select(m => m.UserID.Value).ToList();
lstUserCanView.Add(UserLoginID);
#endregion
#region process
string E_APPROVED = LeaveDayStatus.E_APPROVED.ToString();
string E_FIRST_APPROVED = LeaveDayStatus.E_FIRST_APPROVED.ToString();
List<Att_LeaveDay> lstLeaveDaySendMail = new List<Att_LeaveDay>();
foreach (var leaID in lstLeaveDay)
{
var LeaveDay = repoAtt_LeaveDay.GetById(leaID);
lstLeaveDaySendMail.Add(LeaveDay);
if (LeaveDay.UserApproveID2 != null && lstUserCanView.Contains(LeaveDay.UserApproveID2.Value))
{
LeaveDay.Status = E_APPROVED;
}
if (LeaveDay.UserApproveID != null && lstUserCanView.Contains(LeaveDay.UserApproveID.Value))
{
LeaveDay.Status = E_FIRST_APPROVED;
}
}
var stt = repoAtt_LeaveDay.SaveChanges();
#endregion
if (stt == DataErrorCode.Success)
{
#region getdata
List<Hre_ProfileEntity> lstProfile = new List<Hre_ProfileEntity>();
List<Sys_TemplateSendMail> template = new List<Sys_TemplateSendMail>();
Sys_TemplateSendMail tempApprove = new Sys_TemplateSendMail();
Sys_TemplateSendMail tempReturn = new Sys_TemplateSendMail();
List<Cat_LeaveDayType> lstLeaveDayType = new List<Cat_LeaveDayType>();
string[] strsParaKey = null;
string bodyContent = null;
string titleMail = null;
string[] strsParaValues = null;
string[] strsParaValues_Return = null;
string _typeTemplate = EnumDropDown.EmailType.E_APPROVED_LEAVEDAY.ToString();
string _typeTemplate_return = EnumDropDown.EmailType.E_APPROVED_LEAVEDAY_RETURN.ToString();
var repoSys_TemplateSendMail = new CustomBaseRepository<Sys_TemplateSendMail>(unitOfWork);
template = repoSys_TemplateSendMail.FindBy(s => s.Type == _typeTemplate || s.Type == _typeTemplate_return).ToList();
if (template.Count < 2)
return DataErrorCode.Error_NoTemplateMail.ToString();
var repoCat_LeaveDayType = new CustomBaseRepository<Cat_LeaveDayType>(unitOfWork);
lstLeaveDayType = repoCat_LeaveDayType.FindBy(s => s.IsDelete == null).ToList();
tempApprove = template.Where(s => s.Type == _typeTemplate).FirstOrDefault();
tempReturn = template.Where(s => s.Type == _typeTemplate_return).FirstOrDefault();
string proIDS = string.Join(",", lstLeaveDaySendMail.Select(s => s.ProfileID.ToString()).Distinct().ToList());
proIDS = Common.DotNetToOracle(proIDS);
lstProfile = GetData<Hre_ProfileEntity>(proIDS, ConstantSql.hrm_hr_sp_get_ProfileByIds, userLogin, ref status);
strsParaKey = new string[]
{
EnumDropDown.EmailType_APPROVED_LEAVEDAY.E_UserName.ToString(),
EnumDropDown.EmailType_APPROVED_LEAVEDAY.E_ProfileName.ToString(),
EnumDropDown.EmailType_APPROVED_LEAVEDAY.E_CodeEmp.ToString(),
EnumDropDown.EmailType_APPROVED_LEAVEDAY.E_DateStart.ToString(),
EnumDropDown.EmailType_APPROVED_LEAVEDAY.E_DateEnd.ToString(),
EnumDropDown.EmailType_APPROVED_LEAVEDAY.E_Status.ToString(),
//.........这里部分代码省略.........
示例10: ValidateSaveWorkday
//.........这里部分代码省略.........
WorkdaySave.LateEarlyReason = LateEarlyReason;
}
//Cat_TAMScanReasonMiss TAMScanReasonMiss = EntityService.CreateQueryable<Cat_TAMScanReasonMiss>(false, GuidContext, Guid.Empty, m => m.TAMScanReasonMissName == MissInOutReason).FirstOrDefault();
Cat_TAMScanReasonMiss TAMScanReasonMiss = repoCat_TAMScanReasonMiss.FindBy(m => m.IsDelete == null && m.ID == MissInOutReason).FirstOrDefault();
if (TAMScanReasonMiss != null)
{
if (WorkdayOld.MissInOutReason == Guid.Empty || WorkdayOld.MissInOutReason != TAMScanReasonMiss.ID)
{
Notes += "MissInOutReason:" + TAMScanReasonMiss.TAMScanReasonMissName;
}
WorkdaySave.TAMScanReasonMissName = TAMScanReasonMiss.TAMScanReasonMissName;
}
else
{
Notes += "MissInOutReason:" + "NULL";
WorkdaySave.MissInOutReason = null;
}
#endregion
#region Đăng Ký Nghỉ LeaveDay
string LeavedayCode = string.Empty;
if (WorkdaySave.udLeavedayCode1 != null && WorkdayOld.udLeavedayCode1 != WorkdaySave.udLeavedayCode1)
{
LeavedayCode = WorkdaySave.udLeavedayCode1;
if (LeavedayCode == "CO")
{
message = ConstantMessages.CantRegisterCO.TranslateString();
return message;
//Common.MessageBoxs(Messages.Msg, LanguageManager.GetString(Messages.CantRegisterCO), MessageBox.Icon.WARNING, string.Empty);
//return new { valid = true };
}
}
if (WorkdayOld != null && (!string.IsNullOrEmpty(WorkdayOld.udLeavedayCode1) || !string.IsNullOrEmpty(WorkdayOld.udLeavedayCode2)))
{
if (!string.IsNullOrEmpty(WorkdayOld.udLeavedayStatus1) && WorkdayOld.udLeavedayStatus1 == LeaveDayStatus.E_APPROVED.ToString())
{
message = ConstantMessages.StatusApproveCannotEdit.TranslateString();
return message;
//Common.MessageBoxs(Messages.Msg, LanguageManager.GetString(Messages.DataCantBeModify), MessageBox.Icon.WARNING, string.Empty);
//return new { valid = true };
}
}
#endregion
string TypeOld = WorkdaySave.Type;
//if (isChangeTamScan)
//{
// WorkdaySave.udIsManualFromTamScan = true;
//}
List<Att_WorkdayEntity> lstWorkdaySave = new List<Att_WorkdayEntity>() { WorkdaySave };
List<Att_Workday> lstWorkdayNew = ComputeWorkday(lstWorkdaySave.Translate<Att_Workday>(), ShiftAll, isChangeTamScan, UserLogin);
WorkdaySave.Type = TypeOld;
if (lstWorkdayNew.Count > 0)
{
Att_Workday workdayNew = lstWorkdayNew.FirstOrDefault();
if (workdayNew != null)
{
if (LeavedayCode != "")
{
string ErrLeave = SaveLeaveDay(workdayNew, LeavedayCode, UserLogin);
if (ErrLeave != string.Empty)
{
return ErrLeave;
//Common.MessageBoxs(Messages.Msg, ErrLeave, MessageBox.Icon.WARNING, string.Empty);
//return new { valid = true };
}
}
workdayNew.Type = TypeOld;
if (IsChangeLateEarly)
workdayNew.LateEarlyDuration = MinuteLateEarly;
//if (Notes != string.Empty)
//{
// Notes = "(" + UserLogin + "-" + string.Format("{0:dd/MM/yyyy hh:mm:ss}", DateTime.Now) + "-[" + Notes + "])";
//}
string NoteValidated = workdayNew.Note + Notes;
if (NoteValidated.Length > 2000)
{
NoteValidated = NoteValidated.Substring(NoteValidated.Length - 2000, 2000);
}
if (Notes != string.Empty)
{
workdayNew.SrcType = WorkdaySrcType.E_MANUAL.ToString();
}
workdayNew.Note = NoteValidated;
if (workdayNew.Type == string.Empty)
{
workdayNew.Type = WorkdayType.E_NORMAL.ToString();
}
DateTime DateNew = workdayNew.WorkDate;
Guid ProfileID = workdayNew.ProfileID;
}
}
repoAtt_Workday.Edit(lstWorkdayNew);
//EntityService.AddEntity<Att_Workday>(GuidContext, lstWorkdayNew.ToArray());
//EntityService.SubmitChanges(GuidContext, LoginUserID);
repoAtt_Workday.SaveChanges();
//unitOfWork.SaveChanges();
return message;
}
}
示例11: SaveLeaveDay
//.........这里部分代码省略.........
lstO.Add(null);
Sys_AllSetting config = GetData<Sys_AllSetting>(lstO, ConstantSql.hrm_sys_sp_get_AllSetting, UserLogin, ref status).FirstOrDefault();
//Sys_AppConfig config = EntityService.GetEntity<Sys_AppConfig>(false, GuidContext, Guid.Empty, m => m.Info == E_STANDARD_WORKDAY);
string validateEmpProbation = leavedayServices.ValidateLeaveTypeByNewEmployee(config, lstLeaveDayInsert);
if (validateEmpProbation != string.Empty)
{
return validateEmpProbation;
}
#endregion
#region triet.mai cap nhat leaveDays va leaveHours
lstLeaveDayInsert.AddRange(lstLeaveDayInDbUpdate);
if (lstLeaveDayInsert.Count > 0)
{
List<Cat_LeaveDayType> lstLeaveDayType = repoCat_LeaveDayType.FindBy(m => m.IsDelete == null).ToList<Cat_LeaveDayType>();
//List<Cat_LeaveDayType> lstLeaveDayType = EntityService.CreateQueryable<Cat_LeaveDayType>(false, GuidContext, Guid.Empty).ToList<Cat_LeaveDayType>();
List<Guid> lstProfileID1 = lstLeaveDayInsert.Select(m => m.ProfileID).Distinct().ToList<Guid>();
List<Hre_Profile> lstProfile = repoHre_Profile.FindBy(m => lstProfileID1.Contains(m.ID)).ToList<Hre_Profile>();
//List<Hre_Profile> lstProfile = EntityService.CreateQueryable<Hre_Profile>(false, GuidContext, Guid.Empty, m => lstProfileID1.Contains(m.ID)).ToList<Hre_Profile>();
DateTime dateMin1 = lstLeaveDayInsert.Min(m => m.DateStart).Date;
DateTime dateMax1 = lstLeaveDayInsert.Max(m => m.DateEnd);
List<Att_Roster> lstRosterTypeGroup = new List<Att_Roster>();
List<Att_RosterGroup> lstRosterGroup = new List<Att_RosterGroup>();
var lstGrade = repoAtt_Grade.FindBy(m => lstProfileID1.Contains(m.ProfileID.Value))
.Select(m => new { m.ID, m.ProfileID, m.MonthStart, m.GradeAttendanceID })
.OrderByDescending(m => m.MonthStart).ToList();
//var lstGrade = EntityService.CreateQueryable<Sal_Grade>(false, GuidContext, Guid.Empty, m => lstProfileID1.Contains(m.ProfileID))
// .Select(m => new { m.ID, m.ProfileID, m.MonthStart, m.GradeID })
// .OrderByDescending(m => m.MonthStart)
// .Execute();
List<Cat_GradeAttendance> lstGradeAttendance = repoCat_GradeAttendance.FindBy(m => m.IsDelete == null).ToList();
//List<Cat_GradeCfg> lstGradeCfg = EntityService.CreateQueryable<Cat_GradeCfg>(false, GuidContext, Guid.Empty).ToList<Cat_GradeCfg>();
List<Hre_WorkHistory> listWorkHistory = repoHre_WorkHistory.FindBy(m => m.DateEffective <= dateMax1 && lstProfileID1.Contains(m.ProfileID)).OrderByDescending(m => m.DateEffective).ToList<Hre_WorkHistory>();
//List<Hre_WorkHistory> listWorkHistory = EntityService.CreateQueryable<Hre_WorkHistory>(false, GuidContext, Guid.Empty, m => m.DateEffective <= dateMax1 && lstProfileID1.Contains(m.ProfileID)).OrderByDescending(m => m.DateEffective).ToList<Hre_WorkHistory>();
E_APPROVED = RosterStatus.E_APPROVED.ToString();
string E_ROSTERGROUP = RosterType.E_ROSTERGROUP.ToString();
if (dateMin1 == null || dateMax1 == null)
{
lstRosterTypeGroup = repoAtt_Roster.FindBy(m => lstProfileID1.Contains(m.ProfileID) && m.Status == E_APPROVED && m.Type == E_ROSTERGROUP).ToList<Att_Roster>();
//lstRosterTypeGroup = EntityService.Instance.CreateQueryable<Att_Roster>(false, guidContext, Guid.Empty, m => lstProfileID.Contains(m.ProfileID) && m.Status == E_APPROVED && m.Type == E_ROSTERGROUP).ToList<Att_Roster>();
lstRosterGroup = repoAtt_RosterGroup.FindBy(m => m.DateStart != null && m.DateEnd != null).ToList<Att_RosterGroup>();
//lstRosterGroup = EntityService.Instance.CreateQueryable<Att_RosterGroup>(false, guidContext, Guid.Empty, m => m.DateStart != null && m.DateEnd != null).ToList<Att_RosterGroup>();
}
else
{
lstRosterTypeGroup = repoAtt_Roster.FindBy(m => lstProfileID1.Contains(m.ProfileID) && m.Status == E_APPROVED && m.Type == E_ROSTERGROUP && m.DateStart <= dateMax1).ToList<Att_Roster>();
//lstRosterTypeGroup = EntityService.Instance.CreateQueryable<Att_Roster>(false, guidContext, Guid.Empty, m => lstProfileID.Contains(m.ProfileID) && m.Status == E_APPROVED && m.Type == E_ROSTERGROUP && m.DateStart <= DateTo).ToList<Att_Roster>();
lstRosterGroup = repoAtt_RosterGroup.FindBy(m => m.DateStart != null && m.DateEnd != null && m.DateStart <= dateMax1 && m.DateEnd >= dateMin1).ToList<Att_RosterGroup>();
//lstRosterGroup = EntityService.Instance.CreateQueryable<Att_RosterGroup>(false, guidContext, Guid.Empty, m => m.DateStart != null && m.DateEnd != null && m.DateStart <= DateTo && m.DateEnd >= DateFrom).ToList<Att_RosterGroup>();
}
//RosterDAO.GetRosterGroup(GuidContext, lstProfileID1, dateMin1, dateMax1, out lstRosterTypeGroup, out lstRosterGroup);
List<Cat_DayOff> lstHoliday = repoCat_DayOff.FindBy(m => m.IsDelete == null).ToList<Cat_DayOff>();
//List<Cat_DayOff> lstHoliday = EntityService.CreateQueryable<Cat_DayOff>(false, GuidContext, Guid.Empty).ToList<Cat_DayOff>();
string E_APPROVED1 = RosterStatus.E_APPROVED.ToString();
E_ROSTERGROUP = RosterType.E_ROSTERGROUP.ToString();
List<Att_Roster> lstRoster = repoAtt_Roster.FindBy(m => m.Status == E_APPROVED1 && m.DateStart <= dateMax1 && m.DateEnd >= dateMin1 && lstProfileID1.Contains(m.ProfileID)).ToList<Att_Roster>();
//List<Att_Roster> lstRoster = EntityService.CreateQueryable<Att_Roster>(false, GuidContext, Guid.Empty, m => m.Status == E_APPROVED1 && m.DateStart <= dateMax1 && m.DateEnd >= dateMin1 && lstProfileID1.Contains(m.ProfileID)).ToList<Att_Roster>();
List<DateTime> lstHolidayType = lstHoliday.Select(m => m.DateOff).ToList<DateTime>();
//LeaveDayDAO ldDao = new LeaveDayDAO();
foreach (var item in lstLeaveDayInsert)
{
if (item.DurationType != null && item.DurationType != LeaveDayDurationType.E_FULLSHIFT.ToString())
continue;
Cat_LeaveDayType leaveDayType = lstLeaveDayType.Where(m => m.ID == item.LeaveDayTypeID).FirstOrDefault();
if (leaveDayType == null)
continue;
Hre_Profile profileInLeave = lstProfile.Where(m => m.ID == item.ProfileID).FirstOrDefault();
if (profileInLeave == null)
continue;
DateTime dateFrom = item.DateStart;
DateTime dateTo = item.DateEnd;
dateTo = dateTo.AddDays(1).AddMinutes(-1);
Guid GradeAttendanceID = lstGrade.Where(m => m.ProfileID == profileInLeave.ID && m.MonthStart <= dateMax1 && m.GradeAttendanceID.HasValue).Select(m => m.GradeAttendanceID.Value).FirstOrDefault();
Cat_GradeAttendance gradeAttendance = lstGradeAttendance.Where(m => m.ID == GradeAttendanceID).FirstOrDefault();
List<Att_Roster> lstRosterByProfile = lstRoster.Where(m => m.ProfileID == profileInLeave.ID).ToList();
List<Hre_WorkHistory> listWorkHistoryByProfile = listWorkHistory.Where(m => m.ProfileID == profileInLeave.ID && m.DateEffective < dateTo).ToList();
List<Att_Roster> lstRosterByProfileTypeGroup = lstRosterByProfile.Where(m => m.Type == E_ROSTERGROUP).ToList();
leavedayServices.AnalyseTotalLeaveDaysAndHours(item, leaveDayType, profileInLeave, gradeAttendance, lstRosterByProfile, lstRosterGroup, listWorkHistoryByProfile, lstHoliday, shifts);
if (item.ID == Guid.Empty)
{
item.ID = Guid.NewGuid();
repoAtt_LeaveDay.Add(item);
}
else
repoAtt_LeaveDay.Edit(item);
}
}
#endregion
//repoAtt_LeaveDay.Add(lstLeaveDayInsert);
repoAtt_LeaveDay.SaveChanges();
//EntityService.AddEntity<Att_LeaveDay>(GuidContext, lstLeaveDayInsert.ToArray());
return string.Empty;
}
}
示例12: ComputeInsuranceLeaveDetail
//.........这里部分代码省略.........
.FindBy(m => m.IsDelete == null && m.ProfileID != null && lstProfileID.Contains(m.ProfileID.Value)).ToList<Hre_HDTJob>();
List<Cat_JobTitle> lstJobtitle = repoCat_JobTitle.FindBy(s => s.IsDelete == null).ToList();
string E_INSURANCE_LEAVE = AnnualLeaveDetailType.E_INSURANCE_LEAVE.ToString();
#endregion
List<Att_AnnualLeaveDetail> lstInsDetail = new List<Att_AnnualLeaveDetail>();
foreach (var item in lstprofile)
{
List<Att_LeaveDay> lstLeavedayNonAnlByProfile = lstleavedayNonANl.Where(m => m.ProfileID == item.ID).ToList();
List<Att_LeaveDay> lstLeavedayNonAnlByProfileInYear = lstleavedayNonANlInYear.Where(m => m.ProfileID == item.ID).ToList();
List<Hre_HDTJob> lstHDTJobByProfile = lstHDTJob.Where(m => m.ProfileID == item.ID).ToList();
Att_AnnualLeaveDetail annualProfile = new Att_AnnualLeaveDetail();
annualProfile.ID = Guid.NewGuid();
annualProfile.ProfileID = item.ID;
annualProfile.MonthStart = BeginYear;
annualProfile.MonthEnd = EndYear;
annualProfile.Year = Year;
annualProfile.Type = E_INSURANCE_LEAVE;
for (DateTime Month = BeginYear; Month < EndYear; Month = Month.AddMonths(1))
{
double AvailabelInYear = (new Att_AttendanceServices()).GetAnnualLeaveAvailableAllYear( Year, Month.Month, item.DateHire,
item.DateEndProbation, item.DateQuit, formularConfig,
formularCompute, lstLeavedayNonAnlByProfileInYear, lstJobtitle, lstDayOff, lstHDTJobByProfile, lstLeavedayNonAnlByProfile);
if (Month.Month == 1)
annualProfile.Month1 = AvailabelInYear;
if (Month.Month == 2)
annualProfile.Month2 = AvailabelInYear;
if (Month.Month == 3)
annualProfile.Month3 = AvailabelInYear;
if (Month.Month == 4)
annualProfile.Month4 = AvailabelInYear;
if (Month.Month == 5)
annualProfile.Month5 = AvailabelInYear;
if (Month.Month == 6)
annualProfile.Month6 = AvailabelInYear;
if (Month.Month == 7)
annualProfile.Month7 = AvailabelInYear;
if (Month.Month == 8)
annualProfile.Month8 = AvailabelInYear;
if (Month.Month == 9)
annualProfile.Month9 = AvailabelInYear;
if (Month.Month == 10)
annualProfile.Month10 = AvailabelInYear;
if (Month.Month == 11)
annualProfile.Month11 = AvailabelInYear;
if (Month.Month == 12)
annualProfile.Month12 = AvailabelInYear;
}
lstInsDetail.Add(annualProfile);
}
DataErrorCode DataErr = DataErrorCode.Unknown;
if (lstInsDetail.Count > 0)
{
#region lấy dữ liệu dưới DB xóa đi
List<Guid> lstProfileID_InDB = lstInsDetail.Where(m => m.ProfileID != null).Select(m => m.ProfileID.Value).ToList();
List<Att_AnnualLeaveDetail> lstAnnualLeaveDetail_InDB = repoAtt_AnnualLeaveDetail
.FindBy(m => m.IsDelete == null && m.Type == E_INSURANCE_LEAVE && m.Year == Year && m.ProfileID != null
&& lstProfileID_InDB.Contains(m.ProfileID.Value)).ToList();
foreach (var item in lstAnnualLeaveDetail_InDB)
{
item.IsDelete = true;
}
#endregion
repoAtt_AnnualLeaveDetail.Add(lstInsDetail);
try
{
repoAtt_AnnualLeaveDetail.SaveChanges();
}
catch (Exception)
{
return false;
}
//EntityService.AddEntity<Att_AnnualLeaveDetail>(GuidContext, lstInsDetail.ToArray());
//DataErr = EntityService.SubmitChanges(GuidContext, LoginUserID);
//if (DataErr == DataErrorCode.Success)
//{
// Common.MessageBoxs(Messages.Msg, Messages.SaveSuccess, MessageBox.Icon.INFO, string.Empty);
//}
//else
//{
// Common.MessageBoxs(Messages.Msg, Messages.SaveUnSuccess, MessageBox.Icon.INFO, string.Empty);
//}
}
//else
//{
// Common.MessageBoxs(Messages.Msg, Messages.NoDataToCompute, MessageBox.Icon.WARNING, string.Empty);
//}
result = true;
}
return result;
}
示例13: UpdateStatusApprovedProfile
public void UpdateStatusApprovedProfile(string selectedIds)
{
using (var context = new VnrHrmDataContext())
{
var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
var repoProfile = new CustomBaseRepository<Hre_Profile>(unitOfWork);
var repoWorkHistory = new CustomBaseRepository<Hre_WorkHistory>(unitOfWork);
var repoContract = new CustomBaseRepository<Hre_Contract>(unitOfWork);
var repoBasicSalary = new CustomBaseRepository<Sal_BasicSalary>(unitOfWork);
List<Guid> lstProfileIds = selectedIds.Split(',').Select(x => Guid.Parse(x)).ToList();
List<Hre_Profile> lstProfile = repoProfile.FindBy(x => lstProfileIds.Contains(x.ID)).ToList();
var lstWorkHistoty = repoWorkHistory.FindBy(x => lstProfileIds.Contains(x.ProfileID) && x.IsDelete == null).ToList();
var lstContract = repoContract.FindBy(x => lstProfileIds.Contains(x.ProfileID) && x.IsDelete == null).ToList();
var lstBasicSalary = repoBasicSalary.FindBy(x => lstProfileIds.Contains(x.ProfileID) && x.IsDelete == null).ToList();
// cập nhật StatusSyn="E_HIRE"
foreach (var item in lstProfile)
{
item.StatusSyn = ProfileStatusSyn.E_HIRE.ToString();
}
repoProfile.SaveChanges();
if (lstWorkHistoty != null && lstWorkHistoty.Count != 0)
{
// lấy ngày mới nhất để cập nhật Status là E_Approved (Hre_WorkHistory) dửa vào DateEffective
var WorkHistoty = lstWorkHistoty.OrderByDescending(x => x.DateEffective).FirstOrDefault();
WorkHistoty.Status = WorkHistoryStatus.E_APPROVED.ToString();
repoWorkHistory.SaveChanges();
}
if (lstContract != null && lstContract.Count != 0)
{
// lấy ngày mới nhất để cập nhật Status là E_Approved (Hre_Contract) dựa vào DateSigned
var Contract = lstContract.OrderByDescending(x => x.DateSigned).FirstOrDefault();
Contract.Status = "E_APPROVED";
repoContract.SaveChanges();
}
if (lstBasicSalary != null && lstBasicSalary.Count != 0)
{
// lấy ngày mới nhất để cập nhật Status là E_Approved (Sal_BasicSalary) dựa vào DateOfEffect
var BasicSalary = lstBasicSalary.OrderByDescending(x => x.DateOfEffect).FirstOrDefault();
BasicSalary.Status = "E_APPROVED";
repoBasicSalary.SaveChanges();
}
}
}
示例14: ComputeComissionService
//.........这里部分代码省略.........
if (RevenueForShopItem != null)
{
Money_SL = (double)GetObjectValue(new List<Cat_ElementEntity>(), listElementFormula, listShop.Single(m => m.ID == Guid).Formular1).Value;
double Money_Revenue = (double)RevenueForShopItem.Actual * ((double)GetObjectValue(new List<Cat_ElementEntity>(), listElementFormula, listShop.Single(m => m.ID == Guid).Formular).Value / 100);
TotalMoney_RevenueForShop = Money_Revenue - Money_SL;
}
#endregion
Sal_RevenueRecord RecordItem = new Sal_RevenueRecord();
foreach (var j in listKPIBonus)
{
RevenueForShopItem = listRevenueForShop.Where(m => m.ShopID == Guid && m.KPIBonusID == j.ID && (m.DateFrom.Value.Month == Month.Month && m.DateFrom.Value.Year == Month.Year) && (m.DateTo.Value.Month == Month.Month && m.DateTo.Value.Year == Month.Year)).FirstOrDefault();
RecordItem = new Sal_RevenueRecord();
RecordItem.ShopID = Guid;
RecordItem.Month = Month;
RecordItem.KPIBonusID = j.ID;
RecordItem.Type = EnumDropDown.SalesType.E_SALE.ToString();
RecordItem.Note = string.Format("{0:n0}", Money_SL);
if ((RevenueForShopItem != null && RevenueForShopItem.Target <= RevenueForShopItem.Actual) || (RevenueForShopItem != null && RevenueForShopItem.IsPass != null && RevenueForShopItem.IsPass == true))
{
Cat_KPIBonusItemEntity bonusItem = listKPIBonusItem.Where(m => m.ShopID == Guid && m.KPIBonusID == j.ID).FirstOrDefault();
if (bonusItem != null)
{
RecordItem.Amount = TotalMoney_RevenueForShop * (bonusItem.Value / 100);
}
else
{
RecordItem.Amount = 0;
}
}
else
{
RecordItem.Amount = 0;
}
repoRevenueRecord.Add(RecordItem);
}
#region Lấy giá trị cho 2 enum là dòng sản phẩm và sản phẩm
//SAL_COM_PERCENT_SHOP_5
List<Sal_LineItemForShopEntity> listLineItem = listLineItemForShop.Where(m => m.ShopID == Guid && (m.DateFrom.Value.Month == Month.Month && m.DateFrom.Value.Year == Month.Year) && (m.DateTo.Value.Month == Month.Month && m.DateTo.Value.Year == Month.Year)).ToList();
RecordItem = new Sal_RevenueRecord();
RecordItem.ShopID = Guid;
RecordItem.Month = Month;
RecordItem.Type = EnumDropDown.SalesType.E_LINEITEM_MAJOR.ToString();
if (listLineItem != null && listLineItem.Count > 0 && listLineItem.Any(m => m.Actual < m.Target && m.IsPass != true))
{
int NumberPass = 0;
foreach (var lineItem in listLineItem)
{
if ((lineItem.IsPass != null && lineItem.IsPass == true) || lineItem.Actual >= lineItem.Target)
{
NumberPass++;
}
}
if (NumberPass >= 3)
{
RecordItem.Amount = TotalMoney_RevenueForShop * (listShop.Single(m => m.ID == Guid).MainLineProduct / 100);
}
else
{
RecordItem.Amount = 0;
}
}
else
{
RecordItem.Amount = TotalMoney_RevenueForShop * (listShop.Single(m => m.ID == Guid).MainLineProduct / 100);
}
repoRevenueRecord.Add(RecordItem);
//SAL_COM_PERCENT_SHOP_6
List<Sal_ItemForShopEntity> listItem = listItemForShop.Where(m => m.ShopID == Guid && (m.DateFrom.Value.Month == Month.Month && m.DateFrom.Value.Year == Month.Year) && (m.DateTo.Value.Month == Month.Month && m.DateTo.Value.Year == Month.Year)).ToList();
RecordItem = new Sal_RevenueRecord();
RecordItem.ShopID = Guid;
RecordItem.Month = Month;
RecordItem.Type = EnumDropDown.SalesType.E_ITEM_MAJOR.ToString();
if (listItem != null && listItem.Count > 0 && listItem.Any(m => m.Actual < m.Target && m.IsPass != true))
{
RecordItem.Amount = 0;
}
else
{
RecordItem.Amount = TotalMoney_RevenueForShop * (listShop.Single(m => m.ID == Guid).PromoteProduct / 100);
}
repoRevenueRecord.Add(RecordItem);
#endregion
}
#endregion
}
repoRevenueRecord.SaveChanges();
}
}
示例15: CreateComputeOvertime
//.........这里部分代码省略.........
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())
{
Ot.ConfirmHours = Ot.RegisterHours;