private bool Validar() //Funcion que valida todo el registro { bool paso = true; MyErrorProvider.Clear(); if (ProductoTextBox.Text == string.Empty)//Valida que haya un producto seleccionado { MyErrorProvider.SetError(ProductoTextBox, "Debe seleccionar un producto!"); ProductoTextBox.Focus(); paso = false; } if (EntradaIdNumericUpDown.Value > 0)//Valida que si se modifica una entrada el producto sea el mismo! { if (!ValidarProducto()) { MyErrorProvider.SetError(ProductoTextBox, "El producto de la entrada no puede variar!"); VerProductosButton.Focus(); paso = false; } } if (CantidadNumericUpDown.Value == 0)//Valida que la cantidad de entrada sea mayor a 0 { MyErrorProvider.SetError(CantidadNumericUpDown, "La cantidad de la entrada debe ser mayor a 0!"); CantidadNumericUpDown.Focus(); paso = false; } return(paso); }
private void LimpiarProductoGroupBox() // Funcion encargada de limpiar todos los campos de agregar productos { ProductoIdNumericUpDown.Value = 0; DescripcionTextBox.Text = string.Empty; CantidadNumericUpDown.Value = 0; PrecioNumericUpDown.Value = 0; ImporteTextBox.Text = "0.00"; MyErrorProvider.Clear(); VerProductosButton.Focus(); }
private void AgregarProductoButton_Click(object sender, EventArgs e) { MyErrorProvider.Clear(); if (SiProductoExiste()) { return; } if (!ValidaProducto()) { return; } RepositorioBase <DetalleFacturas> Repositorio = new RepositorioBase <DetalleFacturas>(); if (DetalleDataGridView.DataSource != null) { Detalle = (List <DetalleFacturas>)DetalleDataGridView.DataSource; } this.Detalle.Add( new DetalleFacturas( detalleFacturaId: 0, facturaId: (int)FacturaIdNumericUpDown.Value, productoId: (int)ProductoIdNumericUpDown.Value, cantidad: (int)CantidadNumericUpDown.Value, descripcionProducto: DescripcionTextBox.Text, precio: Convert.ToInt32(PrecioNumericUpDown.Value), importe: Convert.ToInt32(ImporteTextBox.Text) ) ); if (Detalle.Count == 0) { EliminarProductoButton.Visible = false; } else { EliminarProductoButton.Visible = true; } CargaGrid(); LimpiarProductoGroupBox(); VerProductosButton.Focus(); }