?? classbookbrower.pas
字號:
unit classbookbrower;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Grids, DBGrids, DB, ADODB;
type
TClassBookBrowerForm = class(TForm)
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
GroupBox2: TGroupBox;
Label1: TLabel;
ComboBox1: TComboBox;
DBGrid1: TDBGrid;
BitBtn1: TBitBtn;
ADOConnection1: TADOConnection;
DataSource1: TDataSource;
ADOQuery1: TADOQuery;
procedure BitBtn1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure ComboBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
ClassBookBrowerForm: TClassBookBrowerForm;
implementation
{$R *.dfm}
procedure TClassBookBrowerForm.BitBtn1Click(Sender: TObject);
begin
Close;
end;
procedure TClassBookBrowerForm.FormActivate(Sender: TObject);
var
adotable:TAdoTable;
begin
adotable:=TAdoTable.Create(self);
adotable.Connection:=adoconnection1;
adotable.TableName:='班級表';
adotable.open;
combobox1.Items.clear;
while not adotable.Eof do
begin
combobox1.items.Add(adotable.fieldbyname('班級名').asstring);
adotable.next;
end;
combobox1.text:='';
adotable.close;
dbgrid1.DataSource:=datasource1;
datasource1.DataSet:=adoquery1;
adoquery1.Connection:=adoconnection1;
adoquery1.Close;
RadioButton1.Checked:=true;
end;
procedure TClassBookBrowerForm.RadioButton1Click(Sender: TObject);
var
adotable:TAdoTable;
begin
adotable:=TAdoTable.Create(self);
adotable.Connection:=adoconnection1;
adotable.TableName:='班級表';
adotable.open;
combobox1.Items.clear;
while not adotable.Eof do
begin
combobox1.items.Add(adotable.fieldbyname('班級名').asstring);
adotable.next;
end;
combobox1.text:='';
adotable.close;
label1.caption:='選擇查詢班級名';
adoquery1.Close;
adoquery1.sql.Clear;
adoquery1.sql.Add('select * from 學生書費歷史庫');
adoquery1.Prepared;
adoquery1.active:=true;
end;
procedure TClassBookBrowerForm.RadioButton2Click(Sender: TObject);
var
adotable:TAdoTable;
begin
adotable:=TAdoTable.Create(self);
adotable.Connection:=adoconnection1;
adotable.TableName:='單位信息表';
adotable.open;
combobox1.Items.clear;
while not adotable.Eof do
begin
combobox1.items.Add(adotable.fieldbyname('單位名').asstring);
adotable.next;
end;
combobox1.text:='';
adotable.close;
label1.caption:='選擇單位名';
adoquery1.Close;
adoquery1.sql.Clear;
adoquery1.sql.Add('select * from 學生書費歷史庫');
adoquery1.Prepared;
adoquery1.active:=true;
end;
procedure TClassBookBrowerForm.ComboBox1Click(Sender: TObject);
begin
adoquery1.Close;
adoquery1.sql.clear;
adoquery1.SQL.Add('select * from 學生書費歷史庫 where 班級名=:s0');
adoquery1.Parameters.clear;
adoquery1.Parameters.AddParameter;
adoquery1.Parameters[0].name:='s0';
adoquery1.Parameters[0].DataType:=ftstring;
adoquery1.Parameters[0].Direction:=pdinput;
adoquery1.Parameters[0].Value:=combobox1.text;
adoquery1.Prepared;
adoquery1.active:=true;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -