📄 ufindemployee.pas
字号:
unit UFindEmployee;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls;
type
TForm_FindEmployee = class(TForm)
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Edit1: TEdit;
SpeedButton1: TSpeedButton;
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form_FindEmployee: TForm_FindEmployee;
implementation
uses Umain;
{$R *.dfm}
procedure TForm_FindEmployee.RadioButton1Click(Sender: TObject);
begin
edit1.Enabled := true;
edit1.SetFocus;
end;
procedure TForm_FindEmployee.RadioButton2Click(Sender: TObject);
begin
edit1.Enabled := true;
edit1.SetFocus;
end;
procedure TForm_FindEmployee.SpeedButton1Click(Sender: TObject);
begin
if trim(edit1.Text) = '' then
showmessage('请选择查询方式后输入查询内容')
else
begin
if RadioButton1.Checked = true then
begin
try
with Form_Main.ADOQDBGrid do
begin
close;
SQL.Clear;
SQL.Add('select * from Employee');
SQL.Add('WHERE Employee_ID=''' + trim(edit1.Text) + '''');
open;
Form_Main.label2.Caption := '共找到 ' + inttostr(Form_Main.ADOQDBGrid.RecordCount) + '条符合条件的记录';
if Form_Main.ADOQDBGrid.RecordCount = 0 then
showmessage('没找到编号为:' + '' + trim(edit1.Text) + ' ' + '的记录!')
end;
except
showmessage('查询失败');
end;
close;
end;
if RadioButton2.Checked = true then
begin
try
with Form_Main.ADOQDBGrid do
begin
close;
SQL.Clear;
SQL.Add('select * from Employee');
SQL.Add('WHERE Employee_name like''%' + edit1.Text + '%''');
open;
Form_Main.label2.Caption := '共找到 ' + inttostr(Form_Main.ADOQDBGrid.RecordCount) + '条符合条件的记录';
if Form_Main.ADOQDBGrid.RecordCount = 0 then
showmessage('没找到姓名为:' + '' + edit1.Text + ' ' + '的记录!')
end;
except
showmessage('查询失败');
end;
close;
end;
end;
end;
procedure TForm_FindEmployee.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
SpeedButton1Click(Sender);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -