📄 unit8.~pas
字号:
unit Unit8;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm8 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
ComboBox1: TComboBox;
Label4: TLabel;
ComboBox2: TComboBox;
Label5: TLabel;
ComboBox3: TComboBox;
Label6: TLabel;
ComboBox4: TComboBox;
Label7: TLabel;
ComboBox5: TComboBox;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form8: TForm8;
implementation
uses Unit7, Unit4;
{$R *.dfm}
procedure TForm8.Button1Click(Sender: TObject);
var
search:string;
begin
search:=trim(edit1.Text);
datamodule7.ADOQuery1.Close;
datamodule7.ADOQuery1.SQL.Clear;
datamodule7.ADOQuery1.SQL.Add('select 课程号 from cc where 课程号='''+search+'''');
datamodule7.ADOQuery1.Prepared;
datamodule7.ADOQuery1.Open;
if not datamodule7.ADOQuery1.Eof then
begin
showmessage('号码已存在,请重新输入!');
end
else
begin
try
datamodule7.ADOConnection1.BeginTrans;
datamodule7.adoquery1.close;
datamodule7.adoquery1.SQL.Clear;
datamodule7.ADOQuery1.SQL.Add('insert into cc values(:课程号,:课程名,:系别,:专业,:课程类别,:教材,:学年)');
datamodule7.ADOQuery1.Parameters.ParamByName('课程号').Value := edit1.Text;
datamodule7.ADOQuery1.Parameters.ParamByName('课程名').Value := edit2.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;
procedure TForm8.Button2Click(Sender: TObject);
begin
form4.show;
form8.Close;
end;
procedure TForm8.ComboBox1Change(Sender: TObject);
var
search:string;
begin
search:=trim(combobox1.Text);
datamodule7.ADOQuery1.Close;
datamodule7.ADOQuery1.SQL.Clear;
datamodule7.ADOQuery1.SQL.Add('select 系名 from sys where 院名='''+search+'''');
datamodule7.ADOQuery1.Prepared;
datamodule7.ADOQuery1.Open;
while not datamodule7.ADOQuery1.Eof do
begin
search:=datamodule7.ADOQuery1.FieldValues['系名'];
combobox2.Items.Add(search); //注意!1!!!!!!!!!!!
datamodule7.ADOQuery1.Next;
end
end;
procedure TForm8.FormShow(Sender: TObject);
var
search:string;
begin
search:=trim(edit1.Text);
datamodule7.ADOQuery1.Close;
datamodule7.ADOQuery1.SQL.Clear;
datamodule7.ADOQuery1.SQL.Add('select 教材 from cc where 课程号='''+search+'''');
datamodule7.ADOQuery1.Prepared;
datamodule7.ADOQuery1.Open;
while not datamodule7.ADOQuery1.Eof do
begin
search:=datamodule7.ADOQuery1.FieldValues['教材'];
combobox4.Items.Add(search); //注意!1!!!!!!!!!!!
datamodule7.ADOQuery1.Next;
end
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -