Unit18.pas
上传用户:szyozho
上传日期:2013-04-13
资源大小:3688k
文件大小:48k
源码类别:

教育系统应用

开发平台:

Delphi

  1. unit Unit18;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, ExtCtrls, StdCtrls, ComCtrls, Buttons, Menus, DB, DBTables;
  6. type
  7.   Tpaperautoform = class(TForm)
  8.     MainMenu1: TMainMenu;
  9.     N5: TMenuItem;
  10.     N19: TMenuItem;
  11.     N6: TMenuItem;
  12.     N21: TMenuItem;
  13.     FontDialog1: TFontDialog;
  14.     Memo1: TMemo;
  15.     Label1: TLabel;
  16.     Label2: TLabel;
  17.     BitBtn1: TBitBtn;
  18.     Label3: TLabel;
  19.     ProgressBar1: TProgressBar;
  20.     BitBtn2: TBitBtn;
  21.     ComboBox2: TComboBox;
  22.     Query1: TQuery;
  23.     ListBox1: TListBox;
  24.     SpeedButton1: TSpeedButton;
  25.     SpeedButton2: TSpeedButton;
  26.     ListBox2: TListBox;
  27.     N1: TMenuItem;
  28.     N3: TMenuItem;
  29.     N7: TMenuItem;
  30.     N8: TMenuItem;
  31.     N4: TMenuItem;
  32.     N9: TMenuItem;
  33.     N10: TMenuItem;
  34.     N11: TMenuItem;
  35.     N12: TMenuItem;
  36.     N13: TMenuItem;
  37.     procedure definediff(a:integer);
  38.     procedure N19Click(Sender: TObject);
  39.     procedure U1Click(Sender: TObject);
  40.     procedure N12Click(Sender: TObject);
  41.     procedure N13Click(Sender: TObject);
  42.     procedure N14Click(Sender: TObject);
  43.     procedure N16Click(Sender: TObject);
  44.     procedure N2Click(Sender: TObject);
  45.     procedure BitBtn1Click(Sender: TObject);
  46.     procedure FormShow(Sender: TObject);
  47.     procedure FormCreate(Sender: TObject);
  48.     procedure BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
  49.       Shift: TShiftState; X, Y: Integer);
  50.     procedure ComboBox2Change(Sender: TObject);
  51.     procedure SpeedButton1Click(Sender: TObject);
  52.     procedure SpeedButton2Click(Sender: TObject);
  53.     procedure N1Click(Sender: TObject);
  54.     procedure N24Click(Sender: TObject);
  55.     procedure N9Click(Sender: TObject);
  56.     procedure N10Click(Sender: TObject);
  57.     procedure N11Click(Sender: TObject);
  58.     procedure N7Click(Sender: TObject);
  59.     procedure N8Click(Sender: TObject);
  60.   private
  61.     { Private declarations }
  62.   public
  63.   // tmno: array[1..5] of string=('一、','二、','三、','四、','五、');
  64.     thao: array[1..800] of integer;
  65.       havetake: array[1..800] of integer;
  66.       diff: array[1..5] of integer;
  67.     { Public declarations }
  68.    // tmno: array[1..5] of string=('一、','二、','三、','四、','五、');
  69.   end;
  70. var
  71.   paperautoform: Tpaperautoform;
  72.    tmno: array[1..5] of string=('一、','二、','三、','四、','五、');
  73.         TF:array[1..9] of string=('f','f','f','f','f','f','f','f','f');
  74.       paperallnumber,choosenumber,judgenumber,filltextnumber,readpronumber,procedurenumber:integer;
  75. implementation
  76.     uses printers, Unit10, Unit22, Unit3, Unit4;
  77. {$R *.dfm}
  78. procedure Tpaperautoform.definediff(a:integer);
  79. var
  80. g:integer;
  81. begin
  82. case a of
  83. 1:
  84. begin
  85. if (copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1)='')
  86.    or (copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1)='0')
  87.     then
  88.       diff[1]:=1
  89.       else
  90.       diff[1]:=strtoint(copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1) );
  91. if (copy(floattostr(paperallnumber*0.4),1,pos('.',floattostr(paperallnumber*0.4))-1)='')
  92.      or (copy(floattostr(paperallnumber*0.4),1,pos('.',floattostr(paperallnumber*0.4))-1)='0')
  93.       then
  94.         diff[2]:=1
  95.         else
  96.          diff[2]:=strtoint(copy(floattostr(paperallnumber*0.4),1,pos('.',floattostr(paperallnumber*0.4))-1));
  97.  if (copy(floattostr(paperallnumber*0.4),1,pos('.',floattostr(paperallnumber*0.4))-1)='')
  98.       or (copy(floattostr(paperallnumber*0.4),1,pos('.',floattostr(paperallnumber*0.4))-1)='0')
  99.        then
  100.            diff[3]:=1
  101.             else
  102.             diff[3]:=strtoint(copy(floattostr(paperallnumber*0.4),1,pos('.',floattostr(paperallnumber*0.4))-1));
  103. if (copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1)='')
  104.         or (copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1)='0')
  105.         then
  106.            diff[4]:=1
  107.             else
  108.           diff[4]:=strtoint(copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1));
  109. diff[5]:=0;
  110. end;
  111. 2:
  112. begin
  113. if (copy(floattostr(paperallnumber*0.05),1,pos('.',floattostr(paperallnumber*0.05))-1)='')
  114.     or (copy(floattostr(paperallnumber*0.05),1,pos('.',floattostr(paperallnumber*0.05))-1)='0')
  115.       then
  116.       diff[1]:=1
  117.       else
  118.        diff[1]:=strtoint(copy(floattostr(paperallnumber*0.05),1,pos('.',floattostr(paperallnumber*0.05))-1) );
  119. if (copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1)='')
  120.      or (copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1)='0')
  121.       then
  122.          diff[2]:=1
  123.         else
  124.          diff[2]:=strtoint(copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1));
  125. if (copy(floattostr(paperallnumber*0.7),1,pos('.',floattostr(paperallnumber*0.7))-1)='')
  126.       or (copy(floattostr(paperallnumber*0.7),1,pos('.',floattostr(paperallnumber*0.7))-1)='0')
  127.        then
  128.            diff[3]:=1
  129.             else
  130.             diff[3]:=strtoint(copy(floattostr(paperallnumber*0.7),1,pos('.',floattostr(paperallnumber*0.7))-1));
  131. if (copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1)='')
  132.          or (copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1)='0')
  133.            then
  134.            diff[4]:=1
  135.             else
  136.              diff[4]:=strtoint(copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1));
  137. if (copy(floattostr(paperallnumber*0.05),1,pos('.',floattostr(paperallnumber*0.05))-1)='')
  138.      or (copy(floattostr(paperallnumber*0.05),1,pos('.',floattostr(paperallnumber*0.05))-1)='0')
  139.           then
  140.            diff[5]:=1
  141.             else
  142.              diff[5]:=strtoint(copy(floattostr(paperallnumber*0.05),1,pos('.',floattostr(paperallnumber*0.05))-1));
  143. diff[5]:=0;
  144. end;
  145. 3:
  146. begin
  147. diff[1]:=0;
  148. if (copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1)='')
  149.        or (copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1)='0')
  150.        then
  151.            diff[2]:=1
  152.             else
  153.              diff[2]:=strtoint(copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1));
  154. if (copy(floattostr(paperallnumber*0.4),1,pos('.',floattostr(paperallnumber*0.4))-1)='')
  155.         or (copy(floattostr(paperallnumber*0.4),1,pos('.',floattostr(paperallnumber*0.4))-1)='0')
  156.            then
  157.            diff[3]:=1
  158.             else
  159.              diff[3]:=strtoint(copy(floattostr(paperallnumber*0.4),1,pos('.',floattostr(paperallnumber*0.4))-1));
  160. if (copy(floattostr(paperallnumber*0.4),1,pos('.',floattostr(paperallnumber*0.4))-1)='')
  161.      or (copy(floattostr(paperallnumber*0.4),1,pos('.',floattostr(paperallnumber*0.4))-1)='0')
  162.          then
  163.            diff[4]:=1
  164.             else
  165.              diff[4]:=strtoint(copy(floattostr(paperallnumber*0.4),1,pos('.',floattostr(paperallnumber*0.4))-1));
  166. if (copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1)='')
  167.        or (copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1)='0')
  168.        then
  169.            diff[5]:=1
  170.             else
  171.              diff[5]:=strtoint(copy(floattostr(paperallnumber*0.1),1,pos('.',floattostr(paperallnumber*0.1))-1));
  172. end;
  173. end;
  174. end;
  175. procedure Tpaperautoform.N19Click(Sender: TObject);
  176. begin
  177. if fontdialog1.Execute then
  178. begin
  179. memo1.Font:=fontdialog1.Font;
  180. end;
  181. end;
  182. procedure Tpaperautoform.U1Click(Sender: TObject);
  183. begin
  184. memo1.Undo;
  185. end;
  186. procedure Tpaperautoform.N12Click(Sender: TObject);
  187. begin
  188.  Memo1.PasteFromClipboard;
  189. end;
  190. procedure Tpaperautoform.N13Click(Sender: TObject);
  191. begin
  192. memo1.SelectAll;
  193. paperautoform.N11.Enabled:=true;
  194. paperautoform.N12.Enabled:=true;
  195. end;
  196. procedure Tpaperautoform.N14Click(Sender: TObject);
  197. begin
  198. memo1.PasteFromClipboard;
  199. end;
  200. procedure Tpaperautoform.N16Click(Sender: TObject);
  201. begin
  202. memo1.SelectAll;
  203. //paperautoform.N14.Enabled:=true;
  204. //paperautoform.N13.Enabled:=true;
  205. end;
  206. procedure Tpaperautoform.N2Click(Sender: TObject);
  207. //var lines :integer;
  208.  //   prntext:system.text;
  209. begin
  210. Screen.Cursor:=crHourGlass;
  211.   try
  212.     print;
  213.     ShowMessage('打印完毕');
  214.   finally
  215.     Screen.Cursor:=crDefault;
  216.   end;
  217.   {
  218.     if printdialog1.Execute then
  219.     assignprn(prntext);
  220.     rewrite(prntext);
  221.     printer.canvas.Font:=memo1.font;
  222.     for lines:=0 to memo1.Lines.Count-1 do
  223.     begin
  224.     writeln(prntext,memo1.lines[lines]);
  225.     system.Close(prntext);
  226.     end;  }
  227. end;
  228. procedure Tpaperautoform.BitBtn1Click(Sender: TObject);
  229.  var
  230. tt,pp,cc,mm,ii,n,diffnum,temp,m,r,ran,q,i,j:integer;
  231.  t,hade:boolean;
  232.  c,f,ju,re,p:integer;
  233. begin
  234. pp:=1;
  235. //ListBox2.Enabled:=false;
  236. if ComboBox2.Text='' then
  237. begin
  238. showmessage('请选择试卷难度!');
  239. exit;
  240. end;
  241.   
  242.  //Label3.Caption:='';
  243. //Label3.Caption:='试卷正在提取中,请耐心等待...           ';
  244. //Label3.Show;
  245. c:=choosenumber;
  246. f:=filltextnumber;
  247. ju:=judgenumber;
  248. re:=readpronumber;
  249. p:=procedurenumber;
  250. progressbar1.Position:=0;
  251. progressbar1.Max:=paperallnumber+10;
  252.  progressbar1.Position:=10;
  253. randomize;
  254. temp:=0;
  255. i:=1;
  256. t:=false;
  257. definediff(ComboBox2.ItemIndex+1);
  258. //  showmessage(inttostr(choosenumber));
  259.        for ii:=ListBox2.Items.Count-1 downto 0 do
  260.        begin
  261.       if  ListBox2.Items[ii]='第一章 C语言基础知识'  then  TF[1]:='t';
  262.       if  ListBox2.Items[ii]='第二章 数据类型、运算符与表达式'  then  TF[2]:='t';
  263.       if  ListBox2.Items[ii]='第三章 顺序结构'  then  TF[3]:='t';
  264.       if  ListBox2.Items[ii]='第四章 选择结构'  then  TF[4]:='t';
  265.       if  ListBox2.Items[ii]='第五章 循环控制'  then  TF[5]:='t';
  266.       if  ListBox2.Items[ii]='第六章 数组指针'  then  TF[6]:='t';
  267.       if  ListBox2.Items[ii]='第七章 函数  结构体与共用体'  then  TF[7]:='t';
  268.       if  ListBox2.Items[ii]='第八章 预处理命令'  then  TF[8]:='t';
  269.       if  ListBox2.Items[ii]='第九章 常用算法设计'  then  TF[9]:='t';
  270.      end;
  271.      //选择题
  272.       //TF存放的是要考的与不考的章,标号就是代表第几章
  273. paperautoform.Memo1.Text:='';
  274. paperautoform.Memo1.Text:='             '+definepaperform.DBEdit1.Text+'                   '+'总分:'+definepaperform.DBEdit2.Text+#13#10#13#10#13#10;
  275. paperautoform.Memo1.Text:=paperautoform.Memo1.Text+'学校__________班级__________姓名__________得分________'+#13#10#13#10;
  276. autoanswerform.Memo1.Text:='';
  277. autoanswerform.Memo1.Text:='             '+definepaperform.DBEdit1.Text+'答案'+#13#10#13#10;
  278. if definepaperform.DBEdit3.Text<>'0' then
  279. begin
  280. tt:=0;
  281.    paperautoform.Memo1.Text:=paperautoform.Memo1.Text+''+#13#10+tmno[pp]+'选择题'+'(共'+definepaperform.DBEdit3.Text+'小题,每题'+definepaperform.DBEdit6.Text+'分,小计'+definepaperform.DBEdit9.Text+'分).'+#13#10+'';
  282.    autoanswerform.Memo1.Text:=autoanswerform.Memo1.Text+''+#13#10+tmno[pp]+'选择题: '+#13#10+'';
  283.     pp:=pp+1;
  284. end;
  285.   //    showmessage('cb');
  286.     //----------------------------------------------------------------
  287.     //------------------------------------------------------------
  288.    while choosenumber<>0 do
  289.    begin
  290.   // if ListBox2.Items.Text='' then
  291.  //
  292.        query1.Close;
  293.        query1.SQL.Clear;
  294.        query1.SQL.Add('select tno from ti_choose') ;
  295.        if ListBox2.Count>=1 then
  296.        begin
  297.        // if ListBox2.Count=1 then
  298.             for mm:=1 to 9 do
  299.             begin
  300.             if TF[mm]='t' then
  301.             begin
  302.             query1.SQL.Add(' where tno not like  '''+inttostr(mm)+'%''');
  303.             break;
  304.             end;
  305.             end;
  306.          if listBox2.Count>1 then
  307.           begin
  308.            for mm:=1 to 9 do
  309.               if TF[mm]='t'   then
  310.               begin
  311.              query1.SQL.Add(' and tno not like  '''+inttostr(mm)+'%''');
  312.      //      showmessage(query1.SQL.Text);
  313.            end;
  314.               end;
  315.        end;
  316.     query1.Open;
  317.     query1.First;
  318.       {
  319.  if ComboBox1.ItemIndex=-1 then
  320.       begin
  321.    query1.Close;
  322.    query1.SQL.Clear;
  323.    query1.SQL.add('select tno from ti_choose');
  324.    query1.Open;
  325.    query1.First;
  326.       end;
  327.    if ComboBox1.ItemIndex=0 then
  328.       begin
  329.    query1.Close;
  330.    query1.SQL.Clear;
  331.    query1.SQL.add('select tno from ti_choose where tno not like ''1%%%''');
  332.    query1.Open;
  333.    query1.First;
  334.       end;
  335.       if ComboBox1.ItemIndex=1 then
  336.       begin
  337.    query1.Close;
  338.    query1.SQL.Clear;
  339.    query1.SQL.add('select tno from ti_choose where tno not like ''2%%%''');
  340.    query1.Open;
  341.    query1.First;
  342.       end;
  343.       if ComboBox1.ItemIndex=2 then
  344.       begin
  345.    query1.Close;
  346.    query1.SQL.Clear;
  347.    query1.SQL.add('select tno from ti_choose where tno not like ''3%%%''');
  348.    query1.Open;
  349.    query1.First;
  350.       end;
  351.       if ComboBox1.ItemIndex=3 then
  352.       begin
  353.    query1.Close;
  354.    query1.SQL.Clear;
  355.    query1.SQL.add('select tno from ti_choose where tno not like ''4%%%''');
  356.    query1.Open;
  357.    query1.First;
  358.       end;
  359.       if ComboBox1.ItemIndex=4 then
  360.       begin
  361.    query1.Close;
  362.    query1.SQL.Clear;
  363.    query1.SQL.add('select tno from ti_choose where tno not like ''5%%%''');
  364.    query1.Open;
  365.    query1.First;
  366.       end;
  367.       if ComboBox1.ItemIndex=5 then
  368.       begin
  369.    query1.Close;
  370.    query1.SQL.Clear;
  371.    query1.SQL.add('select tno from ti_choose where tno not like ''6%%%''');
  372.    query1.Open;
  373.    query1.First;
  374.       end;
  375.       if ComboBox1.ItemIndex=6 then
  376.       begin
  377.    query1.Close;
  378.    query1.SQL.Clear;
  379.    query1.SQL.add('select tno from ti_choose where tno not like ''7%%%''');
  380.    query1.Open;
  381.    query1.First;
  382.       end;
  383.       if ComboBox1.ItemIndex=7 then
  384.       begin
  385.    query1.Close;
  386.    query1.SQL.Clear;
  387.    query1.SQL.add('select tno from ti_choose where tno not like ''8%%%''');
  388.    query1.Open;
  389.    query1.First;
  390.       end;
  391.       if ComboBox1.ItemIndex=8 then
  392.       begin
  393.    query1.Close;
  394.    query1.SQL.Clear;
  395.    query1.SQL.add('select tno from ti_choose where tno not like ''9%%%''');
  396.    query1.Open;
  397.    query1.First;
  398.       end;
  399.       }
  400. while not query1.Eof do
  401. begin
  402.       hade:=false;
  403.       if i=1 then
  404.       begin
  405.      thao[i]:=((Query1.FieldValues['tno']) div 10);
  406.    //   memo1.Text:=memo1.Text+inttostr(thao[i])+'  ';
  407.       end
  408.       else
  409.        if i>1 then
  410.       begin
  411.           for  j:=i-1 downto 1 do
  412.           begin
  413.            if thao[j]=((Query1.FieldValues['tno']) div 10) then
  414.              begin
  415.              t:=true ;
  416.              break;
  417.              end
  418.             else
  419.              t:=false;
  420.            end;
  421.           if not t then
  422.          begin
  423.        thao[i]:=((Query1.FieldValues['tno']) div 10);
  424.    //      memo1.Text:=memo1.Text+inttostr(thao[i])+'  ';
  425.         t:=false;
  426.        end;
  427.       end;
  428.    query1.Next;
  429.    if not t then
  430.       i:=i+1;
  431.  end;
  432.           temp:=random(i-1)+1;
  433.    r:=thao[temp];
  434.    q:=random(9)+1;
  435.     ran:=r*10+q;
  436.     //  if m=1 then
  437.     // havetake[1]:=0000;
  438.      // else if
  439.      for m:=1 to 800 do havetake[m]:=0;
  440.     for m:=1  to 800 do
  441.     begin
  442.     if havetake[m]=ran then
  443.       begin
  444.       showmessage('chongfu');
  445.        hade:=true;
  446.        break;
  447.        end;
  448.     end;
  449.     if not hade then
  450.       begin
  451.       for m:=0 to 800 do
  452.         if havetake[m]=0 then
  453.           begin
  454.           havetake[m]:=ran;
  455.           break;
  456.           end;
  457.   //    showmessage(inttostr(ran));
  458.     query1.Close;
  459.     query1.SQL.Clear;
  460.     query1.SQL.Add('select tigan,xa,xb,xc,xd,answer,difficulty from ti_choose where tno=:no');
  461.     query1.ParamByName('no').Value:=ran;
  462.     query1.Open;
  463.     if choosenumber<>0 then
  464.     begin
  465.     
  466.     if query1.RecordCount<>0 then //continue //showmessage('ddd')
  467.    // else
  468.      begin
  469.      n:= strtoint(query1.FieldByName('difficulty').AsString);
  470.  if   diff[n] <>0 then
  471.     // if definediff[strtoint(query1.fieldbyname('difficulty').AsString)]<>0   then
  472.           begin
  473. //      memo1.Text:=memo1.Text+'选择题';
  474.           tt:=tt+1;
  475. //  showmessage(inttostr(ran));
  476.     memo1.Text:=memo1.Text+inttostr(tt)+'、'+query1.fieldbyname('tigan').AsString+#13#10;
  477.     memo1.Text:=memo1.Text+query1.fieldbyname('xa').AsString+#13#10;
  478.     memo1.Text:=memo1.Text+query1.fieldbyname('xb').AsString+#13#10;
  479.     memo1.Text:=memo1.Text+query1.fieldbyname('xc').AsString+#13#10;
  480.     memo1.Text:=memo1.Text+query1.fieldbyname('xd').AsString+#13#10;
  481.      autoanswerform.Memo1.Text:=autoanswerform.Memo1.Text+inttostr(tt)+'、'+query1.fieldbyname('answer').AsString+#13#10;
  482.     choosenumber:=choosenumber-1;
  483.      n:=n-1;
  484.    // strtoint(query1.fieldbyname('difficulty').AsString):=strtoint(query1.fieldbyname('difficulty').AsString)-1;
  485.        end;
  486.         end;
  487.        end;
  488.  //i:=thao[]
  489.        end;
  490.   // showmessage('choosestop');
  491.  end;
  492.     progressbar1.Position:=progressbar1.Position+c;
  493.        //判断题
  494.      //  showmessage('ce');
  495.        //-----------------------------------------------------------
  496.        //--------------------------------------------------------------
  497.        if definepaperform.DBEdit4.Text<>'0' then
  498.   begin
  499.       tt:=0;
  500.    paperautoform.Memo1.Text:=paperautoform.Memo1.Text+''+#13#10+tmno[pp]+'判断题'+'(共'+definepaperform.DBEdit4.Text+'小题,每题'+definepaperform.DBEdit7.Text+'分,小计'+definepaperform.DBEdit10.Text+'分).'+#13#10+'';
  501.   autoanswerform.Memo1.Text:=autoanswerform.Memo1.Text+''+#13#10+tmno[pp]+'判断题: '+#13#10+'';
  502.    pp:=pp+1;
  503. end;
  504.        while judgenumber<>0 do
  505.        begin
  506.        query1.Close;
  507.        query1.SQL.Clear;
  508.        query1.SQL.Add('select tno from ti_judge') ;
  509.        if ListBox2.Count>=1 then
  510.        begin
  511.        // if ListBox2.Count=1 then
  512.             for mm:=1 to 9 do
  513.             begin
  514.             if TF[mm]='t' then
  515.             begin
  516.             query1.SQL.Add(' where tno not like  '''+inttostr(mm)+'%''');
  517.             break;
  518.             end;
  519.             end;
  520.          if listBox2.Count>1 then
  521.           begin
  522.            for mm:=1 to 9 do
  523.               if TF[mm]='t'   then
  524.               begin
  525.              query1.SQL.Add(' and tno not like  '''+inttostr(mm)+'%''');
  526.       //     showmessage(query1.SQL.Text);
  527.            end;
  528.               end;
  529.        end;
  530.     query1.Open;
  531.     query1.First;
  532.     {
  533.     //  showmessage('judgebegin');
  534.       if ComboBox1.ItemIndex=-1 then
  535.       begin
  536.    query1.Close;
  537.    query1.SQL.Clear;
  538.    query1.SQL.add('select tno from ti_judge');
  539.    query1.Open;
  540.    query1.First;
  541.       end;
  542.    if ComboBox1.ItemIndex=0 then
  543.       begin
  544.    query1.Close;
  545.    query1.SQL.Clear;
  546.    query1.SQL.add('select tno from ti_judge where tno not like ''1%%%''');
  547.    query1.Open;
  548.    query1.First;
  549.       end;
  550.       if ComboBox1.ItemIndex=1 then
  551.       begin
  552.    query1.Close;
  553.    query1.SQL.Clear;
  554.    query1.SQL.add('select tno from ti_judge where tno not like ''2%%%''');
  555.    query1.Open;
  556.    query1.First;
  557.       end;
  558.       if ComboBox1.ItemIndex=2 then
  559.       begin
  560.    query1.Close;
  561.    query1.SQL.Clear;
  562.    query1.SQL.add('select tno from ti_judge where tno not like ''3%%%''');
  563.    query1.Open;
  564.    query1.First;
  565.       end;
  566.       if ComboBox1.ItemIndex=3 then
  567.       begin
  568.    query1.Close;
  569.    query1.SQL.Clear;
  570.    query1.SQL.add('select tno from ti_judge where tno not like ''4%%%''');
  571.    query1.Open;
  572.    query1.First;
  573.       end;
  574.       if ComboBox1.ItemIndex=4 then
  575.       begin
  576.    query1.Close;
  577.    query1.SQL.Clear;
  578.    query1.SQL.add('select tno from ti_judge where tno not like ''5%%%''');
  579.    query1.Open;
  580.    query1.First;
  581.       end;
  582.       if ComboBox1.ItemIndex=5 then
  583.       begin
  584.    query1.Close;
  585.    query1.SQL.Clear;
  586.    query1.SQL.add('select tno from ti_judge where tno not like ''6%%%''');
  587.    query1.Open;
  588.    query1.First;
  589.       end;
  590.       if ComboBox1.ItemIndex=6 then
  591.       begin
  592.    query1.Close;
  593.    query1.SQL.Clear;
  594.    query1.SQL.add('select tno from ti_judge where tno not like ''7%%%''');
  595.    query1.Open;
  596.    query1.First;
  597.       end;
  598.       if ComboBox1.ItemIndex=7 then
  599.       begin
  600.    query1.Close;
  601.    query1.SQL.Clear;
  602.    query1.SQL.add('select tno from ti_judge where tno not like ''8%%%''');
  603.    query1.Open;
  604.    query1.First;
  605.       end;
  606.       if ComboBox1.ItemIndex=8 then
  607.       begin
  608.    query1.Close;
  609.    query1.SQL.Clear;
  610.    query1.SQL.add('select tno from ti_judge where tno not like ''9%%%''');
  611.    query1.Open;
  612.    query1.First;
  613.       end;
  614.         }
  615. while not query1.Eof do
  616. begin
  617.       hade:=false;
  618.       if i=1 then
  619.       begin
  620.      thao[i]:=((Query1.FieldValues['tno']) div 10);
  621.    //   memo1.Text:=memo1.Text+inttostr(thao[i])+'  ';
  622.       end
  623.       else
  624.        if i>1 then
  625.       begin
  626.           for  j:=i-1 downto 1 do
  627.           begin
  628.            if thao[j]=((Query1.FieldValues['tno']) div 10) then
  629.              begin
  630.              t:=true ;
  631.              break;
  632.              end
  633.             else
  634.              t:=false;
  635.            end;
  636.           if not t then
  637.          begin
  638.        thao[i]:=((Query1.FieldValues['tno']) div 10);
  639.    //      memo1.Text:=memo1.Text+inttostr(thao[i])+'  ';
  640.         t:=false;
  641.        end;
  642.       end;
  643.    query1.Next;
  644.    if not t then
  645.       i:=i+1;
  646.  end;
  647.           temp:=random(i-1)+1;
  648.    r:=thao[temp];
  649.    q:=random(9)+1;
  650.     ran:=r*10+q;
  651.     //  if m=1 then
  652.     // havetake[1]:=0000;
  653.      // else if
  654.      for m:=1 to 800 do havetake[m]:=0;
  655.     for m:=1  to 800 do
  656.     begin
  657.     if (havetake[m] div 10)=r then
  658.       begin
  659.       showmessage('chongfu');
  660.        hade:=true;
  661.        break;
  662.        end;
  663.     end;
  664.     if not hade then
  665.       begin
  666.       for m:=0 to 800 do
  667.         if havetake[m]=0 then
  668.           begin
  669.           havetake[m]:=ran;
  670.           break;
  671.           end;
  672.   //    showmessage(inttostr(ran));
  673.     query1.Close;
  674.     query1.SQL.Clear;
  675.     query1.SQL.Add('select tigan,answer,difficulty from ti_judge where tno=:no');
  676.     query1.ParamByName('no').Value:=ran;
  677.     query1.Open;
  678.     if judgenumber<>0 then
  679.     begin
  680.        
  681.     if query1.RecordCount<>0 then //continue//showmessage('ddd')
  682.  //   else
  683.      begin
  684.      n:= strtoint(query1.FieldByName('difficulty').AsString);
  685.  if   diff[n] <>0 then
  686.     // if definediff[strtoint(query1.fieldbyname('difficulty').AsString)]<>0   then
  687.           begin
  688.           //    memo1.Text:=memo1.Text+'判断题';
  689.        tt:=tt+1;
  690.  // showmessage(inttostr(ran));
  691.     memo1.Text:=memo1.Text+inttostr(tt)+'、'+query1.fieldbyname('tigan').AsString+#13#10;
  692.      autoanswerform.Memo1.Text:=autoanswerform.Memo1.Text+inttostr(tt)+'、'+query1.fieldbyname('answer').AsString+#13#10;
  693.     judgenumber:=judgenumber-1;
  694.      n:=n-1;
  695.    // strtoint(query1.fieldbyname('difficulty').AsString):=strtoint(query1.fieldbyname('difficulty').AsString)-1;
  696.        end;
  697.         end;
  698.        end;
  699.  //i:=thao[]
  700.        end;
  701.    //    showmessage('judgestop');
  702.        end;
  703.        progressbar1.Position:=progressbar1.Position+ju;
  704.        
  705. if definepaperform.DBEdit12.Text<>'0' then
  706. begin
  707. tt:=0;
  708.    paperautoform.Memo1.Text:=paperautoform.Memo1.Text+''+#13#10#13#10+tmno[pp]+'填空题'+'(共'+definepaperform.DBEdit12.Text+'小题,每题'+definepaperform.DBEdit13.Text+'分,小计'+definepaperform.DBEdit14.Text+'分).'+#13#10+'';
  709.   autoanswerform.Memo1.Text:=autoanswerform.Memo1.Text+''+#13#10+tmno[pp]+'填空题: '+#13#10+'';
  710.       pp:=pp+1;
  711.       end;
  712.         //填空题
  713.        //----------------------------------------------------------------
  714.        //----------------------------------------------------------------------
  715.       while filltextnumber<>0 do
  716.       begin
  717.       query1.Close;
  718.        query1.SQL.Clear;
  719.        query1.SQL.Add('select tno from ti_filltext') ;
  720.        if ListBox2.Count>=1 then
  721.        begin
  722.        // if ListBox2.Count=1 then
  723.             for mm:=1 to 9 do
  724.             begin
  725.             if TF[mm]='t' then
  726.             begin
  727.             query1.SQL.Add(' where tno not like  '''+inttostr(mm)+'%''');
  728.             break;
  729.             end;
  730.             end;
  731.          if listBox2.Count>1 then
  732.           begin
  733.            for mm:=1 to 9 do
  734.               if TF[mm]='t'   then
  735.               begin
  736.              query1.SQL.Add(' and tno not like  '''+inttostr(mm)+'%''');
  737.      //      showmessage(query1.SQL.Text);
  738.            end;
  739.               end;
  740.        end;
  741.     query1.Open;
  742.     query1.First;
  743.     {
  744.     //    showmessage('filltextbegin');
  745.       if ComboBox1.ItemIndex=-1 then
  746.       begin
  747.    query1.Close;
  748.    query1.SQL.Clear;
  749.    query1.SQL.add('select tno from ti_filltext');
  750.    query1.Open;
  751.    query1.First;
  752.       end;
  753.    if ComboBox1.ItemIndex=0 then
  754.       begin
  755.    query1.Close;
  756.    query1.SQL.Clear;
  757.    query1.SQL.add('select tno from ti_filltext where tno not like ''1%%%''');
  758.    query1.Open;
  759.    query1.First;
  760.       end;
  761.       if ComboBox1.ItemIndex=1 then
  762.       begin
  763.    query1.Close;
  764.    query1.SQL.Clear;
  765.    query1.SQL.add('select tno from ti_filltext where tno not like ''2%%%''');
  766.    query1.Open;
  767.    query1.First;
  768.       end;
  769.       if ComboBox1.ItemIndex=2 then
  770.       begin
  771.    query1.Close;
  772.    query1.SQL.Clear;
  773.    query1.SQL.add('select tno from ti_filltext where tno not like ''3%%%''');
  774.    query1.Open;
  775.    query1.First;
  776.       end;
  777.       if ComboBox1.ItemIndex=3 then
  778.       begin
  779.    query1.Close;
  780.    query1.SQL.Clear;
  781.    query1.SQL.add('select tno from ti_filltext where tno not like ''4%%%''');
  782.    query1.Open;
  783.    query1.First;
  784.       end;
  785.       if ComboBox1.ItemIndex=4 then
  786.       begin
  787.    query1.Close;
  788.    query1.SQL.Clear;
  789.    query1.SQL.add('select tno from ti_filltext where tno not like ''5%%%''');
  790.    query1.Open;
  791.    query1.First;
  792.       end;
  793.       if ComboBox1.ItemIndex=5 then
  794.       begin
  795.    query1.Close;
  796.    query1.SQL.Clear;
  797.    query1.SQL.add('select tno from ti_filltext where tno not like ''6%%%''');
  798.    query1.Open;
  799.    query1.First;
  800.       end;
  801.       if ComboBox1.ItemIndex=6 then
  802.       begin
  803.    query1.Close;
  804.    query1.SQL.Clear;
  805.    query1.SQL.add('select tno from ti_filltext where tno not like ''7%%%''');
  806.    query1.Open;
  807.    query1.First;
  808.       end;
  809.       if ComboBox1.ItemIndex=7 then
  810.       begin
  811.    query1.Close;
  812.    query1.SQL.Clear;
  813.    query1.SQL.add('select tno from ti_filltext where tno not like ''8%%%''');
  814.    query1.Open;
  815.    query1.First;
  816.       end;
  817.       if ComboBox1.ItemIndex=8 then
  818.       begin
  819.    query1.Close;
  820.    query1.SQL.Clear;
  821.    query1.SQL.add('select tno from ti_filltext where tno not like ''9%%%''');
  822.    query1.Open;
  823.    query1.First;
  824.       end;
  825.         }
  826. while not query1.Eof do
  827. begin
  828.       hade:=false;
  829.       if i=1 then
  830.       begin
  831.      thao[i]:=((Query1.FieldValues['tno']) div 10);
  832.    //   memo1.Text:=memo1.Text+inttostr(thao[i])+'  ';
  833.       end
  834.       else
  835.        if i>1 then
  836.       begin
  837.           for  j:=i-1 downto 1 do
  838.           begin
  839.            if thao[j]=((Query1.FieldValues['tno']) div 10) then
  840.              begin
  841.              t:=true ;
  842.              break;
  843.              end
  844.             else
  845.              t:=false;
  846.            end;
  847.           if not t then
  848.          begin
  849.        thao[i]:=((Query1.FieldValues['tno']) div 10);
  850.    //      memo1.Text:=memo1.Text+inttostr(thao[i])+'  ';
  851.         t:=false;
  852.        end;
  853.       end;
  854.    query1.Next;
  855.    if not t then
  856.       i:=i+1;
  857.  end;
  858.           temp:=random(i-1)+1;
  859.    r:=thao[temp];
  860.  
  861.    q:=random(9)+1;
  862.     ran:=r*10+q;
  863.     //  if m=1 then
  864.     // havetake[1]:=0000;
  865.      // else if
  866.      for m:=1 to 800 do havetake[m]:=0;
  867.     for m:=1  to 800 do
  868.     begin
  869.     if havetake[m]=ran then
  870.       begin
  871.       showmessage('chongfu');
  872.        hade:=true;
  873.        break;
  874.        end;
  875.     end;
  876.     if not hade then
  877.       begin
  878.       for m:=0 to 800 do
  879.         if havetake[m]=0 then
  880.           begin
  881.           havetake[m]:=ran;
  882.           break;
  883.           end;
  884.   //    showmessage(inttostr(ran));
  885.     query1.Close;
  886.     query1.SQL.Clear;
  887.     query1.SQL.Add('select tigan,ka,kb,kc,kd,difficulty from ti_filltext where tno=:no');
  888.     query1.ParamByName('no').Value:=ran;
  889.     query1.Open;
  890.     if filltextnumber<>0 then
  891.     begin
  892.      
  893.     if query1.RecordCount<>0 then //continue//showmessage('ddd')
  894.    // else
  895.      begin
  896.      n:= strtoint(query1.FieldByName('difficulty').AsString);
  897.  if   diff[n] <>0 then
  898.     // if definediff[strtoint(query1.fieldbyname('difficulty').AsString)]<>0   then
  899.           begin
  900.             tt:=tt+1;
  901.       //  memo1.Text:=memo1.Text+'填空题';
  902.  // showmessage(inttostr(ran));
  903.     memo1.Text:=memo1.Text+inttostr(tt)+'、'+query1.fieldbyname('tigan').AsString+#13#10;
  904.        autoanswerform.Memo1.Text:=autoanswerform.Memo1.Text+inttostr(tt)+'、'+query1.fieldbyname('ka').AsString+#13#10;
  905.           if query1.fieldbyname('kb').AsString<>'' then
  906.              autoanswerform.Memo1.Text:=autoanswerform.Memo1.Text+query1.fieldbyname('kb').AsString+#13#10;
  907. //form.Memo1.Text:=madeanswerform.Memo1.Text+#10+'   '+query1.fieldbyname('kb').AsString+' '+#13;
  908.  if query1.fieldbyname('kc').AsString<>'' then
  909.    autoanswerform.Memo1.Text:=autoanswerform.Memo1.Text+query1.fieldbyname('kc').AsString+#13#10;
  910.  //madeanswerform.Memo1.Text:=answerform.Memo1.Text+#10+'   '+query1.fieldbyname('kc').AsString+' '+#13;
  911.  if query1.fieldbyname('kd').AsString<>'' then
  912.     autoanswerform.Memo1.Text:=autoanswerform.Memo1.Text+query1.fieldbyname('kd').AsString+#13#10;
  913.  //madeanswerform.Memo1.Text:=madeanswerform.Memo1.Text+#10+'   '+query1.fieldbyname('kd').AsString+' '+#13;
  914.     filltextnumber:=filltextnumber-1;
  915.      n:=n-1;
  916.    // strtoint(query1.fieldbyname('difficulty').AsString):=strtoint(query1.fieldbyname('difficulty').AsString)-1;
  917.        end;
  918.         end;
  919.        end;
  920.  //i:=thao[]
  921.        end;
  922.   //       showmessage('filltextstop');
  923.         end;
  924.         progressbar1.Position:=progressbar1.Position+f;
  925.   if definepaperform.DBEdit5.Text<>'0' then
  926. begin
  927.      tt:=0;
  928.    paperautoform.Memo1.Text:=paperautoform.Memo1.Text+''+#13#10+tmno[pp]+'程序阅读题'+'(共'+definepaperform.DBEdit5.Text+'小题,每题'+definepaperform.DBEdit8.Text+'分,小计'+definepaperform.DBEdit11.Text+'分).'+#13#10+'';
  929.   autoanswerform.Memo1.Text:=autoanswerform.Memo1.Text+''+#13#10+tmno[pp]+'程序阅读题:'+#13#10+'';
  930.     pp:=pp+1;
  931. end;
  932.        //程序阅读
  933.        //------------------------------------------------------------------------
  934.        //---------------------------------------------------------------------------
  935.         while readpronumber<>0 do
  936.         begin
  937.         query1.Close;
  938.        query1.SQL.Clear;
  939.        query1.SQL.Add('select tno from ti_readpro') ;
  940.        if ListBox2.Count>=1 then
  941.        begin
  942.        // if ListBox2.Count=1 then
  943.             for mm:=1 to 9 do
  944.             begin
  945.             if TF[mm]='t' then
  946.             begin
  947.             query1.SQL.Add(' where tno not like  '''+inttostr(mm)+'%''');
  948.             break;
  949.             end;
  950.             end;
  951.          if listBox2.Count>1 then
  952.           begin
  953.            for mm:=1 to 9 do
  954.               if TF[mm]='t'   then
  955.               begin
  956.              query1.SQL.Add(' and tno not like  '''+inttostr(mm)+'%''');
  957.          //  showmessage(query1.SQL.Text);
  958.            end;
  959.               end;
  960.        end;
  961.     query1.Open;
  962.     query1.First;
  963. {
  964.      //     showmessage('readprobegib');
  965.       if ComboBox1.ItemIndex=-1 then
  966.       begin
  967.    query1.Close;
  968.    query1.SQL.Clear;
  969.    query1.SQL.add('select tno from ti_readpro');
  970.    query1.Open;
  971.    query1.First;
  972.       end;
  973.    if ComboBox1.ItemIndex=0 then
  974.       begin
  975.    query1.Close;
  976.    query1.SQL.Clear;
  977.    query1.SQL.add('select tno from ti_readpro where tno not like ''1%%%''');
  978.    query1.Open;
  979.    query1.First;
  980.       end;
  981.       if ComboBox1.ItemIndex=1 then
  982.       begin
  983.    query1.Close;
  984.    query1.SQL.Clear;
  985.    query1.SQL.add('select tno from ti_readpro where tno not like ''2%%%''');
  986.    query1.Open;
  987.    query1.First;
  988.       end;
  989.       if ComboBox1.ItemIndex=2 then
  990.       begin
  991.    query1.Close;
  992.    query1.SQL.Clear;
  993.    query1.SQL.add('select tno from ti_readpro where tno not like ''3%%%''');
  994.    query1.Open;
  995.    query1.First;
  996.       end;
  997.       if ComboBox1.ItemIndex=3 then
  998.       begin
  999.    query1.Close;
  1000.    query1.SQL.Clear;
  1001.    query1.SQL.add('select tno from ti_readpro where tno not like ''4%%%''');
  1002.    query1.Open;
  1003.    query1.First;
  1004.       end;
  1005.       if ComboBox1.ItemIndex=4 then
  1006.       begin
  1007.    query1.Close;
  1008.    query1.SQL.Clear;
  1009.    query1.SQL.add('select tno from ti_readpro where tno not like ''5%%%''');
  1010.    query1.Open;
  1011.    query1.First;
  1012.       end;
  1013.       if ComboBox1.ItemIndex=5 then
  1014.       begin
  1015.    query1.Close;
  1016.    query1.SQL.Clear;
  1017.    query1.SQL.add('select tno from ti_readpro where tno not like ''6%%%''');
  1018.    query1.Open;
  1019.    query1.First;
  1020.       end;
  1021.       if ComboBox1.ItemIndex=6 then
  1022.       begin
  1023.    query1.Close;
  1024.    query1.SQL.Clear;
  1025.    query1.SQL.add('select tno from ti_readpro where tno not like ''7%%%''');
  1026.    query1.Open;
  1027.    query1.First;
  1028.       end;
  1029.       if ComboBox1.ItemIndex=7 then
  1030.       begin
  1031.    query1.Close;
  1032.    query1.SQL.Clear;
  1033.    query1.SQL.add('select tno from ti_readpro where tno not like ''8%%%''');
  1034.    query1.Open;
  1035.    query1.First;
  1036.       end;
  1037.       if ComboBox1.ItemIndex=8 then
  1038.       begin
  1039.    query1.Close;
  1040.    query1.SQL.Clear;
  1041.    query1.SQL.add('select tno from ti_readpro where tno not like ''9%%%''');
  1042.    query1.Open;
  1043.    query1.First;
  1044.       end;
  1045.             }
  1046. while not query1.Eof do
  1047. begin
  1048.       hade:=false;
  1049.       if i=1 then
  1050.       begin
  1051.      thao[i]:=((Query1.FieldValues['tno']) div 10);
  1052.    //   memo1.Text:=memo1.Text+inttostr(thao[i])+'  ';
  1053.       end
  1054.       else
  1055.        if i>1 then
  1056.       begin
  1057.           for  j:=i-1 downto 1 do
  1058.           begin
  1059.            if thao[j]=((Query1.FieldValues['tno']) div 10) then
  1060.              begin
  1061.              t:=true ;
  1062.              break;
  1063.              end
  1064.             else
  1065.              t:=false;
  1066.            end;
  1067.           if not t then
  1068.          begin
  1069.        thao[i]:=((Query1.FieldValues['tno']) div 10);
  1070.    //      memo1.Text:=memo1.Text+inttostr(thao[i])+'  ';
  1071.         t:=false;
  1072.        end;
  1073.       end;
  1074.    query1.Next;
  1075.    if not t then
  1076.       i:=i+1;
  1077.  end;
  1078.           temp:=random(i-1)+1;
  1079.    r:=thao[temp];
  1080.  
  1081.    q:=random(9)+1;
  1082.     ran:=r*10+q;
  1083.     //  if m=1 then
  1084.     // havetake[1]:=0000;
  1085.      // else if
  1086.      for m:=1 to 800 do havetake[m]:=0;
  1087.     for m:=1  to 800 do
  1088.     begin
  1089.     if havetake[m]=ran then
  1090.       begin
  1091.       showmessage('chongfu');
  1092.        hade:=true;
  1093.        break;
  1094.        end;
  1095.     end;
  1096.     if not hade then
  1097.       begin
  1098.       for m:=0 to 800 do
  1099.         if havetake[m]=0 then
  1100.           begin
  1101.           havetake[m]:=ran;
  1102.           break;
  1103.           end;
  1104.   //    showmessage(inttostr(ran));
  1105.     query1.Close;
  1106.     query1.SQL.Clear;
  1107.     query1.SQL.Add('select tigan,ctigan1,x1a,x1b,x1c,x1d,ctigan2,x2a,x2b,x2c,x2d,ctigan3,x3a,x3b,x3c,x3d,answer1,answer2,answer3,difficulty from ti_readpro where tno=:no');
  1108.     query1.ParamByName('no').Value:=ran;
  1109.     query1.Open;
  1110.     if readpronumber<>0 then
  1111.     begin
  1112.           
  1113.     if query1.RecordCount<>0 then// continue//showmessage('ddd')
  1114.    // else
  1115.      begin
  1116.      n:= strtoint(query1.FieldByName('difficulty').AsString);
  1117.  if   diff[n] <>0 then
  1118.     // if definediff[strtoint(query1.fieldbyname('difficulty').AsString)]<>0   then
  1119.           begin
  1120.             tt:=tt+1;
  1121.            // memo1.Text:=memo1.Text+'程序阅读题';
  1122.  //  showmessage(inttostr(ran));
  1123.     memo1.Text:=memo1.Text+inttostr(tt)+'、'+query1.fieldbyname('tigan').AsString+#13#10;
  1124.      memo1.Text:=memo1.Text+query1.fieldbyname('ctigan1').AsString+#13#10;
  1125.      memo1.Text:=memo1.Text+query1.fieldbyname('x1a').AsString+#13#10;
  1126.      memo1.Text:=memo1.Text+query1.fieldbyname('x1b').AsString+#13#10;
  1127.      memo1.Text:=memo1.Text+query1.fieldbyname('x1c').AsString+#13#10;
  1128.      memo1.Text:=memo1.Text+query1.fieldbyname('x1d').AsString+#13#10;
  1129.      if query1.FieldByName('ctigan2').AsString<>'' then
  1130.      begin
  1131.      memo1.Text:=memo1.Text+query1.fieldbyname('ctigan2').AsString+#13#10;
  1132.      memo1.Text:=memo1.Text+query1.fieldbyname('x2a').AsString+#13#10;
  1133.      memo1.Text:=memo1.Text+query1.fieldbyname('x2b').AsString+#13#10;
  1134.      memo1.Text:=memo1.Text+query1.fieldbyname('x2c').AsString+#13#10;
  1135.      memo1.Text:=memo1.Text+query1.fieldbyname('x2d').AsString+#13#10;
  1136.      end;
  1137.        if query1.FieldByName('ctigan3').AsString<>'' then
  1138.      begin
  1139.      memo1.Text:=memo1.Text+query1.fieldbyname('ctigan3').AsString+#13#10;
  1140.      memo1.Text:=memo1.Text+query1.fieldbyname('x3a').AsString+#13#10;
  1141.      memo1.Text:=memo1.Text+query1.fieldbyname('x3b').AsString+#13#10;
  1142.      memo1.Text:=memo1.Text+query1.fieldbyname('x3c').AsString+#13#10;
  1143.      memo1.Text:=memo1.Text+query1.fieldbyname('x3d').AsString+#13#10;
  1144.      end;
  1145.        autoanswerform.Memo1.Text:=autoanswerform.Memo1.Text+query1.Fieldbyname('answer1').AsString+#13#10;
  1146.        if query1.FieldByName('answer2').AsString<>'' then
  1147.        autoanswerform.Memo1.Text:=autoanswerform.Memo1.Text+query1.Fieldbyname('answer2').AsString+#13#10;
  1148.        if query1.FieldByName('answer3').AsString<>'' then
  1149.        autoanswerform.Memo1.Text:=autoanswerform.Memo1.Text+inttostr(tt)+'、'+query1.Fieldbyname('answer3').AsString+#13#10;
  1150.     readpronumber:=readpronumber-1;
  1151.      n:=n-1;
  1152.    // strtoint(query1.fieldbyname('difficulty').AsString):=strtoint(query1.fieldbyname('difficulty').AsString)-1;
  1153.        end;
  1154.         end;
  1155.        end;
  1156.  //i:=thao[]
  1157.        end;
  1158.      //    showmessage('readprostop');
  1159.        end;
  1160.         //   showmessage(inttostr(procedurenumber));
  1161.         progressbar1.Position:=progressbar1.Position+re;
  1162. if definepaperform.DBEdit15.Text<>'0' then
  1163. begin
  1164.        tt:=0;
  1165.    paperautoform.Memo1.Text:=paperautoform.Memo1.Text+''+#13#10+tmno[pp]+'编程题'+'(共'+definepaperform.DBEdit15.Text+'小题,每题'+definepaperform.DBEdit16.Text+'分,小计'+definepaperform.DBEdit17.Text+'分).'+#13#10+'';
  1166.   autoanswerform.Memo1.Text:=autoanswerform.Memo1.Text+''+#13#10+tmno[pp]+'编程题:'+#13#10+'';
  1167.      pp:=pp+1;
  1168.      end;
  1169.         //编程题
  1170.        //------------------------------------------------------------------------
  1171.        //-----------------------------------------------------------------------
  1172.        while procedurenumber<>0 do
  1173.        begin
  1174.        query1.Close;
  1175.        query1.SQL.Clear;
  1176.        query1.SQL.Add('select tno from ti_procedure') ;
  1177.        if ListBox2.Count>=1 then
  1178.        begin
  1179.        // if ListBox2.Count=1 then
  1180.             for mm:=1 to 9 do
  1181.             begin
  1182.             if TF[mm]='t' then
  1183.             begin
  1184.             query1.SQL.Add(' where tno not like  '''+inttostr(mm)+'%''');
  1185.             break;
  1186.             end;
  1187.             end;
  1188.          if listBox2.Count>1 then
  1189.           begin
  1190.            for mm:=1 to 9 do
  1191.               if TF[mm]='t'   then
  1192.               begin
  1193.              query1.SQL.Add(' and tno not like  '''+inttostr(mm)+'%''');
  1194.        //    showmessage(query1.SQL.Text);
  1195.            end;
  1196.               end;
  1197.        end;
  1198.     query1.Open;
  1199.     query1.First;
  1200. {
  1201.      //    showmessage('procedurebdgin');
  1202.       if ComboBox1.ItemIndex=-1 then
  1203.       begin
  1204.    query1.Close;
  1205.    query1.SQL.Clear;
  1206.    query1.SQL.add('select tno from ti_procedure');
  1207.    query1.Open;
  1208.    query1.First;
  1209.       end;
  1210.    if ComboBox1.ItemIndex=0 then
  1211.       begin
  1212.    query1.Close;
  1213.    query1.SQL.Clear;
  1214.    query1.SQL.add('select tno from ti_procedure where tno not like ''1%%%''');
  1215.    query1.Open;
  1216.    query1.First;
  1217.       end;
  1218.       if ComboBox1.ItemIndex=1 then
  1219.       begin
  1220.    query1.Close;
  1221.    query1.SQL.Clear;
  1222.    query1.SQL.add('select tno from ti_procedure where tno not like ''2%%%''');
  1223.    query1.Open;
  1224.    query1.First;
  1225.       end;
  1226.       if ComboBox1.ItemIndex=2 then
  1227.       begin
  1228.    query1.Close;
  1229.    query1.SQL.Clear;
  1230.    query1.SQL.add('select tno from ti_procedure where tno not like ''3%%%''');
  1231.    query1.Open;
  1232.    query1.First;
  1233.       end;
  1234.       if ComboBox1.ItemIndex=3 then
  1235.       begin
  1236.    query1.Close;
  1237.    query1.SQL.Clear;
  1238.    query1.SQL.add('select tno from ti_procedure where tno not like ''4%%%''');
  1239.    query1.Open;
  1240.    query1.First;
  1241.       end;
  1242.       if ComboBox1.ItemIndex=4 then
  1243.       begin
  1244.    query1.Close;
  1245.    query1.SQL.Clear;
  1246.    query1.SQL.add('select tno from ti_procedure where tno not like ''5%%%''');
  1247.    query1.Open;
  1248.    query1.First;
  1249.       end;
  1250.       if ComboBox1.ItemIndex=5 then
  1251.       begin
  1252.    query1.Close;
  1253.    query1.SQL.Clear;
  1254.    query1.SQL.add('select tno from ti_procedure where tno not like ''6%%%''');
  1255.    query1.Open;
  1256.    query1.First;
  1257.       end;
  1258.       if ComboBox1.ItemIndex=6 then
  1259.       begin
  1260.    query1.Close;
  1261.    query1.SQL.Clear;
  1262.    query1.SQL.add('select tno from ti_procedure where tno not like ''7%%%''');
  1263.    query1.Open;
  1264.    query1.First;
  1265.       end;
  1266.       if ComboBox1.ItemIndex=7 then
  1267.       begin
  1268.    query1.Close;
  1269.    query1.SQL.Clear;
  1270.    query1.SQL.add('select tno from ti_procedure where tno not like ''8%%%''');
  1271.    query1.Open;
  1272.    query1.First;
  1273.       end;
  1274.       if ComboBox1.ItemIndex=8 then
  1275.       begin
  1276.    query1.Close;
  1277.    query1.SQL.Clear;
  1278.    query1.SQL.add('select tno from ti_procedure where tno not like ''9%%%''');
  1279.    query1.Open;
  1280.    query1.First;
  1281.       end;
  1282.                 }
  1283. while not query1.Eof do
  1284. begin
  1285.       hade:=false;
  1286.       if i=1 then
  1287.       begin
  1288.      thao[i]:=((Query1.FieldValues['tno']) div 10);
  1289.    //   memo1.Text:=memo1.Text+inttostr(thao[i])+'  ';
  1290.       end
  1291.       else
  1292.        if i>1 then
  1293.       begin
  1294.           for  j:=i-1 downto 1 do
  1295.           begin
  1296.            if thao[j]=((Query1.FieldValues['tno']) div 10) then
  1297.              begin
  1298.              t:=true ;
  1299.              break;
  1300.              end
  1301.             else
  1302.              t:=false;
  1303.            end;
  1304.           if not t then
  1305.          begin
  1306.        thao[i]:=((Query1.FieldValues['tno']) div 10);
  1307.    //      memo1.Text:=memo1.Text+inttostr(thao[i])+'  ';
  1308.         t:=false;
  1309.        end;
  1310.       end;
  1311.    query1.Next;
  1312.    if not t then
  1313.       i:=i+1;
  1314.  end;
  1315.           temp:=random(i-1)+1;
  1316.    r:=thao[temp];
  1317.  
  1318.    q:=random(9)+1;
  1319.     ran:=r*10+q;
  1320.     //  if m=1 then
  1321.     // havetake[1]:=0000;
  1322.      // else if
  1323.      for m:=1 to 800 do havetake[m]:=0;
  1324.     for m:=1  to 800 do
  1325.     begin
  1326.     if havetake[m]=ran then
  1327.       begin
  1328.       showmessage('chongfu');
  1329.        hade:=true;
  1330.        break;
  1331.        end;
  1332.     end;
  1333.     if not hade then
  1334.       begin
  1335.       for m:=0 to 800 do
  1336.         if havetake[m]=0 then
  1337.           begin
  1338.           havetake[m]:=ran;
  1339.           break;
  1340.           end;
  1341.   //    showmessage(inttostr(ran));
  1342.     query1.Close;
  1343.     query1.SQL.Clear;
  1344.     query1.SQL.Add('select tigan,answer,difficulty from ti_procedure where tno=:no');
  1345.     query1.ParamByName('no').Value:=ran;
  1346.     query1.Open;
  1347.     if procedurenumber<>0 then
  1348.     begin
  1349.    
  1350.     if query1.RecordCount<>0 then// continue//showmessage('ddd')
  1351.    //   else
  1352.      begin
  1353.      n:= strtoint(query1.FieldByName('difficulty').AsString);
  1354.  if   diff[n] <>0 then
  1355.     // if definediff[strtoint(query1.fieldbyname('difficulty').AsString)]<>0   then
  1356.           begin
  1357.                tt:=tt+1;
  1358.               //   memo1.Text:=memo1.Text+'编程题';
  1359. //  showmessage(inttostr(ran));
  1360.     memo1.Text:=memo1.Text+inttostr(tt)+'、'+query1.fieldbyname('tigan').AsString+#13#10;
  1361.     autoanswerform.Memo1.Text:=autoanswerform.Memo1.Text+inttostr(tt)+'、'+query1.fieldbyname('answer').AsString+#13#10;
  1362.     procedurenumber:=procedurenumber-1;
  1363.      n:=n-1;
  1364.    // strtoint(query1.fieldbyname('difficulty').AsString):=strtoint(query1.fieldbyname('difficulty').AsString)-1;
  1365.        end;
  1366.         end;
  1367.        end;
  1368.  //i:=thao[]
  1369.        end;
  1370.     end;
  1371.        //  showmessage('pocedurestop');
  1372.        progressbar1.Position:=progressbar1.Position+p;
  1373.     Label3.Hide;
  1374.     showmessage('试卷提取完毕!');
  1375.     for cc:=1 to 9 do
  1376.     TF[cc]:='f';
  1377.        
  1378. end;
  1379. procedure Tpaperautoform.FormShow(Sender: TObject);
  1380. begin
  1381. choosenumber:=strtoint(definepaperform.DBEdit3.Text);
  1382. judgenumber:=strtoint(definepaperform.DBEdit4.Text);
  1383. filltextnumber:=strtoint(definepaperform.DBEdit12.Text);
  1384. readpronumber:=strtoint(definepaperform.DBEdit5.Text);
  1385. procedurenumber:=strtoint(definepaperform.DBEdit15.Text);
  1386. //showmessage(inttostr(choosenumber)+'    '+inttostr(judgenumber)+'   '+inttostr(filltextnumber)+'    '+inttostr(readpronumber)+'     '+inttostr(procedurenumber));
  1387. paperallnumber:=choosenumber+judgenumber+filltextnumber+readpronumber+procedurenumber;
  1388. end;
  1389. procedure Tpaperautoform.FormCreate(Sender: TObject);
  1390. begin
  1391. label3.Hide;
  1392. end;
  1393. procedure Tpaperautoform.BitBtn1MouseDown(Sender: TObject;
  1394.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1395. begin
  1396. if ComboBox2.Text<>'' then
  1397. label3.Show;
  1398. end;
  1399. procedure Tpaperautoform.ComboBox2Change(Sender: TObject);
  1400. var
  1401. i,j:integer;
  1402. begin
  1403. choosenumber:=strtoint(definepaperform.DBEdit3.Text);
  1404. judgenumber:=strtoint(definepaperform.DBEdit4.Text);
  1405. filltextnumber:=strtoint(definepaperform.DBEdit12.Text);
  1406. readpronumber:=strtoint(definepaperform.DBEdit5.Text);
  1407. procedurenumber:=strtoint(definepaperform.DBEdit15.Text);
  1408. //showmessage(inttostr(choosenumber)+'    '+inttostr(judgenumber)+'   '+inttostr(filltextnumber)+'    '+inttostr(readpronumber)+'     '+inttostr(procedurenumber));
  1409. paperallnumber:=choosenumber+judgenumber+filltextnumber+readpronumber+procedurenumber;
  1410.  
  1411. paperautoform.ProgressBar1.Position:=0;
  1412. memo1.Text:='';
  1413. exit;
  1414. for i:=0 to 800 do
  1415. begin
  1416.  paperautoform.thao[i]:=0;
  1417.  paperautoform.havetake[i]:=0;
  1418.  end;
  1419.  for j:=1 to 5 do
  1420.  paperautoform.diff[j]:=0;
  1421.     query1.Close;
  1422.     query1.Open;
  1423. end;
  1424. procedure Tpaperautoform.SpeedButton1Click(Sender: TObject);
  1425. var
  1426. i:integer;
  1427. begin
  1428. for i:=0 to ListBox1.Items.Count-1 do
  1429. if ListBox1.Selected[i] then
  1430. begin
  1431. ListBox2.Items.Append(ListBox1.Items[i]);
  1432. ListBox1.Items.Delete(i);
  1433. break;
  1434. end;
  1435. end;
  1436. procedure Tpaperautoform.SpeedButton2Click(Sender: TObject);
  1437. var
  1438. i:integer;
  1439. begin
  1440. for i:=ListBox2.Items.Count-1 downto 0 do
  1441.  if ListBox2.Selected[i] then
  1442.  begin
  1443.   ListBox1.Items.Append(ListBox2.Items[i]);
  1444.   ListBox2.Items.Delete(i);
  1445.  
  1446.  break;
  1447.    end;
  1448. //end;
  1449. end;
  1450. procedure Tpaperautoform.N1Click(Sender: TObject);
  1451. begin
  1452.     autoanswerform.Show;
  1453. end;
  1454. procedure Tpaperautoform.N24Click(Sender: TObject);
  1455. begin
  1456. //mainform.papertime:=mainform.papertime+1;
  1457.   query1.Close;
  1458.    query1.SQL.Clear;
  1459.    query1.SQL.text:='insert into papermanager values(:gg,''自动'',:ss,:dd)'  ;
  1460. // query1.ParamByName('nn').AsInteger:=mainform.papertime;
  1461.  query1.ParamByName('gg').AsString:=definepaperform.DBEdit1.Text;
  1462.  query1.ParamByName('ss').AsString:=paperautoform.Memo1.Text  ;
  1463.  query1.ParamByName('dd').AsString:=autoanswerform.Memo1.Text     ;
  1464. //  query1.ParamByName('hh').AsInteger:=strtoint(definepaperform.DBEdit18.Text) ;
  1465.    query1.ExecSQL;
  1466.    DataModule4.Table_papermanager.Active:=false;
  1467.    DataModule4.Table_papermanager.Active:=true;
  1468. end;
  1469. procedure Tpaperautoform.N9Click(Sender: TObject);
  1470. begin
  1471. memo1.Undo;
  1472. end;
  1473. procedure Tpaperautoform.N10Click(Sender: TObject);
  1474. begin
  1475. memo1.CutToClipboard;
  1476. end;
  1477. procedure Tpaperautoform.N11Click(Sender: TObject);
  1478. begin
  1479. memo1.CopyToClipboard;
  1480. end;
  1481. procedure Tpaperautoform.N7Click(Sender: TObject);
  1482. begin
  1483.   query1.Close;
  1484.    query1.SQL.Clear;
  1485.     query1.SQL.text:='insert into papermanager values(:gg,''自动'',:ss,:dd)'  ;
  1486. query1.ParamByName('gg').AsString:=definepaperform.DBEdit1.Text;
  1487.  query1.ParamByName('ss').AsString:=paperautoform.Memo1.Text ;
  1488.  query1.ParamByName('dd').AsString:=autoanswerform.Memo1.Text ;
  1489. //  query1.ParamByName('hh').AsInteger:=strtoint(definepaperform.DBEdit18.Text) ;
  1490.    query1.ExecSQL;
  1491.   //  mainform.papertime:=mainform.papertime+1;
  1492. //savedialog1.Title:='保存生成后的试卷';
  1493. //savedialog1.FileName:=fname;
  1494. //if savedialog1.Execute then
  1495.  //  begin
  1496.   // filename:=savedialog1.FileName;
  1497.  //  memo1.Lines.SaveToFile(filename+'.doc');
  1498.  //  end;
  1499.  DataModule4.Table_papermanager.Active:=false;
  1500.    DataModule4.Table_papermanager.Active:=true;
  1501. end;
  1502. procedure Tpaperautoform.N8Click(Sender: TObject);
  1503. begin
  1504. close;
  1505. end;
  1506. end.