//GUARDA CAMBIOS DEL PRODUCTO private void botonGuardar_Click(object sender, EventArgs e) { Producto p = new Producto(); string nombre = textBoxNom.Text; string unidad = comboBoxUMedida.Text; string tipo = comboBoxNuevo.Text; string descripcion = textBoxDescripcion.Text; string cantidad = textBoxCantidad.Text; string precioVenta = textBoxPventa.Text; string codBarras = textBoxCodigoBarras.Text; string productoId; int idAux, cantidadAux; float precioVaux; /*nombre = dataGridView1.CurrentRow.Cells["productoNombre"].Value.ToString(); * unidad = dataGridView1.CurrentRow.Cells["productoUnidadMedida"].Value.ToString(); * tipo = dataGridView1.CurrentRow.Cells["productoTipo"].Value.ToString(); * descripcion = dataGridView1.CurrentRow.Cells["productoDesc"].Value.ToString(); * cantidad = dataGridView1.CurrentRow.Cells["productoCantidad"].Value.ToString(); * precioVenta = dataGridView1.CurrentRow.Cells["productoPrecioVenta"].Value.ToString(); */ productoId = dataGridView1.CurrentRow.Cells["productoId"].Value.ToString(); if (p.ProductoValidar(nombre, tipo, unidad, cantidad, precioVenta) == true) { idAux = int.Parse(productoId); cantidadAux = int.Parse(cantidad); precioVaux = float.Parse(precioVenta); if (p.ModificarProducto(idAux, nombre, unidad, tipo, descripcion, cantidadAux, precioVaux, codBarras) == true) { MessageBox.Show("La modificacion se realizo con exito"); } else { MessageBox.Show("La modificacion no se pudo realizar"); } //Vaciador de campos VaciarCampos(); botonGuardar.Enabled = false; panelNuevoProducto.Visible = false; DataGridLlenar(); } /*DataSet DS = new DataSet(); * p = new Producto(); * DS = p.MostrarProducto(); * dataGridView1.DataSource = DS.Tables[0];*/ }
//AGREGA NUEVO PRODUCTO private void BtnGuardar_Click(object sender, EventArgs e) { string nombre, tipo, descripcion, unidadMedida, cantidad, precioVenta, productoCodBarras; nombre = textBoxNom.Text; tipo = comboBoxNuevo.Text; descripcion = textBoxDescripcion.Text; unidadMedida = comboBoxUMedida.Text; cantidad = textBoxCantidad.Text; precioVenta = textBoxPventa.Text; productoCodBarras = textBoxCodigoBarras.Text; Producto producto = new Producto(); if (producto.ProductoValidar(nombre, tipo, unidadMedida, cantidad, precioVenta)) { long cantidadEntero = long.Parse(cantidad); int precioVentaEntero = int.Parse(precioVenta); if (producto.AgregarProducto(nombre, unidadMedida, tipo, descripcion, cantidadEntero, precioVentaEntero, productoCodBarras) == true) { MessageBox.Show("Se creo el nuevo producto con éxito"); DataGridLlenar(); panelNuevoProducto.Visible = false; VaciarCampos(); } else { MessageBox.Show("No se pudo guardar el producto"); } } }