怎麽实现按一下按钮,比如“新增”按钮,让入库单号自动生成,比方说今天的第一张入库单号为20030428001,再按一下“新增”,则新入库单编号为20030428002,即实现入库单号自增长(入库单号前8位代表日期)

解决方案 »

  1.   

    用copy载取后几位,根据其序列进行递增.
      

  2.   

    可以写代码自己实现,首先得到数据库中最大的id,于今天的日期比较,如果不相同id为今天的日期加上001,如果相同取出后三位,在上面加一。应该不困难。
      

  3.   

    string s="20030428"
    int no;
    string c = IntToStr(no);
    int i = 4- leangth(c);
    int j;
    for  j = 1 to i do
     s =s  + "0";
    s = s+ c;
    return s;
      

  4.   

    var s,d,l,n:string;
    begin
      d:=copy('20030428002',1,8);
      s:=copy('20030428002',9,3);
      if d<>formatdatetime('yyyymmdd',now) then 
         n:=formatdatetime('yyyymmdd',now)+'001'
      else 
      begin
        l:='00'+inttostr(inc(strtoint(s)));
        n:=d+copy(l,length(l)-2,3);
      end;
      
      

  5.   

    var
     s,d,j,n:string;
    begin
      d:=copy('20030428002',1,8);
      s:=copy('20030428002',9,3);
      if d<>formatdatetime('yyyymmdd',now) then 
         n:=formatdatetime('yyyymmdd',now)+'001'
      else 
      begin
        j:=copy(inttostr(strtoint('1'+s)+1),2,3);
        n:=d+j;
      end;