private void btnPborrar_Click(object sender, EventArgs e) { MysqlProducto del = new MysqlProducto(); if (MessageBox.Show("Seguro que Deseas borrar este Producto", "Producto", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { MessageBox.Show("Error Al intentar borrar"); } else { try { long Codigo = Convert.ToInt64(txtCodigo.Text); del.delet(Codigo); Producto.Cargadatos(DgridProducto); txtCodigo.Clear(); txtProducto.Clear(); txtPrecio.Clear(); txtDecripcion.Clear(); pcbProducto.Image = null; imagen2 = null; } catch (Exception) { MessageBox.Show("Error Al intentar borrar"); } } }
private void btnPmodificar_Click(object sender, EventArgs e) { MysqlProducto mod = new MysqlProducto(); try { long id = Convert.ToInt64(txtCodigo.Text); mod.actualizar(id, txtProducto.Text, Convert.ToInt16(txtPrecio.Text), txtDecripcion.Text, imagen2); Producto.Cargadatos(DgridProducto); } catch (Exception) { MessageBox.Show("Error Al intentar actualizar la informacion"); } }
private void btnPagregar_Click(object sender, EventArgs e) { MysqlProducto add = new MysqlProducto(); try { if (!Validaciones.NombrePersonal(txtProducto.Text)) { ErrorProvider1.SetError(txtProducto, "Error solo letras porfavor, No puede estar vacio este campo "); txtProducto.Focus(); } else { ErrorProvider1.SetError(txtProducto, ""); if (!Validaciones.numeros(txtPrecio.Text)) { ErrorProvider1.SetError(txtPrecio, "Error solo numeros porfavor, No puede estar vacio este campo "); txtPrecio.SelectAll(); } else { ErrorProvider1.SetError(txtPrecio, ""); txtCodigo.Clear(); add.add(txtProducto.Text, Convert.ToInt32(txtPrecio.Text), txtDecripcion.Text, imagen2); Producto.Cargadatos(DgridProducto); txtProducto.Clear(); txtPrecio.Clear(); txtDecripcion.Clear(); pcbProducto.Image = null; imagen2 = null; } } } catch (Exception) { MessageBox.Show("Intenta Con otro Id de Producto"); } }