📄 unit5.pas
字号:
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm5 = class(TForm)
edtStuNo: TEdit;
edtStuName: TEdit;
edtStuClass: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
function StuExistsCheck(strStuNO: String): Boolean;
public
{ Public declarations }
end;
var
Form5: TForm5;
implementation
uses Unit2, ADODB, DB;
{$R *.dfm}
procedure TForm5.Button2Click(Sender: TObject);
begin
ModalResult := mrCancel;
end;
function TForm5.StuExistsCheck(strStuNO: String): Boolean;
begin
with DM.qryTmp do
begin
if Active then Active := False;
SQL.Text := 'Select * From Students Where StuNO=' + QuotedStr(Trim(strStuNO));
Open;
if RecordCount = 0 then
Result := False
else
Result := True;
end;
end;
procedure TForm5.Button1Click(Sender: TObject);
var
StrCmd : String;
begin
if StuExistsCheck(Trim(edtStuNo.Text)) then
begin
Application.MessageBox('','',MB_OK);
ModalResult := mrCancel;
end
else begin
with DM.qryTmp do
begin
if Active then Active := False;
StrCmd := 'Insert into Students(StuNO, StuName, StuClass) Values('
+ QuotedStr(Trim(edtStuNo.Text)) + ','
+ QuotedStr(Trim(edtStuName.Text)) + ','
+ QuotedStr(Trim(edtStuClass.Text))
+ ')';
SQL.Text := StrCmd;
if ExecSQL=1 then
ModalResult := mrOk
else
ModalResult := mrCancel;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -