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

📄 cl.pas

📁 一个比较好的网上考试系统
💻 PAS
字号:
unit cl;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, DB, ADODB;

type
  TForm9 = class(TForm)
    Label1: TLabel;
    cb2: TComboBox;
    Label2: TLabel;
    Edit1: TEdit;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    q8: TADOQuery;
    GroupBox1: TGroupBox;
    Label3: TLabel;
    q9: TADOQuery;
    procedure SpeedButton2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    kemu:string;
  end;

var
  Form9: TForm9;

implementation
uses denglu,juan;
{$R *.dfm}

procedure TForm9.SpeedButton2Click(Sender: TObject);
begin
  close();
end;

procedure TForm9.FormCreate(Sender: TObject);
begin
  q8.Close;
  q8.SQL.Clear;
  q8.SQL.Add('select * from course');
  q8.Open;
      while (not q8.Eof ) do
       begin
       cb2.Items.Add(q8.Fields[1].AsString);
       q8.Next;
       end;
          cb2.ItemIndex:=0;
          q9.Close;
          q9.SQL.Clear;
          q9.SQL.Add('select * from temp ');
          q9.Open;
             if not  q9.Eof   then
               SpeedButton1.Caption:='清空题目'
            else
               SpeedButton1.Caption:='选取题目' ;
end;
    //---------------窗体产生时将所有的课程名加到combox中--------------------------
procedure TForm9.SpeedButton1Click(Sender: TObject);
var
  no:string;
  sum:integer;
begin
  if  SpeedButton1.Caption='清空题目' then
    begin
      q9.Close;
      q9.SQL.Clear;
      q9.SQL.Add('select * from temp');
      q9.Open;
         while not q9.eof do
            begin
            q9.Delete;
            q9.Next;
            end;
            q9.Close;
            SpeedButton1.Caption:='选取题目';
            MessageBox(handle, '题目清除成功!', '提示',  mb_IconInformation + mb_Ok);
            exit;
    end;
                    //----------------若temp表中有题目删除其-----------------------------------
 if  SpeedButton1.Caption='选取题目' then
    begin
       if edit1.Text='' then
          begin
            MessageBox(handle, '输入考试时间!', '提示',  mb_IconInformation + mb_Ok);
            exit;
          end
      else
        begin
         q8.Close;
         q8.SQL.Clear;
         q8.SQL.Add('select * from course where cname='+chr(39)+cb2.Text+chr(39));
         q8.Open;
         no:=q8.Fields[0].AsString;
         q8.Close;
         q8.SQL.Clear;
         q8.SQL.Add('select * from timu where cno='+chr(39)+no+chr(39));
         q8.Open;
         sum:=0;
           while (not q8.Eof) and (sum<=100)do
             begin
             sum:=sum+q8.Fields[3].AsInteger;
             q9.Close;
             q9.SQL.Clear;
             q9.sql.Add('select * from temp');
             q9.Open;
             q9.Insert;
             q9.Fields[0].AsString:=q8.Fields[0].AsString;
             q9.Fields[1].AsString:=q8.Fields[1].AsString;
             q9.Fields[2].AsString:=q8.Fields[3].AsString;
             q9.Fields[3].AsString:=q8.Fields[4].AsString;
             q9.Fields[4].AsString:=q8.Fields[5].AsString;
             q9.Fields[5].AsString:=q8.Fields[6].AsString;
             q9.Fields[6].AsString:=q8.Fields[7].AsString;
             q9.Fields[7].AsString:=q8.Fields[8].AsString;
             q9.Fields[8].AsString:=q8.Fields[9].AsString;
             q9.Fields[9].AsString:=q8.Fields[10].AsString;
             q9.Fields[10].AsString:=q8.Fields[11].AsString;
             q9.Fields[11].AsString:=q8.Fields[12].AsString;
             q9.Fields[12].AsString:=q8.Fields[13].AsString;
             q9.Fields[13].AsString:=q8.Fields[14].AsString;
             q9.Fields[14].AsString:=q8.Fields[15].AsString;
             q9.Fields[15].AsString:=q8.Fields[16].AsString;
             q9.Fields[16].AsString:=edit1.Text;
             q9.Post;
             q8.Next;
      end;
       q9.Close;
       q8.Close;
       SpeedButton1.Caption:='清空题目';
       MessageBox(handle, '题目选取成功!', '提示',  mb_IconInformation + mb_Ok);
       form10.q10.Active:=false;
       form10.q10.Active:=true;   //------------------刷新试卷浏览中的题目------------------
        form9.Close;
        kemu:= cb2.Text;
       exit;
    end;
end;  //------------------------------选取本次考试的题目并加到temp表中---------------------
end;

end.

⌨️ 快捷键说明

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