当前位置: 首页>>代码示例>>C#>>正文


C# CustomBaseRepository.Edit方法代码示例

本文整理汇总了C#中CustomBaseRepository.Edit方法的典型用法代码示例。如果您正苦于以下问题:C# CustomBaseRepository.Edit方法的具体用法?C# CustomBaseRepository.Edit怎么用?C# CustomBaseRepository.Edit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CustomBaseRepository的用法示例。


在下文中一共展示了CustomBaseRepository.Edit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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;
                }

            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:57,代码来源:Att_AnnualLeaveDetailServices.cs

示例2: 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();
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:52,代码来源:Att_CompensationServices.cs

示例3: 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();
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:45,代码来源:FIN_PurchaseRequestService.cs

示例4: ProcessApproved

        /// <summary>
        /// [Hieu.Van]
        /// Xử lý duyệt động đa cấp
        /// ProcessApproved (Tài khoản Login - LoginID, Value Dropdownlist - userApprovedID, Id Bản ghi - recordID, Enum màn hình - type)
        /// </summary>
        /// <param name="LoginID"></param>
        /// <param name="userApprovedID"></param>
        /// <param name="recordID"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public string ProcessApproved(string host, Guid LoginID, Guid userApprovedID, Guid recordID, string type)
        {
            DataErrorCode status = DataErrorCode.Success;
            string stt = string.Empty;
            var Services = new BaseService();
            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_ConfigProcessApprove = new CustomBaseRepository<Sys_ConfigProcessApprove>(unitOfWork);
                var UserLogin = string.Empty;
                var record = GetData<FIN_PurchaseRequestEntity>(recordID, ConstantSql.hrm_hr_sp_get_PurchaseRequestById, UserLogin, ref stt).FirstOrDefault();
                var configProcess = repoSys_ConfigProcessApprove.FindBy(s => s.IsDelete == null && s.Function == type && s.CurrentStatus == record.Status).FirstOrDefault();
                double total = record.Total != null ? record.Total.Value : 0.0;
                List<ElementFormula> listFomula = new List<ElementFormula>();
                ElementFormula FomulaItem = new ElementFormula("Total", total, 0);
                ElementFormula statusItem = new ElementFormula(configProcess.NextStatusFormular, configProcess.NextStatusFormular, 1);
                listFomula.Add(FomulaItem);
                listFomula.Add(statusItem);
                string nextStatus = Services.GetObjectValue(new List<Cat_ElementEntity>(), listFomula, configProcess.NextStatusFormular).ToString();


                if (configProcess != null && userApprovedID == Guid.Empty && nextStatus != "Approved")
                {
                    return DataErrorCode.Error_NoUserApproved.ToString();
                }
                if (record.Status == EnumDropDown.Status.E_REJECTED.ToString())
                {
                    return DataErrorCode.Error_Reject.ToString();
                }
                var recordEdit = repoFIN_PurchaseRequest.FindBy(s => s.ID == recordID).FirstOrDefault();
                // lấy UserInfoID hiện tại của bản ghi
                var userApprovedCurrent = repoSys_UserApprove.FindBy(s => s.ID == recordEdit.UserApproveID).FirstOrDefault();
                // Kiểm tra tài khoản login có được phép Duyệt hay ko?
                if (LoginID == Guid.Empty || userApprovedCurrent.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 (recordEdit.UserApproveID == null && record.UserCreateID == LoginID)
                    {
                    }
                    else
                    {
                        return DataErrorCode.NoPermission.ToString();
                    }
                }
                recordEdit.Status = nextStatus;
                if (userApprovedID == Guid.Empty)
                {
                    recordEdit.UserApproveID = null;
                }
                else
                {
                    recordEdit.UserApproveID = userApprovedID;
                }
                repoFIN_PurchaseRequest.Edit(recordEdit);
                status = repoFIN_PurchaseRequest.SaveChanges();

                if (nextStatus != "Approved")
                {
                    status = SendMail_ToNextApproved(host, recordID, userApprovedID, nextStatus, type);
                }

                if (status == DataErrorCode.Success)
                {
                    //var configProcess = repoSys_ConfigProcessApprove.FindBy(s => s.IsDelete == null && s.Function == type && s.CurrentStatus == nextStatus).FirstOrDefault();
                    if (nextStatus == "Approved")
                    {
                        return DataErrorCode.Success.ToString();
                    }
                    else
                    {
                        return DataErrorCode.Success_Forward.ToString();
                    }
                }

                return status.ToString();
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:89,代码来源:FIN_PurchaseRequestService.cs

示例5: 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())
//.........这里部分代码省略.........
开发者ID:dtafe,项目名称:vnr,代码行数:101,代码来源:Att_OvertimePermitConfigServices.cs

示例6: CalAllowOvertime


//.........这里部分代码省略.........
            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();

                List<ProfileDateTime> lstWorkdayCanBeOT = new List<ProfileDateTime>();

                foreach (var item in lstOvertime)
                {
                    if (item.WorkDateRoot == null)
                        continue;
                    if (item.IsNonOvertime == null)
                        continue;

                    ProfileDateTime workdayNotOt = new ProfileDateTime();
                    workdayNotOt.ProfileID = item.ProfileID;
                    workdayNotOt.WorkDate = item.WorkDateRoot.Value;
                    lstWorkdayCanBeOT.Add(workdayNotOt);
                }



                List<Att_OvertimeEntity> lstOvertimeInCache = lstOvertimeCache;
                List<Att_OvertimeEntity> lstOvertimeInCache_Profile = lstOvertimeInCache.Where(m => lstProfileID.Contains(m.ProfileID)).ToList();

                var _tmp = lstOvertimeInCache_Profile;
                for (int i = 0; i < _tmp.Count(); i++)
                    lstOvertimeInCache.Remove(lstOvertimeInCache_Profile[i]);

                List<Att_OvertimeEntity> lstOvertimeNonBe_Delete = new List<Att_OvertimeEntity>();
                foreach (var item in lstOvertimeInCache_Profile)
                {
                    if (lstWorkdayCanBeOT.Any(m => m.ProfileID == item.ProfileID && m.WorkDate == item.WorkDateRoot))
                    {
                        item.IsNonOvertime = null;
                        lstOvertimeNonBe_Delete.Add(item);
                    }
                }
                //Để tính lại lũy kế sau khi xong
                OvertimePermitEntity overtimePermit = getOvertimePermit(userLogin);
                //List<Att_WorkdayEntity> lstWorkday = repoAtt_workday.FindBy(m => m.WorkDate >= minDate && m.WorkDate <= maxDate && lstProfileID.Contains(m.ProfileID)).ToList().Translate<Att_WorkdayEntity>();
                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> LstNonOTSelect = repoAtt_NoneOvertime.FindBy(m => m.WorkDay >= minDate && m.WorkDay <= maxDate && lstProfileID.Contains(m.ProfileID.Value)).ToList<Att_NonOverTime>();
                List<Att_NonOverTime> LstNonOTSelect = new List<Att_NonOverTime>();
                if (lstProfileID.Count < 2000)
                {
                    LstNonOTSelect = repoAtt_workday
                        .FindBy(m => m.IsDelete == null && m.WorkDate >= minDate && m.WorkDate <= maxDate && lstProfileID.Contains(m.ProfileID)).ToList().Translate<Att_NonOverTime>();
                }
                else
                {
                    LstNonOTSelect = repoAtt_workday
                        .FindBy(m => m.IsDelete == null && m.WorkDate >= minDate && m.WorkDate <= maxDate).ToList().Translate<Att_NonOverTime>();
                }

                foreach (var item in lstOvertimeNonBe_Delete)
                {
                    Att_NonOverTime NonOT = LstNonOTSelect.Where(m => m.ProfileID == item.ProfileID && m.OvertimeTypeID == item.OvertimeTypeID && m.WorkDay == item.WorkDateRoot && m.Type == item.udTypeBeginOTWithShift).FirstOrDefault();
                    if (NonOT != null)
                    {
                        NonOT.IsDelete = true;
                    }
                }
                if (LstNonOTSelect.Count > 0)
                {
                    repoAtt_NoneOvertime.Edit(LstNonOTSelect);
                    unitOfWork.SaveChanges();
                }
                //BindToGrid(lstOvertimeCache);
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:101,代码来源:Att_OvertimeServices.cs

示例7: CreateComputeOvertime


//.........这里部分代码省略.........

                #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;
                        if (Ot.MethodPayment == EnumDropDown.PaymentType.E_TIMEOFF.ToString() || Ot.MethodPayment == EnumDropDown.PaymentType.E_CASHOUT_TIMEOFF.ToString())
                            InsertToTimeOffInlieu = true;
                    }
                    Ot.ReasonOT = strReasonOT;
                    Ot.UserApproveID = UserAppvove.ID;
                    Guid ProfileID = Ot.ProfileID;
                    DateTime beginOt = Ot.WorkDate;
                    DateTime endOt = beginOt.AddHours(Ot.RegisterHours);
                    Att_OvertimeEntity OvertimeRemove = lstOvertimeCache.Where(m => m.ID == Ot.ID).FirstOrDefault();
                    if (OvertimeRemove != null)
                    {
                        int index = lstOvertimeCache.IndexOf(OvertimeRemove);
                        lstOvertimeCache.Remove(OvertimeRemove);
                        lstOvertimeCache.Insert(index, Ot);
                    }
开发者ID:dtafe,项目名称:vnr,代码行数:66,代码来源:Att_OvertimeServices.cs

示例8: 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();

                
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:83,代码来源:Sys_AllSettingServices.cs

示例9: SetSickLeaveBeginYear

        public void SetSickLeaveBeginYear(List<Guid> lstProfileIDs, double? limitMaximum, int Year)
        {
            //Đối với phép ốm thì tạm thời tính từ đầu năm đến cuối năm
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoAtt_AnnualLeave = new CustomBaseRepository<Att_AnnualLeave>(unitOfWork);
                var repoCat_LeaveDayType = new CustomBaseRepository<Cat_LeaveDayType>(unitOfWork);
                var repoAtt_LeaveDay = new CustomBaseRepository<Att_LeaveDay>(unitOfWork);
                int LastYear = Year - 1;
                DateTime beginLastYear = new DateTime(LastYear, 1, 1);
                DateTime endLastYear = beginLastYear.AddYears(1).AddMinutes(-1);
                List<Guid> SickLeaveType = repoCat_LeaveDayType.FindBy(m => m.IsDelete == null && m.Code == "SICK").Select(m => m.ID).ToList();
                string Approve = LeaveDayStatus.E_APPROVED.ToString();
                var lstLeaveDay = repoAtt_LeaveDay.FindBy(m =>
                    m.IsDelete == null
                    && m.Status == Approve
                    && m.DateStart < endLastYear
                    && m.DateEnd >= beginLastYear
                    && SickLeaveType.Contains(m.LeaveDayTypeID)
                    && lstProfileIDs.Contains(m.ProfileID)).Select(m => new { m.ProfileID, m.TotalDuration }).ToList();

                List<Att_AnnualLeave> lstAnnualLeaveInDB = repoAtt_AnnualLeave.FindBy(m => m.IsDelete == null && (m.Year == Year || m.Year == LastYear) && lstProfileIDs.Contains(m.ProfileID)).ToList();

                foreach (var ProfileID in lstProfileIDs)
                {
                    Att_AnnualLeave AnnualLeaveByProfile = lstAnnualLeaveInDB.Where(m => m.ProfileID == ProfileID && m.Year == Year).FirstOrDefault();
                    Att_AnnualLeave AnnualLeaveByProfile_Last = lstAnnualLeaveInDB.Where(m => m.ProfileID == ProfileID && m.Year == LastYear).FirstOrDefault();
                    bool IsNew = false;
                    if (AnnualLeaveByProfile == null)
                    {
                        IsNew = true;
                        AnnualLeaveByProfile = new Att_AnnualLeave();
                        AnnualLeaveByProfile.ID = Guid.NewGuid();
                        AnnualLeaveByProfile.ProfileID = ProfileID;
                        AnnualLeaveByProfile.Year = Year;
                        AnnualLeaveByProfile.MonthStart = 1;
                    }

                    double InitLastYear = 0;
                    if (AnnualLeaveByProfile_Last != null)
                        InitLastYear = AnnualLeaveByProfile_Last.InitSickValue;
                    double remainLastYear = InitLastYear - lstLeaveDay.Where(m => m.ProfileID == ProfileID).Sum(m => m.TotalDuration ?? 0);
                    if (limitMaximum != null)
                    {
                        AnnualLeaveByProfile.InitSickValue = remainLastYear > limitMaximum.Value ? limitMaximum.Value : remainLastYear;
                        AnnualLeaveByProfile.SurplusSicklastYear = remainLastYear > limitMaximum ? remainLastYear - limitMaximum : 0;
                    }
                    else
                    {
                        AnnualLeaveByProfile.InitSickValue = remainLastYear;
                        AnnualLeaveByProfile.SurplusSicklastYear = 0;
                    }
                    if (IsNew)
                    {
                        repoAtt_AnnualLeave.Add(AnnualLeaveByProfile);
                    }
                    else
                    {
                        repoAtt_AnnualLeave.Edit(AnnualLeaveByProfile);
                    }
                }
                repoAtt_AnnualLeave.SaveChanges();
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:65,代码来源:Att_AnnualLeaveServices.cs

示例10: SetAnnualLeaveBeginYear


//.........这里部分代码省略.........
        ///// <param name="annualLeaveId"></param>
        ///// <returns></returns>
        //public Att_AnnualLeaveEntity GetAnnualLeaveById(int annualLeaveId)
        //{
        //    using (var context = new VnrHrmDataContext())
        //    {
        //        var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
        //        IAtt_AnnualLeaveRepository repo = new Att_AnnualLeaveRepository(unitOfWork);
        //        var data = repo.GetAnnualLeaveById(annualLeaveId);
        //        return data;
        //    }
        //}

        //#endregion

        //#endregion
        #endregion

        #region thanh toán phép năm đầu kỳ

        public void SetAnnualLeaveBeginYear(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_AnnualLeave = new CustomBaseRepository<Att_AnnualLeave>(unitOfWork);
                var repoAtt_AnnualDetail = new CustomBaseRepository<Att_AnnualDetail>(unitOfWork);
                var repoSal_UnusualAllowance = new CustomBaseRepository<Sal_UnusualAllowance>(unitOfWork);
                var repoAtt_CutOffDuration = new CustomBaseRepository<Att_CutOffDuration>(unitOfWork);
                //nếu có rồi thì chỉ cần Update
                //Nếu chưa có thì tạo mới
                Att_CutOffDuration CutOffDuration = new Att_CutOffDuration();
                if (CuttOffDurationID != null)
                {
                    CutOffDuration = repoAtt_CutOffDuration.FindBy(m => m.ID == CuttOffDurationID).FirstOrDefault();
                }


                int LastYear = Year - 1;
                DateTime? MaxTime = repoAtt_AnnualDetail.FindBy(m => m.IsDelete != null && m.Year == LastYear).OrderByDescending(m => m.MonthYear).Select(m => m.MonthYear).FirstOrDefault();
                List<Att_AnnualDetail> lstAnnualDetail = new List<Att_AnnualDetail>();
                if (MaxTime != null)
                {
                    lstAnnualDetail = repoAtt_AnnualDetail.FindBy(m => m.MonthYear == MaxTime
                        && m.ProfileID != null
                        && lstProfileIDs.Contains(m.ProfileID.Value)).ToList();
                }
                var lstAnnualLeaveInDB = repoAtt_AnnualLeave.FindBy(m => m.IsDelete == null && m.Year == Year && lstProfileIDs.Contains(m.ProfileID)).ToList();


                foreach (var ProfileID in lstProfileIDs)
                {
                    Att_AnnualLeave AnnualLeaveByProfile = lstAnnualLeaveInDB.Where(m => m.ProfileID == ProfileID).FirstOrDefault();
                    bool IsNew = false;
                    if (AnnualLeaveByProfile == null)
                    {
                        IsNew = true;
                        AnnualLeaveByProfile = new Att_AnnualLeave();
                        AnnualLeaveByProfile.ID = Guid.NewGuid();
                        AnnualLeaveByProfile.ProfileID = ProfileID;
                        AnnualLeaveByProfile.Year = Year;
                        AnnualLeaveByProfile.MonthStart = 1;

                    }
                    AnnualLeaveByProfile.MonthResetAnlOfBeforeYear = MonthResetANL;
                    double RemainLastYear = lstAnnualDetail.Where(m => m.ProfileID == ProfileID).Select(m => m.Remain ?? 0).FirstOrDefault();
                    if (limitMaximum != null)
                    {
                        AnnualLeaveByProfile.InitAnlValue = RemainLastYear > limitMaximum.Value ? limitMaximum.Value : RemainLastYear;
                        AnnualLeaveByProfile.SurplusAnllastYear = RemainLastYear > limitMaximum ? RemainLastYear - limitMaximum : 0;
                        if (CutOffDuration.ID != null && CutOffDuration.ID != Guid.Empty && AllowanceTypeID != null)
                        {
                            Sal_UnusualAllowance UnusualAllowance = new Sal_UnusualAllowance();
                            UnusualAllowance.ProfileID = ProfileID;
                            UnusualAllowance.MonthStart = CutOffDuration.DateStart;
                            UnusualAllowance.MonthEnd = CutOffDuration.DateEnd;
                            UnusualAllowance.UnusualEDTypeID = AllowanceTypeID;
                            UnusualAllowance.Amount = AnnualLeaveByProfile.SurplusAnllastYear;
                            repoSal_UnusualAllowance.Add(UnusualAllowance);
                        }
                    }
                    else
                    {
                        AnnualLeaveByProfile.InitAnlValue = RemainLastYear;
                        AnnualLeaveByProfile.SurplusAnllastYear = 0;
                    }
                    //Sửa lại theo phần tử mới mà Sơn build
                    if (IsNew)
                    {
                        repoAtt_AnnualLeave.Add(AnnualLeaveByProfile);
                    }
                    else
                    {
                        repoAtt_AnnualLeave.Edit(AnnualLeaveByProfile);
                    }
                }
                repoAtt_AnnualLeave.SaveChanges();
                repoSal_UnusualAllowance.SaveChanges();
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:101,代码来源:Att_AnnualLeaveServices.cs

示例11: GetMealRecordSummary

        public List<Can_MealRecordEntity> GetMealRecordSummary(string _line, string _catering, string _canteen, DateTime dateStart, DateTime dateEnd, List<Hre_ProfileEntity> lstProfileIDs, string UserLogin)
        {
            dateStart = dateStart.Date;
            dateEnd = dateEnd.Date.AddDays(1).AddMilliseconds(-1);

            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoCan_MealRecord = new CustomBaseRepository<Can_MealRecord>(unitOfWork);
                var repoCan_TamScanLog = new CustomBaseRepository<Can_TamScanLogCMS>(unitOfWork);
                var repoCan_Line = new CustomBaseRepository<Can_Line>(unitOfWork);
                var repoCan_Canteen = new CustomBaseRepository<Can_Canteen>(unitOfWork);
                var repoCan_Catering = new CustomBaseRepository<Can_Catering>(unitOfWork);
                var repoSys_AllSetting = new CustomBaseRepository<Sys_AllSetting>(unitOfWork);
                string status = string.Empty;
                //string strIDs = string.Join(",", lstProfileIDs.ToArray());
                #region xử lý cấu hình giờ kết thúc ăn - DateStart & DateEnd
                DateTime dateConfig = DateTime.MinValue;
                var rsTimeConfig = GetData<Sys_AllSettingEntity>(AppConfig.HRM_CAN_MEALRECORD_EATEND_CONFIG.ToString(), ConstantSql.hrm_sys_sp_get_AllSettingByKey, UserLogin, ref status).FirstOrDefault();
                if (rsTimeConfig != null && rsTimeConfig.Value1 != null)
                {
                    dateConfig = DateTimeHelper.ConvertStringToDateTime(rsTimeConfig.Value1, ConstantFormat.HRM_Format_YearMonthDay_HoursMinSecond_ffffff.ToString());
                }
                double hourConfig = dateConfig.Hour + (((double)dateConfig.Minute) / 60);
                dateStart = dateStart.Date.AddHours(hourConfig);
                dateEnd = dateEnd.Date.AddDays(1).AddHours(hourConfig).AddMilliseconds(-1);
                #endregion

                #region cấu hình số phút xử lý trùng
                int rsScanMulti = 0;
                var rsScanMultiConfig = GetData<Sys_AllSettingEntity>(AppConfig.HRM_CAN_MEALRECORD_SCANMULTI_CONFIG.ToString(), ConstantSql.hrm_sys_sp_get_AllSettingByKey, UserLogin, ref status).FirstOrDefault();

                if (rsScanMultiConfig != null)
                {
                    rsScanMulti = rsScanMultiConfig.Value1 != null ? int.Parse(rsScanMultiConfig.Value1.ToString()) : 0;
                }
                #endregion

                var tamScanLogs = repoCan_TamScanLog
                    .FindBy(s => dateStart <= s.TimeLog && s.TimeLog <= dateEnd)
                    .Select(s => new { s.MachineCode, s.CardCode, s.TimeLog, s.ID })
                    .ToList();
                var cardCodes = tamScanLogs.Select(s => s.CardCode).ToList();

                //strIDs = Common.DotNetToOracle(strIDs);
                //var profiles = GetData<Hre_ProfileEntity>(strIDs, ConstantSql.hrm_hr_sp_get_ProfileByIds, ref status)
                //    .Where(s => cardCodes.Contains(s.CodeAttendance) && lstProfileIDs.Contains(s.ID))
                var profiles = lstProfileIDs
                    .Where(s => cardCodes.Contains(s.CodeAttendance))
                    .Select(s => new { s.ID, s.CodeAttendance, s.CodeEmp, s.ProfileName, s.OrgStructureName }).ToList();

                tamScanLogs = tamScanLogs.Where(s => profiles.Select(p => p.CodeAttendance).Contains(s.CardCode)).OrderBy(s => s.CardCode).ThenBy(s=>s.TimeLog).ToList();
                var lines = repoCan_Line.FindBy(s => s.IsDelete == null).ToList();
                var canteens = repoCan_Canteen.FindBy(s => s.IsDelete == null).ToList();
                var caterings = repoCan_Catering.FindBy(s => s.IsDelete == null).ToList();
                if (_line != null)
                {
                    List<Guid> lstLine = _line.Split(',').Select(Guid.Parse).ToList();
                    lines = lines.Where(s => lstLine.Contains(s.ID)).ToList();
                }
                if (_canteen != null)
                {
                    List<Guid> lstcanteen = _canteen.Split(',').Select(Guid.Parse).ToList();
                    canteens = canteens.Where(s => lstcanteen.Contains(s.ID)).ToList();
                }
                if (_catering != null)
                {
                    List<Guid> lstcatering = _catering.Split(',').Select(Guid.Parse).ToList();
                    caterings = caterings.Where(s => lstcatering.Contains(s.ID)).ToList();
                }

                List<object> lstObj = new List<object>();
                lstObj.Add(dateStart);
                lstObj.Add(dateEnd);
                List<Can_MealRecordCheckEntity> mealRecordCheckList = GetData<Can_MealRecordCheckEntity>(lstObj, ConstantSql.hrm_can_sp_get_MealRecord_ByDateFromDateTo, UserLogin, ref status);
                Can_MealRecordEntity record = new Can_MealRecordEntity();
                List<Can_MealRecordEntity> lstRecord = new List<Can_MealRecordEntity>();
                List<Can_MealRecord> lstEdit = new List<Can_MealRecord>();
                List<Can_MealRecord> lstAdd = new List<Can_MealRecord>();

                List<Guid> lstDuplicateTamScan = new List<Guid>();
                foreach (var tamScanLog in tamScanLogs)
                {
                    if (lstDuplicateTamScan.Contains(tamScanLog.ID))
                        continue;

                    record = new Can_MealRecordEntity();
                    var profile = profiles.FirstOrDefault(s => s.CodeAttendance == tamScanLog.CardCode);
                    var line = lines.FirstOrDefault(s => tamScanLog.MachineCode == s.MachineCode);

                    if (profile != null && line != null)
                    { 
                        #region xử lý quẹt thẻ trùng theo HRM_CAN_MEALRECORD_SCANMULTI_CONFIG
                        var tamScanLogProfiles = tamScanLogs
                            .Where(s => s.CardCode == tamScanLog.CardCode && s.TimeLog.Value.Date == tamScanLog.TimeLog.Value.Date && s.MachineCode == tamScanLog.MachineCode)
                            .OrderBy(s => s.TimeLog)
                            .ToList();

                        if (tamScanLogProfiles.Count > 1 && rsScanMulti > 0)
                        {
//.........这里部分代码省略.........
开发者ID:dtafe,项目名称:vnr,代码行数:101,代码来源:Can_MealRecordServices.cs

示例12: AnalyzeAnnualDetail


//.........这里部分代码省略.........
                var lstGradeCgf = unitOfWork.CreateQueryable<Cat_GradeAttendance>().ToList();
                var lstLeaveDayTypeAnnual = unitOfWork.CreateQueryable<Cat_LeaveDayType>(s => s.IsAnnualLeave == true).ToList();
                List<Guid> lstAnnualTypeID = lstLeaveDayTypeAnnual.Select(s => s.ID).ToList();
                string E_APPROVED = LeaveDayStatus.E_APPROVED.ToString();



                var lstAnnualDetailInDB_Query = unitOfWork.CreateQueryable<Att_AnnualDetail>(m => m.ProfileID != null && m.Year == Year);
                var lstLeaveDayAnl_Query = unitOfWork.CreateQueryable<Att_LeaveDay>(m =>
                    m.Status == E_APPROVED
                    && m.DateStart <= EndYear
                    && m.DateEnd >= BeginYearToGetData
                    && m.LeaveDayTypeID != null
                    && lstAnnualTypeID.Contains(m.LeaveDayTypeID));
                var lstAttGrade_Query = unitOfWork.CreateQueryable<Att_Grade>();
                var lstAnualLeaveCfg_Query = unitOfWork.CreateQueryable<Att_AnnualLeave>(m => m.Year == Year);
                var lstlstRoster_Query = unitOfWork.CreateQueryable<Att_Roster>(m =>
                    m.Status == E_APPROVED
                    && m.DateStart <= EndYear
                    && m.DateEnd >= BeginYearToGetData);
                if (isFullEmp != null && isFullEmp.Value == false)
                {
                    lstAnnualDetailInDB_Query = lstAnnualDetailInDB_Query.Where(m => m.ProfileID != null && lstProfileID.Contains(m.ProfileID.Value));
                    lstLeaveDayAnl_Query = lstLeaveDayAnl_Query.Where(m => lstProfileID.Contains(m.ProfileID));
                    lstAttGrade_Query = lstAttGrade_Query.Where(m => m.ProfileID != null && lstProfileID.Contains(m.ProfileID.Value));
                    lstAnualLeaveCfg_Query = lstAnualLeaveCfg_Query.Where(m => lstProfileID.Contains(m.ProfileID));
                    lstlstRoster_Query = lstlstRoster_Query.Where(m => lstProfileID.Contains(m.ProfileID));
                }

                var lstAnnualDetailInDB = lstAnnualDetailInDB_Query.ToList();
                var lstLeaveDayAnl = lstLeaveDayAnl_Query.Select(m => new Att_LeaveDayInfo()
                {
                    ID = m.ID
                    ,
                    ProfileID = m.ProfileID
                    ,
                    DateStart = m.DateStart
                    ,
                    DateEnd = m.DateEnd
                    ,
                    LeaveDayTypeID = m.LeaveDayTypeID
                    ,
                    TotalDuration = m.TotalDuration
                    ,
                    Duration = m.Duration
                    ,
                    DurationType = m.DurationType
                    ,
                    LeaveDays = m.LeaveDays
                    ,
                    LeaveHours = m.LeaveHours
                }).ToList();
                var lstAttGrade = lstAttGrade_Query.ToList();
                var lstAnualLeaveCfg = lstAnualLeaveCfg_Query.ToList();
                var lstRoster = lstlstRoster_Query.Select(m => new Att_RosterInfo() { ID = m.ID, ProfileID = m.ProfileID, Type = m.Type, MonShiftID = m.MonShiftID, TueShiftID = m.TueShiftID, WedShiftID = m.WedShiftID, ThuShiftID = m.ThuShiftID, FriShiftID = m.FriShiftID, SatShiftID = m.SatShiftID, SunShiftID = m.SunShiftID }).ToList();


                var lstRosterGroup = unitOfWork.CreateQueryable<Att_RosterGroup>(m => m.DateStart <= EndYear && m.DateEnd >= BeginYearToGetData).ToList();
                var lstDayOff = unitOfWork.CreateQueryable<Cat_DayOff>(m => m.DateOff >= BeginYearToGetData && m.DateOff <= EndYear).ToList();

                // Phép Năm chốt Từ Ngày 1 -> 31 Hàng Tháng 
                bool IsFrom1To31 = false;
                string type2 = AppConfig.HRM_ATT_ANNUALLEAVE_ANNUALBEGINMONTHTOENDMONTH.ToString();
                Sys_AllSetting sys_ANNUAL_BEGINMONTHTO_ENDMONTH = unitOfWork.CreateQueryable<Sys_AllSetting>(sy => sy.Name == type2).FirstOrDefault();
                if (sys_ANNUAL_BEGINMONTHTO_ENDMONTH != null && sys_ANNUAL_BEGINMONTHTO_ENDMONTH.Value1 == bool.TrueString)
                {
                    IsFrom1To31 = true;
                }
                List<Guid> lstPositionIDs = lstProfile.Where(m => m.PositionID != null).Select(m => m.PositionID.Value).Distinct().ToList();
                List<Cat_Position> lstPosition = unitOfWork.CreateQueryable<Cat_Position>(m => lstPositionIDs.Contains(m.ID)).ToList<Cat_Position>();
                var lstAllSetting = unitOfWork.CreateQueryable<Sys_AllSetting>().ToList();

                var lstHDTJob=new List<Hre_HDTJob>();
                foreach (var templstProfileId in lstProfileID.Chunk(1000))
                {
                    lstHDTJob.AddRange(unitOfWork.CreateQueryable<Hre_HDTJob>(Guid.Empty, m => m.ProfileID != null && templstProfileId.Contains(m.ProfileID.Value)).ToList());
                }
                foreach (var profile in lstProfile)
                {
                    var lstGradeByProfile = lstAttGrade.Where(m => m.ProfileID == profile.ID).OrderByDescending(m => m.MonthStart).ToList();
                    var lstLeaveDayByprofile = lstLeaveDayAnl.Where(m => m.ProfileID == profile.ID).ToList();
                    var AnualLeaveCfg = lstAnualLeaveCfg.Where(m => m.ProfileID == profile.ID).FirstOrDefault();
                    var lstRosterByProfile = lstRoster.Where(m => m.ProfileID == profile.ID).ToList();
                    var position = lstPosition.Where(m => m.ID == profile.PositionID).FirstOrDefault();

                    List<Att_AnnualDetail> lstAnnualDetailByProfile_Update = new List<Att_AnnualDetail>();

                    List<Att_AnnualDetail> lstAnnualDetailByProfile = AnalyzeAnnualDetailPerProfile(profile,
                        lstGradeCgf, lstGradeByProfile, BeginYear, EndYear, lstLeaveDayByprofile, lstAnnualDetailInDB,
                        AnualLeaveCfg, lstRosterByProfile, lstRosterGroup, lstDayOff, IsFrom1To31,
                        position, lstAllSetting, lstHDTJob, out  lstAnnualDetailByProfile_Update, userLogin);
                    lstResult.AddRange(lstAnnualDetailByProfile);
                    lstResult.AddRange(lstAnnualDetailByProfile_Update);
                    repoAtt_AnnualDetail.Add(lstAnnualDetailByProfile);
                    repoAtt_AnnualDetail.Edit(lstAnnualDetailByProfile_Update);
                }
                repoAtt_AnnualDetail.SaveChanges();
                return lstResult;
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:101,代码来源:Att_AnnualDetailServices.cs

示例13: 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;
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:101,代码来源:Att_ComputeWorkdayAdjustServices.cs

示例14: 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;
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:101,代码来源:Att_ComputeWorkdayAdjustServices.cs

示例15: ProcessSendRequest

        /// <summary>
        /// [Hieu.Van]
        /// Xử lý Gửi yêu cầu phê duyệt
        /// </summary>
        /// <param name="LoginID"></param>
        /// <param name="userApprovedID"></param>
        /// <param name="recordID"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public string ProcessSendRequest(string host, Guid LoginID, Guid userApprovedID, 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 record = repoFIN_PurchaseRequest.FindBy(s => s.ID == recordID).FirstOrDefault();
                if (record.UserCreateID != LoginID)
                {
                    return DataErrorCode.NoPermission.ToString();
                }
                if (record.Status == EnumDropDown.Status.E_REJECTED.ToString())
                {
                    return DataErrorCode.Error_Reject.ToString();
                }
                if (record.Status != null)
                {
                    return DataErrorCode.Error_SendRequest.ToString();
                }
                var userApproved = repoSys_UserApprove.FindBy(s => s.ID == userApprovedID).FirstOrDefault();
                // Lấy status hiện tại của bản ghi
                string currentStatus = record.Status;

                // truyền từ Dropdownlist chọn người duyệt, lấy ra giá trị Status tiếp theo
                string nextStatus = userApproved.CurrentStatus;

                record.Status = nextStatus;
                record.UserApproveID = userApprovedID;
                repoFIN_PurchaseRequest.Edit(record);
                status = repoFIN_PurchaseRequest.SaveChanges();

                
                if (status == DataErrorCode.Success)
                {
                    if (nextStatus != "Approved")
                    {
                        status = SendMail_ToNextApproved(host, recordID, userApprovedID, nextStatus, type);
                    }

                    var repoSys_ConfigProcessApprove = new CustomBaseRepository<Sys_ConfigProcessApprove>(unitOfWork);
                    var configProcess = repoSys_ConfigProcessApprove.FindBy(s => s.IsDelete == null && s.Function == type && s.CurrentStatus == record.Status).FirstOrDefault();
                    if (configProcess == null)
                    {
                        return DataErrorCode.Success.ToString();
                    }
                    else
                    {
                        return DataErrorCode.Success_Forward.ToString();
                    }
                }

                return status.ToString();
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:66,代码来源:FIN_PurchaseRequestService.cs


注:本文中的CustomBaseRepository.Edit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。