📄 unit10.pas
字号:
unit Unit10;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, ExtCtrls, DB, DBTables, StdCtrls, Buttons, Mask,
DBCtrls;
type
TForm10 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
DataSource1: TDataSource;
Query1: TQuery;
Query1BDEDesigner: TStringField;
Query1BDEDesigner2: TStringField;
Query1BDEDesigner3: TStringField;
zw: TStringField;
Query1BDEDesigner4: TIntegerField;
chengji: TDBGrid;
Panel3: TPanel;
Label1: TLabel;
Label2: TLabel;
xzl: TEdit;
Label3: TLabel;
xdf: TEdit;
Label4: TLabel;
Label5: TLabel;
tzl: TEdit;
Label6: TLabel;
tdf: TEdit;
Label7: TLabel;
zf: TEdit;
Label8: TLabel;
tc: TBitBtn;
sel: TQuery;
xz: TEdit;
xw: TEdit;
tz: TEdit;
tw: TEdit;
xzf: TEdit;
tzf: TEdit;
BitBtn1: TBitBtn;
Panel4: TPanel;
Label9: TLabel;
DBGrid1: TDBGrid;
Label10: TLabel;
Label11: TLabel;
DBMemo1: TDBMemo;
Label12: TLabel;
DBEdit1: TDBEdit;
Label13: TLabel;
DBEdit2: TDBEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
chucuox: TQuery;
DataSource2: TDataSource;
DataSource3: TDataSource;
chucuot: TQuery;
DBEdit3: TDBEdit;
wr: TQuery;
DataSource4: TDataSource;
Label14: TLabel;
Edit1: TEdit;
Label15: TLabel;
procedure FormActivate(Sender: TObject);
procedure Query1CalcFields(DataSet: TDataSet);
procedure tcClick(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form10: TForm10;
implementation
uses unit9, Unit6, Unit1;
{$R *.dfm}
procedure TForm10.FormActivate(Sender: TObject);
var
i:integer;
begin
//将试题编号插入表中
query1.Open;
query1.Edit;
for i:=1 to query1.RecordCount do
begin
query1.edit;
query1.FieldByName('试题编号').AsInteger :=i;
query1.Next ;
end;
chengji.Columns.Items[1].Title.Caption :=' '+chengji.Columns.Items[1].Title.Caption;
chengji.Columns.Items[2].Title.Caption :=' '+chengji.Columns.Items[2].Title.Caption;
chengji.Columns.Items[4].Title.Caption :=' '+chengji.Columns.Items[4].Title.Caption;
sel.SQL.Clear ;
sel.SQL.Add('select * from 考卷试题库 where 题型='+''''+'选择题'+'''');
sel.Open;//检查试卷中是否有选择题
if not sel.IsEmpty then
begin
sel.SQL.Clear ;
sel.SQL.Add('select 本题型总分 from 确定试卷库 where 试卷号=:no and 题型='+''''+'选择题'+'''');
sel.ParamByName('no').AsString :=student.juanhao.Text ;
sel.Open;
xzf.Text :=sel.Fields.Fields[0].AsString ;
sel.SQL.Clear ;
sel.SQL.Add('select * from 考卷试题库 where 题型='+''''+'选择题'+''''+' and 是否正确='+''''+'是 '+'''');
sel.Open;
xz.Text :=inttostr(sel.RecordCount );
sel.SQL.Clear ;
sel.SQL.Add('select * from 考卷试题库 where 题型='+''''+'选择题'+''''+' and isnull(是否正确)');
sel.Open;
xw.Text :=inttostr(sel.RecordCount );
end;
sel.SQL.Clear ;
sel.SQL.Add('select * from 考卷试题库 where 题型='+''''+'填空'+'''');
sel.Open;
if not sel.IsEmpty then
begin
sel.SQL.Clear ;
sel.SQL.Add('select 本题型总分 from 确定试卷库 where 试卷号=:no and 题型='+''''+'填空'+'''');
sel.ParamByName('no').AsString :=student.juanhao.Text ;
sel.Open;
tzf.Text :=sel.Fields.Fields[0].AsString ;
sel.SQL.Clear ;
sel.SQL.Add('select * from 考卷试题库 where 题型='+''''+'填空'+''''+' and 是否正确='+''''+'是 '+'''');
sel.Open;
tz.Text :=inttostr(sel.RecordCount );
sel.SQL.Clear ;
sel.SQL.Add('select * from 考卷试题库 where 题型='+''''+'填空'+''''+' and isnull(是否正确)');
sel.Open;
tw.Text :=inttostr(sel.RecordCount );
end;
if xz.Text ='0' then
begin
xzl.Text :='0';
xdf.Text :='0';
end
else
begin
xzl.Text:=copy(floattostr(100*strtofloat(xz.Text )/(strtofloat(xz.text)+strtofloat(xw.Text))),1,4)+'%';
xdf.Text :=copy(floattostr(strtofloat(xz.Text )/(strtofloat(xz.text)+strtofloat(xw.Text))*strtofloat(xzf.Text )),1,4);
end;
if tz.Text ='0' then
begin
tzl.Text :='0';
tdf.Text :='0';
end
else
begin
tzl.Text:=copy(floattostr(100*strtofloat(tz.Text )/(strtofloat(tz.text)+strtofloat(tw.Text))),1,4)+'%';
tdf.Text :=copy(floattostr(strtofloat(tz.Text )/(strtofloat(tz.text)+strtofloat(tw.Text))*strtofloat(tzf.Text )),1,4);
end;
zf.Text :=copy(floattostr(strtofloat(xdf.Text) +strtofloat(tdf.Text)),1,4);
tc.SetFocus ;
end;
procedure TForm10.Query1CalcFields(DataSet: TDataSet);
begin
if dataset.FieldByName('是否正确').AsString ='是' then
zw.Value :=' √'
else
zw.Value :=' ×';
end;
procedure TForm10.tcClick(Sender: TObject);
begin
sel.SQL.Clear ;
sel.SQL.Add('insert into 考生成绩表 values(:no,:name,:xf,:tf,:zf,:juanno)');
sel.ParamByName('no').AsString :=student.no.Text;
sel.ParamByName('name').AsString :=student.name.Text ;
sel.ParamByName('xf').AsString :=xdf.Text ;
sel.ParamByName('tf').AsString :=tdf.Text ;
sel.ParamByName('zf').AsString :=zf.Text ;
sel.ParamByName('juanno').AsString :=student.juanhao.Text ;
sel.ExecSQL ;
form6.close;
form10.Close;
end;
procedure TForm10.BitBtn1Click(Sender: TObject);
var
tk:string;
pie:string;
begin
pie:='''';
if student.Edit1.Text ='外语' then
tk:='外语填空题库'
else
tk:='线性代数填空题库';
panel4.Visible :=true;
chucuox.SQL.Clear ;
chucuox.SQL.Add('select 题目,选项A,选项B,选项C,选项D,考生答案,正确答案 from 考卷试题库 where isnull(是否正确)'+' and 题型='+''''+'选择题'+'''');
chucuox.Open;
chucuot.SQL.Clear ;
chucuot.SQL.Add('select 题号,题目,选项A+'+pie+','+pie+'+选项B+'+pie+','+pie+'+选项C+'+pie+','+pie+'+选项D as ksda from 考卷试题库 where isnull(是否正确)'+' and 题型='+''''+'填空'+'''');
chucuot.Open;
edit1.Text :=inttostr(chucuot.RecordCount );
if dbedit3.text<>'' then
begin
wr.SQL.Clear ;
wr.SQL.Add('select 空1+'+pie+','+pie+'+空2+'+pie+','+pie+'+空3+'+pie+','+pie+'+空4 as ri from '+tk+' where 题号=:no');
wr.ParamByName('no').AsString :=dbedit3.Text ;
wr.Open;
end;
DBGrid1.Columns[0].Width :=120;
DBGrid1.Columns[1].Width :=150;
DBGrid1.Columns[2].Width :=120;
DBGrid1.Columns[3].Width :=120;
DBGrid1.Columns[4].Width :=100;
DBGrid1.Columns[5].Width :=120;
DBGrid1.Columns[6].Width :=100;
end;
procedure TForm10.Button3Click(Sender: TObject);
begin
form1.Close;
end;
procedure TForm10.Button1Click(Sender: TObject);
var
tk:string;
pie:string;
begin
pie:='''';
if student.Edit1.Text ='外语' then
tk:='外语填空题库'
else
tk:='线性代数填空题库';
chucuot.Prior ;
wr.SQL.Clear ;
if dbedit3.text<>'' then
begin
wr.SQL.Add('select 空1+'+pie+','+pie+'+空2+'+pie+','+pie+'+空3+'+pie+','+pie+'+空4 as ri from '+tk+' where 题号=:no');
wr.ParamByName('no').AsString :=dbedit3.Text ;
wr.Open;
end;
end;
procedure TForm10.Button2Click(Sender: TObject);
var
tk:string;
pie:string;
begin
pie:='''';
if student.Edit1.Text ='外语' then
tk:='外语填空题库'
else
tk:='线性代数填空题库';
chucuot.next ;
wr.SQL.Clear ;
if dbedit3.text<>'' then
begin
wr.SQL.Add('select 空1+'+pie+','+pie+'+空2+'+pie+','+pie+'+空3+'+pie+','+pie+'+空4 as ri from '+tk+' where 题号=:no');
wr.ParamByName('no').AsString :=dbedit3.Text ;
wr.Open;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -