private void NuevoProductofrm_Load(object sender, EventArgs e) { Negocios.Negocio negocio = new Negocios.Negocio(); negocio.ObtenerComboBoxes(boxMarca, "marcas"); negocio.ObtenerComboBoxes(boxCategoria, "Categorias"); negocio = null; this.Text = "Keruministrador - Nuevo Producto"; if (id != 0) { negocio = new Negocios.Negocio(); Producto prod = new Producto(); prod = negocio.ObtenerProducto(id); if (prod.imagen != "" && prod.imagen.Length > 5) { Image img = negocio.ObtenerImagen(prod.imagen); SetearImagen(img); } SetearDatos(prod); titulo.Text = "Modificar Producto"; this.Text = "Keruministrador - Modificar Producto"; } txtCod.MaxLength = 50; txtNombre.MaxLength = 50; txtDesc.MaxLength = 150; txtPrecioCentavos.MaxLength = 2; imageTxT.MaxLength = 150; negocio = null; }
private void button1_Click(object sender, EventArgs e) { try { if (validarDatos()) { Negocios.Negocio negocio = new Negocios.Negocio(); Producto prod = new Producto(); prod.id = id; prod.codigo = txtCod.Text; prod.nombre = txtNombre.Text; prod.descripcion = txtDesc.Text; prod.imagen = imageTxT.Text; prod.marca = boxMarca.SelectedIndex + 1; prod.categoria = boxCategoria.SelectedIndex + 1; prod.precio = precio; if (prod.id != 0) { negocio.Actualizar(prod); MessageBox.Show("Producto Actualizado", "Keruministrador - Actualizar Producto"); } else { negocio.NuevoProducto(prod); MessageBox.Show("Producto Creado", "Keruministrador - Nuevo Producto"); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Keruministrador - Error!"); } }
private void imageTxT_TextChanged(object sender, EventArgs e) { try { if (imageTxT.Text != "") { Negocios.Negocio negocio = new Negocios.Negocio(); Image img = negocio.ObtenerImagen(imageTxT.Text); SetearImagen(img); negocio = null; } } catch (Exception ex) { throw ex; } }
private void Producto_Detalle_Load(object sender, EventArgs e) { try { Negocios.Negocio negocio = new Negocios.Negocio(); negocio.ObtenerComboBoxes(boxMarca, "marcas"); negocio.ObtenerComboBoxes(boxCategoria, "Categorias"); Producto prod = new Producto(); prod = negocio.ObtenerProducto(iid); if (prod.imagen != "" && prod.imagen.Length > 5) { Image img = negocio.ObtenerImagen(prod.imagen); SetearImagen(img); } SetearDatos(prod); } catch (Exception ex) { MessageBox.Show(ex.Message, "Keruministrador - Error!"); this.Close(); } }