private void InitializeValidator()
 {
     this.validator = new ControlValidator();
     validator.Add(new ControlValidation(rTxtDescripcion, control => control.Text != "", "Complete el campo descripcion."));
     validator.Add(new ControlValidation(cmbRubro, control => ((ComboBox)control).SelectedItem != null, "Elija un rubro de publicacion."));
     validator.Add(new ControlValidation(txtDireccion, control => control.Text != "", "Complete el campo dirección."));
     validator.Add(new ControlValidation(cmbGrado, control => ((ComboBox)control).SelectedItem != null, "Elija un grado de publicacion."));
     validator.Add(new ControlValidation(cmbEstado, control => ((ComboBox)control).SelectedItem != null, "Elija un estado de publicacion."));
 }
Пример #2
0
        public RegistroDeUsuarioForm(Form previousForm)
        {
            InitializeComponent();
            this.previousForm      = previousForm;
            this.rolRepository     = new RolRepository();
            this.usuarioRepository = new UsuarioRepository();
            this.controlValidator  = new ControlValidator();
            controlValidator.Add(new ControlValidation(txtPassword, control => control.Text != "", "Ingrese Contraseña"));
            controlValidator.Add(new ControlValidation(txtUsername, control => control.Text != "", "Ingrese Nombre de Usuario"));

            controlValidator.Add(new ControlValidation(cmbRoles, control => ((ComboBox)control).SelectedItem != null, "Complete todos los Campos"));
            ComboBoxFiller <Rol, decimal> .Fill(cmbRoles)
            .KeyAs(rol => rol.IdRol)
            .ValueAs(rol => rol.Descripcion)
            .With(rolRepository.RolesDeClienteYEmpresa());
        }
Пример #3
0
 public bool IsEnabled(LogLevel level)
 {
     return(ControlValidator.IsHandleCreated(this.textBoxLogs) && !ControlValidator.IsDisposed(this.textBoxLogs));
 }
 private void InitializeValidator()
 {
     this.validator = new ControlValidator();
     validator.Add(new ControlValidation(txtDescripcion, control => control.Text.Length >= 3, "El campo descripcion es obligatorio y debe escribir al menos tres caracteres."));
 }
 private void InitializeValidator()
 {
     this.controlValidator = new ControlValidator();
     controlValidator.Add(new ControlValidation(txtFila, control => control.Text.Length <= 3, "La fila debe tener un maximo de tres caracteres."));
     controlValidator.Add(new ControlValidation(cmbTipoUbicacion, control => ((ComboBox)control).SelectedItem != null, "Seleccione un tipo de ubicación."));
 }
Пример #6
0
        /// <summary>
        /// Method that determines whether the contents of a field are valid
        /// </summary>
        /// <param name="errNotifier">ErrorProvider component that will be used to provide error notification</param>
        /// <param name="control">Control that is being validated ( also the one that the ErrorProvider component will
        /// render itself next to if an error occurs.</param>
        /// <param name="errMessage">String containing the error message to show if the validation fails</param>
        /// <param name="validator">Delegate that points to a method that will perform the validation</param>
        /// <returns></returns>
        public static bool FieldIsValid(ErrorProvider errNotifier, Control control, string errMessage, ControlValidator validator)
        {
            bool isValid = false;

            // invoke the method that will perform the validation against the control
            if (!validator(control))
            {
                // if the validation did not pass then set the error message next to the control
                errNotifier.SetError(control, errMessage);
                isValid = false;
            }
            else
            {
                // clear the error message associated with the control
                errNotifier.SetError(control, "");
                isValid = true;
            }

            return(isValid);
        }