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

📄 xinxi.~pas

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

interface

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

type
  TForm5 = class(TForm)
    GroupBox1: TGroupBox;
    xh: TEdit;
    Label1: TLabel;
    xm: TEdit;
    Label2: TLabel;
    xb: TEdit;
    Label3: TLabel;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    q4: TADOQuery;
    procedure SpeedButton1Click(Sender: TObject);
    procedure xhKeyPress(Sender: TObject; var Key: Char);
    procedure SpeedButton2Click(Sender: TObject);
    
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form5: TForm5;

implementation
 uses denglu;
{$R *.dfm}

procedure TForm5.SpeedButton1Click(Sender: TObject);
begin
   if xh.text='' then
     begin
      MessageBox(handle, '输入学生学号!', '提示',  mb_IconInformation + mb_Ok);
      exit;
      end;
    if xm.Text='' then
      begin
       MessageBox(handle, '输入学生姓名!', '提示',  mb_IconInformation + mb_Ok);
      exit;
     end;
    if xb.Text='' then
      begin
       MessageBox(handle, '输入学生所在系!', '提示',  mb_IconInformation + mb_Ok);
       exit;
      end;
//------------------------- 学生的基本信息不能为空------------------------------------
        if xh.Text <>'' then
            begin
            q4.Close;
            q4.SQL.Clear;
            q4.SQL.Add('select * from student where sno='+char(39)+xh.Text+char(39));
            q4.Active:=true;
              if not q4.Eof then       //----------------学号是数据库表中的主码不能相同 -------------
                begin
                 MessageBox(handle, '此学号已存在!', '提示',  mb_IconInformation + mb_Ok);
                     xh.Clear;
                     xm.Clear;
                     xb.Clear;
                     xh.SetFocus;
                     exit;
                  end
              else
                 begin
                  q4.Insert;
                  q4.FieldByName('sno').AsString:=xh.Text;
                  q4.FieldByName('name').AsString :=xm.Text;
                  q4.FieldByName('dept').AsString:=xb.Text;
                 q4.Post;
                  xh.Clear;
                  xm.Clear;
                  xb.Clear;
                   MessageBox(handle, '添加成功!', '提示',  mb_IconInformation + mb_Ok);
                   form5.Visible:=false;
                        end;
                   //----------------------------将学生的基本信息输入到数据库中 ------------------------




             end;

end;

procedure TForm5.xhKeyPress(Sender: TObject; var Key: Char);
begin
 if not (key in ['0'.. '9']) then
     begin
      MessageBox(handle, '输入数字!', '提示',  mb_IconInformation + mb_Ok);
      exit;
     end;
end;             //-----------------------学号框中必须输入的是0到9的数字 ----------------------



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

end.

⌨️ 快捷键说明

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