📄 ustugrrep.pas
字号:
{ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: QuickReport 3.0 for Delphi 3.0/4.0/5.0 ::
:: ::
:: Master/Detail report with some extra code ::
:: ::
:: Copyright (c) 1995-1999 QuSoft AS ::
:: All Rights Reserved ::
:: ::
:: web: http://www.qusoft.com fax: +47 22 41 74 91 ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }
unit uStuGrRep;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
QuickRpt, Qrctrls, Db, DBTables, ExtCtrls, ADODB;
type
TfrmStuGrRep = class(TForm)
QuickRep1: TQuickRep;
DetailBand1: TQRBand;
PageHeaderBand1: TQRBand;
QRStuSno: TQRSubDetail;
QRStuGr: TQRSubDetail;
QRGroupKind: TQRGroup;
QRShapeGray: TQRShape;
GroupFooterBand1: TQRBand;
QRBand1: TQRBand;
QRBand2: TQRBand;
QRExpr1: TQRExpr;
QRExpr2: TQRExpr;
QRLabel6: TQRLabel;
QRShape1: TQRShape;
QRLabel4: TQRLabel;
QRLabel7: TQRLabel;
QRLabel8: TQRLabel;
QRLabel9: TQRLabel;
QRLabel10: TQRLabel;
QRLabel11: TQRLabel;
QRLabel12: TQRLabel;
QRDBText3: TQRDBText;
QRDBText1: TQRDBText;
QRDBText4: TQRDBText;
QRDBText9: TQRDBText;
QRDBStuSNo: TQRDBText;
QRDBStuSName: TQRDBText;
QRDBText5: TQRDBText;
QRDBText2: TQRDBText;
QRDBText6: TQRDBText;
ADOQrySdept: TADOQuery;
ADOQryStuSno: TADOQuery;
ADOQryStuGr: TADOQuery;
DsSdept: TDataSource;
DSStuSNo: TDataSource;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure QRStuSnoBeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
procedure QRStuGrBeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
procedure QRGroupKindBeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
procedure DetailBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
procedure QRStuGrAfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
procedure PageHeaderBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmStuGrRep: TfrmStuGrRep;
implementation
uses uDm ;
{$R *.DFM}
procedure TfrmStuGrRep.FormCreate(Sender: TObject);
begin
if not ADOQrySdept.Active then
ADOQrySdept.Active := True ;
if not ADOQryStuSno.Active then
ADOQryStuSno.Active := True ;
if not ADOQryStuGr.Active then
ADOQryStuGr.Active := True ;
end;
procedure TfrmStuGrRep.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if ADOQryStuGr.Active then
ADOQryStuGr.Close ;
if ADOQryStuSno.Active then
ADOQryStuSno.Close ;
if ADOQrySdept.Active then
ADOQrySdept.Close ;
end;
procedure TfrmStuGrRep.DetailBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
begin
// If there are no subdetails, then we print this band. Otherwise we
// let the group header print the controls from this band. Group bands
// can be reprinted on page breaks, which detail and subdetails can't do.
ADOQryStuSno.First;
PrintBand := ADOQryStuSno.EOF;
// If it's our turn to print and the group band has our controls, then
// we take them back.
if PrintBand and (Sender.ControlCount = 0) then
with QRGroupKind do
while ControlCount > 0 do
Controls[0].Parent := Sender;
end;
procedure TfrmStuGrRep.QRGroupKindBeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
begin
// We grab the detail band fields right from under it.
if Sender.ControlCount = 0 then
with DetailBand1 do
While ControlCount > 0 do
Controls[0].Parent := Sender;
end;
procedure TfrmStuGrRep.QRStuSnoBeforePrint(
Sender: TQRCustomBand; var PrintBand: Boolean);
begin
// We are print the order information on the first item subdetail
// record. If there are no item records, then we print the subdetail
// Enable the order fields on the item subdetail band. After they are
// printed once, they will be disabled until the next order/item set
QRDBStuSNo.Enabled := true;
QRDBStuSName.Enabled := QRDBStuSNo.Enabled;
// Only allow this band to print if there are no subdetails
ADOQryStuGr.First;
PrintBand := ADOQryStuGr.EOF;
end;
procedure TfrmStuGrRep.QRStuGrBeforePrint(
Sender: TQRCustomBand; var PrintBand: Boolean);
begin
// toggle the item background so that we can have alternating colors
// like the greenbar paper we all know and love.
with QRShapeGray.Brush do
if Color = $00F0F0F0 then
Color := $00E0E0E0
else
Color := $00F0F0F0;
end;
procedure TfrmStuGrRep.QRStuGrAfterPrint(
Sender: TQRCustomBand; BandPrinted: Boolean);
begin
// After we print it once, we disable the controls
QRDBStuSNo.Enabled := false;
QRDBStuSName.Enabled := QRDBStuSNo.Enabled;
end;
procedure TfrmStuGrRep.PageHeaderBand1BeforePrint(
Sender: TQRCustomBand; var PrintBand: Boolean);
begin
// Re-enable the order fields on the item subdetail so that the order
// information will be repeated after a page break
QRDBStuSNo.Enabled := true;
QRDBStuSName.Enabled := QRDBStuSNo.Enabled;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -