📄 unit2.pas
字号:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,Unit7;
type
TForm2 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Label3: TLabel;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
ComboBox1: TComboBox;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
var
search:string;
begin
search:=trim(edit1.Text);
datamodule7.ADOQuery1.Close;
datamodule7.ADOQuery1.SQL.Clear;
datamodule7.ADOQuery1.SQL.Add('select 教师号 from teacher 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 teacher values(:教师号,:教师名,:系别)');
datamodule7.ADOQuery1.Parameters.ParamByName('教师号').Value := edit1.Text;
datamodule7.ADOQuery1.Parameters.ParamByName('教师名').Value := edit2.Text;
datamodule7.ADOQuery1.Parameters.ParamByName('系别').Value := combobox1.Text;
showmessage('请确认输入信息!');
datamodule7.adoquery1.Prepared;
datamodule7.ADOQuery1.ExecSQL;
showmessage('注册成功!') ;
datamodule7.ADOConnection1.CommitTrans;
except
showmessage('注册失败!') ;
datamodule7.ADOConnection1.RollbackTrans;
end;
end;
edit1.Text:='';
edit2.Text:='';
combobox1.Text:='';
form1.Show;
form2.Close;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
form1.show;
form2.Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -