⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 u_sjzdsc.pas

📁 试卷管理系统
💻 PAS
📖 第 1 页 / 共 3 页
字号:
           end
           else
           begin
               wDoc1.Application.Selection.TypeText(txxhhz[m]+'、'+tbl_sttx.FieldByName('txmc').AsString+'('
                                  +inttostr(Query2.fieldbyname('totalfs').AsInteger)+'分)');
           end;

           wDoc1.Application.Selection.TypeParagraph;

           wDoc2.Activate;
           wDoc2.Application.Selection.EndKey(wdStory);
           wDoc2.Application.Selection.Font.Bold := True;
           wDoc2.Application.Selection.Font.Name := '宋体';
           wDoc2.Application.Selection.Font.Size := 14;

           wDoc2.Application.Selection.TypeText(txxhhz[m]+'、'+tbl_sttx.FieldByName('txmc').AsString);
           wDoc2.Application.Selection.TypeParagraph;

           Query2.Close;

           tbl_tmp_stlb.Filter:='txxh='+inttostr(Query1.fieldbyname('txxh').AsInteger);
           k:=1;
           tbl_tmp_stlb.First;
           while not tbl_tmp_stlb.Eof do
           begin
             tbl_stk.Locate('zyxh;gwlbxh;gwzlxh;khdxxh;txxh;stxh',VarArrayOf([
                            PMyList(MyList.Items[i])^.zyxh,
                            PMyList(MyList.Items[i])^.gwlbxh,
                            PMyList(MyList.Items[i])^.gwzlxh,
                            PMyList(MyList.Items[i])^.khdxxh,
                            tbl_tmp_stlb.fieldbyname('txxh').AsInteger,
                            tbl_tmp_stlb.fieldbyname('stxh').AsInteger]),
                            []);
             //写试题题目
             if tbl_stk.FieldByName('tmifwb').AsBoolean then
             begin
               wDoc1.Activate;

               wDoc1.Application.Selection.Font.Bold := false;
               wDoc1.Application.Selection.Font.Name := '宋体';
               wDoc1.Application.Selection.Font.Size := 14;

               //判断题加前导(    )
               if tbl_tmp_stlb.fieldbyname('txxh').AsInteger<>5 then
               begin
                 wDoc1.Application.Selection.TypeText(inttostr(k)+'、');
               end
               else
               begin
                 wDoc1.Application.Selection.TypeText(inttostr(k)+'、 (      )');
               end;
               wDoc1.Application.Selection.TypeText(trim(tbl_stk.FieldByName('wbtm').AsString));
               wDoc1.Application.Selection.TypeParagraph;
             end
             else
             begin
               blobStream := TBlobStream.Create(TBlobField(tbl_stk.FieldByName('twtm')), bmRead);
               if  blobStream.Size>0 then
               begin
                 blobstream.position:=0;
                 olecontainer1.loadfromstream(blobstream);

                 olecontainer1.SaveAsDocument(Pb_runpath+'\temp\tmp.doc');

                 wDoc:=WordObject.OpenDoc(Pb_runpath+'\temp\tmp.doc');

                 wDoc.Content.Copy;

                 wDoc.Close;

                 wDoc1.Activate;

                 wDoc1.Application.Selection.Font.Bold := false;
                 wDoc1.Application.Selection.Font.Name := '宋体';
                 wDoc1.Application.Selection.Font.Size := 14;

                 //判断题加前导(    )
                 if tbl_tmp_stlb.fieldbyname('txxh').AsInteger<>5 then
                 begin
                   wDoc1.Application.Selection.TypeText(inttostr(k)+'、');
                 end
                 else
                 begin
                   wDoc1.Application.Selection.TypeText(inttostr(k)+'、 (      )');
                 end;

                 wDoc1.Application.Selection.EndKey(wdStory,wdExtend);
                 wDoc1.Application.Selection.Paste;
               end
               else
               begin
                 wDoc1.Activate;

                 wDoc1.Application.Selection.Font.Bold := false;
                 wDoc1.Application.Selection.Font.Name := '宋体';
                 wDoc1.Application.Selection.Font.Size := 14;

                 //判断题加前导(    )
                 if tbl_tmp_stlb.fieldbyname('txxh').AsInteger<>5 then
                 begin
                   wDoc1.Application.Selection.TypeText(inttostr(k)+'、');
                 end
                 else
                 begin
                   wDoc1.Application.Selection.TypeText(inttostr(k)+'、 (      )');
                 end;
               end;
               BlobStream.Free;
             end;

             //写试题答案
             if tbl_stk.FieldByName('daifwb').AsBoolean then
             begin
               wDoc2.Activate;

               wDoc2.Application.Selection.Font.Bold := false;
               wDoc2.Application.Selection.Font.Name := '宋体';
               wDoc2.Application.Selection.Font.Size := 14;

               wDoc2.Application.Selection.TypeText(inttostr(k)+'、');

               wDoc2.Application.Selection.TypeText(trim(tbl_stk.FieldByName('wbda').AsString));
               wDoc2.Application.Selection.TypeParagraph;
             end
             else
             begin
               blobStream := TBlobStream.Create(TBlobField(tbl_stk.FieldByName('twda')), bmRead);
               if  blobStream.Size>0 then
               begin
                 blobstream.position:=0;
                 olecontainer1.DestroyObject;
                 olecontainer1.loadfromstream(blobstream);

                 olecontainer1.SaveAsDocument(Pb_runpath+'\temp\tmp.doc');

                 wDoc:=WordObject.OpenDoc(Pb_runpath+'\temp\tmp.doc');

                 wDoc.Content.Copy;

                 wDoc.Close;

                 wDoc2.Activate;

                 wDoc2.Application.Selection.Font.Bold := false;
                 wDoc2.Application.Selection.Font.Name := '宋体';
                 wDoc2.Application.Selection.Font.Size := 14;

                 wDoc2.Application.Selection.TypeText(inttostr(k)+'、');

                 wDoc2.Application.Selection.EndKey(wdStory,wdExtend);
                 wDoc2.Application.Selection.Paste;
               end
               else
               begin
                 wDoc2.Activate;

                 wDoc2.Application.Selection.Font.Bold := false;
                 wDoc2.Application.Selection.Font.Name := '宋体';
                 wDoc2.Application.Selection.Font.Size := 14;

                 wDoc2.Application.Selection.TypeText(inttostr(k)+'、');

                 wDoc2.Application.Selection.EndKey(wdStory,wdExtend);
               end;
               BlobStream.Free;
             end;
             k:=k+1;

             progressfrm.ProgressBar1.StepIt;

             tbl_tmp_stlb.Next;
           end;
           m:=m+1;
           Query1.Next;
       end;

       wDoc1.Save;
       wDoc1.Activate;
       wDoc1.Application.Selection.HomeKey(wdStory);
       wDoc2.Save;
       wDoc2.Activate;
       wDoc2.Application.Selection.HomeKey(wdStory);
       wDoc1.Activate;

       tbl_tmp_stlb.Filter:='';

       //产生试卷顺序号
       n:=tbl_sjk.RecordCount;
       max:=0;
       tbl_sjk.First;
       while not tbl_sjk.Eof do
       begin
         if max<tbl_sjk.fieldbyname('sjxh').AsInteger then max:=tbl_sjk.fieldbyname('sjxh').AsInteger;
          tbl_sjk.Next;
       end;

       sjxh:=1;
       if n<max then
       begin
         for k:=1 to max do
         begin
          if not tbl_sjk.Locate('sjxh',k,[]) then
          begin
            sjxh:=k;
            break;
          end;
        end;
       end
       else
         sjxh:=n+1;

       tbl_tmp_stlb.First;

       tbl_sjk.Append;

       tbl_sjk.FieldByName('sjxh').AsInteger:=sjxh;
       tbl_sjk.FieldByName('zyxh').AsInteger:=PMyList(MyList.Items[i])^.zyxh;
       tbl_sjk.FieldByName('gwlbxh').AsInteger:=PMyList(MyList.Items[i])^.gwlbxh;
       tbl_sjk.FieldByName('gwzlxh').AsInteger:=PMyList(MyList.Items[i])^.gwzlxh;
       tbl_sjk.FieldByName('khdxxh').AsInteger:=PMyList(MyList.Items[i])^.khdxxh;
       tbl_sjk.FieldByName('sjscfaname').AsString:=combobox1.Text;
       tbl_sjk.FieldByName('sjscdate').AsDateTime:=DateTimePicker1.DateTime;

       st_sjnr := Tstringstream.create('');
       st_sjda := Tstringstream.create('');

       olecontainer1.CreateObjectFromFile(strto1,false);
       olecontainer1.savetostream(st_sjnr);
       tbl_sjk.FieldByName('sjnr').Value:=st_sjnr.DataString;

       olecontainer1.DestroyObject;
       olecontainer1.CreateObjectFromFile(strto2,false);
       olecontainer1.savetostream(st_sjda);
       tbl_sjk.FieldByName('sjda').Value:=st_sjda.DataString;

       tbl_sjk.Post;

       st_sjnr.Free;
       st_sjda.Free;

     end;//单个试卷生成完毕
  end;//配题套数循环结束
 end;//考核对象循环结束i

  progressfrm.Close;
  Screen.Cursor := Save_Cursor;

  for i := 0 to (MyList.Count - 1) do
  begin
    ARecord := MyList.Items[i];
    Dispose(ARecord);
  end;
  MyList.Free;

  if Assigned(WordObject) then
  begin
    if WordObject.Application.Documents.Count>0 then
    begin
      WordObject.Visible:=true;
      WordObject.Application.Activate;
      v1:=WordObject.Application.Documents.Count-1;
      WordObject.Application.Documents.Item(v1).Activate;
      v1:=WordObject.Application.Documents.Count;
      WordObject.Application.Documents.Item(v1).Activate;
      SetWindowPos(Handle,HWND_BOTTOM,0,0,0,0,SWP_NOMOVE+SWP_NOSIZE);
    end;
  end;
end;

procedure Tfrm_sjzdsc.FormClose(Sender: TObject; var Action: TCloseAction);
var
  i:integer;
begin
  if Assigned(WordObject) then begin
    WordObject.Free;
    WordObject := nil;
  end;

  OleContainer1.DestroyObject;
  tbl_sjscfanr.Close;
  tbl_sjscfa.Close;
  tbl_zy.Close;
  tbl_gwlb.Close;
  tbl_gwzl.Close;
  tbl_khdx.Close;
  tbl_sjk.Close;
  tbl_stk.Close;
  tbl_tmp_stlb.Close;
  for i:=0 to ptrlist.Count-1 do
  begin
    dispose(ptrlist.Items[i]);
  end;
  ptrlist.Free;
end;

procedure Tfrm_sjzdsc.CopyDirectory(AHandle: THandle; AFromDir,
  AToDir: String);
var
  FileOp:SHFILEOPSTRUCT;
begin
  with FileOp do
  begin
    Wnd:=AHandle;
    wFunc:=FO_COPY;
    pFrom:=PChar(AFromDir);
    pTo:=PChar(AToDir);
    fFlags:= FOF_NOCONFIRMATION;
    hNameMappings:=nil;
  end;
  SHFileOperation(FileOp);
end;

procedure Tfrm_sjzdsc.BitBtn1Click(Sender: TObject);
var
  form:Tfrm_scfanr;
begin
  form:=Tfrm_scfanr.Create(self);
  form.Table1.Filter:='faname='+ QuotedStr(ComboBox1.Text);
  form.Table2.Filter:='faname='+ QuotedStr(ComboBox1.Text);
  form.ShowModal;
  form.Free;
end;

procedure Tfrm_sjzdsc.WordQuit(Sender: TObject);
begin
  WordObject.Free;
  WordObject := nil;
end;

end.


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -