📄 randomsystem.pas
字号:
unit randomsystem;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, ExtCtrls, DB, DBTables, ADODB;
type
TForm9 = class(TForm)
Panel1: TPanel;
Bevel1: TBevel;
Bevel2: TBevel;
DBGrid1: TDBGrid;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
DataSource1: TDataSource;
Button10: TButton;
GroupBox1: TGroupBox;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
ComboBox4: TComboBox;
ComboBox5: TComboBox;
ComboBox6: TComboBox;
ComboBox7: TComboBox;
ComboBox3: TComboBox;
Button5: TButton;
Button9: TButton;
Label2: TLabel;
Label3: TLabel;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Label1: TLabel;
Edit1: TEdit;
Button11: TButton;
Button12: TButton;
ADOQuery1: TADOQuery;
ADOConnection1: TADOConnection;
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button12Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form9: TForm9;
implementation
{$R *.dfm}
procedure TForm9.Button5Click(Sender: TObject);
begin //退出
combobox1.Text :='';
combobox2.Text :='';
combobox3.Text :='';
combobox4.Text :='';
combobox5.Text :='';
combobox6.Text :='';
combobox7.Text :='';
edit1.text:='';
adoquery1.SQL.Text:='';
adoquery1.Active:=false;
button1.Enabled :=false;
button2.Enabled :=false;
button3.Enabled :=false;
button4.Enabled :=false;
button6.Enabled :=false;
button7.Enabled :=false;
button8.Enabled :=false;
button10.Enabled :=false;
button12.Enabled :=false;
form9.Close;
end;
procedure TForm9.Button4Click(Sender: TObject);
begin //最后一条
adoquery1.Last;
end;
procedure TForm9.Button3Click(Sender: TObject);
begin //下一条
adoquery1.Next ;
end;
procedure TForm9.Button2Click(Sender: TObject);
begin //上一条
adoquery1.Prior;
end;
procedure TForm9.Button1Click(Sender: TObject);
begin //第一条
adoquery1.First ;
end;
procedure TForm9.Button7Click(Sender: TObject);
begin //删除
beep();
if (messagedlg('真的要删除此记录?',mtconfirmation,[mbyes,mbno],0)=mryes) then
begin
dbgrid1.ReadOnly :=false;
adoquery1.Delete ;
dbgrid1.ReadOnly:=true;
end;
end;
procedure TForm9.Button6Click(Sender: TObject);
begin //修改
dbgrid1.ReadOnly :=false;
adoquery1.Edit;
button1.Enabled :=false;
button2.Enabled :=false;
button3.Enabled :=false;
button4.Enabled :=false;
button6.Enabled :=false;
button7.Enabled :=false;
button8.Enabled :=false;
button10.Enabled :=true;
button12.Enabled :=true;
end;
procedure TForm9.Button8Click(Sender: TObject);
begin //添加
dbgrid1.ReadOnly :=false;
adoquery1.Append ;
button1.Enabled :=false;
button2.Enabled :=false;
button3.Enabled :=false;
button4.Enabled :=false;
button10.Enabled :=true;
button12.Enabled :=true;
button8.Enabled :=false;
button6.Enabled :=false;
button7.Enabled :=false;
end;
procedure TForm9.Button9Click(Sender: TObject);
var //进入维护
s:string;
begin
if (combobox1.Text='') and (combobox2.Text='') and (combobox5.Text='') and (combobox4.text='') and (combobox6.Text='' ) and (combobox3.Text ='')and(combobox7.Text='')and (edit1.Text ='')then
begin
application.MessageBox('请选择信息集条件','提示',32);
end
else
begin
if (edit1.Text ='')and(combobox1.Text='') and (combobox2.Text='') and (combobox5.Text='') and (combobox4.text='') and (combobox6.Text='' ) and (combobox3.Text <>'')and(combobox7.Text='') then
begin //性别
adoquery1.Active:=false;
adoquery1.sql.Clear;
s:='select * from a01 where 性别='''+trim(combobox3.Text)+'''';
adoquery1.sql.Add(s);
adoquery1.Active :=true;
if adoquery1.RecordCount<>0 then
begin
button1.Enabled :=true;
button2.Enabled :=true;
button3.Enabled :=true;
button4.Enabled :=true;
button6.Enabled :=true;
button7.Enabled :=true;
button8.Enabled :=true;
end
else
begin
beep();
application.MessageBox('没有您想要的记录!','提示',32);
button6.Enabled :=false;
button7.Enabled :=false;
button8.Enabled :=false;
adoquery1.Active :=false;
end;
end
else
begin
if (edit1.Text ='')and(combobox1.Text='') and (combobox2.Text='') and (combobox5.Text<>'') and (combobox4.text<>'') and (combobox6.Text='' ) and (combobox3.Text='')and(combobox7.Text='') then
begin //年龄
adoquery1.Active :=false;
adoquery1.sql.Clear;
s:='select * from a01 where '+' 年龄 between '+ trim(combobox4.text)+' and '+trim(combobox5.Text);
adoquery1.sql.Add(s);
adoquery1.Active :=true;
if adoquery1.RecordCount<>0 then
begin
button1.Enabled :=true;
button2.Enabled :=true;
button3.Enabled :=true;
button4.Enabled :=true;
button6.Enabled :=true;
button7.Enabled :=true;
button8.Enabled :=true;
end
else
begin
beep();
application.MessageBox('没有您想要的记录!','提示',32);
button6.Enabled :=false;
button7.Enabled :=false;
button8.Enabled :=false;
adoquery1.Active :=false;
end;
end
else
begin
if (edit1.Text ='')and(combobox1.Text='') and (combobox2.Text='') and (combobox5.Text='') and (combobox4.text='') and (combobox6.Text<>'' ) and (combobox3.Text='')and(combobox7.Text<>'') then
begin //学历
adoquery1.Active:=false;
adoquery1.sql.Clear;
s:='select * from a01,a08 where '+'学历代码 between '+inttostr(combobox6.ItemIndex)+' and '+inttostr(combobox7.ItemIndex)+' and '+' a01.标识号=a08.标识号 ';
adoquery1.sql.Add(s);
adoquery1.Active :=true;
if adoquery1.RecordCount<>0 then
begin
button1.Enabled :=true;
button2.Enabled :=true;
button3.Enabled :=true;
button4.Enabled :=true;
button6.Enabled :=true;
button7.Enabled :=true;
button8.Enabled :=true;
end
else
begin
beep();
application.MessageBox('没有您想要的记录!','提示',32);
button6.Enabled :=false;
button7.Enabled :=false;
button8.Enabled :=false;
adoquery1.Active :=false;
end;
end
else
begin
if (edit1.Text ='')and(combobox1.Text<>'') and (combobox2.Text='') and (combobox5.Text='') and (combobox4.text='') and (combobox6.Text='' ) and (combobox3.Text='')and(combobox7.Text='') then
begin //人事单位名称
adoquery1.Active :=false;
adoquery1.sql.Clear;
s:='select * from a01 where 人事单位名称='''+trim(combobox1.text)+'''';
adoquery1.sql.Add(s);
adoquery1.Active :=true;
if adoquery1.RecordCount<>0 then
begin
button1.Enabled :=true;
button2.Enabled :=true;
button3.Enabled :=true;
button4.Enabled :=true;
button6.Enabled :=true;
button7.Enabled :=true;
button8.Enabled :=true;
end
else
begin
beep();
application.MessageBox('没有您想要的记录!','提示',32);
button6.Enabled :=false;
button7.Enabled :=false;
button8.Enabled :=false;
adoquery1.Active :=false;
end;
end
else if (edit1.Text ='')and(combobox1.Text='') and (combobox2.Text<>'') and (combobox5.Text='') and (combobox4.text='') and (combobox6.Text='' ) and (combobox3.Text='')and(combobox7.Text='') then
begin //专家名称
adoquery1.Active :=false;
adoquery1.sql.Clear;
s:='select * from a24 where 专家名称='''+trim(combobox2.text)+'''';
adoquery1.sql.Add(s);
adoquery1.Active :=true;
if adoquery1.RecordCount<>0 then
begin
button1.Enabled :=true;
button2.Enabled :=true;
button3.Enabled :=true;
button4.Enabled :=true;
button6.Enabled :=true;
button7.Enabled :=true;
button8.Enabled :=true;
end
else
begin
beep();
application.MessageBox('没有您想要的记录!','提示',32);
button6.Enabled :=false;
button7.Enabled :=false;
button8.Enabled :=false;
adoquery1.Active :=false;
end;
end
else if (edit1.Text <>'')and(combobox1.Text='') and (combobox2.Text='') and (combobox5.Text='') and (combobox4.text='') and (combobox6.Text='' ) and (combobox3.Text='')and(combobox7.Text='') then
begin //姓名
adoquery1.Active :=false;
adoquery1.sql.Clear;
s:='select * from a01 where 姓名='''+trim(edit1.Text)+'''';
adoquery1.sql.Add(s);
adoquery1.Active :=true;
if adoquery1.RecordCount<>0 then
begin
button1.Enabled :=true;
button2.Enabled :=true;
button3.Enabled :=true;
button4.Enabled :=true;
button6.Enabled :=true;
button7.Enabled :=true;
button8.Enabled :=true;
end
else
begin
beep();
application.MessageBox('没有您想要的记录!','提示',32);
button6.Enabled :=false;
button7.Enabled :=false;
button8.Enabled :=false;
adoquery1.Active :=false;
end;
end
else if (edit1.Text='') and (combobox1.Text='') and (combobox2.Text='') and (combobox5.Text<>'') and (combobox4.text<>'') and (combobox6.Text<>'' ) and (combobox3.Text='')and(combobox7.Text<>'') then
begin //年龄和学历
adoquery1.Active :=false;
adoquery1.sql.Clear;
s:='select * from a01,a08 where '+' 年龄 between '+trim(combobox4.text)+' and '+trim(combobox5.text)+' and '+' 学历代码 between '+inttostr(combobox6.itemindex)+' and '+inttostr(combobox7.itemindex)+' and '+' a01.标识号 = a08.标识号';
adoquery1.SQL.Add(s);
adoquery1.Active :=true;
if adoquery1.RecordCount<>0 then
begin
button1.Enabled :=true;
button2.Enabled :=true;
button3.Enabled :=true;
button4.Enabled :=true;
button6.Enabled :=true;
button7.Enabled :=true;
button8.Enabled :=true;
end
else
begin
beep();
application.MessageBox('没有您想要的记录!','提示',32);
button6.Enabled :=false;
button7.Enabled :=false;
button8.Enabled :=false;
adoquery1.Active :=false;
end;
end
else if (edit1.Text='') and (combobox1.Text='') and (combobox2.Text='') and (combobox5.Text<>'') and (combobox4.text<>'') and (combobox6.Text='' ) and (combobox3.Text<>'')and(combobox7.Text='') then
begin //性别和年龄
adoquery1.Active :=false;
adoquery1.SQL.Clear;
s:='select * from a01 where 性别='''+trim(combobox3.Text)+''''+' and 年龄 between '+combobox4.Text+' and '+combobox5.Text;
adoquery1.SQL.Add(s);
adoquery1.Active :=true;
if adoquery1.RecordCount<>0 then
begin
button1.Enabled :=true;
button2.Enabled :=true;
button3.Enabled :=true;
button4.Enabled :=true;
button6.Enabled :=true;
button7.Enabled :=true;
button8.Enabled :=true;
end
else
begin
beep();
application.MessageBox('没有您想要的记录!','提示',32);
button6.Enabled :=false;
button7.Enabled :=false;
button8.Enabled :=false;
adoquery1.Active :=false;
end;
end
else if (edit1.Text='') and (combobox1.Text<>'') and (combobox2.Text='') and (combobox5.Text<>'') and (combobox4.text<>'') and (combobox6.Text='' ) and (combobox3.Text='')and(combobox7.Text='') then
begin //人事单位名称和年龄
adoquery1.Active :=false;
adoquery1.SQL.Clear;
s:='select * from a01 where 人事单位名称='''+trim(combobox1.Text)+''''+' and 年龄 between '+trim(combobox4.Text)+' and '+trim(combobox5.Text);
adoquery1.SQL.Add(s);
adoquery1.Active:=true;
if adoquery1.RecordCount<>0 then
begin
button1.Enabled :=true;
button2.Enabled :=true;
button3.Enabled :=true;
button4.Enabled :=true;
button6.Enabled :=true;
button7.Enabled :=true;
button8.Enabled :=true;
end
else
begin
beep();
application.MessageBox('没有您想要的记录!','提示',32);
button6.Enabled :=false;
button7.Enabled :=false;
button8.Enabled :=false;
adoquery1.Active :=false;
end;
end
else if (edit1.Text ='')and(combobox1.Text<>'') and (combobox2.Text='') and (combobox5.Text<>'') and (combobox4.text<>'') and (combobox6.Text<>'' ) and (combobox3.Text='')and(combobox7.Text<>'') then
begin //人事单位名称,年龄和学历
adoquery1.Active :=false;
adoquery1.sql.Clear;
s:='select * from a01,a08 where 人事单位名称='''+trim(combobox1.text)+''''+' and '+' 年龄 between '+trim(combobox4.Text)+' and '+trim(combobox5.Text)+' and '+' a08.学历代码 between '+inttostr(combobox6.ItemIndex)+' and '+inttostr(combobox7.ItemIndex)+' and '+' a01.标识号=a08.标识号';
adoquery1.sql.Add(s);
adoquery1.Active :=true;
if adoquery1.RecordCount<>0 then
begin
button1.Enabled :=true;
button2.Enabled :=true;
button3.Enabled :=true;
button4.Enabled :=true;
button6.Enabled :=true;
button7.Enabled :=true;
button8.Enabled :=true;
end
else
begin
beep();
application.MessageBox('没有您想要的记录!','提示',32);
button6.Enabled :=false;
button7.Enabled :=false;
button8.Enabled :=false;
adoquery1.Active :=false;
end;
end
else if (edit1.Text ='')and(combobox1.Text='') and (combobox2.Text='') and (combobox5.Text<>'') and (combobox4.text<>'') and (combobox6.Text<>'' ) and (combobox3.Text<>'')and(combobox7.Text<>'') then
begin //性别、年龄和学历
adoquery1.Active:=false;
adoquery1.sql.Clear;
s:='select * from a01,a08 where 性别='''+trim(combobox3.text)+''''+' and '+' 年龄 between '+trim(combobox4.Text)+' and '+trim(combobox5.Text)+' and '+' a08.学历代码 between '+inttostr(combobox6.ItemIndex)+' and '+inttostr(combobox7.ItemIndex)+' and '+' a01.标识号=a08.标识号';
adoquery1.sql.Add(s);
adoquery1.Active :=true;
if adoquery1.RecordCount<>0 then
begin
button1.Enabled :=true;
button2.Enabled :=true;
button3.Enabled :=true;
button4.Enabled :=true;
button6.Enabled :=true;
button7.Enabled :=true;
button8.Enabled :=true;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -