📄 系统程序文挡1.txt
字号:
implementation//系统启动窗体
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
xuqiu.show;//选择需求
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
button1.SetFocus ;
end;
var
xuqiu: Txuqiu;//需求窗体对话框
implementation
uses Unit3, Unit9, Unit11, Unit12, Unit15, Unit14;
{$R *.dfm}
procedure Txuqiu.xuqiu1Click(Sender: TObject);
var
no:string;
begin
case xuqiu1.ItemIndex of //选择功能需求
0:begin teacher.show; xuqiu.Close ; end;//教师预定试卷
1:begin student.show;xuqiu.Close;end;//考生参加考试
2:begin tianchong.show;xuqiu.Close;end;//填充题库
3:begin selchengji.show;xuqiu.Close ;end;//查询单个学生成绩
4:begin//查询某试卷整体答题情况
selfen1.selfen.Close;
no:=inputbox('输入试卷号','请输入您要查询的试卷号!','103');
if no<>'' then
begin
xuqiu.Tag:=strtoint(no);
selfen1.selfen.ParamByName('no').AsString :=no;
selfen1.selfen.Open;
showmessage('参加本次考试的学生有'+inttostr(selfen1.selfen.RecordCount )+'人!');
end;
if selfen1.selfen.IsEmpty then
begin
showmessage('对不起!没有您需要的成绩!');
end
else
begin//设置各字段宽度
selfen1.Show;
selfen1.DBGrid1.Columns[0].Width :=120;
selfen1.DBGrid1.Columns[1].Width :=180;
selfen1.DBGrid1.Columns[2].Width :=120;
selfen1.DBGrid1.Columns[3].Width :=120;
selfen1.DBGrid1.Columns[4].Width :=120;
end;
end;
end;
if (xuqiu1.ItemIndex =4) and (selfen1.selfen.IsEmpty) then
xuqiu1.ItemIndex :=-1;
end;
var
teacher: Tteacher;//教师登陆对话框
implementation
uses Unit4;
{$R *.dfm}
procedure Tteacher.Button1Click(Sender: TObject);
begin
//校验身份
if (no.text='') or (name.Text='') or (ke.Text ='') then
begin
showmessage('登陆信息不完整!请认真检查!');
end
else
begin
sfjy.Close;
sfjy.ParamByName('no').AsString :=trim(no.Text);
sfjy.ParamByName('name').AsString :=trim(name.Text);
sfjy.ParamByName('kecheng').AsString :=trim(ke.Text);
sfjy.Open;
if not sfjy.IsEmpty then
begin//登陆成功
showmessage(name.text+' 老师您好!欢迎您预订本系统试卷!');
xuanke.show;
teacher.Close;
end
else
begin//登陆失败
showmessage('对不起!只有本校教师且所教课程相符才能预定试卷!');
end;
end;
end;
procedure Tteacher.noKeyPress(Sender: TObject; var Key: Char);
begin
//是否是有效字符
if not ((key>=#48) and (key<=#57) ) then
begin
showmessage('对不起!您输入了非法的字符!');
key:=#13;
no.Text:='';
end;
end;
procedure Tteacher.FormActivate(Sender: TObject);
begin
no.SetFocus ;
end;
end.
var
student: Tstudent;//考生登陆对话框
implementation
uses Unit5, Unit6, Unit7;
{$R *.dfm}
procedure kongshu1(); //根据填空数目来设定4个填空框的隐现
begin
form6.k1.SetFocus ;
form6.k1.SelectAll ;
case strtoint(form6.kongshu.Text) of
1:begin form6.lk2.Visible :=false;form6.k2.Visible :=false;
form6.lk3.Visible :=false;form6.k3.Visible :=false;
form6.lk4.Visible:=false;form6.k4.Visible :=false;end;
2:begin form6.lk3.Visible :=false;form6.k3.Visible :=false;
form6.lk4.Visible:=false;form6.k4.Visible :=false;end;
3:begin form6.lk4.Visible:=false;form6.k4.Visible :=false;end;
end;
end;
procedure Tstudent.Button1Click(Sender: TObject);//提交考生信息
var
xk,tk,ke1:string;
begin
form6.Tag:=1;
isxuan.SQL.Clear ;
isxuan.SQL.Add('select * from 考生成绩表 where 学生学号=:no and 所选试卷号=:juanno');
isxuan.ParamByName('no').AsString :=no.Text ;
isxuan.ParamByName('juanno').AsString :=juanhao.Text;
isxuan.Open; //查询是否已经参加考试
if isxuan.IsEmpty then
begin
isxuan.SQL.Clear;
isxuan.SQL.Add('delete from 考卷试题库');
isxuan.ExecSQL ;
selstudent.Close ;
selstudent.ParamByName('no1').AsString :=no.Text ;
selstudent.ParamByName('name').AsString :=name.Text ;
selstudent.Open;
if selstudent.IsEmpty then
begin//信息无效
showmessage('对不起!您输入的学号和姓名无效!请查证后再输入!');
no.Text :='';
name.Text :='';
juanhao.Text :='';
end
else
begin
if juanhao.Text ='' then
showmessage('请将您要参加考试试卷的试卷号填写完整!')
else
begin
inssjk.SQL.Clear ;
inssjk.SQL.Add('select 所属课程 from 确定试卷库 where 试卷号=:no');
inssjk.ParamByName('no').AsString :=juanhao.Text ;
inssjk.Open; // 检查是否为有效的试卷号
ke1:=ke.text;
edit1.Text:=ke.Text;
if inssjk.IsEmpty then
showmessage('对不起!您输入了无效的试卷号!')
else
begin
if ke.Text ='外语' then //选择课程
begin
xk:='外语选择题库';
tk:='外语填空题库';
end
else
begin
xk:='线性代数选择题库';
tk:='线性代数填空题库';
end;
xk1.Text :=xk;
tk1.Text :=tk;
inssjk.SQL.Clear ;
inssjk.SQL.Add('insert into 考卷试题库 (题号,题型,题目,选项A,选项B,选项C,选项D,正确答案,所属课程) select 题号,题型,题目,选项A,选项B,选项C,选项D,正确答案,所属课程 from '+xk+' where 题号 in (select 题号 from 确定试卷库 where 题型='+''''+'选择题'+''''+' and 试卷号=:no)');
inssjk.ParamByName('no').AsString :=juanhao.Text;
inssjk.ExecSQL ; //插入选择题
inssjk.SQL.Clear ;
inssjk.SQL.Add('insert into 考卷试题库 (题号,题型,题目,填空数目,所属课程) select 题号,题型,题目,填空数目,所属课程 from '+tk+' where 题号 in (select 题号 from 确定试卷库 where 题型='+''''+'填空'+''''+' and 试卷号=:no)');
inssjk.ParamByName('no').AsString :=juanhao.Text;
inssjk.ExecSQL ; //插入填空题
//以试卷的形式展示
isxuan.SQL.Clear ;
isxuan.SQL.Add('select * from 考卷试题库');
isxuan.Open;
if not isxuan.IsEmpty then //试卷插入成功
begin
isxuan.SQL.Clear ;
isxuan.SQL.Add('select * from 确定试卷库 where 题型='+''''+'选择题'+''''+' and 试卷号=:no');
isxuan.ParamByName('no').AsString :=juanhao.Text ;
isxuan.Open;
form6.show;
if not isxuan.IsEmpty then //判定是不是只有填空题
begin
form6.query1.ParamByName('tixing').AsString :='选择题' ;
end
else
form6.query1.ParamByName('tixing').AsString :='填空';
form6.query1.open;
form6.shumu.Caption :=inttostr(form6.Query1.RecordCount );
form6.BitBtn7.Visible :=false;
form6.juanno.Caption :=form6.juanno.Caption +' :'+juanhao.Text ;
form6.kecheng.Caption :=form6.kecheng.Caption +' :'+ke1 ;
form6.k1.ReadOnly :=false; //将四个填空项设为可修改
form6.k2.ReadOnly :=false;
form6.k3.ReadOnly :=false;
form6.k4.ReadOnly :=false;
if isxuan.IsEmpty then //试卷中无选择题
begin
form6.xuanze.Visible :=false;
form6.tiankong.Visible :=true;
form6.xz.Visible :=false;
form6.tk.Visible :=false;
form6.shumu1.Caption :=inttostr(form6.Query1.RecordCount) ;
kongshu1();
end;
isxuan.SQL.Clear ;
isxuan.SQL.Add('select * from 确定试卷库 where 题型='+''''+'填空'+''''+' and 试卷号=:no');
isxuan.ParamByName('no').AsString :=juanhao.Text ;
isxuan.Open; //判定试卷中是否有填空题填空题
if isxuan.IsEmpty then
form6.tk.Visible :=false;
end;
//展示结束
end;
end;
end;
end
else
showmessage('对不起!您已经参加了考试!');
end;
procedure Tstudent.noKeyPress(Sender: TObject; var Key: Char);
begin
//是否是有效字符
if not ((key>=#48) and (key<=#57) ) then
begin
showmessage('对不起!您输入了非法的字符!');
key:=#13;
no.Text:='';
end;
end;
procedure Tstudent.juanhaoKeyPress(Sender: TObject; var Key: Char);
begin
//是否是有效字符
if not ((key>=#48) and (key<=#57) ) then
begin
showmessage('对不起!您输入了非法的字符!');
key:=#13;
juanhao.Text:='';
end;
end;
procedure Tstudent.FormActivate(Sender: TObject);
begin
no.SetFocus ;
edit1.Tag:=1;
end;
end.
var
xuanke: Txuanke; //选定试卷所属课程
implementation
uses Unit5,unit3;
{$R *.dfm}
procedure Txuanke.selkeClick(Sender: TObject);
begin //选取试卷所属课程
if selke.ItemIndex =0 then
begin
if teacher.ke.Text ='线性代数' then
begin
selke.Tag:=0;
form5.Show;
end
else
showmessage('对不起,您只能预定外语试卷!');
end
else
begin
if teacher.ke.Text ='外语' then
begin
selke.Tag:=1;
form5.Show;
end
else
showmessage('对不起,您只能预定线性代数试卷!');
end;
end;
end.
var
Form5: TForm5;
implementation
uses unit4, Unit6,unit3, Unit7,unit8;
{$R *.dfm}
//此函数为按数目,范围提供随即数
function qurand(num,range1:integer):integer;
var
i,j,k:integer;
zancun:array[0..100] of integer;
begin
form5.cunrnd.Clear ;
zancun[0]:=trunc(random(range1)+1);
form5.cunrnd.Items.Add(inttostr(trunc(random(range1)+1))) ;
while form5.jiegou.tag<num-1 do
begin
i:=trunc(random(range1)+1);
for j:=0 to form5.Tag do
begin
if i=zancun[j] then
break;
end;
if j>form5.tag then
begin
form5.jiegou.Tag:=form5.jiegou.Tag+1;
form5.Tag:=form5.Tag+1;
zancun[form5.Tag]:=i;
form5.cunrnd.Items.Add(inttostr(i)) ;
end;
end;
form5.cunrnd.Items.Strings[0]:=inttostr(zancun[0]);
form5.Tag:=0;
form5.jiegou.Tag:=0;
end;
procedure TForm5.quanzidongClick(Sender: TObject);
var
k,h,juanno:integer;
begin
button3.Tag:=0;
qktk.ExecSQL ;
if quanzidong.Checked =true then
begin
if xuanke.selke.tag=0 then
begin //将线性代数试题插入试卷库
chuansong.SQL.Add('select * from 线性代数选择题库');
chuansong.Open;
if not chuansong.IsEmpty then
begin
h:=qurand(7,chuansong.RecordCount); //从题库中所有的试题中选择7道题
chuansong.SQL.Clear ;
chuansong.SQL.Add('insert into 考卷试题库 (题号,题型,题目,选项A,选项B,选项C,选项D,正确答案,所属课程) select 题号,题型,题目,选项A,选项B,选项C,选项D,正确答案,所属课程 from 线性代数选择题库 where 题号=:no');
for k:=0 to cunrnd.Items.Count-1 do
begin
chuansong.ParamByName('no').AsString :=cunrnd.items.strings[k];
chuansong.ExecSQL ;
end;
chuansong.SQL.Clear ;
end
else
showmessage('对不起!选择题库中没有试题!');
//插入线性代数填空试题
chuansong.SQL.Clear ;
chuansong.SQL.Add('select * from 线性代数填空题库');
chuansong.Open;
if not chuansong.IsEmpty then
begin
h:=qurand(7,chuansong.RecordCount);
chuansong.SQL.Clear ;
chuansong.SQL.Add('insert into 考卷试题库 (题号,题型,题目,选项A,选项B,选项C,选项D,填空数目,所属课程) select 题号,题型,题目,空1,空2,空3,空4,填空数目,所属课程 from 线性代数填空题库 where 题号=:no');
for k:=0 to cunrnd.Items.Count-1 do
begin
chuansong.ParamByName('no').AsString :=cunrnd.Items.Strings[k];
chuansong.ExecSQL ;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -