⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit3.~pas

📁 人口普查的工作表现在两个方面
💻 ~PAS
字号:
unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls, DBCtrls, Grids, DBGrids, DB,
  DBTables;

type
  TForm3 = class(TForm)
    Table1: TTable;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    DBNavigator1: TDBNavigator;
    Memo1: TMemo;
    SpeedButton1: TSpeedButton;
    Label1: TLabel;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    RadioButton4: TRadioButton;
    RadioButton5: TRadioButton;
    RadioButton6: TRadioButton;
    RadioButton7: TRadioButton;
    RadioButton8: TRadioButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    procedure SpeedButton1Click(Sender: TObject);
    
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;

implementation

{$R *.dfm}

procedure TForm3.SpeedButton1Click(Sender: TObject);
var
s1:real;
s2:real;
s3:real;
s4:string;
s5:string;
s6:string;
bookmark1:tbookmark;
begin
table1.Refresh;
if  table1.RecordCount=0 then
showmessage('对不起,你的数据为空,不能统计')
else begin
s1:=table1.RecordCount;
str(s1,s4);
edit3.Text:=s4;
with table1 do
try
  disablecontrols;
  filtered:=false;
  if radiobutton1.Checked=true then memo1.Text :='姓名='+''''+edit1.Text+'''';
  if radiobutton2.Checked=true then memo1.Text:='年龄='+edit1.Text;
  if radiobutton3.Checked=true then memo1.Text :='职业='+''''+edit1.Text+'''';
  if radiobutton4.Checked=true then memo1.Text :='职称='+''''+edit1.Text+'''';
  if radiobutton5.Checked=true then memo1.Text :='最高学历='+''''+edit1.Text+'''';
  if radiobutton6.Checked=true then memo1.Text :='工资收入='+edit1.Text;
  if radiobutton7.Checked=true then memo1.Text :='国籍='+''''+edit1.Text+'''';
  if radiobutton8.Checked=true then memo1.Text :='婚否='+''''+edit1.Text+'''';
  filter:=memo1.Text;
  if(radiobutton1.Checked=false)and(radiobutton2.Checked =false)and(radiobutton3.Checked=false)
  and(radiobutton4.Checked=false)and(radiobutton5.Checked=false)and(radiobutton6.Checked=false)
  then
  filtered:=false
  else
  filtered:=true;
  s2:=table1.RecordCount;
finally
  enablecontrols;
if table1.RecordCount=0 then begin
messagebeep(1);
s2:=table1.RecordCount;
showmessage('没有符合条件的记录,请确认条件或放弃查询!');
if messageDlg('是否继续查询统计?只有结束查询统计才能作其他操作!',mtinformation,[mbYes,mbNo],0)=mrno then begin
s3:=s2/s1;
str(s2:8:2,s5);
edit4.Text:=s5;
str(s3:8:2,s6);
edit2.Text:=s6;
filtered:=false;
  table1.Close;
  table1.Open;
end;
end else begin
showmessage('记录已经找到!');
bookmark1:=table1.GetBookmark;
s2:=table1.RecordCount;
s3:=s2/s1;
str(s2:8:2,s5);
edit4.Text:=s5;
str(s3:8:2,s6);
edit2.Text:=s6;
  filtered:=false;
  table1.Close;
  table1.Open;
end;
end;
end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -