如何自动生成编号??不重复的
KH090002.....KH090100......
09表示年份
顺便说一下,我找过别人的方法,开始如果删除就可能会出现重复。请问如何解决?
KH090002.....KH090100......
09表示年份
顺便说一下,我找过别人的方法,开始如果删除就可能会出现重复。请问如何解决?
解决方案 »
- 从C#转到delphi的困惑
- dll中的string类型??
- 用ado导出数据为excel文件用什么方法比较好?
- 挑战新难度---delphi+光笔扫描问题
- 程序和网页集成的问题
- 请问, 我写了一个接收wm_syscommand消息的过程,内容如下,可是其他消息却不好使了?????????????
- 困扰我两天的简单问题
- 在做程序员过程中,如果女朋友要你陪她,可你要工作,你该怎么办?
- 关于这ACTIVEFORM的几个问题,大虾进来看看了
- >>>>>>>>>>如何实现这个功能?(关于数据库的问题)<<<<<<<<<<
- 我是菜鸟 请教一下delphi开发工具
- 好久没有在CSDN冒泡了,***送分***
i:integer;
curdate:string;
begin
adodataset1.open;
for i:=0 to adodataset1.recordcount do
begin
curdate:=FormatDatetime('yy',now);
//adodataset1.Append;
edit1.Text:='kh'+curdate+'-00'+inttostr(i+1);
next;
CREATE proc sp_GenerateDocCode @form_id int, @doc_code nvarchar(20) output
as
declare
@flow_num nvarchar(6),
@flow_num_length int--更新流水号
update sys_eform
set flow_num = flow_num + 1
where form_id = @form_id and convert(nvarchar(6), flow_date, 112) = convert(nvarchar(6),getdate(), 112)--初始流水号
update sys_eform
set flow_date = getdate(), flow_num = 1
where form_id = @form_id and convert(nvarchar(6), flow_date, 112) <> convert(nvarchar(6),getdate(), 112)select @flow_num = convert(nvarchar(6), flow_num), @flow_num_length = flow_num_length
from sys_eform where form_id = @form_id
while (len(@flow_num) < @flow_num_length) begin
set @flow_num = '0' + @flow_num
end--组合流水号
select @doc_code = form_code_prefix + form_code_separator + convert(nvarchar(6), flow_date, 112) + form_code_separator + @flow_num from sys_eform where form_id = @form_idGO
var
strSql, strValue, strYY: String;
Temp: Integer;
begin
with adoquery do
begin
try
Close;
SQL.Clear;
strYY := FormatDateTime('yy', Now);
strSql := 'Select Max(ID) from 表名';
strSql := strSql + ' Where ID like ''%' + strYY+ '%''';
SQL.Add(strSql);
Open;
if adoquery.RecordCount = 0 then
Result := 'KH'+ strYY + '0001'
else
begin
strValue := Trim(adoquery.FieldByName('ID').AsString);
if strValue = '' then
Result := 'KH'+ strYY + '0001'
else
begin
strValue := Trim(Copy(strValue, 5, 4));
Temp := StrToInt(strValue) + 1;
Result := 'KH'+ strYY + Format('%.4d', [Temp]);
end;
end;
except
Result := 'KH'+ strYY + '0001';
end;
end;
end;