Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        protected override void DeleteValidate(NobatKari nobatKari)
        {
            ShiftRepository shiftRep = new ShiftRepository(false);
            int             count    = shiftRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new Shift().NobatKari), nobatKari));

            if (count > 0)
            {
                NHibernateSessionManager.Instance.RollbackTransactionOn();
                UIValidationExceptions exception = new UIValidationExceptions();
                exception.Add(ExceptionResourceKeys.NobatKariUsedByShift, "این نوبت کاری به شیفت انتساب داده شده است", ExceptionSrc);
                throw exception;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// «اعتبارسنجی
        /// «نام شیفت خالی نباشد
        /// «نام شیفت تکراری نباشد
        /// «رنگ شیفت نباید خالی باشد
        /// «رنگ شیفت نباید تکراری باشد
        /// « کد تعریف شده نباید تکراری باشد
        /// </summary>
        /// <param name="shift"></param>
        protected override void UpdateValidate(Shift shift)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (Utility.IsEmpty(shift.Name))
            {
                exception.Add(ExceptionResourceKeys.ShiftNameRequierd, "بروزرسانی - نام شیفت نباید خالی باشد", ExceptionSrc);
            }
            else
            {
                if (shiftRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => shift.Name), shift.Name),
                                                       new CriteriaStruct(Utility.GetPropertyName(() => shift.ID), shift.ID, CriteriaOperation.NotEqual)) > 0)
                {
                    exception.Add(ExceptionResourceKeys.ShiftNameRepeated, "بروزرسانی - نام شیفت نباید تکراری باشد", ExceptionSrc);
                }
            }

            if (Utility.IsEmpty(shift.Color))
            {
                exception.Add(ExceptionResourceKeys.ShiftColorRequierd, "بروزرسانی - رنگ شیفت نباید خالی باشد", ExceptionSrc);
            }
            else
            {
                if (shiftRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => shift.Color), shift.Color),
                                                       new CriteriaStruct(Utility.GetPropertyName(() => shift.ID), shift.ID, CriteriaOperation.NotEqual)) > 0)
                {
                    exception.Add(ExceptionResourceKeys.ShiftColorRepeated, "بروزرسانی - رنگ شیفت نباید تکراری باشد", ExceptionSrc);
                }
            }

            if (shift.ShiftType == null)
            {
                exception.Add(ExceptionResourceKeys.ShiftTypeRequierd, "بروزرسانی - نوع شیفت نباید خالی باشد", ExceptionSrc);
            }
            else if (shift.ShiftType != ShiftTypesEnum.COMPENSATION_OVERTIME &&
                     shift.ShiftType != ShiftTypesEnum.OVERTIME &&
                     shift.ShiftType != ShiftTypesEnum.WORK)
            {
                exception.Add(ExceptionResourceKeys.ShiftTypeRequierd, "بروزرسانی - نوع شیفت نامعتبر میباشد", ExceptionSrc);
            }

            if (!Utility.IsEmpty(shift.CustomCode))
            {
                if (shiftRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => shift.CustomCode), shift.CustomCode),
                                                       new CriteriaStruct(Utility.GetPropertyName(() => shift.ID), shift.ID, CriteriaOperation.NotEqual)) > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.ShiftCustomCodeRepeated, "بروزرسانی - کد گروه کاری نباید تکراری باشد7", ExceptionSrc));
                }
            }

            if (exception.Count > 0)
            {
                throw exception;
            }
        }