没有整理,希望有帮助!:)
procedure PfbtOKPaperImport();
var
vTestType,vTestDiff:String;
vItemIndex:integer;
strContent,strAnswer:Tmemorystream;
begin
if MainForm.fnedContentImport.text='' then
begin
Application.messageBox('试卷输出文档名没有填写!','错误',mb_ok+MB_ICONWARNING);
MainForm.fnedContentImport.SetFocus;
exit;
end;
if MainForm.fnedAnswerImport.Text='' then
begin
Application.messageBox('答卷输出文档名没有填写!','错误',mb_ok+MB_ICONWARNING);
MainForm.fnedAnswerImport.SetFocus;
exit;
end;
// 添加试卷及答案记录
dm.tbExamInformation.Open;
dm.tbExamInformation.Append;
dm.tbExamInformation.FieldByName('TestYear').AsString:=MainForm.seTestYear.Text;
dm.tbExamInformation.FieldByName('TestTerm').AsString:=MainForm.fcbTestTerm.Text;
dm.tbExamInformation.FieldByName('TestSpeciality').AsString:=MainForm.dblcSpecialityName.Text;
dm.tbExamInformation.FieldByName('TestType').AsString:=vTestType;
dm.tbExamInformation.FieldByName('TestDifficulty').AsString:=vTestDiff;
strContent:=Tmemorystream.Create; // 处理试卷
strContent.LoadFromFile(MainForm.fnedContentImport.Text);
strContent.Position:=0;
Tblobfield(dm.tbExamInformation.FieldByName('TestContent')).loadfromstream(strContent);
strAnswer:=Tmemorystream.Create; // 处理答卷
strAnswer.LoadFromFile(MainForm.fnedAnswerImport.Text);
strAnswer.Position:=0;
Tblobfield(dm.tbExamInformation.FieldByName('TestAnswer')).loadfromstream(strAnswer);
try
dm.tbExamInformation.Post;
finally
begin
strContent.Free;
strAnswer.Free;
end
end;
dm.tbExamInformation.Close;
ShowMessage('试卷及答卷导入成功!');
end;
procedure fbtExitPaperImport();
begin
ExitToBegin();
end;
procedure fbtOKPaperExport();
var
str:Tmemorystream;
begin
if MainForm.fnedContentExport.text='' then
begin
Application.messageBox('试卷输出文档名没有填写!','错误',mb_ok+MB_ICONWARNING);
MainForm.fnedContentExport.SetFocus;
exit;
end;
if MainForm.fnedAnswerExport.Text='' then
begin
Application.messageBox('答卷输出文档名没有填写!','错误',mb_ok+MB_ICONWARNING);
MainForm.fnedAnswerExport.SetFocus;
exit;
end;
str:=Tmemorystream.Create;
str.Position:=0;
Tblobfield(dm.tbExamInformation.FieldByName('TestContent')).savetostream(str);
str.SaveToFile(MainForm.fnedContentExport.Text);
str.Free;
str:=Tmemorystream.Create;
str.Position:=0;
Tblobfield(dm.tbExamInformation.FieldByName('TestAnswer')).savetostream(str);
str.SaveToFile(MainForm.fnedAnswerExport.Text);
str.Free;
ShowMessage('试卷及答卷导出成功!');
end;