📄 unit12.~pas
字号:
unit Unit12;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,unit7, StdCtrls, Grids, DBGrids, ExtCtrls,unit1;
type
TForm12 = class(TForm)
Panel1: TPanel;
DBGrid1: TDBGrid;
Label1: TLabel;
ComboBox1: TComboBox;
Label2: TLabel;
ComboBox2: TComboBox;
Label3: TLabel;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form12: TForm12;
implementation
uses Unit5;
{$R *.dfm}
procedure TForm12.Button2Click(Sender: TObject);
begin
combobox1.Items.Clear;
combobox2.Items.Clear;
form5.show;
form12.Close;
end;
procedure TForm12.FormShow(Sender: TObject);
var
search:string;
begin
//search:=trim(combobox1.Text);
datamodule7.ADOQuery1.Close;
datamodule7.ADOQuery1.SQL.Clear;
datamodule7.ADOQuery1.SQL.Add('select student.学生号,student.学生名,student.系别,student.专业,sc.课程号,班级 from student,tc,sc,cc where tc.课程号=cc.课程号 and cc.课程号=sc.课程号 and sc.学生号=student.学生号 and tc.教师号='''+form1.edit1.text+'''');
datamodule7.ADOQuery1.Open;
while not datamodule7.ADOQuery1.Eof do
begin
search:=datamodule7.ADOQuery1.FieldValues['学生号'];
combobox1.Items.Add(search); //注意!1!!!!!!!!!!!
datamodule7.ADOQuery1.Next;
end
end;
procedure TForm12.ComboBox1Change(Sender: TObject);
var
search:string;
begin
search:=trim(combobox1.Text);
datamodule7.ADOQuery1.Close;
datamodule7.ADOQuery1.SQL.Clear;
datamodule7.ADOQuery1.SQL.Add('select 学生号,学生名,系别,专业,课程号,课程名,班级 from student,sc,cc where cc.课程号=sc.课程号 and sc.学生号=student.学生号 and sc.学生号='''+combobox1.text+'''');
datamodule7.ADOQuery1.Open;
while not datamodule7.ADOQuery1.Eof do
begin
search:=datamodule7.ADOQuery1.FieldValues['课程号'];
combobox1.Items.Add(search); //注意!1!!!!!!!!!!!
datamodule7.ADOQuery1.Next;
end
end;
procedure TForm12.Button1Click(Sender: TObject);
begin
if combobox1.Text='' then
begin
showmessage('输入值不能为空!请重新输入!');
end
else
begin
try
datamodule7.ADOConnection1.BeginTrans;
datamodule7.adoquery1.close;
datamodule7.adoquery1.SQL.Clear;
datamodule7.ADOQuery1.SQL.Add('updata sc set 分数 ='''+edit1.Text+'''');
//datamodule7.ADOQuery1.Parameters.ParamByName('学生号').Value := combobox1.Text;
//datamodule7.ADOQuery1.Parameters.ParamByName('课程号').Value := combobox2.Text;
//datamodule7.ADOQuery1.Parameters.ParamByName('分数').Value := edit1.Text;
//datamodule7.ADOQuery1.Parameters.ParamByName('系别').Value := combobox1.Text;
//datamodule7.ADOQuery1.Parameters.ParamByName('专业').Value := combobox2.Text;
//datamodule7.ADOQuery1.Parameters.ParamByName('课程类别').Value := combobox3.Text;
//datamodule7.ADOQuery1.Parameters.ParamByName('教材').Value := combobox4.Text;
//datamodule7.ADOQuery1.Parameters.ParamByName('学年').Value := combobox5.Text;
showmessage('请确认输入信息!');
datamodule7.adoquery1.Prepared;
datamodule7.ADOQuery1.ExecSQL;
showmessage('注册成功!') ;
datamodule7.ADOConnection1.CommitTrans;
except
showmessage('注册失败!') ;
datamodule7.ADOConnection1.RollbackTrans;
end;
end
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -