11-01-2012, 10:14 PM
السلام عليكم
كود :
Function ID_Validation(SEGEL_NO:String):Boolean;
var i, TOT:Integer;
TEMP, FIN:String;
begin
TOT := 0;
For i := 1 To 9 do begin
If (i = 1) Or (i = 3) Or (i = 5) Or (i = 7) Or (i = 9) Then
begin
TEMP := IntToStr(strtoint(Copy(SEGEL_NO, i, 1)) * 2);
If Length(TEMP) = 1 Then TEMP := '0' + TEMP;
TOT := TOT + strtoint(Copy(TEMP, 1, 1)) + strtoint(Copy(TEMP, 2, 1));
end
Else
TOT := TOT + strtoint(Copy(SEGEL_NO, i, 1));
End;
If Length(IntToStr(TOT)) = 1 Then
FIN := '0' + inttostr(TOT)
Else
FIN := inttostr(TOT);
Result := (StrToInt(Copy(FIN, 2, 1)) = StrToInt(Copy(SEGEL_NO, 10, 1))) Or (StrToInt(Copy(SEGEL_NO, 10, 1)) = 10 - StrToInt(Copy(FIN, 2, 1)))
end;
