public bool Validar() { bool paso = true; MyErrorProvider.Clear(); if (string.IsNullOrWhiteSpace(ArticuloTextBox.Text)) { MyErrorProvider.SetError(ArticuloTextBox, "Debe insertar almenos un articulo."); ArticuloTextBox.Focus(); paso = false; } if (string.IsNullOrWhiteSpace(CodigoMaskedTextBox.Text)) { MyErrorProvider.SetError(CodigoMaskedTextBox, "Debe asignarle un codigo."); CodigoMaskedTextBox.Focus(); paso = false; } if (PrecioNumericUpDown.Value <= 0) { MyErrorProvider.SetError(PrecioNumericUpDown, "Debe asignarle un precio valido."); PrecioNumericUpDown.Focus(); paso = false; } if (string.IsNullOrWhiteSpace(UnidadComboBox.Text)) { MyErrorProvider.SetError(UnidadComboBox, "Debe agregarle una medida."); UnidadComboBox.Focus(); paso = false; } return paso; }
private bool ValidarCampos() { if (CategoriaComboBox.SelectedIndex == -1) { errorProvider1.SetError(AbrirCategoriasButton, "Seleccione la Categoría"); CategoriaComboBox.Focus(); return(false); } errorProvider1.Clear(); if (CantidadTextBox.Text == string.Empty) { errorProvider1.SetError(CantidadTextBox, "Ingrese la cantidad"); CantidadTextBox.Focus(); return(false); } errorProvider1.Clear(); if (!float.TryParse(CantidadTextBox.Text, out float cantidad)) { errorProvider1.SetError(CantidadTextBox, "Debe ingresar un valor numérico entero"); CantidadTextBox.Focus(); return(false); } errorProvider1.Clear(); if (cantidad < 0) { errorProvider1.SetError(CantidadTextBox, "Debe ingresar un valor mayor a cero"); CantidadTextBox.Focus(); return(false); } errorProvider1.Clear(); if (ArticuloTextBox.Text == string.Empty) { errorProvider1.SetError(ArticuloTextBox, "Ingrese el Nombre del Artículo"); ArticuloTextBox.Focus(); return(false); } errorProvider1.Clear(); if (PrecioTextBox.Text == string.Empty) { errorProvider1.SetError(PrecioTextBox, "Ingrese el Costo del Artículo"); PrecioTextBox.Focus(); return(false); } errorProvider1.Clear(); if (!decimal.TryParse(PrecioTextBox.Text, out decimal costo)) { errorProvider1.SetError(PrecioTextBox, "Debe ingresar un valor numérico entero"); PrecioTextBox.Focus(); return(false); } errorProvider1.Clear(); if (costo < 0) { errorProvider1.SetError(PrecioTextBox, "Debe ingresar un valor mayor a cero"); PrecioTextBox.Focus(); return(false); } errorProvider1.Clear(); if (PresentacionComboBox.SelectedIndex == -1) { errorProvider1.SetError(AbrirPresentacionButton, "Seleccione la Presentación del Artículo"); PresentacionComboBox.Focus(); return(false); } errorProvider1.Clear(); return(true); }