private bool Validar() { bool paso = true; errorProvider.Clear(); if (ProductocomboBox.Text == "") { errorProvider.SetError(ProductocomboBox, "Elija el producto"); ProductocomboBox.Focus(); paso = false; } if (ProductoEntradanumericUpDown.Value < 1) { errorProvider.SetError(ProductoEntradanumericUpDown, "La entrada debe ser mayor a 1"); ProductoEntradanumericUpDown.Focus(); paso = false; } return(paso); }
private void AgragraAlGrid_Click(object sender, EventArgs e) { RepositorioBase <Productos> db = new RepositorioBase <Productos>(); Productos producto; if (ProductocomboBox.Text == "") { return; } producto = db.Buscar((int)ProductocomboBox.SelectedValue); if (ProductocomboBox.Text == "") { errorProvider.SetError(ProductocomboBox, "Debe elegir un Producto"); ProductocomboBox.Focus(); return; } if (PrecionumericUpDown.Value < Convert.ToDecimal(producto.Costo)) { errorProvider.SetError(PrecionumericUpDown, "El precio de venta debe ser mayor al precio del costo"); PrecionumericUpDown.Focus(); return; } if (producto.Existencia - Convert.ToDouble(CantidadnumericUpDown.Value) < 0) { errorProvider.SetError(CantidadnumericUpDown, "El almacen del producto no es suficiente "); CantidadnumericUpDown.Focus(); return; } if (ExisteEnGrid() == false) { errorProvider.SetError(ProductocomboBox, "El Producto ya existe en el Grid"); ProductocomboBox.Focus(); return; } if (CantidadnumericUpDown.Value < 1) { errorProvider.SetError(CantidadnumericUpDown, "Debe elegir una cantidad "); CantidadnumericUpDown.Focus(); return; } double import = Convert.ToDouble(PrecionumericUpDown.Value * CantidadnumericUpDown.Value); if (detalleDataGridView.DataSource != null) { this.Detalle = (List <VentasDetalle>)detalleDataGridView.DataSource; } this.Detalle.Add(new VentasDetalle() { VentaId = Convert.ToInt32(VentaIdnumericUpDown.Value), ProductoId = Convert.ToInt32(ProductocomboBox.SelectedValue), Cantidad = Convert.ToDouble(CantidadnumericUpDown.Value), Precio = Convert.ToDouble(PrecionumericUpDown.Value), Importe = import, Itbis = (producto.ProductoItbis * import) / 100 }); LimpiaProducto(); CargarGrid(); CalcularItbis(); CalcularSubtotal(); CalcularTotal(); }