条码校验
=======
    // return: 0 not valid barcode; 1: is valid reader barcode; 2: is valid item barcode
    public int VerifyBarcode(string strBarcode,
        out string strError)
    {
        strError = "";
        if (String.IsNullOrEmpty(strBarcode) == true)
        {
            strError = "条码为空";
            return 0;
        }
        // 读者
        if (strBarcode.Length == 7)
        {
            char c = strBarcode[0];
            if (c != 'P' && c != 'S' && c != 'R' && c != 'T')
            {
                strError = "读者条码第一字符应当为PSRT之一";
                return 0;
            }
            string strNumber = strBarcode.Substring(1);
            if (IsPureNumber(strNumber) == false)
            {
                strError = "读者条码第一字符以外的其他字符应当为纯数字";
                return 0;
            }
            return 1;
        }
        // 册
        if (strBarcode.Length == 8)
        {
            char c = strBarcode[0];
            if (c != 'L')
            {
                strError = "册条码第一字符应当为L";
                return 0;
            }
            string strNumber = strBarcode.Substring(1);
            if (IsPureNumber(strNumber) == false)
            {
                strError = "册条码第一字符以外的其他字符应当为纯数字";
                return 0;
            }
            return 2;
        }
        strError = "条码长度既不是7位,也不是8位";
        return 0;
    }
        // 检测字符串是否为纯数字(不包含'-','.'号)
        public static bool IsPureNumber(string s)
        {
            if (s == null)
                return false;
            for(int i=0;i<s.Length;i++) 
            {
                if ( s[i] > '9' || s[i] < '0' )
                    return false;
            }
            return true;
        }