View difference between Paste ID: FbW268rE and Q9QzgpZX
SHOW: | | - or go back to the newest paste.
1-
public static int getEAN13CheckSum(string strData)
1+
public static string getEAN13CheckSum(string valore)
2
{
3-
	int iLen = strData.Length;
3+
	int iSum = 0;
4-
	int i = 0;
4+
	int iDigit = 0;
5-
	int result = 0;
5+
6-
	int getSum = 0;
6+
	// Calculate the checksum digit here.
7-
	string parseStr = strData.Trim();
7+
	for( int i = valore.Length; i >= 1; i-- )
8-
	string CharInt = "";
8+
9-
	while (parseStr.Length != 0) // (iLen - 1))
9+
		iDigit = Convert.ToInt32( valore.Substring( i - 1, 1 ) );
10
		if( i % 2 == 0 )
11-
		CharInt = ClsReusable.Left(parseStr, 1); // Len: 1 - Line Size ( Trim first two character )
11+
		{	// odd
12-
		parseStr = ClsReusable.Right(parseStr, parseStr.Length - 1);
12+
			iSum += iDigit * 3;
13
		}
14-
		if ((i % 2) == 0)
14+
15-
			result = Convert.ToInt32(CharInt) * 1; //Even num Position
15+
		{	// even
16
			iSum += iDigit * 1;
17-
			result = Convert.ToInt32(CharInt) * 3; //Odd num Position
17+
		}
18
	}
19-
		i = i + 1;
19+
20-
		getSum = result + getSum;
20+
	int iCheckSum = ( 10 - ( iSum % 10 )  ) % 10;
21-
		result = 0;
21+
	return iCheckSum.ToString();
22
}