コード例 #1
0
        /// <summary>
        /// Dependent on the checktype, method checks either for overlaps between the new submitted vacation request and DB-stored lock periods,
        /// or between overlaps with a vacation request by the deputy
        /// </summary>
        /// <param name="CheckType"> an int value that choose the test type</param>
        /// <returns> true if no lock or overlap is present, else false</returns>
        public Boolean Validate(int CheckType)
        {
            Boolean result = true; // assumes that no locks or overlaps exist

            switch (CheckType)
            {
                case CHECK_CATEGORY_LOCK_PERIOD:
                    DBQuery dbqLock = new DBQuery();
                    // the DB Query checks whether on ore more lock period(s) lie(s) in vacation request time period
                    var lockList = dbqLock.SelectLockPeriods(_vacationRequest);
                    if (lockList.Count() > 0)
                    {
                        result = false;
                    }
                    break;

                case CHECK_CATEGORY_VACATION_OVERLAP_PERIOD:
                    DBQuery dbqDeputy = new DBQuery();
                    String deputyID = dbqDeputy.SelectDeputy(_vacationRequest);
                    if ( !deputyID.Equals("null") && deputyID != String.Empty)
                    {
                        var overlapList = dbqDeputy.SelectUncanceledEmployeeVacationRequestInTimePeriod(_vacationRequest, deputyID);
                        if (overlapList.Count() > 0)
                        {
                            foreach (var i in overlapList)
                            {
                                //change OverlapNote of existing VacationRequest of Deputy
                                DBQuery dbq = new DBQuery();
                                dbq.UpdateVacationRequestPeriodOverlapNote(i.Item1, true);
                            }
                            result = false;
                        }
                    }
                    break;
                default: break;
            }
            return result;
        }
コード例 #2
0
        /// <summary>
        /// (1) checks if remaining vacation days of employee suffice, 
        /// (2) sets lock period flag if appropriate,
        /// (3) sets vacation period overlap flag if appropriate
        /// </summary>
        /// <param name="VacationRequest"> a vacation request, passed by reference</param>
        /// <returns></returns>
        public Boolean Validate(VacationRequest VacationRequest)
        {
            Boolean result = false;

            ///<remarks> this value must be numeric</remarks>
            //checks remaining vacation days
            DBQuery dbq = new DBQuery();
            int remainingVacationDays = dbq.SelectRemainingVacationDays(VacationRequest.getEmployeeID());

            // determine working days in vacation request
            int vacationWorkingDays = VacationRequest.DetermineWorkingDaysInVacationRequest(VacationRequest);

            // only proceed if time period of vacation request contains working days
            if (vacationWorkingDays > 0)
            {
                VacationRequest.setNetVacationDays(vacationWorkingDays);

                // Check  VacationRequest overlap with others already existing VacationRequests of Requester without state "canceled"
                var VRList = dbq.SelectUncanceledEmployeeVacationRequestInTimePeriod(VacationRequest, VacationRequest.getEmployeeID());

                Boolean overlap = false;
                Boolean insufficientRemainingVacationDays = false;

                if (VRList.Count > 0)
                {
                    overlap = true;
                    ErrorState.ErrorStateInstance.setError(ErrorState.OVERLAP_WITH_OWN_VACATION_REQUEST);
                }
                if (remainingVacationDays < vacationWorkingDays)
                {
                    insufficientRemainingVacationDays = true;
                    ErrorState.ErrorStateInstance.setError(ErrorState.INSUFFICIENT_REMAINING_VACATION_DAYS);
                }
                // if requester has enough remaining Vacation Days AND no submitted vacation request(s) in this time period, go ahead
                if (!insufficientRemainingVacationDays && !overlap)
                {
                    TimePeriodOverlapCheck check = new TimePeriodOverlapCheck(VacationRequest);

                    //check lock period
                    if (!check.Validate(TimePeriodOverlapCheck.CHECK_CATEGORY_LOCK_PERIOD))
                    {
                        //overlap existing
                        VacationRequest.setVacationLockPeriodNote(true);
                    }

                    //check overlap period with Deputy
                    if (!check.Validate(TimePeriodOverlapCheck.CHECK_CATEGORY_VACATION_OVERLAP_PERIOD))
                    {
                        //overlap existing
                        VacationRequest.setVacationPeriodOverlapNote(true);
                    }

                    if (VacationRequest.getVacationStartDate() < DateTime.Now)
                    {
                        //if VacationRequestEndDate is in past the new Processingstatus is: agreed, so the decision of the DivisionManager is the next step
                        VacationRequest.setVacationRequestProcessingState(VacationRequestProcessingState.agreed);
                    }
                    result = true;
                }
            }
            else
            {
                ErrorState.ErrorStateInstance.setError(ErrorState.ZERO_NET_VACATION_DAYS_IN_VACATION_REQUEST);
            }
            return result;
        }
コード例 #3
0
        /// <summary>
        /// Removes the TRUE-flag in all vacation requests of the shift partner, if the given vacation request is cancelled by its requester.
        /// Use requester ID of vacation request to identity the shiftpartner and startdate and enddate to retrieve vacation requests of the deputy
        /// </summary>
        /// <param name="vacationRequest">use requesterID to find deputy, use time period to specify overlap time period </param>
        /// <returns>TRUE if successful, else FALSE</returns>
        private Boolean RemoveVacationPeriodOverlapNote(VacationRequest vacationRequest)
        {
            Boolean result = true;
            DBQuery dbq = new DBQuery();

            String deputyID = dbq.SelectDeputy(vacationRequest);
            if (!deputyID.Equals("null") && deputyID != String.Empty)
            {
                var overlapList = dbq.SelectUncanceledEmployeeVacationRequestInTimePeriod(vacationRequest, deputyID);
                if (overlapList.Count > 0)
                {
                    foreach (var i in overlapList)
                    {
                        //change OverlapNote of existing VacationRequest of Deputy
                        result = dbq.UpdateVacationRequestPeriodOverlapNote(i.Item1, false);
                        if (!result) break;
                    }
                }
            }
            return result;
        }