Example #1
0
        public bool Eval(object value, ErrorControl ctrl)
        {
            if (value is string)
            {
                if (string.IsNullOrWhiteSpace((string)value))
                {
                    ctrl.setError("Das Feld darf nicht leer sein!");
                    return false;
                }
            }
            else
            {
                if (value == null)
                {
                    ctrl.setError("Bitte wählen Sie ein Objekt aus!");
                    return false;
                }
            }

            return true;
        }
Example #2
0
        public double BindFrom_Double(Control ctrl, ErrorControl errctrl, IRule rule)
        {
            ctrl.BackColor = Color.Empty;
            errctrl.clearError();

            double result = 0;
            if (!double.TryParse(ctrl.Text, out result))
            {
                haserrors = true;
                ctrl.BackColor = Color.Red;
                errctrl.setError("Der Wert muss eine Zahl sein!");
            }

            if (rule != null)
            {
                if (!rule.Eval(result, errctrl))
                {
                    haserrors = true;
                    ctrl.BackColor = Color.Red;
                }
            }

            return result;
        }