예제 #1
0
 internal StopWorksBLL MapStopWork(StopWorks StopWork)
 {
     try
     {
         StopWorksBLL StopWorkBLL = null;
         if (StopWork != null)
         {
             StopWorkBLL = new StopWorksBLL()
             {
                 StopWorkID                  = StopWork.StopWorkID,
                 StopWorkStartDate           = StopWork.StopWorkStartDate.Date,
                 StopWorkEndDate             = StopWork.StopWorkEndDate.Value.Date,
                 StartStopWorkDecisionNumber = StopWork.StartStopWorkDecisionNumber,
                 StartStopWorkDecisionDate   = StopWork.StartStopWorkDecisionDate, // != null?StopWork.StartStopWorkDecisionDate.Value.Date : Convert.ToDateTime(null),
                 EndStopWorkDecisionNumber   = StopWork.EndStopWorkDecisionNumber,
                 EndStopWorkDecisionDate     = StopWork.EndStopWorkDecisionDate,   //!= null ? StopWork.EndStopWorkDecisionDate.Value.Date : Convert.ToDateTime(null),
                 Note                  = StopWork.Note,
                 StopPoint             = StopWork.StopPoint,
                 EmployeeCareerHistory = new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(StopWork.EmployeesCareersHistory),
                 IsConvicted           = StopWork.IsConvicted,
                 StopWorkType          = new StopWorksTypesBLL().MapStopWorkType(StopWork.StopWorksTypes),
                 CreatedBy             = new EmployeesCodesBLL().MapEmployeeCode(StopWork.CreatedByNav),
                 CreatedDate           = StopWork.CreatedDate,
                 LastUpdatedDate       = StopWork.LastUpdatedDate,
             };
         }
         return(StopWorkBLL);
     }
     catch
     {
         throw;
     }
 }
예제 #2
0
        public Result EndStopWork()
        {
            Result result = null;

            #region Check EndDate Should be more than startDate
            if (this.StopWorkEndDate < this.StopWorkStartDate)
            {
                result            = new Result();
                result.Entity     = this;
                result.EnumMember = StopWorkValidationEnum.RejectedBecauseOfEndDateShouldBeMoreThanStartDate.ToString();
                result.EnumType   = typeof(StopWorkValidationEnum);
                return(result);
            }
            #endregion

            #region Check is there another stopwork not ended
            StopWorks StopWork = new StopWorksDAL().GetByStopWorkID(this.StopWorkID);
            if (StopWork.EmployeesCareersHistory.EmployeeCareerHistoryID == this.EmployeeCareerHistory.EmployeeCareerHistoryID)
            {
                result = IsThereStopWorkNotEnding(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID, this.StopWorkID);
                if (result != null)
                {
                    if (this.IsConvicted == null)// && ((StopWorksBLL)result.Entity).IsConvicted != this.IsConvicted)
                    {
                        return(result);
                    }
                }
            }
            else
            {
                result = IsThereStopWorkNotEnding(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID);
                if (result != null)
                {
                    return(result);
                }
            }
            #endregion

            StopWorks stopWork = new StopWorks()
            {
                StopWorkID = this.StopWorkID,
                EmployeeCareerHistoryID     = this.EmployeeCareerHistory.EmployeeCareerHistoryID,
                StopWorkEndDate             = this.StopWorkEndDate,
                StopWorkStartDate           = this.StopWorkStartDate,
                StartStopWorkDecisionNumber = this.StartStopWorkDecisionNumber,
                StartStopWorkDecisionDate   = this.StartStopWorkDecisionDate,
                EndStopWorkDecisionDate     = this.EndStopWorkDecisionDate,
                EndStopWorkDecisionNumber   = this.EndStopWorkDecisionNumber,
                StopPoint       = this.StopPoint,
                IsConvicted     = this.IsConvicted,
                StopWorkTypeID  = this.StopWorkType.StopWorkTypeID,
                Note            = this.Note,
                LastUpdatedDate = DateTime.Now,
                LastUpdatedBy   = this.LoginIdentity.EmployeeCodeID
            };
            new StopWorksDAL().EndStopWork(stopWork);

            this.EmployeeCareerHistory = new EmployeesCareersHistoryBLL().GetByEmployeeCareerHistoryID(this.EmployeeCareerHistory.EmployeeCareerHistoryID);
            new BaseAssigningsBLL()
            {
                LoginIdentity = this.LoginIdentity
            }.BreakLastAssigning(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID,
                                 this.StopWorkEndDate.HasValue ? this.StopWorkEndDate.Value : DateTime.Now,
                                 AssigningsReasonsEnum.StopWorkFinished);

            result = new Result()
            {
                Entity     = this,
                EnumType   = typeof(StopWorkValidationEnum),
                EnumMember = StopWorkValidationEnum.Done.ToString()
            };

            return(result);
        }
예제 #3
0
        public virtual Result Add()
        {
            Result result;

            result = CommonHelper.IsNoConflictWithOtherProcess(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID, this.StopWorkStartDate, this.StopWorkEndDate ?? DateTime.Now);

            if (result != null)
            {
                return(result);
            }

            #region
            if (this.StopWorkEndDate == null)
            {
                this.StopWorkEndDate = this.StopWorkStartDate.AddYears(10);
            }
            #endregion

            #region Check EndDate Should be more than startDate
            if (this.StopWorkEndDate < this.StopWorkStartDate)
            {
                result            = new Result();
                result.Entity     = this;
                result.EnumMember = StopWorkValidationEnum.RejectedBecauseOfEndDateShouldBeMoreThanStartDate.ToString();
                result.EnumType   = typeof(StopWorkValidationEnum);
                return(result);
            }
            #endregion

            #region Check is there another stopwork not ended
            result = IsThereStopWorkNotEnding(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID);
            if (result != null)
            {
                return(result);
            }
            #endregion

            StopWorks stopWork = new StopWorks()
            {
                CreatedBy                   = this.LoginIdentity.EmployeeCodeID,
                StopWorkEndDate             = this.StopWorkEndDate,
                StopWorkStartDate           = this.StopWorkStartDate,
                StartStopWorkDecisionNumber = this.StartStopWorkDecisionNumber,
                StartStopWorkDecisionDate   = this.StartStopWorkDecisionDate,
                EndStopWorkDecisionNumber   = this.EndStopWorkDecisionNumber,
                EndStopWorkDecisionDate     = this.EndStopWorkDecisionDate,
                EmployeeCareerHistoryID     = this.EmployeeCareerHistory.EmployeeCareerHistoryID,
                StopPoint                   = this.StopPoint,
                IsConvicted                 = this.IsConvicted,
                Note           = this.Note,
                StopWorkTypeID = this.StopWorkType.StopWorkTypeID,
                CreatedDate    = DateTime.Now
            };

            this.StopWorkID = new StopWorksDAL().Insert(stopWork);

            result            = new Result();
            result.Entity     = this;
            result.EnumMember = StopWorkValidationEnum.Done.ToString();
            result.EnumType   = typeof(StopWorkValidationEnum);
            return(result);
        }