protected bool CheckPort(TCTextBox txt)
 {
     if (string.IsNullOrEmpty(txt.Text))
     {
         errorProvider1.SetError(txt, "请设置端口");
         return false;
     }
     int port = 0;
     if (int.TryParse(txt.Text, out port) == false)
     {
         errorProvider1.SetError(txt, "端口值错误!");
         return false;
     }
     if (port < System.Net.IPEndPoint.MinPort || port > System.Net.IPEndPoint.MaxPort)
     {
         errorProvider1.SetError(txt, "请输入[" + System.Net.IPEndPoint.MinPort + "-" + System.Net.IPEndPoint.MaxPort + "]之间的端口。");
         return false;
     }
     return true;
 }
Exemple #2
0
        protected bool CheckPort(TCTextBox txt)
        {
            if (string.IsNullOrEmpty(txt.Text))
            {
                errorProvider1.SetError(txt, "请设置端口");
                return(false);
            }
            int port = 0;

            if (int.TryParse(txt.Text, out port) == false)
            {
                errorProvider1.SetError(txt, "端口值错误!");
                return(false);
            }
            if (port < System.Net.IPEndPoint.MinPort || port > System.Net.IPEndPoint.MaxPort)
            {
                errorProvider1.SetError(txt, "请输入[" + System.Net.IPEndPoint.MinPort + "-" + System.Net.IPEndPoint.MaxPort + "]之间的端口。");
                return(false);
            }
            return(true);
        }
        protected bool CheckIP(TCTextBox txt)
        {
            if (string.IsNullOrEmpty(txt.Text))
            {
                errorProvider1.SetError(txt, "请设置服务IP地址");
                return false;
            }
            if (txt.Text.ToLower().Trim().Equals("localhost"))
            {
                return true;
            }

            string patten = @"\b(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5])\b";
            if (System.Text.RegularExpressions.Regex.IsMatch(txt.Text.Trim(), patten) == false)
            {
                errorProvider1.SetError(txt, "请输入正确的IP地址。");
                return false;
            }

            return true;
        }
Exemple #4
0
        protected bool CheckIP(TCTextBox txt)
        {
            if (string.IsNullOrEmpty(txt.Text))
            {
                errorProvider1.SetError(txt, "请设置服务IP地址");
                return(false);
            }
            if (txt.Text.ToLower().Trim().Equals("localhost"))
            {
                return(true);
            }

            string patten = @"\b(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5])\b";

            if (System.Text.RegularExpressions.Regex.IsMatch(txt.Text.Trim(), patten) == false)
            {
                errorProvider1.SetError(txt, "请输入正确的IP地址。");
                return(false);
            }

            return(true);
        }