📄 unit2.pas
字号:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, StdCtrls, ExtCtrls, Mask;
type
TForm_floorconfig1 = class(TForm)
Query1: TQuery;
Panel1: TPanel;
Edit_floorNum: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
But_submit1: TButton;
But_next1: TButton;
Label4: TLabel;
Edit_floorcount: TEdit;
Edit_roomcount: TEdit;
Button1: TButton;
procedure But_submit1Click(Sender: TObject);
procedure But_next1Click(Sender: TObject);
procedure Edit_floorcountKeyPress(Sender: TObject; var Key: Char);
procedure Edit_roomcountKeyPress(Sender: TObject; var Key: Char);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form_floorconfig1: TForm_floorconfig1;
implementation
uses Unit3;
{$R *.dfm}
procedure TForm_floorconfig1.But_submit1Click(Sender: TObject);
var floorcount,roomcount :integer;
f,r :integer;
begin
///在个Edit都不能为空
if Edit_floorNum.Text='' then
begin
showmessage('楼房号不能为空!');
Edit_floorNum.SetFocus;
end
else
if Edit_floorcount.Text='' then
begin
showmessage('楼层数不能为空!');
Edit_floorcount.SetFocus;
end
else
if Edit_roomcount.Text='' then
begin
showmessage('每层房间数不能为空!');
Edit_roomcount.SetFocus;
end
else
begin
floorcount:=strtoint(Form_floorconfig1.Edit_floorcount.Text);
roomcount:=strtoint(Form_floorconfig1.Edit_roomcount.Text);
for f:=1 to floorcount do
with Form_floorconfig1.Query1 do
begin
for r:=1 to roomcount do
begin
Close;
SQL.Clear;
SQL.Add('insert into room(Num_room) values(:x1)');
if r<10 then
parambyname('x1').asstring:=Edit_floorNum.Text+inttostr(f)+'0'+inttostr(r)
else
parambyname('x1').asstring:=Edit_floorNum.Text+inttostr(f)+inttostr(r);
ExecSQL;
end;
end;
end;
end;
procedure TForm_floorconfig1.But_next1Click(Sender: TObject);
begin
///在个Edit都不能为空
if Edit_floorNum.Text='' then
begin
showmessage('楼房号不能为空!');
Edit_floorNum.SetFocus;
end
else
if Edit_floorcount.Text='' then
begin
showmessage('楼层数不能为空!');
Edit_floorcount.SetFocus;
end
else
if Edit_roomcount.Text='' then
begin
showmessage('每层房间数不能为空!');
Edit_roomcount.SetFocus;
end
else
begin
//application.CreateForm(TForm_floorconfig2,Form_floorconfig2);
Form_floorconfig2.Show;
//Form_floorconfig2.Free;
Form_floorconfig1.Hide;
end;
end;
procedure TForm_floorconfig1.Edit_floorcountKeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in ['0'..'9',#13,#8]) then
key:=#0;
end;
procedure TForm_floorconfig1.Edit_roomcountKeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in ['0'..'9',#13,#8]) then
key:=#0;
end;
procedure TForm_floorconfig1.Button1Click(Sender: TObject);
begin
Form_floorconfig1.Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -