📄 unit6.pas
字号:
unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, DB, ADODB;
type
TForm6 = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
DBGrid1: TDBGrid;
Label3: TLabel;
Edit3: TEdit;
Label4: TLabel;
Button1: TButton;
Button2: TButton;
DataSource1: TDataSource;
ADOQuery1: TADOQuery;
Button3: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form6: TForm6;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm6.Button2Click(Sender: TObject);
begin
form6.Close;
end;
procedure TForm6.Button1Click(Sender: TObject);
begin
if(Edit1.Text='')then
showmessage('学号不能够为空,请确认后重新输入!')
else
begin
if (Edit2.Text ='')then
showmessage('课程编号 不能够为空,请确认后重新输入!')
else
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select stu_no from stud_score where stu_no='''+Edit1.Text+'''');
adoquery1.Open;
if adoquery1.RecordCount=0 then
showmessage('没有找到学号为'''+Edit1.Text+'''的成绩记录信息!')
else
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select Cour_no from stud_score where Cour_no='''+Edit2.Text+'''');
adoquery1.Open;
if (adoquery1.RecordCount=0)then
showmessage('没有找到课程号为'''+Edit2.Text+'''的成绩信息!')
else
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select stu_no,Cour_no from stud_score where stu_no='''+Edit1.Text+'''and Cour_no='''+Edit2.Text+'''');
adoquery1.Open;
if adoquery1.RecordCount=0 then
showmessage('不存在学号为'''+Edit1.Text+'''课程编号为'''+Edit2.Text+'''的成绩信息记录')
else
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('update stud_score set score='''+Edit3.Text+''' where stu_no='''+Edit1.Text+'''and Cour_no='''+Edit2.Text+'''');
adoquery1.ExecSQL;
showmessage('修改成功!');
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select stu_no as"学号",Cour_no as"班号",score as"分数" from stud_score where stu_no='''+Edit1.Text+'''and Cour_no='''+Edit2.Text+'''');
adoquery1.Open;
end
end
end
end
end
end;
procedure TForm6.Button3Click(Sender: TObject);
begin
if Edit1.Text='' then
showmessage('学号不能够为空')
else
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select stu_no as"学号" ,Cour_no as"课程号" from stud_score where stu_no='''+Edit1.Text+'''');
adoquery1.Open;
if adoquery1.RecordCount=0 then
showmessage('不存在学号为'''+Edit1.Text+'''的成绩信息记录')
else
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select stu_no as"学号",Cour_no as"课程号", score as"分数" from stud_score where stu_no='''+Edit1.Text+'''');
adoquery1.Open;
end
end
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -