【正文】
[39。ID39。]:=user。 [39。PASSWD39。]:=passwd。 Open。 //在用戶請中查詢該用戶和密碼是否存在 Flag:=( not IsEmpty)。 if Flag then begin Login:=FieldValues[39。NAME39。]。 IsPass:=Flag。 end else begin Login:=39。39。 (39。請重新輸入! 39。, 39。登錄失敗 39。, MB_OK)。 end。 Close。 end。 end。 系統(tǒng)登出: procedure 。 begin :=False。 //斷開數(shù)據(jù)庫的連接 end。 17. 加密模塊: 單元文件名: 。 簡單的加密算法。 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:=39。39。 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。 18. 主模塊 系統(tǒng)的主界面,包括系統(tǒng)登陸。在沒有進行登陸之前 4個功能按鈕為灰色。 第一個按鈕為客房管理,其次是餐飲管理,再次是客戶查詢,最后是收費管理。 19. 客房管理 模塊 客房管理包括客房預(yù)定,入住,調(diào)整。其界面如下: 操作介紹: 預(yù)定:首先在證件編號文體框中輸入相關(guān)的證件編號,按回車鍵,顯示如下窗口: 輸入完整后單擊添加則返回上一個界面,相關(guān)的數(shù)據(jù)將自動填寫。然后在右邊選擇相應(yīng)的客房等級。在網(wǎng)格中將顯示該等級的所有空閑房號。選擇一個房間,再點擊“新建”按鈕,然后點擊“添加”??头款A(yù)定完畢。 入住:在證件編號文體框中輸入相關(guān)的證件編號,按回車鍵。如果該客戶已經(jīng)預(yù)定則自動顯示信息,否則將彈出上面的窗口要求輸入信息。 20. 餐飲管理 包括選菜、點菜、打單: 下面是其相代碼說明: procedure (Sender: TObject)。 var id:integer。 total:single。 begin if sid=39。39。 then begin B_neworderClick(nil)。 end。 //訂單明細 id:=(39。order_detail39。,39。id39。)。 with Q_foodetail do begin Append。 Fields[0].AsInteger:=id。 Fields[1].AsString:=sid。 Fields[2].AsString:=。 Fields[3].AsString:=。 Fields[4].AsString:=。 Post。 DisableControls。 Close。 Open。 EnableControls。 end。 //更新總訂單的總金額 with do begin Edit。 total:=(sid)。 Fields[3].AsFloat:=total。 Post。 end。 end。 //撤銷選擇的一項菜目 procedure (Sender: TObject)。 var total:Single。 begin with Q_foodetail do begin if IsEmpty then Exit。 if not Active then begin ParamByName(39。sid39。).Value:=sid。 Open。 end。 Delete。 end。 total:=(sid)。 with do begin if not Active then Open。 Locate(39。id39。,sid,[])。 Edit。 Fields[3].AsFloat:=total。 Post。 end。 end。 procedure (Sender: TObject)。 begin //新建總訂單 sid:=。 with do begin Open。 Append。 Fields[0].AsString:=sid。 Fields[1].AsString:=DateTimeToStr(Now)。 Fields[2].AsString:=Trim()。 Post。 end。 with Q_foodetail do begin Close。 ParamByName(39。sid39。).Value:=sid。 Prepare。 Open。 end。 end。 打單:票據(jù)示例如下。 二.后臺管理 13. 數(shù)據(jù)模塊 該模塊是整個程序數(shù)據(jù)的提供者,以及包括大部分的處理函數(shù)和實現(xiàn)功能。 單元文件名: ,數(shù)據(jù)模塊名: DM_main。 部分代碼分析: 設(shè)置前臺操作員的密碼: procedure (password:String)。 begin password:=Copy(password+password, 1, 10)。 password:=Encrypt(password, 111)。 //加密單元 with T_operator do begin Edit。 FieldValues[39。PASSWD39。]:=password。 end。 end。 根據(jù)客房 ID 篩選客房: procedure (RoomID:String)。 begin with T_room_modify do begin Close。 if length(RoomID)0 then begin Filter:=39。ID=39。39。39。+RoomID+39。39。39。39。 Filtered:=True。 end else Filtered:=False。 Open。 end。 end。 獲得客房級別: procedure (RoomLevel:TStrings)。 begin 。 (39。全部級別 39。)。 with Q_room_level do begin Open。 First。 while not Eof do begin (FieldValues[39。DESCRIPT39。])。 Next。 end。 Close。 end。 end。 客房統(tǒng)計圖實現(xiàn)函數(shù): //StarDate: 開始日期; EndDate:結(jié)束日期; procedure (StartDate,EndDate:TDate。 TimeStep, StatType:Boolean。RoomLevel:Integer。 BarSeries:TBarSeries)。 var StatResult:integer。 MidDate:TDate。 StatLabel:String。 begin 。 while StartDateEndDate do begin MidDate:=GetNextDate(StartDate, TimeStep)。 if StatType then StatResult:=SumTurnover(StartDate, MidDate) else StatResult:=SumUsedRoom(StartDate, MidDate, RoomLevel)。 if TimeStep then StatLabel:=FormatDateTime(39。dd39。, StartDate)+39。日 39。 else StatLabel:=FormatDateTime(39。mm39。, StartDate)+39。月 39。 (StatResult,StatLabel)。 StartDate:=MidDate。 end。 end。 換算下個月(日)日期: function (StartDate:TDate。TimeStep:Boolean):TDate。 var TimeYear,TimeMonth:String。 begin if TimeStep then Result:=StartDate+1 else begin TimeYear:=FormatDateTime(39。yyyy39。, StartDate)。 TimeMonth:=FormatDateTime(39。mm39。, StartDate)。 if TimeMonth=39。1239。 then begin TimeYear:=IntToStr(StrToInt(TimeYear)+1)。 TimeMonth:=39。0139。 end else TimeMonth:=IntToStr(StrToInt(TimeMonth)+1)。 Result:=StrToDate(TimeYear+39。39。+TimeMonth+39。0139。)。 end。 end。 14. 系統(tǒng)登陸模塊 該系統(tǒng)登陸將連接數(shù)據(jù)庫的管理員用戶表進行驗證: procedure (Sender: TObject)。 var sSql:string。 begin if (Trim()=39。39。)or(=39。39。) then begin MessageDlg(39。請輸入管理員帳號和密碼! 39。, mtWarning, [mbOK, mbHelp], 6)。 。 Exit。 end。 sSql:=39。select * from admin_user where name=39。39。%s39。39。 and passwd=39。39。%s39。39。39。 with do begin :=Format(sSql,[Trim(),])。 Open。 if IsEmpty then begin MessageDlg(39。連接錯誤!請確認管理員帳號和密 碼! 39。, mtWarning, [mbOK, mbHelp], 6)。 。 Exit。 end else begin Close。 。 end。 end。 end。 登陸界面: 15. 主控程序 后臺管理主窗口如下: 后臺管理程序采用 MDI風格窗體。 并采用事件管理機制 ActionList管理所有功能模塊的點擊事件: procedure (Sender: TObject)。 begin (TF_add, F_add)。 :=False。 end。 procedure (Sender: TObject)。 begin (TF_modify, F_modify)。 :=False。 end。 procedure (Sender: TObject)。 begin 。 end。 procedure (Sender: TObject)。 begin Close。 end。 procedu