示例#1
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            SymptomCathegory cathegory = (value as BindingGroup).Items[0] as SymptomCathegory;

            if (cathegory.Name == null || cathegory.Name.Length == 0)
            {
                return(new ValidationResult(false, "The name value can't be empty"));
            }
            if (cathegory.Name != null && cathegory.Name.Length > 50)
            {
                return(new ValidationResult(false, "Cathegory name is too long. Length should be smaller than 50 characters"));
            }
            if (cathegory.ParentCathegory != null && cathegory.ParentCathegory.ToString() == cathegory.Id.ToString())
            {
                return(new ValidationResult(false, "Cathegory can not be 'parent cathegory' for its self"));
            }

            DiseaseDatabaseEntities tempContext = new DiseaseDatabaseEntities();

            if (tempContext.SymptomCathegories.Count(s => (s.Name == cathegory.Name) && (s.Id != cathegory.Id)) > 0)
            {
                return(new ValidationResult(false, "Cathegory names have to be unique"));
            }

            return(ValidationResult.ValidResult);
        }
示例#2
0
        private void SymptomCathegoryViewSource_Filter(object sender, FilterEventArgs e)
        {
            SymptomCathegory cat = e.Item as SymptomCathegory;

            if (cat != null)
            {
                e.Accepted = (cat.Name.ToUpper().Contains(SymptomCathegoriesSearchBox.Text.ToUpper()));
            }
        }