public void LlenarCampo(string id) { DAL.Producto prod = BRL.ProductoBRL.DevolverProducto(id); txtid.Text = prod.Codigo.ToString(); txtNombre.Text = prod.Nombre; txtPrecio.Text = prod.PrecioVenta.ToString(); numCantidad.Value = (decimal)prod.Stock; //para los combox llenar con el valor de DB cmBoxClasificacion.SelectedIndex = prod.Clasificacion.Codigo; cmBoxTipo.SelectedIndex = prod.Tipo.Codigo; cmBoxUnidad.SelectedIndex = prod.Unidad.Id; }
private void btnActualizar_Click(object sender, EventArgs e) { DAL.Producto actualizar = new DAL.Producto(); actualizar.Codigo = Convert.ToInt32(txtid.Text); actualizar.Nombre = txtNombre.Text; actualizar.Tipo.Codigo = Convert.ToInt32(cmBoxTipo.SelectedValue); actualizar.Clasificacion.Codigo = Convert.ToInt32(cmBoxClasificacion.SelectedValue); actualizar.Stock = Convert.ToInt32(numCantidad.Value); actualizar.PrecioVenta = Convert.ToDecimal(txtPrecio.Text); actualizar.Unidad.Id = Convert.ToInt32(cmBoxUnidad.SelectedValue); BRL.ProductoBRL.ActualizarProducto(actualizar); Buscar.form.buscar(); this.Close(); }
private void btnIngreso_Click(object sender, EventArgs e) { try { int c = (int)cmBoxClasificacion.SelectedValue; int t = (int)cmBoxTipo.SelectedValue; int u = (int)cmBoxUnidad.SelectedValue; if (!DAL.Validar.validarTxtBox(panel1) && c != 0 && t != 0 && u != 0) { btnIngreso.Enabled = true; DAL.Producto ingreso = new DAL.Producto(); //ingreso.Codigo = txtCodigo.Text; ingreso.Nombre = txtNombre.Text.ToUpper(); ingreso.Stock = Convert.ToInt32(numCantidad.Value); ingreso.PrecioVenta = Convert.ToDecimal(txtPrecio.Text); ingreso.Clasificacion.Codigo = Convert.ToInt32(cmBoxClasificacion.SelectedValue); ingreso.Tipo.Codigo = Convert.ToInt32(cmBoxTipo.SelectedValue); ingreso.Unidad.Id = Convert.ToInt32(cmBoxUnidad.SelectedValue); BRL.ProductoBRL.RegistraProducto(ingreso); this.Close(); //MessageBox.Show(cmBoxClasificacion.SelectedValue + " " + cmBoxTipo.SelectedValue, "Error"); } else { MessageBox.Show("Campos requeridos vacios", "ERROR"); } } catch (SqlException ex) { MessageBox.Show("Error " + ex, "Error SQL", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception) { MessageBox.Show("Errror", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnIngreso_Click(object sender, EventArgs e) { try { int c = (int)cmBoxClasificacion.SelectedValue; int t = (int)cmBoxTipo.SelectedValue; int u = (int)cmBoxUnidad.SelectedValue; if (!DAL.Validar.validarTxtBox(panel1) && c != 0 && t !=0 && u != 0) { btnIngreso.Enabled = true; DAL.Producto ingreso = new DAL.Producto(); //ingreso.Codigo = txtCodigo.Text; ingreso.Nombre = txtNombre.Text.ToUpper(); ingreso.Stock = Convert.ToInt32(numCantidad.Value); ingreso.PrecioVenta = Convert.ToDecimal(txtPrecio.Text); ingreso.Clasificacion.Codigo = Convert.ToInt32(cmBoxClasificacion.SelectedValue); ingreso.Tipo.Codigo = Convert.ToInt32(cmBoxTipo.SelectedValue); ingreso.Unidad.Id = Convert.ToInt32(cmBoxUnidad.SelectedValue); BRL.ProductoBRL.RegistraProducto(ingreso); this.Close(); //MessageBox.Show(cmBoxClasificacion.SelectedValue + " " + cmBoxTipo.SelectedValue, "Error"); } else { MessageBox.Show("Campos requeridos vacios", "ERROR"); } } catch (SqlException ex) { MessageBox.Show("Error " + ex, "Error SQL", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception) { MessageBox.Show("Errror", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void ActualizarProducto(DAL.Producto ingreso) { DAL.Producto.actualizarProducto(ingreso); }
public static void RegistraProducto(DAL.Producto ingreso) { DAL.Producto.registraProducto(ingreso); }