AerolineaFrba.Validacion.estaEntreLimites C# (CSharp) Метод

estaEntreLimites() публичный статический Метод

public static estaEntreLimites ( TextBox txt, decimal limiteInferior, decimal limiteSuperior, System.Boolean numeroDecimal, string nombreCampo ) : System.Boolean
txt System.Windows.Forms.TextBox
limiteInferior decimal
limiteSuperior decimal
numeroDecimal System.Boolean
nombreCampo string
Результат System.Boolean
        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;
        }