Unit1.~pas
资源名称:xiaobai.rar [点击查看]
上传用户:autowell
上传日期:2022-06-21
资源大小:16754k
文件大小:3k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, Grids, DBGrids, DB, ADODB;
- type
- TForm1 = class(TForm)
- DataSource1: TDataSource;
- ADOQuery1: TADOQuery;
- DBGrid1: TDBGrid;
- GroupBox1: TGroupBox;
- RadioButton1: TRadioButton;
- RadioButton2: TRadioButton;
- RadioButton3: TRadioButton;
- Label1: TLabel;
- Button1: TButton;
- Button2: TButton;
- Label2: TLabel;
- Edit1: TEdit;
- Button3: TButton;
- Button4: TButton;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- uses Unit2;
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- adoquery1.connection:=DataModule2.adoconnection1;//adoconnection1连接到库上,而 adoquery1连接到表上,把 adoconnection1单列出来,多个表单可以共享,不用每个表单都用一个
- adoquery1.Active:=true;
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- Form1.close;
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- begin
- //adoquery1.connection:=DataModule2.adoconnection1;
- //adoquery1.active:=true;
- with adoquery1 do
- begin
- close;
- with sql do
- begin
- clear;
- add('select * from students where');
- if radiobutton1.Checked then
- add('学号=' + quotedstr(edit1.Text));
- if radiobutton2.Checked then
- add('姓名=' + quotedstr(edit1.Text));
- if radiobutton3.Checked then
- add('班级=' + quotedstr(edit1.Text));
- end;
- open;
- adoquery1.Active:=true;
- end;
- if adoquery1.Eof then showmessage('呜呜,什么都没找到。');
- end;
- procedure TForm1.Button4Click(Sender: TObject);
- var
- strcustmerid:string;
- strcommend1,strcommend2,strcommend3:string;
- begin
- begin
- strcustmerid:=trim(edit1.Text);
- strcommend1:='学号 like ''%'+strcustmerid+'%''';
- strcommend2:='姓名 like ''%'+strcustmerid+'%''';
- strcommend3:='班级 like ''%'+strcustmerid+'%''';
- with adoquery1 do
- begin
- close;
- with sql do
- begin
- clear;
- add('select * from students where');
- if radiobutton1.Checked then
- add(strcommend1);
- if radiobutton2.Checked then
- add(strcommend2);
- if radiobutton3.Checked then
- add(strcommend3);
- end;
- open;
- adoquery1.Active:=true;
- end;
- if adoquery1.Eof then showmessage('呜呜,什么都没找到。');
- end;
- end;
- end.