unit query1;

interface

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

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

var
  QueryForm1: TQueryForm1;

implementation

{$R *.dfm}

procedure TQueryForm1.Button2Click(Sender: TObject);
begin
Edit1.Text:='';
Edit3.Text:='' ;
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select * From Profession.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 Profession.db');
    Query1.Open;
    End;
end;

procedure TQueryForm1.Button1Click(Sender: TObject);
begin
Edit2.Text:='';
Edit3.Text:='' ;
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select * From Profession.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 Profession.db');
    Query1.Open;
    end;
End;
procedure TQueryForm1.Button3Click(Sender: TObject);
begin
Edit2.Text:='';
Edit1.Text:='' ;
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select * From Profession.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 Profession.db');
    Query1.Open;
    end;
end;

procedure TQueryForm1.BitBtn1Click(Sender: TObject);
begin
Close;
end;

end.
