当前位置:首页 > 软件开发 > dev
firefox

将小写数字金额转成大写金额

procedure tfmbmzc.bitbtn2click(sender: tobject); //金额转换
const
  chnum : array[0..9] of string = (零,壹,贰,叁,肆,伍,陆,柒,捌,玖);
  chbit : array[0..3] of string = (圆,拾,佰,仟);
var
  y, m, d : word;
  s : string;
  len, n , tmp: integer;
  biszero : boolean;
begin
  decodedate(date, y, m, d);
  jfjechange();
  with fmprint do begin
    qryear.caption:=inttostr(y);
    qrmonth.caption:=inttostr(m);
    qrday.caption:=inttostr(d);

    qrname.caption:=edname.text;

    qrxmoney.caption:=jf;

//对照表生成小写金额的大写
    biszero:=false;
    n:=pos(., jf); //小数点前的处理
    if n=0 then
      len:=length(jf)
    else
      len:=n-1;
    for n:=1 to len do begin
      tmp:=strtoint(jf[n]);
      if tmp=0 then begin
        if n<len then
          biszero:=true
        else if n=len then
          s:=s + chbit[len-n];
      end
      else begin
        if biszero then begin
          s:=s+chnum[0]+chnum[tmp] + chbit[len-n];
          biszero:=false;
        end
        else
          s:=s+chnum[tmp] + chbit[len-n];
      end;
    end;

    if length(jf)>len then begin //小数点后的处理
      if len+2<=length(jf) then begin
        tmp:=strtoint(jf[len+2]);
        if tmp=0 then
          s:=s+零
        else
          s:=s+chnum[tmp]+角;
      end;
      if len+3<=length(jf) then
        s:=s+chnum[strtoint(jf[len+3])]+分;
    end;
    qrdmoney.caption:=s;

    qrshow.caption:=辅修报名注册费。;

    qrhandler.caption:=僧格淋沁;

    quickrep1.preview;
  end;
end;

procedure tfmbmzc.jfjechange();  //对输入框中内容的控制
var
  tmp : string;
begin
//计算"缴费金额"
  jf:=trim(copy(medjfje.text, 1, 4));
  if jf= then //"元"为空
    jf:=0;

  tmp:=trim(copy(medjfje.text, 7, 1));
  if tmp= then begin file://"角"为空
    tmp:=trim(copy(medjfje.text, 10, 1));
    if tmp<> then //填写了"分"
      jf:=jf+.0+tmp;
  end
  else begin //填写了"角"
    jf:=jf+.+tmp;
    tmp:=trim(copy(medjfje.text, 10, 1));
    if tmp<> then //填写了"分"
      jf:=jf+tmp;
  end;

  jf:=floattostr(strtofloat(jf));
end;

end.

 ↓相关文章:
© 2006-2008 All Rights Reserved