酒店客房餐饮管理系统功能完善,能管理普通酒店的客房住宿和餐饮等服务。本系统采用DELPHI和SQL SERVER工具开发,分为前台和后台管理。前台与后台管理程序相对,均共用一个数据库。下面对该系统的部份功能和模块以及代码进行分析。
一.前台管理
该模块是整个程序数据的提供者,以及包括大部分的处理函数和实现功能。
单元文件名:u_data.pas,数据模块名:DM_main。
部分代码分析:
返回指表中某字段的最大值,返回值为整型。因此该函数只能应用字段为整型的表。
function TDM_main.GetMaxId(aTable,aField:string):integer;
var
sSql:string;
begin
Result:=0;
sSql:='select max(%s) from %s';
with Q_getmax do
begin
SQL.Text:=Format(sSql,[aField,aTable]);
Open;
if not IsEmpty then
Result:=Fields[0].AsInteger+1;
Close;
end;
end;
接下来这个函数也是返回最大值,但是其为一个订单的最大编号为字符型。
function TDM_main.GetMaxOrderId:string;
var
id:String;
count:Integer;
begin
with Q_count_order do
begin
Open;
count:=Fields[0].Value;
Close;
end;
id:='000'+IntToStr(count);
id:=Copy(id, length(id)-3, 4);
id:='F'+FormatDateTime('yymmdd',now)+id;
Result:=id;
end;
系统登陆函数:在进行系统的操作处理时,必须登陆。该函数对用户输入的用户名和密码数据库验证。其密码是进行加密的(加密模块稍后分析)
function TDM_main.Login(user, passwd:String):String;
var
Flag:Boolean;
begin
if Database.Connected=false then
Database.Connected:=True;
passwd:=Copy(passwd+passwd, 1, 10);//加密处理
passwd:=Encrypt(passwd, 111);
with Q_login do
begin
Close;
Params.ParamValues['ID']:=user;
Params.ParamValues['PASSWD']:=passwd;
Open;//在用户请中查询该用户和密码是否存在
Flag:=( not IsEmpty);
if Flag then
begin
Login:=FieldValues['NAME'];
IsPass:=Flag;
end
else
begin
Login:='';
Application.MessageBox('请重新输入!', '登录失败', MB_OK);
end;
Close;
end;
end;
系统登出:
procedure TDM_main.Logout;
begin
Database.Connected:=False;//断开数据库的连接
end;
单元文件名:crypt.pas。
简单的加密算法。
const
C1 = 52845;
C2 = 22719;
function Encrypt( S: String; Key: Word): String;
//S:加密的字符串;Key:密钥
var
I: Integer;
j: Integer;
begin
Result := S;
for I := 1 to Length(S) do
begin
Result[I] := char(byte(S[I]) xor (Key shr 8));
Key := (byte(Result[I]) + Key) * C1 + C2;
end;
s:=Result;
Result:='';
for i:=1 to length(s) do
begin
j:=Integer(s[i]);
Result:=Result + Char(65+(j div 26))+Char(65+(j mod 26));
end;
end;
系统的主界面,包括系统登陆。在没有进行登陆之前4个功能按钮为灰色。
第一个按钮为客房管理,其次是餐饮管理,再次是客户查询,最后是收费管理。
客房管理包括客房预定,入住,调整。其界面如下:
操作介绍:
预定:首先在证件编号文体框中输入相关的证件编号,按回车键,显示如下窗口:
输入完整后单击添加则返回上一个界面,相关的数据将自动填写。然后在右边选择相应的客房等级。在网格中将显示该等级的所有空闲房号。选择一个房间,再点击“新建”按钮,然后点击“添加”。客房预定完毕。
入住:在证件编号文体框中输入相关的证件编号,按回车键。如果该客户已经预定则自动显示信息,否则将弹出上面的窗口要求输入信息。
包括选菜、点菜、打单:
下面是其相代码说明:
procedure TF_foodorder.btnOkClick(Sender: TObject);
var
id:integer;
total:single;
begin
if sid='' then
begin
B_neworderClick(nil);
end;
//订单明细
id:=DM_main.GetMaxId('order_detail','id');
with Q_foodetail do
begin
Append;
Fields[0].AsInteger:=id;
Fields[1].AsString:=sid;
Fields[2].AsString:=dbtext1.Caption;
Fields[3].AsString:=edtNum.Text;
Fields[4].AsString:=dbtext4.Caption;
Post;
DisableControls;
Close;
Open;
EnableControls;
end;
//更新总订单的总金额
with DM_main.T_foodorder do
begin
Edit;
total:=DM_main.GetSumPrice(sid);
Fields[3].AsFloat:=total;
Post;
end;
end;
//撤销选择的一项菜目
procedure TF_foodorder.btnCancelClick(Sender: TObject);
var
total:Single;
begin
with Q_foodetail do
begin
if IsEmpty then
Exit;
if not Active then
begin
ParamByName('sid').Value:=sid;
Open;
end;
Delete;
end;
total:=DM_main.GetSumPrice(sid);
with DM_main.T_foodorder do
begin
if not Active then Open;
Locate('id',sid,[]);
Edit;
Fields[3].AsFloat:=total;
Post;
end;
end;
procedure TF_foodorder.B_neworderClick(Sender: TObject);
begin
//新建总订单
sid:=DM_main.GetMaxOrderId;
with DM_main.T_foodorder do
begin
Open;
Append;
Fields[0].AsString:=sid;
Fields[1].AsString:=DateTimeToStr(Now);
Fields[2].AsString:=Trim(edtName.Text);
Post;
end;
with Q_foodetail do
begin
Close;
ParamByName('sid').Value:=sid;
Prepare;
Open;
end;
end;
打单:票据示例如下。
二.后台管理
该模块是整个程序数据的提供者,以及包括大部分的处理函数和实现功能。
单元文件名:u_data.pas,数据模块名:DM_main。
部分代码分析:
设置前台操作员的密码:
procedure TDM_main.SetOperatorPassword(password:String);
begin
password:=Copy(password+password, 1, 10);
password:=Encrypt(password, 111);//加密单元
with T_operator do
begin
Edit;
FieldValues['PASSWD']:=password;
end;
end;
根据客房ID筛选客房:
procedure TDM_main.SetModifyFilter(RoomID:String);
begin
with T_room_modify do
begin
Close;
if length(RoomID)>0 then
begin
Filter:='ID='''+RoomID+'''';
Filtered:=True;
end
else
Filtered:=False;
Open;
end;
end;
获得客房级别:
procedure TDM_main.GetRoomLevel(RoomLevel:TStrings);
begin
RoomLevel.Clear;
RoomLevel.Add('全部级别');
with Q_room_level do
begin
Open;
First;
while not Eof do
begin
RoomLevel.Add(FieldValues['DESCRIPT']);
Next;
end;
Close;
end;
end;
客房统计图实现函数:
//StarDate:开始日期;EndDate:结束日期;
procedure TDM_main.GetRoomStat(StartDate,EndDate:TDate;
TimeStep, StatType:Boolean;RoomLevel:Integer;
BarSeries:TBarSeries);
var
StatResult:integer;
MidDate:TDate;
StatLabel:String;
begin
BarSeries.Clear;
while StartDate<EndDate do
begin
MidDate:=GetNextDate(StartDate, TimeStep);
if StatType then
StatResult:=SumTurnover(StartDate, MidDate)
else
StatResult:=SumUsedRoom(StartDate, MidDate, RoomLevel);
if TimeStep then
StatLabel:=FormatDateTime('dd', StartDate)+'日'
else
StatLabel:=FormatDateTime('mm', StartDate)+'月';
BarSeries.AddY(StatResult,StatLabel);
StartDate:=MidDate;
end;
end;
换算下个月(日)日期:
function TDM_main.GetNextDate(StartDate:TDate;TimeStep:Boolean):TDate;
var
TimeYear,TimeMonth:String;
begin
if TimeStep then
Result:=StartDate+1
else
begin
TimeYear:=FormatDateTime('yyyy', StartDate);
TimeMonth:=FormatDateTime('mm', StartDate);
if TimeMonth='12' then
begin
TimeYear:=IntToStr(StrToInt(TimeYear)+1);
TimeMonth:='01';
end
else
TimeMonth:=IntToStr(StrToInt(TimeMonth)+1);
Result:=StrToDate(TimeYear+'-'+TimeMonth+'-01');
end;
end;
该系统登陆将连接数据库的管理员用户表进行验证:
procedure TF_login.b_loginClick(Sender: TObject);
var
sSql:string;
begin
if (Trim(i_admin.Text)='')or(i_passwd.Text='') then
begin
MessageDlg('请输入管理员帐号和密码!', mtWarning, [mbOK, mbHelp], 6);
i_admin.SetFocus;
Exit;
end;
sSql:='select * from admin_user where name=''%s'' and passwd=''%s''';
with DM_main.Q_admin do
begin
SQL.Text:=Format(sSql,[Trim(i_admin.Text),i_passwd.Text]);
Open;
if IsEmpty then
begin
MessageDlg('连接错误!请确认管理员帐号和密码!', mtWarning, [mbOK, mbHelp], 6);
i_admin.SetFocus;
Exit;
end
else
begin
Close;
self.Close;
end;
end;
end;
登陆界面:
后台管理主窗口如下:
后台管理程序采用MDI风格窗体。
并采用事件管理机制ActionList管理所有功能模块的点击事件:
procedure TF_main.RoomAddExecute(Sender: TObject);
begin
Application.CreateForm(TF_add, F_add);
RoomAdd.Enabled:=False;
end;
procedure TF_main.RoomModifyExecute(Sender: TObject);
begin
Application.CreateForm(TF_modify, F_modify);
RoomModify.Enabled:=False;
end;
procedure TF_main.HelpAboutExecute(Sender: TObject);
begin
F_about.ShowModal;
end;
procedure TF_main.SystemExitExecute(Sender: TObject);
begin
Close;
end;
procedure TF_main.OtherOperatorExecute(Sender: TObject);
begin
Application.CreateForm(TF_operator, F_operator);
OtherOperator.Enabled:=False;
end;
procedure TF_main.OtherCodeExecute(Sender: TObject);
begin
Application.CreateForm(TF_code, F_code);
OtherCode.Enabled:=False;
end;
procedure TF_main.RoomStatExecute(Sender: TObject);
begin
Application.CreateForm(TF_stat, F_stat);
RoomStat.Enabled:=False;
end;
后台数据管理包括:客房管理、餐饮管理、操作员管理,基础数据维护等。
该统计表能统计某个时间段的所有客房的营业额和使用频率,通过生成统计表以支持上层决策。如下图:
(其实现代码以上有介绍)
Copyright © 2019- baoaiwan.cn 版权所有 赣ICP备2024042794号-3
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务