📄 scan.pas
字号:
unit Scan;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ComCtrls, DB, ADODB, QRCtrls, QuickRpt,
ExtCtrls;
type
TForm5 = class(TForm)
PageControl2: TPageControl;
BitBtn1: TBitBtn;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
TabSheet4: TTabSheet;
Label1: TLabel;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Edit1: TEdit;
Button1: TButton;
ListView1: TListView;
StaticText1: TStaticText;
TabSheet1: TTabSheet;
ADOConnection2: TADOConnection;
ADOQuery2: TADOQuery;
DataSource1: TDataSource;
QuickRep1: TQuickRep;
QRBand1: TQRBand;
QRBand2: TQRBand;
QRBand3: TQRBand;
QRDBText1: TQRDBText;
QRDBText2: TQRDBText;
QRDBText3: TQRDBText;
QRDBText4: TQRDBText;
Button2: TButton;
QRLabel1: TQRLabel;
QRLabel2: TQRLabel;
QRLabel3: TQRLabel;
QRLabel4: TQRLabel;
QRLabel5: TQRLabel;
procedure Button1Click(Sender: TObject);
//procedure Button2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
//procedure RadioButton3Click(Sender: TObject);
//procedure RadioButton4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
content : string;
implementation
{$R *.dfm}
procedure TForm5.Button1Click(Sender: TObject);
begin
try
ListView1.Items.Clear;
with ADOquery1 do
begin
content := Edit1.Text;
SQL.Clear;
if RadioButton1.Checked then //根据选中的类型在数据库中查找
begin
SQL.Add('select * from 员工 where 员工号 = '''+Edit1.Text+'''');
end;
if RadioButton2.Checked then
begin
content := '%'+content+'%'; //实现模糊查询
SQL.Add('select * from 员工 where 姓名 like :s0');
Parameters.ParamByName('s0').Value := content;
end;
Open;
while not Eof do
begin
with ListView1.Items.Add do
begin
Caption := FieldByName('员工号').AsString;
SubItems.Add(FieldByName('姓名').AsString);
if FieldByName('性别').AsString = '女' then SubItems.Add('女')
else
SubItems.Add('男');
SubItems.Add(FieldByName('部门').AsString);
SubItems.Add(FieldByName('电话').AsString);
SubItems.Add(FieldByName('籍贯').AsString);
SubItems.Add(FieldByName('备注').AsString);
end;
Next;
end;
StaticText1.Caption:= '共'+IntToStr(RecordCount)+'条记录';
Close;
end;
except
MessageDlg('查询失败',mtError,[mbok],0);
end;
end;
procedure TForm5.BitBtn1Click(Sender: TObject);
begin
Close;
end;
{procedure TForm5.RadioButton4Click(Sender: TObject);
begin
end;}
procedure TForm5.Button2Click(Sender: TObject);
begin
form5.QuickRep1.Preview;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -