procedure TMainForm.Edit2KeyPress(Sender: TObject; var Key: Char); var x: single; s: string; begin if not (Key in ['0'..'9', #8, #13]) then begin Key := #0; ShowMessage('只能输入数字'); end; begin if (key = #13) then begin if Edit1.Text = format('%3d+%3d=',[a,b]) then Eor.EorForm.Label2.Caption:=inttostr(strtoint(Eor.EorForm.Label2.Caption)+1); if Edit1.Text = format('%3d-%3d=',[a,b]) then Eor.EorForm.Label4.Caption:=inttostr(strtoint(Eor.EorForm.Label4.caption)+1); if Edit1.Text = format('%3d*%3d=',[c,d]) then Eor.EorForm.Label6.Caption:=inttostr(strtoint(Eor.EorForm.Label6.Caption)+1); if Edit1.Text = format('%3d/%3d=',[e,d]) then Eor.EorForm.Label8.Caption:=inttostr(strtoint(Eor.EorForm.Label8.Caption)+1); MainForm.Tag:=MainForm.Tag + 1; if StrToInt(Edit2.Text) = Edit1.Tag then begin if Edit1.Text = format('%3d+%3d=',[a,b]) then Eor.EorForm.Label1.Caption:=inttostr(strtoint(Eor.EorForm.Label1.Caption)+1); if Edit1.Text = format('%3d-%3d=',[a,b]) then Eor.EorForm.Label3.Caption:=inttostr(strtoint(Eor.EorForm.Label3.Caption)+1); if Edit1.Text = format('%3d*%3d=',[c,d]) then Eor.EorForm.Label5.Caption:=inttostr(strtoint(Eor.EorForm.Label5.Caption)+1); if Edit1.Text = format('%3d/%3d=',[e,d]) then Eor.EorForm.Label7.Caption:=inttostr(strtoint(Eor.EorForm.Label7.Caption)+1);
ListBox1.Items.Insert(0,format(Edit1.Text+'%3s √',[Edit2.Text]));
ListBox1.Tag := ListBox1.Tag + 1;
ADOQuery1.SQL.Clear;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Insert Into record(userid,question,youranswer,rightanswer,result,time)');
ADOQuery1.SQL.Add('Values(:aa,:bb,:cc,:dd,:ee,:ff)');
ADOQuery1.Parameters.ParamByName('aa').Value:=login.LoginForm.Edit1.Text;
ADOQuery1.Parameters.ParamByName('bb').Value:=Edit1.Text;
ADOQuery1.Parameters.ParamByName('cc').Value:=StrToInt(Edit2.Text);
ADOQuery1.Parameters.ParamByName('dd').Value:=Edit1.Tag;
ADOQuery1.Parameters.ParamByName('ee').Value:='正确';
ADOQuery1.Parameters.ParamByName('ff').Value:=FormatDateTime('yyyy年mm月dd日 hh时nn分ss秒',now());
ADOQuery1.ExecSQL;
ADOQuery2.SQL.Add('select * from record where userid=:aa ');
ADOQuery2.Parameters.ParamByName('aa').Value:=login.LoginForm.Edit1.Text;
ADOQuery2.Open;
end
else
begin
ListBox1.Items.Insert(0,Edit1.Text+Edit2.Text+' ×');
ADOQuery1.SQL.Clear;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Insert Into record(userid,question,youranswer,rightanswer,result,time)');
ADOQuery1.SQL.Add('Values(:aa,:bb,:cc,:dd,:ee,:ff)');
ADOQuery1.Parameters.ParamByName('aa').Value:=login.LoginForm.Edit1.Text;
ADOQuery1.Parameters.ParamByName('bb').Value:=Edit1.Text;
ADOQuery1.Parameters.ParamByName('cc').Value:=StrToInt(Edit2.Text);
ADOQuery1.Parameters.ParamByName('dd').Value:=Edit1.Tag;
ADOQuery1.Parameters.ParamByName('ee').Value:='错误';
ADOQuery1.Parameters.ParamByName('ff').Value:=FormatDateTime('yyyy年mm月dd日 hh时nn分ss秒',now());
ADOQuery1.ExecSQL;
ADOQuery2.SQL.Add('select * from record where userid=:aa ');
ADOQuery2.Parameters.ParamByName('aa').Value:=login.LoginForm.Edit1.Text;
ADOQuery2.Open;
if edit1.Text=format('%3d+%3d=',[a,b]) then
Series1.Add(a,'加法错误率',clgreen);
if edit1.Text=format('%3d-%3d=',[a,b]) then
Series1.Add(a,'减法错误率',clgreen);
if edit1.Text=format('%3d*%3d=',[c,d]) then
Series1.Add(a,'乘法错误率',clgreen);
if edit1.Text=format('%3d/%3d=',[e,d]) then
Series1.Add(a,'除法错误率',clgreen);
end;
MainForm.FormActivate(sender);
x := ListBox1.Tag *100/(MainForm.Tag);
s := #13 + '共做%d题'+#13+#13+#13+ '正确率为: '+#13+#13+'%f%%';
Label1.Caption := format(s,[MainForm.Tag,x]);
end; end; end;
图片是保存在数据库里面吗?还是只保存了图片地址呢?