📄 subjectcount.pas
字号:
unit subjectcount;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DB, DBTables, Grids, DBGrids, DBCtrls, ADODB;
type
Tform16 = class(TForm)
DBCheckBox1: TDBCheckBox;
Panel1: TPanel;
Label7: TLabel;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
ComboBox4: TComboBox;
ComboBox5: TComboBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
ADOTable1: TADOTable;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
form16: Tform16;
implementation
{$R *.dfm}
procedure Tform16.Button3Click(Sender: TObject);
begin
combobox1.Text :='';
combobox2.Text :='';
combobox3.Text :='';
combobox4.Text :='';
combobox5.Text :='';
label12.Caption:='';
label14.Caption:='';
label9.Caption:='';
adoquery1.SQL.Text:='';
adoquery1.Active:=false;
form16.Close;
end;
procedure Tform16.Button2Click(Sender: TObject);
begin
label9.Caption:='';
label12.Caption:='';
label14.Caption:='';
combobox1.Text :='';
combobox2.Text :='';
combobox3.Text :='';
combobox4.Text :='';
combobox5.Text :='';
adoquery1.SQL.Text:='';
adoquery1.Active:=false;
end;
procedure Tform16.Button1Click(Sender: TObject);
var
strsql,s:string;
i1,i2:integer;
count:real;
begin
if (combobox1.Text='') and (combobox2.Text='') and (combobox5.Text<>'') and (combobox3.Text='') and (combobox4.Text='') then
begin
strsql:='select * from a01 where 性别='''+combobox5.Text+'''';
adotable1.Active:=false;
adotable1.Tablename:='a01';
adotable1.Active :=true;
i1:=adotable1.RecordCount;
label12.Caption:=inttostr(i1);
adoquery1.Active:=false;
adoquery1.sql.Clear;
adoquery1.sql.Add(strsql);
adoquery1.Active:=true;
i2:=adoquery1.RecordCount;
label9.Caption:=inttostr(i2);
if i2=0 then
showmessage('库中没有您想要统计的数据!请确认输入的正确性!');
count:=i2/i1;
count:=count*100;
str(count:8:2,s);
label14.Caption:=s+'%';
end;
if (combobox1.Text<>'') and (combobox2.Text='') or (combobox1.Text='') and (combobox2.Text<>'') then
showmessage('请完整的输入统计条件!');
if (combobox5.Text<>'') and (combobox1.Text<>'') and (combobox2.Text<>'') and (combobox3.text='') and (combobox4.Text='') then
begin
strsql:='select * from a01 where 性别='''+combobox5.Text+''''+' and 年龄 between '+combobox1.Text+' and '+combobox2.Text;
adotable1.Active:=false;
adotable1.Tablename:='a01';
adotable1.Active :=true;
i1:=adotable1.RecordCount;
label12.Caption:=inttostr(i1);
adoquery1.Active:=false;
adoquery1.sql.Clear;
adoquery1.sql.Add(strsql);
adoquery1.Active:=true;
i2:=adoquery1.RecordCount;
label9.Caption:=inttostr(i2);
if i2=0 then
showmessage('库中没有您想要统计的数据!请确认输入的正确性!');
count:=i2/i1;
count:=count*100;
str(count:8:2,s);
label14.Caption:=s+'%';
end;
if (combobox1.Text<>'') and (combobox2.text<>'') and (combobox5.Text='') and (combobox3.Text='') and (combobox4.Text='') then
begin
strsql:='select * from a01 where '+' 年龄 between '+combobox1.text+' and '+combobox2.text;
adotable1.Active:=false;
adotable1.Tablename:='a01';
adotable1.Active :=true;
i1:=adotable1.RecordCount;
label12.Caption:=inttostr(i1);
adoquery1.Active:=false;
adoquery1.sql.Clear;
adoquery1.sql.Add(strsql);
adoquery1.Active:=true;
i2:=adoquery1.RecordCount;
label9.Caption:=inttostr(i2);
if i2=0 then
showmessage('库中没有您想要统计的数据!请确认输入的正确性!');
count:=i2/i1;
count:=count*100;
str(count:8:2,s);
label14.Caption:=s+'%';
end;
if (combobox1.Text='') and (combobox2.Text='') and (combobox3.Text<>'') and (combobox4.Text<>'') and (combobox5.Text='') then
begin
strsql:='select * from a01,a08 where '+' 学历代码 between '+inttostr(combobox3.itemindex)+' and '+inttostr(combobox4.itemindex)+' and '+' a01.标识号=a08.标识号';
adotable1.Active:=false;
adotable1.Tablename:='a08';
adotable1.Active :=true;
i1:=adotable1.RecordCount;
label12.Caption:=inttostr(i1);
adoquery1.Active:=false;
adoquery1.sql.Clear;
adoquery1.sql.Add(strsql);
adoquery1.Active:=true;
i2:=adoquery1.RecordCount;
label9.Caption:=inttostr(i2);
if i2=0 then
showmessage('库中没有您想要统计的数据!请确认输入的正确性!');
count:=i2/i1;
count:=count*100;
str(count:8:2,s);
label14.Caption:=s+'%';
end;
if (combobox1.Text<>'') and (combobox2.Text<>'') and (combobox3.Text<>'') and (combobox4.Text<>'') and (combobox5.Text='') then
begin
adotable1.Active:=false;
adotable1.Tablename:='a01';
adotable1.Active :=true;
strsql:='select * from a01,a08 where '+' 年龄 between '+combobox1.text+' and '+combobox2.text+' and '+' 学历代码 between '+inttostr(combobox3.itemindex)+' and '+inttostr(combobox4.itemindex)+' and '+' a01.标识号 = a08.标识号';
i1:=adotable1.RecordCount;
label12.Caption:=inttostr(i1);
adoquery1.Active:=false;
adoquery1.sql.Clear;
adoquery1.sql.Add(strsql);
adoquery1.Active:=true;
i2:=adoquery1.RecordCount;
label9.Caption:=inttostr(i2);
if i2=0 then
showmessage('库中没有您想要统计的数据!请确认输入的正确性!');
count:=i2/i1;
count:=count*100;
str(count:8:2,s);
label14.Caption:=s+'%';
end;
if (combobox1.Text<>'') and (combobox2.Text<>'') and (combobox3.Text<>'') and (combobox4.Text<>'') and (combobox5.text<>'') then
begin
adotable1.Active:=false;
adotable1.Tablename:='a01';
adotable1.Active :=true;
strsql:='select * from a01,a08 where 性别='''+combobox5.Text+''''+' and '+' 年龄 between '+combobox1.text+' and '+combobox2.text+' and '+' a08.学历代码 between '+inttostr(combobox3.itemindex)+' and '+inttostr(combobox4.itemindex)+'and a01.标识号 = a08.标识号';
i1:=adotable1.RecordCount;
label12.Caption:=inttostr(i1);
adoquery1.Active:=false;
adoquery1.sql.Clear;
adoquery1.sql.Add(strsql);
adoquery1.Active:=true;
i2:=adoquery1.RecordCount;
label9.Caption:=inttostr(i2);
if i2=0 then
showmessage('库中没有您想要统计的数据!请确认输入的正确性!');
count:=i2/i1;
count:=count*100;
str(count:8:2,s);
label14.Caption:=s+'%';
end;
if (combobox3.Text<>'') and (combobox4.Text<>'') and (combobox5.Text<>'') and (combobox1.Text='') and (combobox2.Text='') then
begin
adotable1.Active:=false;
adotable1.Tablename:='a08';
adotable1.Active :=true;
strsql:='select * from a01,a08 where '+'a01.性别='''+combobox5.Text+''''+' and'+' 学历代码 between '+inttostr(combobox3.itemindex)+' and '+inttostr(combobox4.itemindex)+' and a01.标识号 = a08.标识号';
i1:=adotable1.RecordCount;
label12.Caption:=inttostr(i1);
adoquery1.Active:=false;
adoquery1.sql.Clear;
adoquery1.sql.Add(strsql);
adoquery1.Active:=true;
i2:=adoquery1.RecordCount;
label9.Caption:=inttostr(i2);
if i2=0 then
showmessage('库中没有您想要统计的数据!请确认输入的正确性!');
count:=i2/i1;
count:=count*100;
str(count:8:2,s);
label14.Caption:=s+'%';
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -