Example #1
0
        protected override void DeleteValidate(Role role)
        {
            UIValidationExceptions exception = new UIValidationExceptions();
            int  count          = userRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new User().Role), role));
            Role roleAlias      = null;
            int  customCodeRole = 0;
            Role roleObj        = (Role)NHibernateSessionManager.Instance.GetSession().QueryOver <Role>(() => roleAlias)
                                  .Where(() => roleAlias.ID == role.ID).SingleOrDefault();

            int.TryParse(roleObj.CustomCode, out customCodeRole);
            NHibernateSessionManager.Instance.GetSession().Evict(roleObj);
            if (customCodeRole != 0 && Enum.IsDefined(typeof(RoleCustomCodeType), customCodeRole))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.RoleSystemNotAllowedDelete, "نقش های سیستمی قابل حذف نمی باشد", ExceptionSrc));
            }
            else if (count > 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.RoleUSedByUser, "حذف - این نقش در تعریف کاربران استفاده شده است", ExceptionSrc));
            }
            if (roleRep.IsRoot(role.ID))
            {
                exception.Add(ExceptionResourceKeys.RoleRootDeleteIllegal, "ریشه نقش نباید حذف شود", ExceptionSrc);
                throw exception;
            }
            if (exception.Count > 0)
            {
                throw exception;
            }
        }
        protected override void UpdateValidate(SecondaryConcept obj)
        {
            GeneralValidation(obj);

            UIValidationExceptions exception = new UIValidationExceptions();

            if (_cnpRep.GetAll().Any(x => x.ID != obj.ID && x.Name.ToUpper().Equals(obj.Name.ToUpper())))
            {
                exception.Add(ExceptionResourceKeys.BSecondaryConceptCodeRepeated, "نام تكراري است", ExceptionSrc);
            }

            if (_cnpRep.GetAll().Any(x => x.ID != obj.ID && x.IdentifierCode.Equals(obj.IdentifierCode)))
            {
                exception.Add(ExceptionResourceKeys.BSecondaryConceptCodeRepeated, "كد تكراري است", ExceptionSrc);
            }

            if (_cnpRep.GetAll().Where(x => x.ID != obj.ID && x.Color == obj.Color).FirstOrDefault() != null)
            {
                exception.Add(ExceptionResourceKeys.BSecondaryConceptCodeRepeated, "رنگ تكراري است", ExceptionSrc);
            }

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #3
0
        protected override void InsertValidate(RuleTemplate obj)
        {
            GeneralValidation(obj);

            UIValidationExceptions exception      = new UIValidationExceptions();
            RuleRepository         ruleRepository = new RuleRepository();
            //if (ruleRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => obj.Name), obj.Name)) > 0)
            //if (ruleRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new RuleTemplate().Name), obj.Name.ToLower())) > 0)
            IList <RuleTemplate> NamequeryOnRule = NHSession.QueryOver <RuleTemplate>()
                                                   .Where(x => x.Name == obj.Name)
                                                   .List <RuleTemplate>();

            if (NamequeryOnRule.Count > 0)
            {
                //if (54ll().Any(x => x.Name.ToUpper().Equals(obj.Name.ToUpper())))
                exception.Add(ExceptionResourceKeys.BRuleCodeRepeated, "نام تكراري است", ExceptionSrc);
            }
            //if (GetAll().Any(x => x.IdentifierCode.Equals(obj.IdentifierCode)))
            //if (ruleRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => obj.IdentifierCode), obj.IdentifierCode)) > 0)
            IList <RuleTemplate> CodequeryOnRule = NHSession.QueryOver <RuleTemplate>().Where(x => x.IdentifierCode == obj.IdentifierCode).List <RuleTemplate>();

            if (CodequeryOnRule.Count > 0)
            {
                exception.Add(ExceptionResourceKeys.BRuleCodeRepeated, "كد تكراري است", ExceptionSrc);
            }
            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="report"></param>
        protected override void UpdateValidate(Report report)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (!this.IsReportRoot(report.ID) &&
                Utility.IsEmpty(report.ParentId))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ReportParentIDRequierd, "نام والد گزارش باید مشخص شود", ExceptionSrc));
            }

            if (Utility.IsEmpty(report.Name))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ReportNameRequierd, "نام گزارش باید مشخص شود", ExceptionSrc));
            }

            else if (report.ParentId != 0 &&
                     reportRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => report.Name), report.Name),
                                                  new CriteriaStruct(Utility.GetPropertyName(() => report.ParentId), report.ParentId),
                                                  new CriteriaStruct(Utility.GetPropertyName(() => report.ID), report.ID, CriteriaOperation.NotEqual)) > 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ReportRepeatedName, "نام گزارش در یک سطح نباید تکراری باشد", ExceptionSrc));
            }

            if (report.IsReport && (report.ReportFile == null || report.ReportFile.ID == 0))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ReportFileNotSpecified, "فایل گزارش انتخاب نشده است", ExceptionSrc));
            }

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #5
0
        protected override void InsertValidate(RuleCategory ruleCategory)
        {
            if (!this.EnableInsertValidate)
            {
                return;
            }

            UIValidationExceptions exception = new UIValidationExceptions();

            if (Utility.IsEmpty(ruleCategory.Name))
            {
                exception.Add(ExceptionResourceKeys.RuleCategoryNameRequierd, "درج - نام دسته قانون نباید خالی باشد", ExceptionSrc);
            }
            else
            {
                if (RuleCategoryRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => ruleCategory.Name), ruleCategory.Name)) > 0)
                {
                    exception.Add(ExceptionResourceKeys.RuleCategoryNameRepeated, "درج - نام دسته قانون نباید تکراری باشد", ExceptionSrc);
                }
                //TODO: درصورتیکه نیاز شد عملیات به دلیل وارد نکردن قانون برای دسته قانون متوقف شود این کد اصلاح گردد
                //else if (ruleCategory.InsertedTemplateIDs == null
                //            ||
                //         ruleCategory.InsertedTemplateIDs.Count() == 0)
                //{
                //    return ;
                //}
            }

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #6
0
        protected override void UpdateValidate(Contractor obj)
        {
            UIValidationExceptions exception = new UIValidationExceptions();
            Boolean IsDefault = this.GetIsDefault(obj);

            if (Utility.IsEmpty(obj.Name))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ContractorNameIsEmpty, "نام پیمانکار نباید خالی باشد", ExceptionSrc));
            }
            if (obj.Code != string.Empty && objectRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new Contractor().Code), obj.Code.ToLower()),
                                                                         new CriteriaStruct(Utility.GetPropertyName(() => new Contractor().ID), obj.ID, CriteriaOperation.NotEqual)) > 0
                )
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ContractorCodeRepeated, "کد پیمانکار تکراری می باشد", ExceptionSrc));
            }
            if (obj.EconomicCode != string.Empty && objectRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new Contractor().EconomicCode), obj.EconomicCode.ToLower()),
                                                                                 new CriteriaStruct(Utility.GetPropertyName(() => new Contractor().ID), obj.ID, CriteriaOperation.NotEqual)) > 0
                )
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ContractorEconomicCodeRepeated, "کد اقتصادی تکراری می باشد", ExceptionSrc));
            }
            if (IsDefault == true && obj.IsDefault == false)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.AtLeastOneContractorMustBeSelectForDefault, "حداقل یکی از پیمانکاران به صورت پیش فرض باید انتخاب شود", ExceptionSrc));
            }
            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #7
0
        /// <summary>
        /// نام جریان خالی نباشد
        /// نام جریان تکراری نباشد
        /// گروه پیشکارت خالی نباشد
        /// </summary>
        /// <param name="flow"></param>
        protected override void UpdateValidate(Flow flow)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (Utility.IsEmpty(flow.FlowName))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.FlowNameRequierd, "نام جریان نباید خالی باشد", ExceptionSrc));
            }
            else
            {
                int count =
                    flowRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new Flow().FlowName), flow.FlowName),
                                               new CriteriaStruct(Utility.GetPropertyName(() => new Flow().ID), flow.ID, CriteriaOperation.NotEqual));
                if (count > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.FlowNameRepeated, "نام جریان نباید تکراری باشد", ExceptionSrc));
                }
            }
            if (flow.AccessGroup == null || flow.AccessGroup.ID == 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.FlowAccessGroupRequierd, "گروه پیشکارت نباید خالی باشد", ExceptionSrc));
            }


            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="assignWorkGroup">گروه کاری تخصیص داده شده به پرسنل</param>
        protected override void InsertValidate(AssignWorkGroup assignWorkGroup)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            PersonRepository    personRep = new PersonRepository(false);
            WorkGroupRepository workRep   = new WorkGroupRepository(false);

            if (assignWorkGroup.Person == null || personRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new Person().ID), assignWorkGroup.Person.ID)) == 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.AssignWorkGroupPersonIdNotExsits, "پرسنلی با این مشخصات یافت نشد", ExceptionSrc));
            }

            if (assignWorkGroup.WorkGroup == null || workRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new WorkGroup().ID), assignWorkGroup.WorkGroup.ID)) == 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.AssignWorkGroupIdNotExsits, "گروه کاری با این مشخصات یافت نشد", ExceptionSrc));
            }
            if (assignWorkGroup.FromDate < Utility.GTSMinStandardDateTime)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.AssignWorkGroupSmallerThanStandardValue, "مقدار تاریخ انتساب گروه محدوده محاسبات از حد مجاز کمتر میباشد", ExceptionSrc));
            }
            if (asignRepository.Find(x => x.Person.ID == assignWorkGroup.Person.ID && x.FromDate.Date == assignWorkGroup.FromDate.Date).Count() > 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.AssignWorkGroupIsRepeated, "تاریخ تکراری است", ExceptionSrc));
            }
            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="calenderType"></param>
        protected override void InsertValidate(CalendarType calenderType)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (Utility.IsEmpty(calenderType.Name))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.CalendarNameRequierd, "درج - نام نباید خالی باشد", ExceptionSrc));
            }
            else if (calendarTypeRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => calenderType.Name), calenderType.Name)) > 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.CalendarNameRepeated, "درج - نام نباید تکراری باشد", ExceptionSrc));
            }

            if (Utility.IsEmpty(calenderType.CustomCode))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.CalendarCustomCodeRequierd, "درج - نام نباید خالی باشد", ExceptionSrc));
            }
            else if (calendarTypeRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => calenderType.CustomCode), calenderType.CustomCode)) > 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.CalendarCustomCodeRepeated, "درج - نام نباید تکراری باشد", ExceptionSrc));
            }

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
        protected override void InsertValidate(DesignedReportGroupColumn obj)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (obj.Column == null || obj.Column.ID == 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.DesignedReportColumnIsRequired, "ستونی جهت ثبت انتخاب نشده است.", ExceptionSrc));
            }
            else if (GetDesignedReportGroupColumns(obj.Report.ID, obj.Person.ID).Count > 4)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.DesignedReportColumnIsMax, "حداکثر تعداد ستون های گره بندی 5 می باشد.", ExceptionSrc));
            }
            else
            {
                DesignedReportGroupColumn groupColumnAilas = null;
                int groupColumnCount = NHSession.QueryOver <DesignedReportGroupColumn>(() => groupColumnAilas)
                                       .Where(() => groupColumnAilas.Column.ID == obj.Column.ID && groupColumnAilas.Person.ID == obj.Person.ID && groupColumnAilas.Report.ID == obj.Report.ID).RowCount();

                if (groupColumnCount > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.DesignedReportColumnIsRepeated, "ستون انتخابی تکراری می باشد.", ExceptionSrc));
                }
            }

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        protected override void InsertValidate(Substitute substitute)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (substitute.Manager == null || substitute.Manager.ID == 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.SubstituteManagerRequiered, "مدیر جانشین مشخص نشده است", ExceptionSrc));
            }
            if (substitute.Person == null || substitute.Person.ID == 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.SubstitutePersonRequiered, "جانشین مشخص نشده است", ExceptionSrc));
            }

            if (substitute.Manager != null && substitute.Manager.ID != 0 && substitute.Person != null && substitute.Person.ID != 0 && GetSubstituteManagerPersonID(substitute) == substitute.Person.ID)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.SubstitutePersonMustNotEqualtoManager, "جانشین نباید با مدیر یکسان باشد", ExceptionSrc));
            }

            if (substitute.FromDate == Utility.GTSMinStandardDateTime || substitute.ToDate == Utility.GTSMinStandardDateTime)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.SubstituteDateRequired, "بازه تاریخی جانشین نامعتبر است ", ExceptionSrc));
            }
            else if (substitute.FromDate > substitute.ToDate)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.SubstituteFromDateGreaterThanToDate, "ابتدای تاریخ از انتها بزرگتر است ", ExceptionSrc));
            }


            if (exception.Count > 0)
            {
                throw exception;
            }
        }
        protected override void UpdateValidate(ApprovalAttendanceScheduleException obj)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (obj.DateTo == null)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ApprovalScheduleDateToRequired, "ویرایش - تاریخ ابتدا نباید خالی باشد", ExceptionSrc));
            }
            if (obj.DateFrom == null)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ApprovalScheduleDateFromRequired, "ویرایش - تاریخ انتها نباید خالی باشد", ExceptionSrc));
            }
            if (obj.Person == null)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ApprovalScheduleCostCenterRequired, "ویرایش - پرسنل نباید خالی باشد", ExceptionSrc));
            }
            if (obj.DateFrom >= obj.DateTo)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ApprovalScheduleDateValidRequired, "ویرایش - بازه ی تاریخی معتبر نمی باشد", ExceptionSrc));
            }
            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #13
0
        /// <summary>
        /// «اعتبارسنجی
        /// «نام نباید خالی باشد
        /// «نام  تکراری نباشد
        /// نظام پزشکی در صورت تهی نبودن باید یکتا باشد
        /// </summary>
        /// <param name="doctor">دکتر</param>
        protected override void InsertValidate(Doctor doctor)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (Utility.IsEmpty(doctor.LastName))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.DoctorLastNameRequierd, "درج - نام نباید خالی باشد", ExceptionSrc));
            }
            if (Utility.IsEmpty(doctor.Nezampezaeshki))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.DoctorNazampezeshkiRequired, "درج - کد نظام پزشکی نباید خالی باشد", ExceptionSrc));
            }
            else
            {
                if (staionRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => doctor.Nezampezaeshki), doctor.Nezampezaeshki)) > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.DoctorNezampezeshkiRepeated, "درج - کد نظام پزشکی نباید تکراری باشد", ExceptionSrc));
                }
            }

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #14
0
        /// <summary>
        /// «اعتبارسنجی
        /// «نام نباید خالی باشد
        /// «نام  تکراری نباشد
        /// کد تعریف شده نباید تکراری باشد
        /// </summary>
        /// <param name="station"></param>
        protected override void InsertValidate(ControlStation station)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (Utility.IsEmpty(station.Name))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.StationNameRequierd, "درج - نام نباید خالی باشد", ExceptionSrc));
            }
            else if (staionRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => station.Name), station.Name)) > 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.StationNameRepeated, "درج - نام نباید تکراری باشد", ExceptionSrc));
            }

            if (!Utility.IsEmpty(station.CustomCode))
            {
                if (staionRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => station.CustomCode), station.CustomCode)) > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.StationCustomCodeRepeated, "درج - کد ایستگاه نباید تکراری باشد", ExceptionSrc));
                }
            }
            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #15
0
        protected override void InsertValidate(Contract obj)
        {
            UIValidationExceptions exception = new UIValidationExceptions();
            Contract contractObj             = GetContractByTitle(obj.Title);

            if (Utility.IsEmpty(obj.Title))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ContractNameRequired, "نام قرارداد نباید خالی باشد", ExceptionSrc));
            }
            if (contractObj != null && obj.ID != contractObj.ID)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ContractTitleIsRepeated, "نام قرارداد نباید تکراری باشد", ExceptionSrc));
            }
            contractObj = GetContractByCode(obj.Code);
            if (contractObj != null && obj.ID != contractObj.ID && obj.Code != string.Empty)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ContractCodeIsRepeated, "کد قرارداد نباید تکراری باشد", ExceptionSrc));
            }

            if (obj.Contractor == null || obj.Contractor.ID == 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ContractContractorRequired, "پیمانکار قرارداد باید انتخاب شود", ExceptionSrc));
            }
            NHSession.Evict(contractObj);

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="calenderType"></param>
        protected override void UpdateValidate(CalendarType calenderType)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            //this.CheckUserInterfaceRuleGroup();

            if (Utility.IsEmpty(calenderType.Name))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.CalendarNameRequierd, "ویرایش - نام نباید خالی باشد", ExceptionSrc));
            }
            else if (calendarTypeRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => calenderType.Name), calenderType.Name),
                                                        new CriteriaStruct(Utility.GetPropertyName(() => calenderType.ID), calenderType.ID, CriteriaOperation.NotEqual)) > 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.CalendarNameRepeated, "ویرایش - نام نباید تکراری باشد", ExceptionSrc));
            }

            if (Utility.IsEmpty(calenderType.CustomCode))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.CalendarCustomCodeRequierd, "ویرایش - نام نباید خالی باشد", ExceptionSrc));
            }
            else if (calendarTypeRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => calenderType.CustomCode), calenderType.CustomCode),
                                                        new CriteriaStruct(Utility.GetPropertyName(() => calenderType.ID), calenderType.ID, CriteriaOperation.NotEqual)) > 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.CalendarCustomCodeRepeated, "ویرایش - نام نباید تکراری باشد", ExceptionSrc));
            }

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #17
0
        protected override void InsertValidate(Contractor obj)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (Utility.IsEmpty(obj.Name))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ContractorNameIsEmpty, "نام پیمانکار نباید خالی باشد", ExceptionSrc));
            }
            if (obj.Code != string.Empty && objectRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new Contractor().Code), obj.Code.ToLower()),
                                                                         new CriteriaStruct(Utility.GetPropertyName(() => new Contractor().ID), obj.ID, CriteriaOperation.NotEqual)) > 0
                )
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ContractorCodeRepeated, "کد پیمانکار تکراری می باشد", ExceptionSrc));
            }
            if (obj.EconomicCode != string.Empty && objectRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new Contractor().EconomicCode), obj.EconomicCode.ToLower()),
                                                                                 new CriteriaStruct(Utility.GetPropertyName(() => new Contractor().ID), obj.ID, CriteriaOperation.NotEqual)) > 0
                )
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.ContractorEconomicCodeRepeated, "کد اقتصادی تکراری می باشد", ExceptionSrc));
            }
            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="calenderType"></param>
        protected override void DeleteValidate(CalendarType calenderType)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            EntityRepository <HolidaysTemplate> holidayRep = new EntityRepository <HolidaysTemplate>();

            int count = holidayRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new HolidaysTemplate().CalendarTypeId), calenderType.ID));

            if (count > 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.CalendarTypeUsedInHolidayTemplates, "حذف - این نوع تعطیلات بدلیل دارا بودن تمپلیت قابل حذف نیست", ExceptionSrc));
            }

            CalendarType calendarObj = GetByID(calenderType.ID);

            if (calendarObj.YearlyHolidayWorkGroupsList.Count > 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.CalendarTypeAssignWorkGroup, "تقویم تعطیلات سالیانه به گروه های کاری انتساب داده شده است", ExceptionSrc));
            }
            NHSession.Evict(calendarObj);
            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #19
0
        /// <summary>
        /// اعتبار سنجی عملیات ویرایش مرکز هزینه پرسنل
        /// </summary>
        /// <param name="CostCenter">مرکز هزینه پرسنل</param>
        protected override void UpdateValidate(CostCenter CostCenter)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (Utility.IsEmpty(CostCenter.Name))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.CostCenterNameRequierd, "نام نباید خالی باشد", ExceptionSrc));
            }
            else
            {
                if (CostCenterRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => CostCenter.Name), CostCenter.Name),
                                                            new CriteriaStruct(Utility.GetPropertyName(() => CostCenter.ID), CostCenter.ID, CriteriaOperation.NotEqual)) > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.CostCenterNameRepeated, "نام نباید تکراری باشد", ExceptionSrc));
                }
            }
            if (!Utility.IsEmpty(CostCenter.Code))
            {
                if (CostCenterRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => CostCenter.Code), CostCenter.Code),
                                                            new CriteriaStruct(Utility.GetPropertyName(() => CostCenter.ID), CostCenter.ID, CriteriaOperation.NotEqual)) > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.CostCenterCodeRepeated, "کد نباید تکراری باشد", ExceptionSrc));
                }
            }


            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #20
0
        /// <summary>
        /// نام خالی نباشد
        /// شناسه والد معتبر باشد
        /// اعتبار سنجی آیتمی که قرار است بروزرسانی شود
        /// نام در گرهای همسطح تکراری نباشد
        /// کد تعریف شده نباید تکراری باشد
        /// </summary>
        /// <param name="dep"></param>
        /// <param name="exception"></param>
        protected override void UpdateValidate(Department dep)
        {
            // والد یک گره بروزرسانی نمیشود .همچنین بنا به محدودیتهای کلاینت هنگام بروزرسانی والد مقداردهی نمیشود
            dep.ParentID = departmentRepository.GetParentID(dep.ID);

            UIValidationExceptions exception = new UIValidationExceptions();

            if (Utility.IsEmpty(dep.Name))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.DepNameRequierd, "نام بخش باید مشخص شود", ExceptionSrc));
            }

            else if (dep.ParentID != 0 &&
                     departmentRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => dep.Name), dep.Name),
                                                             new CriteriaStruct(Utility.GetPropertyName(() => dep.Parent), dep.Parent),
                                                             new CriteriaStruct(Utility.GetPropertyName(() => dep.ID), dep.ID, CriteriaOperation.NotEqual)) > 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.DepartmentRepeatedName, "نام بخش در یک سطح نباید تکراری باشد", ExceptionSrc));
            }

            if (!Utility.IsEmpty(dep.CustomCode))
            {
                if (departmentRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => dep.CustomCode), dep.CustomCode),
                                                            new CriteriaStruct(Utility.GetPropertyName(() => dep.ID), dep.ID, CriteriaOperation.NotEqual)) > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.DepartCustomCodeRepeated, "بروزرسانی - کد تعریف شده در بخش نباید تکراری باشد", ExceptionSrc));
                }
            }

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #21
0
        protected override void UpdateValidate(Role role)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            role.ParentId = roleRep.GetParentId(role.ID);
            if (Utility.IsEmpty(role.Name))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.RoleNameRequierd, "بروزرسانی - نام نقش نباید خالی باشد", ExceptionSrc));
            }
            else if (roleRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => role.Name), role.Name),
                                                new CriteriaStruct(Utility.GetPropertyName(() => role.ID), role.ID, CriteriaOperation.NotEqual)) > 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.RoleNameReplication, "بروزرسانی - نام نقش نباید تکراری باشد", ExceptionSrc));
            }

            if (!Utility.IsEmpty(role.CustomCode))
            {
                if (roleRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => role.CustomCode), role.CustomCode),
                                               new CriteriaStruct(Utility.GetPropertyName(() => role.ID), role.ID, CriteriaOperation.NotEqual)) > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.RoleCodeReplication, "بروزرسانی - کد نقض نباید تکراری باشد", ExceptionSrc));
                }
            }
            if (role.ParentId == 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.RoleParentNotSpecified, "درج - والد انتخاب نشده است", ExceptionSrc));
            }
            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #22
0
        /// <summary>
        /// ویرایش محل ماموریت در دیتابیس
        /// </summary>
        /// <param name="dutyPlace">محل ماموریت</param>
        protected override void UpdateValidate(DutyPlace dutyPlace)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (Utility.IsEmpty(dutyPlace.Name))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.DutyPlaceNameRequierd, "نام نباید خالی باشد", ExceptionSrc));
            }
            else
            {
                if (dutyPlaceRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => dutyPlace.Name), dutyPlace.Name),
                                                    new CriteriaStruct(Utility.GetPropertyName(() => dutyPlace.ID), dutyPlace.ID, CriteriaOperation.NotEqual)) > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.DutyPlaceNameRepeated, "نام نباید تکراری باشد", ExceptionSrc));
                }
            }

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

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #23
0
        /// <summary>
        /// اعتبارسنجی
        /// نام نباید خالی باشد
        /// نام نوبت کاری تکراری نباشد
        /// کد تعریف شده باید تکراری باشد
        /// </summary>
        /// <param name="nobatKari"></param>
        protected override void UpdateValidate(NobatKari nobatKari)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (Utility.IsEmpty(nobatKari.Name))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.NobatKariNameEmpty, "نام نباید خالی باشد", ExceptionSrc));
            }
            else
            {
                if (nobatKariRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => nobatKari.Name), nobatKari.Name),
                                                           new CriteriaStruct(Utility.GetPropertyName(() => nobatKari.ID), nobatKari.ID, CriteriaOperation.NotEqual)) > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.NobatKariRepeated, "نام نباید تکراری باشد", ExceptionSrc));
                }
            }

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

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #24
0
        /// <summary>
        /// عملیات درج محل ماموریت در دیتابیس
        /// </summary>
        /// <param name="dutyPlace">محل ماموریت</param>
        protected override void InsertValidate(DutyPlace dutyPlace)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (dutyPlace.ParentID == 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.DutyPlaceParentRequest, "درج - والد باید مشخص شد", ExceptionSrc));
            }
            if (Utility.IsEmpty(dutyPlace.Name))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.DutyPlaceNameRequierd, "درج - نام نباید خالی باشد", ExceptionSrc));
            }
            else if (dutyPlaceRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => dutyPlace.Name), dutyPlace.Name)) > 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.DutyPlaceNameRepeated, "درج - نام نباید تکراری باشد", ExceptionSrc));
            }

            if (!Utility.IsEmpty(dutyPlace.CustomCode))
            {
                if (dutyPlaceRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => dutyPlace.CustomCode), dutyPlace.CustomCode)) > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.DutyPlaceCustomCodeRepeated, "درج - کد نباید تکراری باشد", ExceptionSrc));
                }
            }
            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #25
0
        protected override void UpdateValidate(RuleCategory ruleCategory)
        {
            if (!this.EnableUpdateValidate)
            {
                return;
            }
            UIValidationExceptions exception = new UIValidationExceptions();

            if (Utility.IsEmpty(ruleCategory.Name))
            {
                exception.Add(ExceptionResourceKeys.RuleCategoryNameRequierd, "بروزرسانی - نام دسته قانون نباید خالی باشد", ExceptionSrc);
            }
            else
            {
                if (RuleCategoryRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => ruleCategory.Name), ruleCategory.Name),
                                                       new CriteriaStruct(Utility.GetPropertyName(() => ruleCategory.ID), ruleCategory.ID, CriteriaOperation.NotEqual)) > 0)
                {
                    exception.Add(ExceptionResourceKeys.RuleCategoryNameRepeated, "بروزرسانی - نام دسته قانون نباید تکراری باشد", ExceptionSrc);
                }
                //TODO: کد اصلاح گردد
                //else if ((ruleCategory.InsertedTemplateIDs == null ||
                //              ruleCategory.InsertedTemplateIDs.Count() == 0)
                //            &&
                //            (ruleCategory.DeletedTemplateIDs == null ||
                //              ruleCategory.DeletedTemplateIDs.Count() == 0))
                //{
                //    return ;
                //}
            }

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #26
0
        /// <summary>
        /// «اعتبارسنجی
        /// «نام نباید خالی باشد
        /// «نام گروه کاری تکراری نباشد
        /// کد تعریف شده نباید تکراری باشد
        /// </summary>
        /// <param name="workgroup"></param>
        protected override void UpdateValidate(WorkGroup workgroup)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (Utility.IsEmpty(workgroup.Name))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.WorkGroupNameRequierd, "نام نباید خالی باشد", ExceptionSrc));
            }
            else
            {
                if (workGroupRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => workgroup.Name), workgroup.Name),
                                                    new CriteriaStruct(Utility.GetPropertyName(() => workgroup.ID), workgroup.ID, CriteriaOperation.NotEqual)) > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.WorkGroupNameRepeated, "نام نباید تکراری باشد", ExceptionSrc));
                }
            }

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

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        protected override void UpdateValidate(UIValidationGroup obj)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (Utility.IsEmpty(obj.Name))
            {
                exception.Add(ExceptionResourceKeys.ValidationGroupNameIsEmpty, "نام گروه اعتبارسنجی نباید خالی باشد", ExceptionSrc);
            }
            else
            {
                if (objectRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new UIValidationGroup().Name), obj.Name.ToLower()),
                                                 new CriteriaStruct(Utility.GetPropertyName(() => new UIValidationGroup().ID), obj.ID, CriteriaOperation.NotEqual)) > 0)
                {
                    exception.Add(ExceptionResourceKeys.ValidationGroupNameIsRepeated, "نام گروه اعتبارسنجی نباید تکراری باشد", ExceptionSrc);
                }
            }
            //if (obj.GroupingList == null || obj.GroupingList.Count == 0 || obj.GroupingList.Where(x => x.RuleID == 0).Count() > 0)
            //{
            //    exception.Add(ExceptionResourceKeys.ValidationGroupRulesIsEmpty, "برای گروه اعتبارسنجی باید قانون انتخاب شود", ExceptionSrc);
            //}

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #28
0
        /// <summary>
        /// «اعتبارسنجی
        /// «نام نباید خالی باشد
        /// «نام نوع استخدام تکراری نباشد
        /// کد تعریف شده نباید تکراری باشد
        /// </summary>
        /// <param name="empl"></param>
        protected override void UpdateValidate(EmploymentType empl)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (Utility.IsEmpty(empl.Name))
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.EmploymentTypeNameRequierd, "نام نباید خالی باشد", ExceptionSrc));
            }
            else
            {
                if (emplRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => empl.Name), empl.Name),
                                                      new CriteriaStruct(Utility.GetPropertyName(() => empl.ID), empl.ID, CriteriaOperation.NotEqual)) > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.EmploymentTypeNameRepeated, "نام نباید تکراری باشد", ExceptionSrc));
                }
            }

            if (!Utility.IsEmpty(empl.CustomCode))
            {
                if (emplRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => empl.CustomCode), empl.CustomCode),
                                                      new CriteriaStruct(Utility.GetPropertyName(() => empl.ID), empl.ID, CriteriaOperation.NotEqual)) > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.EmploymentTypeCustomCodeRepeated, "بروزرسانی - کد نوع استخدام نباید تکراری باشد", ExceptionSrc));
                }
            }

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        protected override void UpdateValidate(Substitute substitute)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (substitute.ID == 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.SubstituteIsNotSpecified, "شناسه جانشین جهت بروزرسانی مشخص نشده است", ExceptionSrc));
            }
            if (substitute.Manager == null || substitute.Manager.ID == 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.SubstituteManagerRequiered, "مدیر جانشین مشخص نشده است", ExceptionSrc));
            }

            if (substitute.Person == null || substitute.Person.ID == 0)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.SubstitutePersonRequiered, "جانشین مشخص نشده است", ExceptionSrc));
            }

            if (substitute.FromDate == Utility.GTSMinStandardDateTime || substitute.ToDate == Utility.GTSMinStandardDateTime)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.SubstituteDateRequired, "بازه تاریخی جانشین نامعتبر است ", ExceptionSrc));
            }
            else if (substitute.FromDate > substitute.ToDate)
            {
                exception.Add(new ValidationException(ExceptionResourceKeys.SubstituteFromDateGreaterThanToDate, "ابتدای تاریخ از انتها بزرگتر است ", ExceptionSrc));
            }

            if (exception.Count > 0)
            {
                throw exception;
            }
        }
Example #30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="assignRuleParameter"></param>
        protected override void UpdateValidate(AssignRuleParameter assignRuleParameter)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (assignRuleParameter.FromDate == null || assignRuleParameter.FromDate <= new DateTime(1921, 3, 21) ||
                assignRuleParameter.ToDate == null || assignRuleParameter.ToDate <= new DateTime(1921, 3, 21))
            {
                exception.Add(ExceptionResourceKeys.AssignParameterDateIsInvalid, "تاریخ ابتدا و انتها باید معتبر باشد", ExceptionSrc);
            }
            else if (assignRuleParameter.FromDate >= assignRuleParameter.ToDate)
            {
                exception.Add(ExceptionResourceKeys.AssignParameterFromDateGreaterThanToDate, "تاریخ ابتدا از انتها بزرگتر است", ExceptionSrc);
            }
            else
            {
                IList <AssignRuleParameter> list = assignRuleParameterRepository.GetByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new AssignRuleParameter().Rule), workingRule),
                                                                                               new CriteriaStruct(Utility.GetPropertyName(() => new AssignRuleParameter().ID), assignRuleParameter.ID, CriteriaOperation.NotEqual));

                IList <DateTime> fromList = list.Select(x => x.FromDate).ToList <DateTime>();
                IList <DateTime> toList   = list.Select(x => x.ToDate).ToList <DateTime>();

                if (HasIntersect(fromList, toList, assignRuleParameter.FromDate, assignRuleParameter.ToDate))
                {
                    exception.Add(ExceptionResourceKeys.AssignParameterDateHasIntersect, "محدوده انتسابها نباید با هم اشتراک داشته باشد", ExceptionSrc);
                }
            }

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