(The Part I)
procedure TFrmFactoryReport1.BtnPrintClick(Sender: TObject);
var
PageNumber: Integer;
begin
//get the number of pages
PageNumber:=0;
FrmFactoryOutPut.QuickRep1.Prepare;
PageNumber:= FrmFactoryOutPut.QuickRep1.QRPrinter.PageNumber;
FrmFactoryOutPut.QuickRep1.QRPrinter.Free;
FrmFactoryOutPut.QuickRep1.QRPrinter:= nil;
SumPageNumber:= PageNumber;
DataModule1.ADOFactoryOutPut.First;
FrmFactoryOutPut.QRLabel8.Caption:= '共 ' + IntToStr(PageNumber) + ' Page ';
FrmFactoryOutPut.Count_Amount:= 0;
FrmFactoryOutPut.QuickRep1.Preview;
end;
The Part II
public
{ Public declarations }
CountAmount: Integer;
Function AddNumber(sStr: String) : String;
function VarToString(Var InputVar: Real;
DecimalPoint:Integer) : String;
var
FactoryAmount: Integer;
procedure TFrmFactoryOutPut.QRBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
begin
FactoryAmount:= 0;
end;
procedure TFrmFactoryOutPut.QRBand3AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
begin
FactoryAmount:= FactoryAmount + DataModule1.ADOFactoryOutPut.Fields.FieldByName('FactoryAmount').AsInteger ;
end;
procedure TFrmFactoryOutPut.QRBand4BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
begin
CountAmount:= CountAmount + FactoryAmount;
QRLabel48.Caption:= 'Amount of The Page: ' + AddNumber(IntToStr(FactoryAmount)) + ' 件';
if Pos(IntToStr(FrmFactoryReport1.SumPageNumber),QRSysData2.Caption) > 0 then
begin
QRLabel48.Caption:= QRLabel48.Caption + ' All : ' + AddNumber(IntToStr(CountAmount)) + ' 件';
end;
end;
Function TFrmFactoryOutPut.AddNumber(sStr: String): String;
begin
if Length(sStr) > 3 then
begin
if Length(sStr) > 6 then
begin
AddNumber:= Copy(sStr,0,Length(sStr)-6) + ',' + Copy(sStr,Length(sStr)-5,3) + ',' + Copy(sStr,Length(sStr)-2,3);
end
else
AddNumber:= Copy(sStr,0,Length(sStr)-3) + ',' + Copy(sStr,Length(sStr)-2,3);
end
else
AddNumber:= sStr;
end;
procedure TFrmFactoryOutPut.QRBand4AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
begin
if Pos(IntToStr(FrmFactoryReport1.SumPageNumber),QRSysData2.Caption) > 0 then
CountAmount:= 0;
end;
function TFrmYarnStateReport.VarToString(Var InputVar: Real;
DecimalPoint:Integer) : String;
var
strOut : String;
i,j : integer;
begin
str(InputVar:14
ecimalPoint,StrOut);
StrOut := trim(StrOut);
if DecimalPoint = 2 then
i := 6 else
i := 3;
while length(strout) > ido
begin
j := length(StrOut) - i + 1;
insert(',',strout,j);
i := i + 4;
end;
i := length(StrOut) - 2;
if Copy(StrOut,1,2) = '-,' then
StrOut := '-'+Copy(StrOut,3,i);
VarToString := StrOut;
end;