unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, DB, ExtCtrls, DBCtrls, DBTables, StdCtrls;type
  TForm1 = class(TForm)
    Query1: TQuery;
    DBNavigator1: TDBNavigator;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Query1Name: TStringField;
    Query1Sex: TStringField;
    Query1BirthDay: TDateTimeField;
    Query1Job: TStringField;
    Query1Dept: TStringField;
    Query1Salary: TIntegerField;
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Button1: TButton;
    RadioGroup1: TRadioGroup;
    procedure RadioGroup1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
  published
    property Text;
    { Public declarations }
  end;var
  Form1: TForm1;
  state:integer;
implementation{$R *.dfm}procedure TForm1.RadioGroup1Click(Sender: TObject);begin
  edit1.Text.Clear;                      {错在这儿}          
  case   RadioGroup1.ItemIndex of
0:    begin
        Label1.caption:='按姓名查询:';
        Label1.Refresh;
        Label2.Caption:='请输入姓名:';
        Label2.Refresh;
        state:=0;
      end;
1:    begin
       Label1.Caption:='按部门查询:';
       Label1.Refresh;
       Label2.Caption:='请输入部门:';
       Label2.Refresh;
       state:=1;
      end;
    end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
  Query1.Open;
  State:=0;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
     Query1.SQL.Clear;
     if state=0 then
     begin
     Query1.SQL.Add('select*from Employee as s where s."姓名"=:Name');
     Query1.Prepare;
     Query1.Params[0].AsString:=trim(edit1.Text);
     end;     if state=1 then
     begin
     Query1.SQL.Add('select*from Employee as s where s."部门"=:Dept');
     Query1.Prepare;
     Query1.Params[0].AsString:=trim(edit1.Text);
     end;
     Query1.Open;
end;end.