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

📄 unit4.~pas

📁 成绩管理系统 主要实现:学生(学号
💻 ~PAS
字号:
unit Unit4;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, StdCtrls, DB, ADODB, ExtCtrls;

type
  TForm4 = class(TForm)
    Label1: TLabel;
    DBGrid1: TDBGrid;
    Button3: TButton;
    RadioGroup1: TRadioGroup;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    GroupBox1: TGroupBox;
    Label2: TLabel;
    Edit1: TEdit;
    Label3: TLabel;
    Edit2: TEdit;
    Button1: TButton;
    DataSource1: TDataSource;
    ADOQuery1: TADOQuery;
    Button2: TButton;
    Button4: TButton;
    procedure Button3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form4: TForm4;

implementation
  uses Unit1;
{$R *.dfm}

procedure TForm4.Button3Click(Sender: TObject);
begin
form4.Close;
end;

procedure TForm4.Button1Click(Sender: TObject);
begin
    if (radiobutton1.Checked) then
      begin
           if(Edit1.text='')then
               showmessage('请输入该生的班号!')
           else if(Edit2.Text='') then
             begin
                showmessage('请输入该生的学号');
             end
            else
                begin
                    adoquery1.Close;
                    adoquery1.sql.Clear;
                    adoquery1.SQL.Add('select stu_no from student where stu_no='''+Edit2.text+'''');
                    adoquery1.Open;
                    if adoquery1.RecordCount=0 then
                       showmessage('学号为的学生信息不存在,请确认后重新输入!')
                    else
                         begin
                         adoquery1.Close;
                         adoquery1.SQL.Clear;
                         adoquery1.SQL.Add('update student set stu_class='''+Edit1.text+'''where stu_no='''+edit2.Text+'''');
                         adoquery1.execSQL;
                         showmessage('添加成功!');
                         adoquery1.Close;
                         adoquery1.sql.Clear;
                         adoquery1.SQL.Add('select stu_no as"学号",stu_class as"班级" from student');
                         adoquery1.Open;
                         end
                end
       end
       else if(radiobutton2.Checked) then
       begin
           if(Edit1.text='')then
               showmessage('请输入该生的班号!')
           else if(Edit2.Text='') then
             begin
                showmessage('请输入该生的学号');
             end
            else
                begin
                    adoquery1.Close;
                    adoquery1.sql.Clear;
                    adoquery1.SQL.Add('select stu_no from student where stu_no='''+Edit2.Text+'''');
                    adoquery1.Open;
                    if adoquery1.RecordCount=0 then
                       showmessage('学号为的学生信息不存在,请确认后重新输入!')
                    else
                         begin
                         adoquery1.Close;
                         adoquery1.SQL.Clear;
                         adoquery1.SQL.Add('update student set stu_class=0 where stu_no='''+edit2.Text+'''');
                         adoquery1.ExecSQL;
                         showmessage('删除成功!');
                         adoquery1.Close;
                         adoquery1.sql.Clear;
                         adoquery1.SQL.Add('select stu_no as"学号",stu_class as"班号" from student where stu_class='''+Edit1.Text+'''');
                         adoquery1.Open;
                         end
                end
        end
end;



procedure TForm4.Button2Click(Sender: TObject);
begin
       if(Edit1.text<>'')then
              begin
                    adoquery1.Close;
                    adoquery1.sql.Clear;
                    adoquery1.SQL.Add('select stu_no as"学号",stu_class as"班号",stu_name as"姓名" from student where stu_class='''+Edit1.Text+'''');
                    adoquery1.Open;
                    if adoquery1.RecordCount=0 then
                              showmessage('班号为'''+Edit1.Text+'''的记录信息不存在!')
                     else  showmessage('班号为'''+Edit1.Text+'''的记录信息如下!')
              end
        else
           begin
                if(Edit2.Text<>'') then
                   begin
                        adoquery1.Close;
                        adoquery1.sql.Clear;
                        adoquery1.SQL.Add('select stu_no as"学号",stu_class as"班号",stu_name as"姓名" from student where stu_no='''+Edit2.Text+'''');
                        adoquery1.Open;
                        if adoquery1.RecordCount=0 then
                              showmessage('学号为'''+Edit2.Text+'''的记录信息不存在!')
                        else  showmessage('学号为'''+Edit2.Text+'''的记录信息如下!')


                   end
                  else
                       showmessage('请输入该生的学号或者班号');
           end

end;

procedure TForm4.Button4Click(Sender: TObject);
begin
         adoquery1.Close;
         adoquery1.sql.Clear;
         adoquery1.SQL.Add('select stu_no as"学号",stu_class as"班号",stu_name as"姓名" from student ');
         adoquery1.Open;
end;

end.

⌨️ 快捷键说明

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