private void btnAgregarProduc_Click(object sender, EventArgs e) { try { if (ValidarProducto() == true) { ProductoEn item = new ProductoEn(); item = new ProductoEn { IdProducto = int.Parse(lblIdProducto.Text), Codigo = txtCodigoProducto.Text, Nombre = txtNombreProducto.Text, Cantidad = int.Parse(txtCantidad.Text), PrecioVenta = decimal.Parse(txtPrecio.Text), Total = int.Parse(txtCantidad.Text) * decimal.Parse(txtPrecio.Text) }; olistProducto.Add(item); CargarGrid(); txtCodigoProducto.Text = ""; txtNombreProducto.Text = ""; txtPrecio.Text = ""; txtCantidad.Text = ""; txtSubTotal.Text = ""; } } catch (Exception ex) { MessageBox.Show("Se genero un error: " + ex.Message.ToString(), "Información", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnBuscarProducto_Click(object sender, EventArgs e) { try { ProductoEn item = new ProductoEn(); string Error = ""; item = Prod.BuscarProducto(txtCodigoProducto.Text, ref Error); if (string.IsNullOrWhiteSpace(Error)) { if (item.IdProducto > 0) { lblIdProducto.Text = item.IdProducto.ToString(); txtNombreProducto.Text = item.Nombre; txtPrecio.Text = item.PrecioVenta.ToString(); txtCantidad.Text = "1"; txtSubTotal.Text = item.PrecioVenta.ToString(); } else { MessageBox.Show("No se encontro el registro, intentelo nuevamente ", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Se genero un error: " + Error, "Información", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("Se genero un error: " + ex.Message.ToString(), "Información", MessageBoxButtons.OK, MessageBoxIcon.Error); } }