Example #1
0
        /// <summary>
        /// 根据账号ID获得该账号的所有请假信息
        /// </summary>
        /// <param name="accountID"></param>
        /// <returns></returns>
        public List <LeaveRequest> GetLeaveRequestByAccountID(int accountID)
        {
            List <LeaveRequest> iRet = _DalLeaveRequest.GetLeaveRequestByAccountID(accountID);

            foreach (LeaveRequest request in iRet)
            {
                if (request != null && request.Account != null)
                {
                    request.Account = _IAccountBll.GetAccountById(request.Account.Id);
                }
            }
            return(iRet);
        }
Example #2
0
        ///// <summary>
        ///// 获取员工可用的剩余调休天数 剩余调休天数-已提交待审核的调休天数-提交了但是没有经过审核就取消中的调休天数
        ///// </summary>
        ///// <param name="accountID"></param>
        ///// <returns></returns>
        //public decimal GetAvailableAdjustRestDaysByEmployeeID(int accountID)
        //{
        //    //获得剩余调休
        //    decimal availableTime = GetNowAdjustRestByAccountID(accountID).SurplusHours;
        //    //获得“提交”的调休小时总数
        //    decimal submittingTotalTime =
        //        _ILeaveRequestDal.SumLeaveRequestCostTimeByEmployeeIDStatusApplyType(accountID, RequestStatus.Submit,
        //                                                                             LeaveRequestTypeEnum.AdjustRest);
        //    //获得“审批中”的调休小时总数
        //    submittingTotalTime +=
        //        _ILeaveRequestDal.SumLeaveRequestCostTimeByEmployeeIDStatusApplyType(accountID, RequestStatus.Approving,
        //                                                                             LeaveRequestTypeEnum.AdjustRest);

        //    //还没审核过就取消了 但仍旧要预扣
        //    submittingTotalTime +=
        //        new GetLeaveRequest(_ILeaveRequestDal, _ILeaveRequestFlowDal).
        //            GetAdjustRestCostTimeByEmployeeWhenCancelAfterSubmit(accountID);
        //    return availableTime - submittingTotalTime;
        //}

        /// <summary>
        ///
        /// </summary>
        /// <param name="leaveRequest"></param>
        /// <returns></returns>
        public bool AdjudgeAdjustAvailable(LeaveRequest leaveRequest)
        {
            int accountID = leaveRequest.Account.Id;
            //获得“提交”的调休小时总数
            //获得“审批中”的调休小时总数
            //还没审核过就取消了 但仍旧要预扣
            List <LeaveRequest>     leaveRequestByAccountID = _ILeaveRequestDal.GetLeaveRequestByAccountID(accountID);
            List <LeaveRequestItem> leaveRequestItems       = new List <LeaveRequestItem>();
            List <LeaveRequestItem> leaveRequestItems2      = new List <LeaveRequestItem>();

            foreach (LeaveRequest request in leaveRequestByAccountID)
            {
                if (request.LeaveRequestType.LeaveRequestTypeID == (int)LeaveRequestTypeEnum.AdjustRest)
                {
                    foreach (LeaveRequestItem item in request.LeaveRequestItems)
                    {
                        if (item.Status.Id == RequestStatus.Submit.Id || item.Status.Id == RequestStatus.Approving.Id)
                        {
                            leaveRequestItems.Add(item);
                        }
                        else if (item.Status.Id == RequestStatus.CancelApproving.Id ||
                                 item.Status.Id == RequestStatus.Cancelled.Id)
                        {
                            leaveRequestItems2.Add(item);
                        }
                    }
                }
            }
            leaveRequestItems.AddRange(new GetLeaveRequest().AdjustIfApprovePass(leaveRequestItems2));
            leaveRequestItems.AddRange(leaveRequest.LeaveRequestItems);

            JudgeAdjustRestCanDelete judgeAdjustRestCanDelete =
                new JudgeAdjustRestCanDelete(leaveRequestItems, accountID);

            try
            {
                judgeAdjustRestCanDelete.Excute();
            }
            catch
            {
                return(false);
            }
            return(true);
        }