📄 unit3.~pas
字号:
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm3 = class(TForm)
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;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure ComboBox2Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses Unit1, Unit7;
{$R *.dfm}
procedure TForm3.Button2Click(Sender: TObject);
begin
form1.show;
form3.Close;
end;
procedure TForm3.Button1Click(Sender: TObject);
var
search:string;
begin
search:=trim(edit1.Text);
datamodule7.ADOQuery1.Close;
datamodule7.ADOQuery1.SQL.Clear;
datamodule7.ADOQuery1.SQL.Add('select 学生号 from student 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 Student 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;
form1.Show;
form3.Close;
end;
procedure TForm3.ComboBox2Change(Sender: TObject);
var
search:string;
begin
search:=trim(combobox2.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['系名'];
combobox3.Items.Add(search); //注意!1!!!!!!!!!!!
datamodule7.ADOQuery1.Next;
end
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -