📄 unit7.pas
字号:
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ADODB, Grids, DBGrids, DB;
type
TForm7 = class(TForm)
Bevel1: TBevel;
Button1: TButton;
Button2: TButton;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
R1: TRadioButton;
R2: TRadioButton;
R3: TRadioButton;
ComboBox1: TComboBox;
ADOTable1: TADOTable;
ComboBox4: TComboBox;
Edit1: TEdit;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure ComboBox2KeyPress(Sender: TObject; var Key: Char);
procedure ComboBox3KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
implementation
{$R *.dfm}
procedure TForm7.Button2Click(Sender: TObject);
begin
edit1.Text:='';
combobox4.ItemIndex:=0;
combobox1.ItemIndex:=0;
label6.Caption:='';
label9.Caption:='';
label12.Caption:='';
adoconnection1.Connected:=false;
form7.Close;
end;
procedure TForm7.Button1Click(Sender: TObject);
var
str:string;
i,i1:integer;
i2:real;
begin
adotable1.Active:=false;
adotable1.Active:=true;
i:=adotable1.RecordCount;
label6.Caption:=inttostr(i);
if r1.Checked=true then
begin
if trim(combobox4.text)<>'' then
begin
str:='select * from xyxxb where 性别='''+trim(combobox4.Text)+'''';
adoquery1.Active:=false;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(str);
adoquery1.Active:=true;
i1:=adoquery1.RecordCount;
if i1=0 then
showmessage('没有找到相关记录!')
else
begin
label9.Caption:=inttostr(i1);
i2:=i1/i;
i2:=i2*100;
label12.Caption:=floattostr(i2);
end;
end
else
showmessage('请选择性别!');
end;
if r2.Checked=true then
begin
if trim(combobox1.text)<>'' then
begin
str:='select * from xyxxb where 民族='''+trim(combobox1.Text)+'''';
adoquery1.Active:=false;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(str);
adoquery1.Active:=true;
i1:=adoquery1.RecordCount;
if i1=0 then
showmessage('没有找到相关记录!')
else
begin
label9.Caption:=inttostr(i1);
i2:=i1/i;
i2:=i2*100;
label12.Caption:=floattostr(i2);
end;
end
else
showmessage('请选择民族!');
end;
if r3.Checked=true then
begin
if trim(edit1.text)<>'' then
begin
str:='select * from xyxxb where 招生人='''+trim(edit1.Text)+'''';
adoquery1.Active:=false;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(str);
adoquery1.Active:=true;
i1:=adoquery1.RecordCount;
if i1=0 then
showmessage('没有找到相关记录!')
else
begin
label9.Caption:=inttostr(i1);
i2:=i1/i;
i2:=i2*100;
label12.Caption:=floattostr(i2);
end;
end
else
showmessage('请输入招生人!');
end;
end;
procedure TForm7.ComboBox2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9',#8]) then
key:=#0;
end;
procedure TForm7.ComboBox3KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9',#8]) then
key:=#0;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -