作者:houxue | 来源:互联网 | 2023-09-14 15:29
本文由编程笔记#小编为大家整理,主要介绍了csharp UDI条码解析相关的知识,希望对你有一定的参考价值。
public static List lRemoveBarcodeSpecialCharacters(string _barcode)
{
List results = new List();
// grab the cable info table
DataTable cableInfo = GlobalVariables.dsMaterialInfo.Tables["Cables"];
try
{
string temp = Regex.Replace(_barcode, @"[+%$]", "");
string remove= temp.Remove(0, 4);
int findIndexOfFirstBackSlash = remove.IndexOf("/");
string removeTheLastChar=remove.Remove(findIndexOfFirstBackSlash-1, 1);
var tempSplit = removeTheLastChar.Split('/').ToList();
//check if the part number being used is a cable
DataRow[] result = cableInfo.Select($"Part_Number = '{tempSplit[0].ToString()}' OR Identifier = '{tempSplit[0].ToString()}'");
if (result.Any())
{
if (!tempSplit[1].StartsWith("U"))
{
var length = tempSplit[1].Length;
var remove1Val = tempSplit[1].ToString().Substring(1, length - 1);
tempSplit[1] = remove1Val;
}
}
results = tempSplit;
}
catch (Exception e)
{
var message = e.Message;
GlobalVariables.GlobalMethods.bHandleFailureCode(7, _barcode);
}
return results;
}