📄 fkao.pas
字号:
unit fkao;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ExtCtrls, Buttons, StdCtrls, DBCtrls;
type
TF_kao = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
StatusBar1: TStatusBar;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Panel5: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
DBText2: TDBText;
DBText3: TDBText;
DBText4: TDBText;
DBText5: TDBText;
Panel7: TPanel;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
SpeedButton10: TSpeedButton;
SpeedButton11: TSpeedButton;
Label7: TLabel;
Label8: TLabel;
DBText6: TDBText;
DBText7: TDBText;
Image1: TImage;
Timer1: TTimer;
SpeedButton12: TSpeedButton;
DBText12: TDBText;
Label13: TLabel;
Label14: TLabel;
DBImage2: TDBImage;
Panel9: TPanel;
Label6: TLabel;
Label11: TLabel;
DBText11: TDBText;
Label12: TLabel;
DBImage1: TDBImage;
Label9: TLabel;
Label10: TLabel;
DBText10: TDBText;
Image2: TImage;
DBText9: TDBText;
DBMemo1: TDBMemo;
DBMemo2: TDBMemo;
Panel6: TPanel;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure SpeedButton6Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton7Click(Sender: TObject);
procedure SpeedButton8Click(Sender: TObject);
procedure SpeedButton9Click(Sender: TObject);
procedure SpeedButton10Click(Sender: TObject);
procedure SpeedButton11Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure SpeedButton12Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
procedure WMGetDlgCode(var msgIn: TWMGetDlgCode); message WM_GETDLGCODE ;
public
{ Public declarations }
end;
var
F_kao: TF_kao;
counttime:integer;
implementation
uses fdata,fscr,main;
{$R *.dfm}
procedure Tf_KAO.WMGetDlgCode;
begin
inherited;
msgIn.Result := msgIn.Result or DLGC_WANTTAB;
end;
procedure TF_kao.FormCreate(Sender: TObject);
begin
if datamodule3.xkaose.DataSet.RecordCount<=0 then
panel6.Visible:=False;
if datamodule3.pkaose.DataSet.RecordCount<=0 then
panel7.Visible:=False;
keypreview:=true;
datamodule3.xkaoqy.First;
datamodule3.pkaoqy.First;
panel4.Caption:='考试时间为'+trim(datamodule3.parse.DataSet.Fields[0].asstring) +'分';
with datamodule3.hotse.DataSet do
begin
with statusbar1.Panels do
begin
Items[0].Text:='A='+chr(strtoint(trim(fields[7].asstring)));
Items[1].Text:='B='+chr(strtoint(trim(fields[8].asstring)));
Items[2].Text:='C='+chr(strtoint(trim(fields[9].asstring)));
Items[3].Text:='D='+chr(strtoint(trim(fields[10].asstring)));
Items[4].Text:='是='+chr(strtoint(trim(fields[0].asstring)));
Items[5].Text:='否='+chr(strtoint(trim(fields[1].asstring)));
Items[6].Text:='上一题=PageUp';
Items[7].Text:='下一题=PageDown';
Items[8].Text:='交卷(看成绩)=Esc';
end;
end;
end;
procedure TF_kao.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if application.MessageBox('是否要退出考试?','提示',mb_yesno)=7 then //7为按下了NO按钮
canclose:=False
else
begin
with datamodule3 do
begin
treese.DataSet.First;
while (datamodule3.treeqy.Eof=False) do //查找考试范围内的表
begin
carqy.Close;
carqy.SQL.clear;
carqy.SQL.Add('select*from'+' '+trim(treese.DataSet.Fields[3].asstring));
carqy.Open;
while (datamodule3.carqy.Eof=False) do
begin
carqy.Edit;
carse.DataSet.Fields[8].AsString:='0';//将标记为被选过的标记去掉
carqy.Post;
carse.DataSet.Next;
end;
datamodule3.treese.DataSet.Next;
end;
end;
Timer1.Enabled:=False;
Speedbutton12.Visible:=False;
Label8.Visible:=False;
Dbtext7.Visible:=False;
Image1.Visible:=False;
Label10.Visible:=False;
Dbtext9.Visible:=False;
Image2.Visible:=False;
panel6.Visible:=True;
panel7.Visible:=True;
end;
end;
procedure TF_kao.SpeedButton6Click(Sender: TObject);
begin
if datamodule3.xkaose.DataSet.RecordCount>0 then
begin
datamodule3.xkaose.DataSet.Prior;
if (trim(datamodule3.xkaose.DataSet.Fields[7].AsString))=(trim(datamodule3.xkaose.DataSet.Fields[9].asstring)) then
image1.Picture.Bitmap.LoadFromFile(extractfilepath(Application.ExeName)+'picture\yes.bmp')
else
image1.Picture.Bitmap.LoadFromFile(extractfilepath(Application.ExeName)+'picture\no.bmp');
end;
end;
procedure TF_kao.SpeedButton3Click(Sender: TObject);
begin
datamodule3.xkaoqy.Edit;
datamodule3.xkaose.DataSet.Fields[9].AsString:='B';
datamodule3.xkaoqy.Post;
end;
procedure TF_kao.SpeedButton4Click(Sender: TObject);
begin
datamodule3.xkaoqy.Edit;
datamodule3.xkaose.DataSet.Fields[9].AsString:='C';
datamodule3.xkaoqy.Post;
end;
procedure TF_kao.SpeedButton5Click(Sender: TObject);
begin
datamodule3.xkaoqy.Edit;
datamodule3.xkaose.DataSet.Fields[9].AsString:='D';
datamodule3.xkaoqy.Post;
end;
procedure TF_kao.SpeedButton2Click(Sender: TObject);
begin
datamodule3.xkaoqy.Edit;
datamodule3.xkaose.DataSet.Fields[9].AsString:='A';
datamodule3.xkaoqy.Post;
end;
procedure TF_kao.SpeedButton7Click(Sender: TObject);
begin
if datamodule3.xkaose.DataSet.RecordCount>0 then
begin
datamodule3.xkaose.DataSet.next;
with datamodule3.xkaose.DataSet do
begin
if ((Trim(Fields[7].AsString))=(Trim(Fields[9].asstring))) then
image1.Picture.Bitmap.LoadFromFile(extractfilepath(Application.ExeName)+'picture\yes.bmp')
else
image1.Picture.Bitmap.LoadFromFile(extractfilepath(Application.ExeName)+'picture\no.bmp') ;
end;
end;
end;
procedure TF_kao.SpeedButton8Click(Sender: TObject);
begin
datamodule3.pkaoqy.Edit ;
datamodule3.pkaose.DataSet.fields[5].AsString:='是';
datamodule3.pkaoqy.Edit;
end;
procedure TF_kao.SpeedButton9Click(Sender: TObject);
begin
datamodule3.pkaoqy.Edit ;
datamodule3.pkaose.DataSet.fields[5].AsString:='否';
datamodule3.pkaoqy.Post;
end;
procedure TF_kao.SpeedButton10Click(Sender: TObject);
begin
if datamodule3.pkaose.DataSet.RecordCount>0 then
begin
datamodule3.pkaose.DataSet.Prior;
if (trim(datamodule3.pkaose.DataSet.Fields[3].AsString))=(trim(datamodule3.pkaose.DataSet.Fields[5].asstring)) then
image2.Picture.Bitmap.LoadFromFile(extractfilepath(Application.ExeName)+'picture\yes.bmp')
else
image2.Picture.Bitmap.LoadFromFile(extractfilepath(Application.ExeName)+'picture\no.bmp');
end;
end;
procedure TF_kao.SpeedButton11Click(Sender: TObject);
begin
if datamodule3.pkaose.DataSet.RecordCount>0 then
begin
datamodule3.pkaose.DataSet.Next;
if (trim(datamodule3.pkaose.DataSet.Fields[3].AsString))=(trim(datamodule3.pkaose.DataSet.Fields[5].asstring)) then
image2.Picture.Bitmap.LoadFromFile(extractfilepath(Application.ExeName)+'picture\yes.bmp')
else
image2.Picture.Bitmap.LoadFromFile(extractfilepath(Application.ExeName)+'picture\no.bmp');
end;
end;
procedure TF_kao.Timer1Timer(Sender: TObject);
begin
counttime:=counttime+1;
panel4.Caption:='考试结束还有'+inttostr(strtoint(trim(datamodule3.parse.DataSet.Fields[0].asstring))-counttime)+'分钟';
if (strtoint(trim(datamodule3.parse.DataSet.Fields[0].asstring))-counttime)=0 then
begin
timer1.Enabled:=false;
if application.MessageBox('考试时间到!'+#13+'是否看成绩?','提示!',mb_yesno)=6 then
speedbutton12.Click;
speedbutton12.Visible:=true;
self.Caption:='考试结束了。';
end;
end;
procedure TF_kao.SpeedButton12Click(Sender: TObject);
begin
label8.Visible:=true;
dbtext7.Visible:=true;
image1.Visible:=true;
speedbutton6.Click;
speedbutton7.Click;
label10.Visible:=true;
dbtext9.Visible:=true;
image2.Visible:=true;
speedbutton10.Click;
speedbutton11.Click;
F_scr.ShowModal;
Timer1.Enabled:=false;
end;
procedure TF_kao.FormShow(Sender: TObject);
begin
if application.MessageBox('开始答卷。','提示!',mb_ok)=1 then
begin
timer1.Enabled:=true;
counttime:=0;
end;
Panel4.Left:=panel1.Width div 2-panel4.Width div 2;
end;
procedure TF_kao.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if strtoint(trim(datamodule3.hotse.DataSet.Fields[6].AsString))=key then
begin
if application.MessageBox('你真的要交卷'+#13+'看成绩吗?','提示!',mb_yesno)=6 then
begin
speedbutton12.Click;
speedbutton12.Visible:=true;
self.Caption:='考试结束了。';
end;
end;
if (Pagecontrol1.ActivePage=tabsheet2) and (datamodule3.pkaose.DataSet.RecordCount>0) then
begin
if strtoint(trim(datamodule3.hotse.DataSet.Fields[0].AsString))=key then
speedbutton8.Click;
if strtoint(trim(datamodule3.hotse.DataSet.Fields[1].AsString))=key then
speedbutton9.Click;
end;
if strtoint(trim(datamodule3.hotse.DataSet.Fields[2].AsString))=key then
begin
if pagecontrol1.ActivePage=tabsheet1 then
speedbutton6.Click
else
speedbutton10.Click;
end;
if strtoint(trim(datamodule3.hotse.DataSet.Fields[3].AsString))=key then
begin
if Pagecontrol1.ActivePage=tabsheet1 then
speedbutton7.Click
else
speedbutton11.Click;
end;
if strtoint(trim(datamodule3.hotse.DataSet.Fields[4].AsString))=key then
F_main.SpeedButton13.Click;
if (Pagecontrol1.ActivePage=tabsheet1) and (datamodule3.xkaose.DataSet.RecordCount>0) then
begin
if strtoint(trim(datamodule3.hotse.DataSet.Fields[7].AsString))=key then
speedbutton2.Click;
if strtoint(trim(datamodule3.hotse.DataSet.Fields[8].AsString))=key then
speedbutton3.Click;
if strtoint(trim(datamodule3.hotse.DataSet.Fields[9].AsString))=key then
speedbutton4.Click;
if strtoint(trim(datamodule3.hotse.DataSet.Fields[10].AsString))=key then
speedbutton5.Click;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -