public static Boolean estaEntreLimites(TextBox txt, decimal limiteInferior, decimal limiteSuperior,Boolean numeroDecimal,string nombreCampo)
{
string cadena = txt.Text;
if (cadena == "")
return true;
if (numeroDecimal)
{
if (!esDecimal(txt))
return true;
}
else
{
if (!esNumero(txt))
return true;
}
decimal numero = Convert.ToDecimal(txt.Text.Replace(".",","));
if (numero < limiteInferior || numero > limiteSuperior)
{
MessageBox.Show("El valor del campo " + nombreCampo + " debe estar entre " + limiteInferior.ToString() + " y " + limiteSuperior.ToString(), "Error en los datos de entrada", MessageBoxButtons.OK);
return false;
}
return true;
}