|
本帖最后由 zhouf 于 2016-6-1 10:20 编辑
报表打印时回写打印人/打印时间/打印次数
1. 进入报表设计环境
2. 开始编写代码
3. 填写代码内容(参见附A)
附A:
- procedure rptMainOnReportPrint(Sender: TfrxComponent);
- var
- sBillNo: string;
- qryCmd: TfrxADOQuery;
- begin
- //获取数据集的单据号列表
- with TfrxADOQuery(MasterData1.DataSet) do
- begin
- first;
- while not Eof do
- begin
- sBillNo := sBillNo+','+FieldByName('入检单号').Asstring;
- Next;
- end;
- end;
- //ShowMessage(sBillNo);
- //回写打印次数/打印人/打印时间
- qryCmd := TfrxADOQuery.Create(nil);
- //qryCmd.Database := TfrxADOQuery(MasterData1.DataSet).Database;
- try
- qryCmd.SQL.Text :=
- ' UPDATE a SET '
- +' iPrintCount = ISNULL(a.iPrintCount,0)+1 '
- +' ,sPrintMan = '+QuotedStr(<CurrentUserId>)
- +' ,tPrintTime = GETDATE() '
- +' FROM dbo.imClothesInHdr a(NOLOCK) '
- +' WHERE a.sBillNo IN (SELECT * FROM dbo.fnpbConvertStringToTable('+ QuotedStr(sBillNo) +','',''))'
- +' AND (a.tPrintTime IS NULL OR a.tPrintTime < DATEADD(SECOND,-2,GETDATE()));'; //两次报表防止重复更新
- //qryCmd.Open;
- qryCmd.ExecSQL;
- finally
- qryCmd.Free;
- end;
- end;
复制代码 |
|