unit query2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, Grids, DBGrids, DB, DBTables, Buttons,
  System.ComponentModel;

type
  Tqueryform2 = class(TForm)
    DataSource1: TDataSource;
    Query1: TQuery;
    DBGrid1: TDBGrid;
    Edit1: TEdit;
    Label1: TLabel;
    Button1: TButton;
    Button2: TButton;
    Edit2: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    Edit3: TEdit;
    Button3: TButton;
    BitBtn1: TBitBtn;
    Query1Field: TStringField;
    Query1Field2: TStringField;
    Query1Field3: TStringField;
    Query1Field4: TStringField;
    Query1Field5: TStringField;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  queryform2: Tqueryform2;

implementation

{$R *.dfm}

procedure Tqueryform2.Button2Click(Sender: TObject);
begin
Edit1.Text:='';
Edit3.Text:='' ;
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select * From student.db');
Query1.SQL.Add('WHERE 姓名='''+Edit2.Text+'''');
Query1.Open;
If Query1.RecordCount=0 then
    Begin
    showMessage('没有需要查询的记录，请重新确认');
    Query1.Close;
    Query1.SQL.Clear;
    Query1.SQL.Add('Select * From student.db');
    Query1.Open;
    End;
end;

procedure Tqueryform2.Button1Click(Sender: TObject);
begin
Edit2.Text:='';
edit3.Text:='' ;
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select * From student.db');
Query1.SQL.Add('WHERE 学号='''+Edit1.Text+'''');
Query1.Open;
If Query1.RecordCount=0 then
    Begin
    showMessage('没有需要查询的记录，请重新确认');
    Query1.Close;
    Query1.SQL.Clear;
    Query1.SQL.Add('Select * From student.db');
    Query1.Open;
    End;

end;

procedure Tqueryform2.Button3Click(Sender: TObject);
begin
Edit1.Text:='';
Edit2.Text:='';
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select * From student.db');
Query1.SQL.Add('WHERE 年级='''+Edit3.Text+'''');
Query1.Open;
If Query1.RecordCount=0 then
    Begin
    showMessage('没有需要查询的记录，请重新确认');
    Query1.Close;
    Query1.SQL.Clear;
    Query1.SQL.Add('Select * From student.db');
    Query1.Open;
    End;
end;
procedure Tqueryform2.BitBtn1Click(Sender: TObject);
begin
Query1.Close;
Queryform2.Hide;
Close;
end;

end.
