📄 report_sj.~pas
字号:
unit report_sj;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, QuickRpt, ExtCtrls, DB, ADODB, QRCtrls, StdCtrls;
type
TF_report_sj = class(TForm)
QuickRep1: TQuickRep;
TitleBand1: TQRBand;
QRLabel1: TQRLabel;
QRLabel2: TQRLabel;
QRLabel3: TQRLabel;
ADOQuery1: TADOQuery;
QRBand1: TQRBand;
qrband2: TQRBand;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
F_report_sj: TF_report_sj;
implementation
uses main,global,U_global_setting;
{$R *.dfm}
procedure TF_report_sj.Button1Click(Sender: TObject);
begin
quickrep1.Preview;
end;
procedure TF_report_sj.FormCreate(Sender: TObject);
var
mylabel:TQRLABEL;
mytext:TQRDBTEXT;
i:integer;
myleft:integer;
colcount:integer;
names:array[0..17] of string;
names_index:integer;
begin
names_index:=0;
if (global.sj_sqlstr<>'') then
begin
try
adoquery1.SQL.Clear;
adoquery1.SQL.Add(global.sj_sqlstr);
adoquery1.Open;
except
if messagedlg('没有正确配置输出项,是否现在要配置?',mtwarning,[mbyes,mbno],0)=mryes then
begin
U_global_setting.F_setting.Show;
U_global_setting.F_setting.PageControl1.Pages[4].SetFocus;
exit;
end
else
exit;
end;
if adoquery1.Eof then
begin
messagedlg('试卷无记录,错误',mterror,[mbok],0);
exit;
end;
if U_global_setting.F_setting.CheckListBox1.Checked[0] then
qrlabel1.Caption:='['+inttostr(adoquery1.FieldValues['试卷号'])+']'
else
qrlabel1.Caption:='';
if U_global_setting.F_setting.CheckListBox1.Checked[1] then
qrlabel2.Caption:=adoquery1.FieldValues['试卷名称']
else
qrlabel2.Caption:='';
if U_global_setting.F_setting.CheckListBox1.Checked[2] then
qrlabel3.Caption:='出卷人:'+adoquery1.FieldValues['出卷人']
else
qrlabel3.Caption:='';
for i:=0 to U_global_setting.F_setting.CheckListBox1.Items.Count-1 do
begin
if U_global_setting.F_setting.CheckListBox1.Checked[i] then
begin
if i=0 then continue;
if i=1 then continue;
if i=2 then continue;
names[names_index]:=U_global_setting.F_setting.CheckListBox1.Items[i];
inc(names_index);
inc(colcount);
end;
end;
for i:=0 to colcount-1 do
begin
mylabel:=Tqrlabel.Create(self);
mylabel.Parent:=qrband1;
with mylabel do
begin
top:=0;
autosize:=false;
left:=myleft;
width:=qrband1.Width div colcount;
// height:=qrband1.Height;
font.Name:='宋体';
caption:=names[i];
font.Size:=12;
alignment:=tacenter;
end;
mytext:=Tqrdbtext.Create(self);
mytext.Parent:=qrband2;
with mytext do
begin
top:=0;
autosize:=false;
left:=myleft;
width:=qrband2.Width div colcount;
// height:=qrband2.Height;
font.Name:='宋体';
font.Size:=8;
dataset:=adoquery1;
datafield:=names[i];
alignment:=tacenter;
end;
myleft:=myleft+qrband2.Width div colcount;
adoquery1.Next;
end; // end of for
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -