你用没用QUICKREPORT组件?这个组件问题比较多,就是你的程序没有问题,在打印的时候也会出错的。

解决方案 »

  1.   

    我用的就是QUICKREPORT组件,部分源代码如下:
    //查询当前账单号
        with qry_accntid do
        begin
         close;
         sql.clear;
         sql.Add('select currentaccntid from accntSerial');
         open;
        end;
      std:=tinifile.create('lxyzh.ini');
      TITLEMC:=std.READstring('TITLE', 'MC', '新概念俱乐部');
      std.free;
      form_warning:=tform_warning.Create(self);
      form_warning.ShowModal;
      if form_warning.ModalResult=mrok then
      begin
       rep_accnt:=trep_accnt.create(self);
       Rep_accnt.QRLabel1.Caption:=titlemc+'结帐单';
       rep_accnt.Qrlth.caption:=form_custlist.table_custtableid.Value;
       rep_accnt.qrlfwy.caption:=form_custlist.table_custwaiterid.Value;
     if trim(edit_xian.text)='' then
       rep_accnt.xian.caption:='0'
      else
       rep_accnt.xian.caption:=edit_xian.text;
     if trim(edit_quan.text)='' then
       rep_accnt.quan.caption:='0'
      else
       rep_accnt.quan.caption:=edit_quan.text;
      if trim(edit_qian.text)='' then
       rep_accnt.qian.caption:='0'
      else
       rep_accnt.qian.caption:=edit_qian.text;
     if trim(edit_zhe.text)='' then
       rep_accnt.zhe.caption:='0'
      else
       rep_accnt.zhe.caption:=edit_zhe.text;
     if trim(edit_zhao.text)='' then
       rep_accnt.zhao.caption:='0'
      else
       rep_accnt.zhao.caption:=edit_zhao.text;
     if trim(edit_zhi.text)='' then
       rep_accnt.zhi.caption:='0'
      else
       rep_accnt.zhi.caption:=edit_zhi.text;
       with query1 do
        begin
          close;
          parambyname('waiterid').datatype:=ftstring;
          parambyname('waiterid').asstring:=form_custlist.table_custwaiterid.Value;
          prepare;
          open;
          rep_accnt.qrlfwy.caption:=fieldbyname('name').asstring;
        end;
       rep_accnt.qrlzd.caption:=formatfloat('00000000',qry_accntid.fieldbyname('Currentaccntid').asfloat);
       if Label4.caption<>'' then
         rep_accnt.qrlshsh.Caption:=Label4.caption
       else
         rep_accnt.qrlshsh.Caption:='0';
       if strtoint(label1.caption) < strtoint(form_custlist.table_custlowprice.Value) then
          rep_accnt.qrlysh.Caption:=form_custlist.table_custlowprice.Value
       else
          rep_accnt.qrlysh.Caption:=label1.Caption;
      rep_accnt.Preview;
      rep_accnt.free;
     end;
    谢谢各位了!
      

  2.   

    我用的就是QUICKREPORT组件,部分源代码如下:
    //查询当前账单号
        with qry_accntid do
        begin
         close;
         sql.clear;
         sql.Add('select currentaccntid from accntSerial');
         open;
        end;
      std:=tinifile.create('lxyzh.ini');
      TITLEMC:=std.READstring('TITLE', 'MC', '新概念俱乐部');
      std.free;
      form_warning:=tform_warning.Create(self);
      form_warning.ShowModal;
      if form_warning.ModalResult=mrok then
      begin
       rep_accnt:=trep_accnt.create(self);
       Rep_accnt.QRLabel1.Caption:=titlemc+'结帐单';
       rep_accnt.Qrlth.caption:=form_custlist.table_custtableid.Value;
       rep_accnt.qrlfwy.caption:=form_custlist.table_custwaiterid.Value;
     if trim(edit_xian.text)='' then
       rep_accnt.xian.caption:='0'
      else
       rep_accnt.xian.caption:=edit_xian.text;
     if trim(edit_quan.text)='' then
       rep_accnt.quan.caption:='0'
      else
       rep_accnt.quan.caption:=edit_quan.text;
      if trim(edit_qian.text)='' then
       rep_accnt.qian.caption:='0'
      else
       rep_accnt.qian.caption:=edit_qian.text;
     if trim(edit_zhe.text)='' then
       rep_accnt.zhe.caption:='0'
      else
       rep_accnt.zhe.caption:=edit_zhe.text;
     if trim(edit_zhao.text)='' then
       rep_accnt.zhao.caption:='0'
      else
       rep_accnt.zhao.caption:=edit_zhao.text;
     if trim(edit_zhi.text)='' then
       rep_accnt.zhi.caption:='0'
      else
       rep_accnt.zhi.caption:=edit_zhi.text;
       with query1 do
        begin
          close;
          parambyname('waiterid').datatype:=ftstring;
          parambyname('waiterid').asstring:=form_custlist.table_custwaiterid.Value;
          prepare;
          open;
          rep_accnt.qrlfwy.caption:=fieldbyname('name').asstring;
        end;
       rep_accnt.qrlzd.caption:=formatfloat('00000000',qry_accntid.fieldbyname('Currentaccntid').asfloat);
       if Label4.caption<>'' then
         rep_accnt.qrlshsh.Caption:=Label4.caption
       else
         rep_accnt.qrlshsh.Caption:='0';
       if strtoint(label1.caption) < strtoint(form_custlist.table_custlowprice.Value) then
          rep_accnt.qrlysh.Caption:=form_custlist.table_custlowprice.Value
       else
          rep_accnt.qrlysh.Caption:=label1.Caption;
      rep_accnt.Preview;
      rep_accnt.free;
     end;
    谢谢各位了!