📄 unit3.pas
字号:
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, DB, DBTables, ExtCtrls, DBCtrls, StdCtrls,
Buttons;
type
TForm3 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Label1: TLabel;
DBNavigator1: TDBNavigator;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
RadioButton5: TRadioButton;
RadioButton6: TRadioButton;
RadioButton7: TRadioButton;
RadioButton8: TRadioButton;
SpeedButton1: TSpeedButton;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Label4: TLabel;
Edit2: TEdit;
Label5: TLabel;
Edit3: TEdit;
Memo1: TMemo;
Table1BDEDesigner: TFloatField;
Table1BDEDesigner2: TStringField;
Table1BDEDesigner3: TFloatField;
Table1BDEDesigner4: TStringField;
Table1BDEDesigner5: TStringField;
Table1BDEDesigner6: TStringField;
Table1BDEDesigner7: TStringField;
Table1BDEDesigner8: TCurrencyField;
Table1BDEDesigner9: TStringField;
Table1BDEDesigner10: TFloatField;
Table1BDEDesigner11: TStringField;
Edit4: TEdit;
Label6: TLabel;
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure RadioButton3Click(Sender: TObject);
procedure RadioButton4Click(Sender: TObject);
procedure RadioButton5Click(Sender: TObject);
procedure RadioButton6Click(Sender: TObject);
procedure RadioButton7Click(Sender: TObject);
procedure RadioButton8Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.RadioButton1Click(Sender: TObject);
begin
memo1.Text:='姓名='+''''+edit1.Text+'''';
end;
procedure TForm3.RadioButton2Click(Sender: TObject);
begin
memo1.Text:='年龄='+edit1.Text;
end;
procedure TForm3.RadioButton3Click(Sender: TObject);
begin
memo1.Text:='职业='+''''+edit1.Text+'''';
end;
procedure TForm3.RadioButton4Click(Sender: TObject);
begin
memo1.Text:='职称='+''''+edit1.Text+'''';
end;
procedure TForm3.RadioButton5Click(Sender: TObject);
begin
memo1.Text:='最高学历='+''''+edit1.Text+'''';
end;
procedure TForm3.RadioButton6Click(Sender: TObject);
begin
memo1.Text:='工资收入='+edit1.Text;
end;
procedure TForm3.RadioButton7Click(Sender: TObject);
begin
memo1.Text:='国籍='+''''+edit1.Text+'''';
end;
procedure TForm3.RadioButton8Click(Sender: TObject);
begin
memo1.Text:='婚否='+''''+edit1.Text+'''';
end;
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 + -