private void button1_Click(object sender, EventArgs e) { if (txtProducto.Text == "" || txtCodigo.Text == "" || txtPrecio.Text == "") { MessageBox.Show("No puedes dejar campos en blanco", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { Producto p = new Producto() { Codigo = txtCodigo.Text, NombreProducto = txtProducto.Text, Precio = Convert.ToDouble(txtPrecio.Text) }; Resultado r = ProductoBLL.AgregarProducto(p); if (r.Codigo == 1) { MessageBox.Show("Producto agregado correctamente", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(r.Mensaje, "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } control.AbrirFormProductos(); } }
private void btnAgregarProducto_Click(object sender, EventArgs e) { try { Producto producto = new Producto(); if (Valido()) { producto.codigo = Convert.ToInt64(TxtCodigo.Text.ToString()); producto.nombreProducto = TxtNombreProducto.Text.ToString(); producto.descripcionProducto = txtDescripcion.Text.ToString(); producto.precio = Convert.ToDouble(TxtPrecio.Text.ToString()); producto.precioCompra = Convert.ToDouble(TxtPrecioCompra.Text.ToString()); producto.cantidadExistencia = Convert.ToInt64(TxtCantidadExistencia.Text.ToString()); Result resultado = new Result(); ProductoBLL productoBLL = new ProductoBLL(); resultado = productoBLL.AgregarProducto(producto); Utilidades.MuestraInfo(resultado.mensaje); if (resultado.estatus == 200) { this.Close(); } } } catch (Exception ex) { Utilidades.MuestraErrores(ex.Message); } }