delphi中 如何使打印的单据号 QRLABLE赋值成为00008,而不是默认的8(10分)

  • 主题发起人 主题发起人 blue747
  • 开始时间 开始时间
QRLabel.Caption := format('%.5d',[8]);
 
忘了说了 要赋值的单据号是变量 Float [:)]
 
Qrlabel.caption:=format('%.5d',[float])
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, QuickRpt, QRCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
QuickRep1: TQuickRep;
TitleBand1: TQRBand;
QRLabel1: TQRLabel;
procedure QRLabel1Print(sender: TObject;
var Value: String);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation
{$R *.dfm}
procedure TForm1.QRLabel1Print(sender: TObject;
var Value: String);
begin
Value:=format('%.5d',[strtoint(Value)]);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
QuickRep1.Preview;
end;

end.

 
Qrlabel.caption:=rightstr(inttostr(int(float)+100000),5)
 
为什么用了变量后会报错呢??
no user transaction is current in progress
用例子 QRLabel.Caption := format('%.5d',[8])却可以
 
我的源程序部分;
procedure Tfrmys.ToolButton3Click(Sender: TObject);
var
mark:integer;
id:double;
djh:double;
begin
id:=0;
if load=true then
application.MessageBox('数据装入状态不能执行保存操作!','提示',MB_OK);
if load=false then
begin
mark:=application.MessageBox('确认此次保存操作!','提示',MB_OKCANCEL);
if mark=IDOK then
begin
tableysd.Active:=true;
tableysd.Last;
id:=tableysdid1.Value;
frmpassword.Database1.StartTransaction;
try
table1.First;
while not table1.Eofdo
begin
id:=id+1;
tableysd.Append;
tableysdid1.Value:=id;
{ysdid2=cgdid1}
tableysdid2.Value:=table1id1.Value;
tableysdspdh.AsString:=table1spdh.AsString;
tableysdpm.AsString:=table1pm.AsString;
tableysdgg.AsString:=table1gg.AsString;
tableysdcd.AsString:=table1cd.AsString;
tableysdyssl.Value:=table1yssl.Value;
tableysdph.AsString:=table1ph.AsString;
tableysdxq.AsString:=table1xq.AsString;
tableysdpzwh.AsString:=table1pzwh.AsString;
tableysdzlzk.AsString:=table1zlzk.AsString;
tableysdysjg.AsString:=table1ysjg.AsString;
tableysdysr.AsString:=table1ysr.AsString;
tableysdcw.AsString:=table1cw.AsString;
tableysdscsp.AsString:=table1scsp.AsString;
tableysdscbh.AsString:=table1scbh.AsString;
tableysdscbh_j.AsString:=table1scbh_j.AsString;
tableysdqt1.Value:=table1qt1.Value;{采购数量}
tableysdqt2.AsString:=table1qt2.AsString;
tableysdqt3.Value:=table1qt3.Value;{采购扣率}
tableysdqt4.AsString:='N';
tableysddhrq.AsString:=table1dhrq.AsString;
tableysdghdwbh.AsString:=table1ghdwbh.AsString;
tableysdghdwmc.AsString:=table1ghdwmc.AsString;
tableysd.Post;
{修改采购单验收字段,qt3=Y}
tablecgd.Active:=true;
tablecgd.SetKey;
tablecgd.FieldByName('id1').value:=table1id1.Value;
if tablecgd.GotoKey then
begin
tablecgd.Edit;
tablecgdqt3.AsString:='Y';
tablecgddhsl.Value:=tablecgddhsl.Value+table1yssl.Value;
tablecgd.Post;
end;
tablecgd.Active:=false;
table1.Next;
end;
{while not table1.Eofdo
}
frmpassword.Database1.Commit;
load:=true;
application.MessageBox('保存操作完成!','提示',MB_OK);
dybz:=true;
frmprint_ysd.QRLabel36.Caption:=frmys.Editdwbh.Text;
frmpassword.Database1.StartTransaction;
try
table2.Active:=true;
djh:=table2ysdjh.Value;
djh:=djh+1;
table2.Edit;
table2ysdjh.Value:=djh;
table2.Post;
frmpassword.Database1.Commit;
{关闭单据号数据库}
table2.Active:=false;
except
application.MessageBox('操作异常失败,请再试一次!','提示',MB_OK);
frmpassword.Database1.Rollback;
end;
frmprint_ysd.QRLabel38.Caption:=format('%.5d',[floattostr(djh)]);
// 就是这里
frmprint_ysd.Preview;
except
frmpassword.Database1.Rollback;
application.MessageBox('数据异常出错!','提示',MB_OK);
end;
{try}
tableysd.Active:=true;
tableysd.Edit;
tableysdysdjh.Value:=djh;
tableysd.Post;
tableysd.Active:=false;
end;
{if mark:=IDOK then
}
end;
{if load=false then
}
 
多人接受答案了。
 
后退
顶部