private void btnBuscarCodigo_Click(object sender, EventArgs e) { try { ProductoBLL _ProductoBLL = new ProductoBLL(); _Producto = _ProductoBLL.ObtenerProducto(int.Parse(this.mskCodigoProducto.Text)); if (_Producto != null) { this.txtNombreProducto.Text = _Producto.Descripcion; this.txtPrecio.Text = _Producto.Precio.ToString("0.00"); this.mskCantidad.Focus(); } else { MessageBox.Show("El Producto No existe !", "Anteción", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception er) { StringBuilder msg = new StringBuilder(); msg.AppendFormat("Message {0}\n", er.Message); MessageBox.Show(msg.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void dgvProducto_CellClick(object sender, DataGridViewCellEventArgs e) { this.dgvListaMateriales.Rows.Clear(); Producto miProducto = new Producto(); ProductoBLL miProductoBLL = new ProductoBLL(); if (dgvProducto.CurrentRow != null) { // txtId.Text = dgvProducto.CurrentRow.Cells["Id"].Value.ToString(); txtCategoriaId.Text = dgvProducto.CurrentRow.Cells["CategoriaId"].Value.ToString(); txtCategoriaDescripcion.Text = dgvProducto.CurrentRow.Cells["CategoriaDescripcion"].Value.ToString(); txtDescripcion.Text = dgvProducto.CurrentRow.Cells["Descripcion"].Value.ToString(); txtPrecioVenta.Text = dgvProducto.CurrentRow.Cells["PrecioVenta"].Value.ToString(); Imagen.BackgroundImage = null; byte[] b = (byte[])dgvProducto.CurrentRow.Cells["Imagen"].Value; MemoryStream ms = new MemoryStream(b); Imagen.Image = Image.FromStream(ms); Imagen.SizeMode = PictureBoxSizeMode.StretchImage; miProducto = miProductoBLL.ObtenerProducto(Convert.ToInt32(dgvProducto.CurrentRow.Cells["Id"].Value)); foreach (var item in miProducto.Req_Productos) { string[] item2 = { item.Material.Id.ToString(), item.Material.Descripcion, item.Material.Uni_Medida, item.Material.Precio.ToString(), item.Cantidad.ToString(), item.Costo.ToString() }; dgvListaMateriales.Rows.Add(item2); } } }