Пример #1
0
        //EVENTO PARA EL BOTON ACEPTAR --> 100%
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            NegocioArticulo negoa = new NegocioArticulo();

            codigo      = txtCodigo.Text;
            nombre      = txtNombre.Text;
            imagen      = txtImagen.Text;
            precio      = txtPrecio.Text;
            cat         = Convert.ToInt32(cmbCategoria.SelectedValue.ToString()); //guarda el id de la opcion elegida --> 100%
            mar         = Convert.ToInt32(cmbMarca.SelectedValue.ToString());     //guarda el id de la opcion elegida --> 100%
            descripcion = txtDescripcion.Text;

            if (!codigo.Equals("") && !nombre.Equals("") && !imagen.Equals("") && !precio.Equals("") && !descripcion.Equals(""))
            {
                if (negoa.existeArticulo(codigo) == false)
                {
                    pre = float.Parse(precio);
                    negoa.guardarArticulo(codigo, nombre, descripcion, mar, cat, imagen, pre);

                    MessageBox.Show("Artículo agregado con exito");
                    limpiarCampos();
                }
                else
                {
                    MessageBox.Show("El código de artículo ya existe");
                }
            }
            else
            {
                MessageBox.Show("Debe completar todos los campos para continuar");
            }
        }