📄 unit9.pas
字号:
unit Unit9;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DB, DBTables, Mask, DBCtrls;
type
Tstudent = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
no: TEdit;
name: TEdit;
Button1: TButton;
selstudent: TQuery;
juanhao: TEdit;
inssjk: TQuery;
ke: TDBEdit;
DataSource1: TDataSource;
isxuan: TQuery;
xk1: TEdit;
tk1: TEdit;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure noKeyPress(Sender: TObject; var Key: Char);
procedure juanhaoKeyPress(Sender: TObject; var Key: Char);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -