/// <summary>
/// 判断是否为小数点数字且带符号
/// </summary>
/// <param name="symbol">A:正负,P:正数</param>
/// <param name="message">小数点位数</param>
/// <param name="message">需检查的数字参数</param>
/// <returns>返回值</returns>
public static bool CheckIsNumberic(string type, string message,int intLength)
{
System.Text.RegularExpressions.Regex rex;
//(@"^\-?\d+(\.\d{1,2})?$") 正负
//(@"^\d+(\.\d{1,2})?$") 正数 switch (type) //A 正负数 P 正数 positive N 负数 negative
{
case "A":
rex = new System.Text.RegularExpressions.Regex(@"^\-?\d+(\.\d{1," + intLength + "})?$");
break;
case "P":
rex = new System.Text.RegularExpressions.Regex(@"^\d+(\.\d{1," + intLength + "})?$");
break;
default:
rex = new System.Text.RegularExpressions.Regex(@"^\-?\d+(\.\d{1," + intLength + "})?$");
break;
}
if (rex.IsMatch(message))
{
return true;
}
else
return false;
} //调用,比如不能超过2位小数
CheckIsNumberic("P", txtUnitPrice.Text.Trim(), )