现在有一个客户编号,比如是cd1085(当然也许会是dds885,或c1025什么别的),现在我想按一下按钮,实现客户号自动加1,cd1085变成cd1086,cd1087......
请问我该如何实现?

解决方案 »

  1.   

    在客户表上使用一个beforeupdate触发器,先得到客户表中最大的客户编号,
    然后加1.
      

  2.   


    http://expert.csdn.net/Expert/topic/1119/1119022.xml?temp=.8083155我发现你小子好走运。是解决长度为6位数的函数;
      public
       rember:string;
       function rem(str:string):string;
        { Public declarations }
      end;
    procedure Tform1.button1click(sender:object)
    begin
    rember:=edit1.text; 就是你的Cm00001
    Edtcode.text.text:=rem(rember);  //调用取下了个cbh的号码;
    end;
    Function Tform1.rem(str:string):string;
    Var
      Str1:string;
      num:string; //用于存放数字
      num1:string; //用于存放字符 A00001;
      sjnum:integer;//用于存放转换后的num;
      i:integer;
      J:INTEGER; //用于存放数字是多少位;
      k:integer;
    begin
       for i:=1 to 6 do
       begin
         str1:=copy(TRIM(str),i,1);    if (str1>='A') AND (STR1<='Z') then
          num1:=num1+str1
          else
          num:=num+str1;
       end;
       j:=length(num);
       sjnum:=strtoint(num);
       sjnum:=sjnum+1;          //将编号加num+1
       num:=inttostr(sjnum);
       if length(num)<j
       then
       k:=j-length(num);
       for i:=1 to k do
       begin
        num:='0'+num;
       end;
       result:=num1+num;
    end;
    注意上面的只能是'A'-'Z', 没有解决'a'-'z'如果是7位把上面的 for i:=1 to 6 改成for i:=1 to 7
      

  3.   

    如果编号是固定格式就好办,用RightStr截取数字部分进行加1,在和非数字部分合成
      

  4.   

    连接数据库,取回一个序列值(ORACLE),然后连接上字符部份.
    假如序列为seq ,则查找SQl为:
    select seq.nextval as a from dual;
      

  5.   

    delphi中有一個mastapp示範程序有解決這方面的問題!