看看我的代码,我是200603010001做编号的.如果你前面的字母都一致,那可以套用.if dm.ADOQuery4.RecordCount = 0 then begin num1 := formatdatetime('yy年MM月dd日',now); num2 := '001'; edit16.Text := num1 + num2 ; end else if dm.ADOQuery4.RecordCount > 0 then begin DM.ADOQuery4.Close ; DM.ADOQuery4.SQL.Clear ; DM.ADOQuery4.SQL.Add('select max(消费单号) from account '); dm.ADOQuery4.Open; if dm.ADOQuery4.Fields[0].Value <> '' then begin num1 := formatdatetime('yy年MM月dd日',now); if copy(dm.ADOQuery4.Fields[0].Value,0,6) = formatdatetime('yy年MM月dd日',now) then begin i := strtoint(copy(dm.ADOQuery4.Fields[0].Value,7,3)) + 1; if length(inttostr(i)) = 1 then num2 := '0' + '0' + inttostr(i) else if length(inttostr(i)) = 2 then num2 := '0' + inttostr(i) else if length(inttostr(i)) = 3 then num2 := inttostr(i) end else num2 := '001'; edit16.Text := num1 + num2 ; end; end;
begin
num1 := formatdatetime('yy年MM月dd日',now);
num2 := '001';
edit16.Text := num1 + num2 ;
end
else if dm.ADOQuery4.RecordCount > 0 then
begin
DM.ADOQuery4.Close ;
DM.ADOQuery4.SQL.Clear ;
DM.ADOQuery4.SQL.Add('select max(消费单号) from account ');
dm.ADOQuery4.Open;
if dm.ADOQuery4.Fields[0].Value <> '' then
begin
num1 := formatdatetime('yy年MM月dd日',now);
if copy(dm.ADOQuery4.Fields[0].Value,0,6) = formatdatetime('yy年MM月dd日',now) then
begin
i := strtoint(copy(dm.ADOQuery4.Fields[0].Value,7,3)) + 1;
if length(inttostr(i)) = 1 then
num2 := '0' + '0' + inttostr(i)
else if length(inttostr(i)) = 2 then
num2 := '0' + inttostr(i)
else if length(inttostr(i)) = 3 then
num2 := inttostr(i)
end
else
num2 := '001';
edit16.Text := num1 + num2 ;
end;
end;