📄 dy1.pas
字号:
unit dy1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, QuickRpt,db,qrctrls,printers,shellapi;
type
Tdy = class(TForm)
ListBox1: TListBox;
ListBox2: TListBox;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
SpeedButton1: TSpeedButton;
bitbtn3: TSpeedButton;
bitbtn4: TSpeedButton;
bitbtn5: TSpeedButton;
bitbtn6: TSpeedButton;
bitbtn1: TSpeedButton;
bitbtn2: TSpeedButton;
bitbtn7: TSpeedButton;
QuickRep1: TQuickRep;
TitleBand1: TQRBand;
ColumnHeaderBand1: TQRBand;
DetailBand1: TQRBand;
procedure BitBtn5Click(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn6Click(Sender: TObject);
procedure BitBtn7Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
dy: Tdy;
maxwidth,totalwidth:integer;
procedure columnswidth;
procedure disposecontrols;
implementation
uses chaxun2, dd1,quan;
{$R *.dfm}
procedure Tdy.BitBtn5Click(Sender: TObject);
begin
disposecontrols;
zcx.Query2.Open;
close;
end;
procedure Tdy.FormPaint(Sender: TObject);
var a,b:real;
i:integer;
begin
a:=clientheight/256;
b:=0;
for i:=255 downto 0 do
begin
canvas.Brush.Color:=$000000000+i*$10000;
canvas.FillRect(rect(0,round(b),clientwidth,round(a+b)));
b:=b+a;
end;
end;
procedure Tdy.FormCreate(Sender: TObject);
begin
bitbtn2.Enabled:=false;
bitbtn7.Enabled:=false;
end;
procedure Tdy.BitBtn1Click(Sender: TObject);
begin
if listbox1.Items.Count=0 then
exit;
if listbox1.Selected[listbox1.ItemIndex] then
begin
listbox2.Items.Add(listbox1.Items[listbox1.itemindex]);
listbox1.Items.Delete(listbox1.ItemIndex);
if listbox2.Items.Count>=1 then
bitbtn2.Enabled:=true;
bitbtn7.Enabled:=true;
end;
end;
procedure Tdy.BitBtn2Click(Sender: TObject);
begin
if listbox2.Items.Count=0 then
exit;
if listbox2.Selected[listbox2.ItemIndex] then
begin
listbox1.Items.Add(listbox2.Items[listbox2.itemindex]);
listbox2.Items.Delete(listbox2.ItemIndex);
end;
if listbox2.Items.Count=0 then
bitbtn2.Enabled:=false;
bitbtn1.Enabled:=true;
bitbtn6.Enabled:=true;
end;
procedure columnswidth;
var i:integer;
qrdbtext:string;
begin
maxwidth:=0;
for i:=0 to dy.ListBox2.Items.Count-1 do
begin
if dy.listbox2.Items.Strings[i]='编号' then
qrdbtext:='bian_hao'
else
if dy.listbox2.Items.Strings[i]='姓名' then
qrdbtext:='xing_ming'
else
if dy.listbox2.Items.Strings[i]='性别' then
qrdbtext:='xing_bie'
else
if dy.listbox2.Items.Strings[i]='旷工次数' then
qrdbtext:='kuang_gong'
else
if dy.listbox2.Items.Strings[i]='事假次数' then
qrdbtext:='shi_jia'
else
if dy.listbox2.Items.Strings[i]='迟到次数' then
qrdbtext:='ci_dao'
else
if dy.listbox2.Items.Strings[i]='部门名称' then
qrdbtext:='bu_men'
else
if dy.listbox2.Items.Strings[i]='职称' then
qrdbtext:='zhi_cheng'
else
if dy.listbox2.Items.Strings[i]='总工资' then
qrdbtext:='zong'
else
if dy.listbox2.Items.Strings[i]='奖金' then
qrdbtext:='jiang_jin'
else
if dy.listbox2.Items.Strings[i]='基本工资' then
qrdbtext:='ji_ben'
else
if dy.listbox2.Items.Strings[i]='出生日期' then
qrdbtext:='date';
if zcx.query2.Fields.FieldByName(qrdbtext).DataSize>maxwidth then
maxwidth:=zcx.query2.Fields.FieldByName(qrdbtext).DataSize;
if length(qrdbtext)>maxwidth then
maxwidth:=length(qrdbtext);
end;
totalwidth:=0;
for i:=0 to dy.ListBox2.Items.Count-1 do
totalwidth:=totalwidth+maxwidth+4;
end;
procedure disposecontrols;
var i:integer;
begin
for i:=0 to dy.titleBand1.ControlCount-1 do
dy.titleBand1.RemoveControl(dy.titleBand1.Controls[0]);
for i:=1 to dy.columnheaderband1.controlcount do
dy.columnheaderband1.removecontrol(dy.columnheaderband1.Controls[0]);
for i:=1 to dy.detailband1.controlcount do
dy.detailband1.RemoveControl(dy.DetailBand1.Controls[0]);
zcx.query2.Close;
end;
procedure Tdy.BitBtn3Click(Sender: TObject);
var i:integer;
leftx:integer;
widthperbyte:integer;
heading:Tqrlabel;
qrlabel:Tqrlabel;
qrdbtext:tqrdbtext;
begin
quickrep1.DataSet:=zcx.query2;
widthperbyte:=3;
columnswidth;
disposecontrols;
if totalwidth*widthperbyte>800 then
begin
application.MessageBox('报表超宽,请调整后再输出','警告',1);
exit;
end
else
if totalwidth*widthperbyte>794 then
dd.QuickRep1.Page.Orientation:=polandscape
else
QuickRep1.Page.Orientation:=poportrait;
heading:=Tqrlabel.Create(self);
heading.Parent:=dy.titleband1;
heading.Caption:=edit1.Text;
heading.Font.Size:=16;
heading.Font.Style:=[fsbold];
heading.Alignment:=tacenter;
heading.Width:=length(edit1.Text)*(widthperbyte+4);
heading.Left:=(QuickRep1.Width-heading.Width)div 3;
heading.Height:=dy.TitleBand1.height-1;
heading.Top:=0;
leftx:=0;
QuickRep1.Font.Size:=8;
for i:=0 to listbox2.Items.Count-1 do
begin
qrlabel:=tqrlabel.Create(self);
qrlabel.Parent:=dy.columnheaderband1;
qrlabel.Font.Style:=[fsbold];
qrlabel.Left:=leftx+2;
qrlabel.Width:=maxwidth*widthperbyte;
qrlabel.Height:=dy.columnheaderband1.height-2;
qrlabel.Top:=6;
qrlabel.Caption:=listbox2.Items.Strings[i];
qrdbtext:=tqrdbtext.Create(self);
qrdbtext.Parent:=dy.DetailBand1;
qrdbtext.Left:=leftx+2;
qrdbtext.Width:=maxwidth*widthperbyte;
qrdbtext.Height:=dy.DetailBand1.height-2;
qrdbtext.Top:=6;
qrdbtext.DataSet:=zcx.query2;
if listbox2.Items.Strings[i]='编号' then
qrdbtext.DataField:='bian_hao'
else
if listbox2.Items.Strings[i]='姓名' then
qrdbtext.DataField:='xing_ming'
else
if listbox2.Items.Strings[i]='性别' then
qrdbtext.DataField:='xing_bie'
else
if listbox2.Items.Strings[i]='旷工次数' then
qrdbtext.DataField:='kuang_gong'
else
if listbox2.Items.Strings[i]='事假次数' then
qrdbtext.DataField:='shi_jia'
else
if listbox2.Items.Strings[i]='迟到次数' then
qrdbtext.DataField:='ci_dao'
else
if listbox2.Items.Strings[i]='部门名称' then
qrdbtext.DataField:='bu_men'
else
if listbox2.Items.Strings[i]='职称' then
qrdbtext.DataField:='zhi_cheng'
else
if listbox2.Items.Strings[i]='总工资' then
qrdbtext.DataField:='zong'
else
if listbox2.Items.Strings[i]='奖金' then
qrdbtext.DataField:='jiang_jin'
else
if listbox2.Items.Strings[i]='基本工资' then
qrdbtext.DataField:='ji_ben'
else
if listbox2.Items.Strings[i]='出生日期' then
qrdbtext.DataField:='date';
leftx:=leftx+maxwidth*widthperbyte+4;
end;
zcx.Query2.Open;
QuickRep1.Preview;
end;
procedure Tdy.BitBtn6Click(Sender: TObject);
var i:integer;
begin
if listbox1.Items.Count=0 then
exit;
for i:=0 to listbox1.Items.Count-1 do
begin
listbox2.Items.Add(listbox1.Items.Strings[i]);
bitbtn1.Enabled:=false;
bitbtn6.Enabled:=false;
bitbtn2.Enabled:=true;
bitbtn7.Enabled:=true;
end;
listbox1.Clear;
end;
procedure Tdy.BitBtn7Click(Sender: TObject);
var i:integer;
begin
if listbox2.Items.Count=0 then
exit;
for i:=0 to listbox2.Items.Count-1 do
begin
listbox1.Items.Add(listbox2.Items.Strings[i]);
bitbtn2.Enabled:=false;
bitbtn7.Enabled:=false;
bitbtn1.Enabled:=true;
bitbtn6.Enabled:=true;
end;
listbox2.Clear;
end;
procedure Tdy.SpeedButton1Click(Sender: TObject);
begin
shellexecute(application.Handle,'open',pchar(s+'\help\cha_xun.htm'),'','',SW_SHOW);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -