📄 unit6.pas
字号:
unit Unit6;
//宿舍信息
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Grids, DBGrids, DB;
type
Tfrm_ssxx = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
ComboBox4: TComboBox;
ComboBox5: TComboBox;
Edit1: TEdit;
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
Edit6: TEdit;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_ssxx: Tfrm_ssxx;
implementation
uses Unit13;
{$R *.dfm}
//-----------------------显示选择信息------------------//
procedure Tfrm_ssxx.FormCreate(Sender: TObject);
begin
with data1.ADO_public do
begin
close;
sql.Clear;
sql.Add('select * from 宿舍管理');
open;
end;
while Not Data1.ADO_public.Eof do
begin
ComboBox1.Items.Add(Data1.ADO_public.FieldByName('楼房号').Value);
ComboBox2.Items.Add(Data1.ADO_public.FieldByName('房间价格').Value);
combobox3.Items.Add(data1.ADO_public.fieldByName('入住人数').Value);
Data1.ADO_public.Next;
end;
end;
//---------------------------信息添加-------------------//
procedure Tfrm_ssxx.Button1Click(Sender: TObject);
begin
if Edit1.Text ='' then
begin
MessageBox(handle,'宿舍号不能为空!','警告',MB_OK+MB_ICONWARNING);
Edit1.SetFocus ;
exit;
end;
if combobox1.Text ='' then
begin
MessageBox(handle,'楼房号不能为空!','警告',MB_OK+MB_ICONWARNING);
combobox1.SetFocus ;
exit;
end;
if combobox3.Text ='' then
begin
MessageBox(handle,'应住人数不能为空!','警告',MB_OK+MB_ICONWARNING);
combobox3.SetFocus ;
exit;
end;
try
with data1.ADO_ssxx do
begin
close;
sql.Clear;
sql.Add('insert 宿舍信息 values (:a,:b,:c,:d,:e,:f,:g,:h)');
parameters.ParamByName('a').Value:=trim(combobox1.Text) + '-' +trim(edit1.Text);
parameters.ParamByName('b').Value:=trim(combobox3.Text);
parameters.ParamByName('c').Value:='';
parameters.ParamByName('d').Value:=trim(combobox5.Text);
parameters.ParamByName('e').Value:=trim(combobox2.Text);
parameters.ParamByName('f').Value:=trim(combobox4.Text);
parameters.ParamByName('g').Value:=trim(edit6.Text);
parameters.ParamByName('h').Value:=trim(memo1.Text);
execsql;
end;
application.MessageBox('添加成功','提示',64);
except
application.MessageBox('添加失败','提示',64);
end;
end;
//----------------------取消--------------------//
procedure Tfrm_ssxx.Button2Click(Sender: TObject);
begin
close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -