/////////////////////// FUNCION DE PRUEBA, VALIDA QUE EL USUARIO INGRESE UNA CANTIDAD SUPERIOR A CERO, ABIERTA A SOLUCIONES
        public static Boolean validarCantidad(Control ObjetoP, ErrorProvider errorProvider, int cant)
        {
            Boolean HayError = false;

            foreach (Control Item in ObjetoP.Controls)
            {
                if (Item is ErrorTextBox)
                {
                    ErrorTextBox Obj = (ErrorTextBox)Item;

                    if (Obj.Validar == true)
                    {
                        if (string.IsNullOrEmpty(Obj.Text.Trim()))
                        {
                            errorProvider.SetError(Obj, "Falta ingresar una cantidad");
                            HayError = true;
                        }

                        if (cant < 1)
                        {
                            errorProvider.SetError(Obj, "Se permiten solamanete valores mayores a cero");
                            HayError = true;
                        }
                    }
                    else
                    {
                        errorProvider.SetError(Obj, "");//// se puede sacar
                    }
                }
            }
            return(HayError);
        }
        public static Boolean validarFormulario(Control Objeto, ErrorProvider ErrorProvider)
        {
            Boolean HayErrores = false;

            // Se busca el ID del producto en cuestion para la comprobacion de nombre
            int id = -1;

            Control[] idControl = Objeto.Controls.Find("txtCodigo", true);
            if (idControl.Length > 0)
            {
                id = Int32.Parse(((TextBox)idControl[0]).Text);
            }

            foreach (Control Item in Objeto.Controls) //revisa cada objeto uno x uno
            {
                if (Item is ErrorTextBox)
                {
                    ErrorTextBox Obj = (ErrorTextBox)Item;
                    Double       dbResult;
                    int          iResult;

                    if (Obj.Validar)
                    {
                        // ----- Validaciones -----
                        // Campo vacio o NULL
                        if (string.IsNullOrEmpty(Obj.Text.Trim()))
                        {
                            ErrorProvider.SetError(Obj, "Debe completar todos los campos");
                            HayErrores = true;
                        }
                        else if (Obj.Name == "txtNombre" && validarNombre(Obj.Text, id))   //nombreExistente(Obj.Text) && !Obj.ValidarDoble)
                        // Validacion nombre
                        {
                            ErrorProvider.SetError(Obj, "El nombre ya existe");
                            HayErrores = true;
                        }
                        else if ((Obj.Name == "txtPrecio" || Obj.Name == "txtTalle") && !Double.TryParse(Obj.Text, out dbResult))
                        // Validacion talle y precio
                        {
                            ErrorProvider.SetError(Obj, "Solo se aceptan valores decimales");
                            HayErrores = true;
                        }
                        else if (Obj.Name == "txtStock" && !Int32.TryParse(Obj.Text, out iResult))
                        // Validación stock
                        {
                            ErrorProvider.SetError(Obj, "No es un número entero");
                            HayErrores = true;
                        }
                    }
                    else
                    {
                        ErrorProvider.SetError(Obj, "");////en su momento se puede sacar
                    }
                }
            }
            return(HayErrores);
        }