function TForm1 . IDcreate: string ; |
var |
i: integer ; |
begin |
with Query do |
begin |
close; |
sql . Clear; |
sql . Add( 'select ID from lendcardkind order by ID' ); |
open; |
for i:= 1000 to 9999 do |
begin //for |
while not eof do |
begin //while |
if strtoint(fieldbyname( 'ID' ).AsString)=i then |
begin |
next; |
Break; |
end |
else |
begin |
if i< 10 then |
result := '000' +inttostr(i) |
else |
if i< 100 then |
result:= '00' +inttostr(i) |
else |
if i< 1000 then |
result:= '0' +inttostr(i) |
else |
if i< 10000 then |
result:=inttostr(i); |
exit; //next; |
//break; |
//break; |
end ; |
end ; //while |
end ; //for |
end ; |
end ; |