Example #1
0
 public static string GetBarCodeType(BarCodeType[] barCodeTypes, string barCode)
 {
     if (string.IsNullOrEmpty(barCode) || barCode.Length < 2)
     {
         return null;
     }
     else if (barCode.StartsWith("$"))
     {
         return barCode.Substring(1, 1);
     }
     else if (barCode.StartsWith(".."))
     {
         return CodeMaster.BarCodeType.DATE.ToString();
     }
     else if (barCode.StartsWith("W"))
     {
         return CodeMaster.BarCodeType.W.ToString();
     }
     else if (barCode.StartsWith("SP"))
     {
         return CodeMaster.BarCodeType.SP.ToString();
     }
     else if (barCode.StartsWith("HU"))
     {
         return CodeMaster.BarCodeType.HU.ToString();
     }
     else if (barCode.StartsWith("DC"))
     {
         return CodeMaster.BarCodeType.DC.ToString();
     }
     else if (barCode.StartsWith("COT"))
     {
         return CodeMaster.BarCodeType.COT.ToString();
     }
     else
     {
         foreach (var codeType in barCodeTypes)
         {
             if (barCode.StartsWith(codeType.PreFixed))
             {
                 return codeType.Type.ToString();
             }
         }
     }
     return null;
 }
Example #2
0
 public static string GetBarCodeType(BarCodeType[] barCodeTypes, string barCode)
 {
     if (string.IsNullOrEmpty(barCode) || barCode.Length < 2)
     {
         return "-1";
     }
     else if (barCode.StartsWith("$"))
     {
         return barCode.Substring(1, 1);
     }
     else if (barCode.StartsWith(".."))
     {
         return CodeMaster.BarCodeType.DATE.ToString();
     }
     else if (barCode.StartsWith("W"))
     {
         return CodeMaster.BarCodeType.W.ToString();
     }
     else if (barCode.StartsWith("SP"))
     {
         return CodeMaster.BarCodeType.SP.ToString();
     }
     //else if (barCode.StartsWith("00"))
     //{
     //    return "00";
     //}
     else
     {
         foreach (var codeType in barCodeTypes)
         {
             if (barCode.StartsWith(codeType.PreFixed))
             {
                 return codeType.Type.ToString();
             }
         }
         return CodeMaster.BarCodeType.HU.ToString();
     }
 }