예제 #1
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            ExcelManager  _manager = new ExcelManager();
            List <ExcelB> listB    = _manager.LoadCollectionExcelB();

            ExcelA entry = (value as BindingGroup).Items[0] as ExcelA;

            if (string.IsNullOrEmpty(entry.Val1))
            {
                return(new ValidationResult(false, "Value 1 must not be empty!"));
            }

            bool contains = false;

            foreach (var item in listB)
            {
                if (item.Val3Main.Equals(entry.Val3))
                {
                    contains = true;
                }
            }

            if (contains)
            {
                return(ValidationResult.ValidResult);
            }
            else
            {
                return(new ValidationResult(false, "Value 3 must exist in ExcelB!"));
            }
        }
예제 #2
0
        private void InitValuesAndCollections()
        {
            // IMPOTANT: The order of these is essential as the last attributes are calling command on set()
            _manager = new ExcelManager();

            AddExcelA = new ExcelA();
            AddExcelB = new ExcelB();

            MyCollectionA             = new ObservableCollection <ExcelA>();
            MyCollectionExcelAValue12 = new ObservableCollection <String>();
            MyCollectionB             = new ObservableCollection <ExcelB>();
            MyCollectionC             = new ObservableCollection <ExcelC>();

            MonthComboboxSource = Constants.Months;
            SelectedMonth       = Constants.getCurrentDateMonth();
        }