Delphi+SQL SERVER小型酒店管理信息系统 第11页
(3)程序主要代码:
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button1Click(Sender: TObject);//“确定”按钮事件
begin
query1.Close;
query1.sql.Clear;
query1.SQL.Add('select * from 用户表 where 用户名=:name and 密码=:pwd and 编号=:id');
query1.Params[0].AsString:=edit1.Text;
query1.Params[1].AsString:=edit2.Text;
query1.Params[2].AsString:=edit3.Text;
query1.Open;
if(query1.Params[0].AsString='')or(query1.Params[1].AsString='')or(query1.Params[2].AsString='') then
begin
showmessage('请输入完整的用户信息!');
edit3.SetFocus;
end
else
begin
if (query1.Params[0].AsString<>query1.FieldByName('用户名').AsString) or (query1.Params[1].AsString<>query1.FieldByName('密码').AsString) or
(query1.Params[2].AsString<>query1.FieldByName('编号').AsString) then
begin
ShowMessage('输入用户名错误,请输入正确的用户名!');
edit3.SetFocus;
end
else
begin
form2.show;
setPower;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
query1.Open;
end;
(3)程序主要代码
a) 当用户单击“添加”时,弹出添加信息表,代码如下:
procedure TForm3.BitBtn3Click(Sender: TObject);
begin
GroupBox3.Visible:=True;
DBEdit1.Enabled:=True;
DBEdit2.Enabled:=True;
DBEdit3.Enabled:=True;
DBEdit4.Enabled:=True;
DBEdit1.SetFocus;
DBGrid1.Enabled:=False;
Panel1.Enabled:=False;
end;
添加用户信息对话框中,当确认输入信息需要保存时,单击“保存”:
procedure TForm3.BitBtn1Click(Sender: TObject);
var
ccc:String;
begin
Try
If (Length(DBEdit1.Text) = 0) Or (Length(DBEdit2.Text) = 0) or (Length(DBEdit3.Text) = 0) Then //用户编号和姓名,密码不能为空
begin
ShowMessage('编号,用户名和密码不能为空');
End
else
begin
if RadioButton1.Checked=True then ccc:='A'
Else