Function TfrmWKOTMas.PrintReport(PrtType:Integer):Boolean;
var
FilePath:String;
i,iRecord,iRec:integer;
begin
FilePath:=ExtractFilePath(Application.ExeName)+'/Reports/'+'WKOTReport.frf';
if not FileExists(FilePath) then
begin
MessageDlg(SReportFileNotExists,mtError,[mbOK],0);
Exit;
end;
qryForPrint.Active :=False;
qryForPrint.SQL.Text :='SELECT * FROM [Person].[dbo].[FN_EmpWKOT_GetBillDetForPrint]('+ qryHead.fieldByName('sysBillNo').AsString +')';
qryForPrint.SQL.Text :=qryForPrint.SQL.Text + ' Order by Class_Name DESC,Serial_Name DESC,Line_Name DESC,Item_Name DESC';
qryForPrint.Active:=True;
iRecord:=qryForPrint.RecordCount;
iRec:=iRecord;
iRecord:=25-(iRecord MOD 25);
if iRecord<25 then
begin
qryhead.Edit;
for i:=1 to iRecorddo
begin
qryForPrint.Append;
iRec:=iRec+1;
qryForPrint.Post;
end;
end;
frReport.LoadFromFile(filePath);
if frReport.PrepareReport then
if PrtType=1 then
frReport.ShowPreparedReport
else
frReport.PrintPreparedReportDlg;
end;