Beispiel #1
0
        //EVENTO AL PRESIONAR EL BOTON ELIMINAR/MODIFICAR --> 100%
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            NegocioArticulo negoa = new NegocioArticulo();
            String          cood;

            cood = frmBusqueda.codigoDelProducto;   //trae el codigo del producto que se uso para la busqueda

            if (opc == 4)
            {
                var res = MessageBox.Show("¿Está seguro desea eliminar este artículo?", "AVISO", MessageBoxButtons.YesNo);
                if (res == DialogResult.Yes)
                {
                    negoa.eliminarArt(cood);
                    MessageBox.Show("Artículo eliminado exitosamente");
                    Dispose();
                }
            }
            if (opc == 2)
            {
                var res = MessageBox.Show("¿Está seguro desea modificar este artículo?", "AVISO", MessageBoxButtons.YesNo);
                if (res == DialogResult.Yes)
                {
                    float pre;

                    codigo = txtCodigo.Text;
                    nombre = txtNombre.Text;

                    if (!codigo.Equals("") && !nombre.Equals(""))
                    {
                        if (negoa.existeArticulo(codigo) == false || codigo.Equals(cood))
                        {
                            imagen      = txtImagen.Text;
                            precio      = txtPrecio.Text;
                            cat         = Convert.ToInt32(cmbCategoria.SelectedIndex + 1); //guarda el id de la opcion elegida --> 100%
                            mar         = Convert.ToInt32(cmbMarca.SelectedIndex + 1);     //guarda el id de la opcion elegida --> 100%
                            descripcion = txtDescripcion.Text;

                            if (precio.Equals(""))
                            {
                                pre = 0;
                            }
                            else
                            {
                                pre = float.Parse(precio);
                            }
                            negoa.modificarArt(cood, codigo, nombre, descripcion, mar, cat, imagen, pre);
                            MessageBox.Show("Artículo modificado con exito");
                            Dispose();
                        }
                        else
                        {
                            MessageBox.Show("El código de artículo ya existe");
                        }
                    }
                    else
                    {
                        MessageBox.Show("El nombre y código son necesarios para continuar");
                    }
                }
            }
        }