酒店客房管理系统设计说明书

课程设计(论文)书

题    目  酒店客房管理系统

学生姓名   

学院名称    管理学院    

        11信管1  

         

指导教师           

第一章  系统分析

一、需求分析

某某酒店是一家综合的大型酒店,设施齐全,该酒店设有餐饮卖场,KTV包房,各种娱乐设施,桑拿洗浴和各种标准客房。随着信息技术的发展和人们对酒店的要求越来越高,该酒店已明显觉得手工管理已不能适应当前酒店高速发展的需要。在意识到使用计算机的重要性后,决定首先在客房部采用酒店客房管理系统。

   二、系统目标

       面对酒店行业的高速发展和酒店行业信息化发展的过程中出现的各种情况,酒店客房管理系统在实施后,应能够达到以下目标:

ü  实现多点操作的信息共享,相互之间的信息传递准确、快捷、顺畅。

ü  服务管理信息化,课随时掌握客人住宿、客房状态、客人挂账等情况。

ü  系统界面友好本酒店客房管理系统面向的用户是酒店内工作人员,所以系统操作上要求简单、方便、快捷,便于用户使用。

ü  通过酒店客房管理系统的实施,可逐步提高酒店客房的管理水平,提升员工素质。

   三、可行性分析

1、开发背景  

   酒店是一个服务至上的行业,从客人的预定开始,到入住登记直至最后退房结账,每一 步骤都要保持一致性的服务水准,错失一步, 会令其辛苦经营的形象功亏一篑。 要成为一间成功的酒店,就必须作到宾至如归,面对酒店业内激烈的竞争形势,各酒店均在努力拓展其服务领域的广度和深度。虽然计算机并不是酒店走向成功的关键元素,但它可以帮助那些真正影响成败的要素发挥更大的效用。因此,采用全新的计算机网络和管理系统,将成为提高酒店的管理效率,改善服务水准的重要手段之一。    

2、经济可行性

   使用本酒店客房管理系统可提高酒店客房管理水平,把大量繁琐的工作简单化,能够有效地

节省人力物力,并能够准确地进行统计和计算,避免人工统计或计算所带来的差错,保证酒店客房管理高效而有序地进行。

    3、技术可行性

       本系统前台采用Microsoft公司的Visual Basic 6.0作为主要的开发工具;数据库选择Microsoft Access数据库系统,该系统在安全性、准确性和运行速度方面都占有一定的优势。

  第二章  系统设计

 一、系统功能图

    根据该酒店的客房具体情况,系统主要功能介绍如下:

ü  住宿管理:住宿登记,追加押金,调房登记,退房结账。

ü  客房管理:客房查询。

ü  查询统计:住宿查询。

为了清晰、全面地介绍酒店客房管理系统的功能以及各个模块间的从属关系,下面以结构图的形式给出系统功能,如图所示。

酒店客房管理系统设计说明书

二、业务流程图

为了使读者更清晰地了解系统的业务流程,下面给出本系统的业务流程:

酒店客房管理系统设计说明书 

三、数据流程图

为了方便用户更加清晰地了解数据流向,在下面画了第一层的数据流程图:

 

四、数据字典

数据流是数据结构在系统内传输的路径。对数据流的描述通常包括以下内容:数据流名、说明、数据流来源、数据流去向、组成等。

(1)数据流的描述

数据流编号:F1

数据流名称:房间信息表

      简述:供用户查询房间信息,选择房间类型

数据流来源:客房查询模块

数据流去向:顾客

数据流组成:房间号,房间类型,价格,房态,标志,备注,配置,使用设置,营业日期。

数据流编号:F2

数据流名称: 发票

      简述:收费凭证

数据流来源:住宿登记模块

数据流去向:顾客

数据流组成:房间类型,房间价格,发票编号,日期

  数据流编号:F3

数据流名称:入住登记表

      简述:登记订房客人的信息及房间信息

数据流来源:住宿登记模块

数据流去向:顾客,后台服务部(即后勤)

数据流组成:凭证号码,姓名,证件名称,证件号码,纤细地址,住宿事由,房间号,客房类型,客房价格,住宿日期,住宿时间,住宿天数,宿费,折扣,应收宿费,预收金额,提醒日期,退宿日期,备注,标志,摘要。

数据流编号:F4

数据流名称:房卡

      简述:作为订房、退房凭证,开房门

数据流来源:住宿登记模块

数据流去向:顾客

数据流组成:房间号

              

数据流编号:F5

数据流名称: 退房信息表

      简述:客人选择的服务的信息

数据流来源:顾客

数据流去向:退房结账模块

数据流组成:凭证号码,姓名,证件名称,证件号码,纤细地址,工作单位,房间号,客房类型,客房价格,住宿日期,住宿时间,住宿天数,宿费,折扣或招待,折扣,应收宿费,杂费,电话费,会议费,存车费,赔偿费,金额总计,预收宿费,退还宿费,退房日期,退房时间,备注    

2)处理逻辑的描述

处理逻辑编号:P1

处理逻辑名称:选择房间

        简述:顾客更具需要选择房间类型

输入的数据流:房间信息表

处理描述:选择需要的房间类型

输出的数据流:房卡、发票

处理逻辑编号:P2

处理逻辑名称:更新住房信息

        简述:有顾客后,要及时更新住房信息

输入的数据流:住宿登记表

处理描述:对住房信息数据进行更新操作

输出的数据流: 新的住房信息

                    

处理逻辑编号:P3

处理逻辑名称:对该顾客进行相应服务

        简述:顾客选择服务,对顾客进行服务

输入的数据流:服务菜单

处理描述:按照顾客所选服务提供服务

输出的数据流: 服务清单

处理逻辑编号:P4

处理逻辑名称:退房

        简述:顾客离开时办理退房结算手续

输入的数据流:入住登记表

处理描述:办理退房结算手续

输出的数据流:退房信息

第三章   数据库设计

一、数据库概要说明

由于酒店客房管理系统中的数据信息量不大,对数据库的要求也不高,所以本系统采用Access 2003数据库。如下图所示:

二、数据库概念设计

   在酒店客房管理系统中,客房是一个重要的实体,客房信息实体包含了客房的基本配置信息以及当前房间状态,其实体E-R图如下:

 

                          登记信息实体E-R图

其余几个数据库表的E-R就不画了,与上图是类似的,各个表内部属性在数据字典中已说明了。

三、数据库逻辑设计

  根据设计好的实体E-R图以及数据字典的描述在数据库中创建数据表,系统数据库中部分(这里只列出登记表和客房信息表)数据表的结构如下:

ü  tb_djb(登记表)

登记表用来保存客人住宿时的住宿登记信息,其结构如下表:

                                tb_djb表的结构

ü  tb_kf(客房信息表)用来保存客房的基础信息,其结构如下:

tb_kf表的结构

第四章  系统实施

一、公共模块设计

在本系统中新建一个Module模块,主要用于共享数据库连接。公共模块代码如下:

Public adocon As New ADODB.Connection

Public adoRs As New ADODB.Recordset

Public Sub Main()

    adocon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

End Sub

Public Function ESQL(ByVal sql As String) As ADODB.Recordset

    Dim cnn As ADODB.Connection

    Dim rs As ADODB.Recordse

    Set cnn = New ADODB.Connection

    cnn.Open StrCnn

    Set rs = New ADODB.Recordset

    rs.Open Trim(sql), cnn, adOpenKeyset, adLockOptimistic

    Set ESQL = rs

End Function

Public Function StrCnn()

    StrCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

End Function

二、主窗体设计

(一)主窗体概述:在主窗体中通过选择菜单命令或单击工具栏中的额按钮,可调用相应程序窗体或进行相应操作,主窗体界面如下图:

(二)主窗体实现过程

1.新建一个标准工程,命名为酒店客房管理系统,在该工程中会自动创建一个新窗体,将该窗体命名为main。Caption属性设置为“酒店客房管理系统”。

2.利用菜单编辑器可以创建相应的菜单。

3.在窗体中添加Toolbar控件(作为主窗体的工具栏)、ImageList控件(用于存放主窗体的界面图片和工具栏的图标)。

4.单击主窗体中的菜单项或者工具栏中图标,通过菜单命令实现调出各个窗体,在个子菜单的Click事件下实现相应操作,代码如下:

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)

    Select Case Button.Key

    Case "DJ"  zsdj_Click   

    Case "TF"  tf_Click   

    Case "CX"  zscx_Click  

End Select  End Sub

Private Sub zsdj_Click()  main_kfdj.Show   Main.Enabled = False  End Sub

Private Sub zjyj_Click()  Load main_zjyj   main_zjyj.Show  Main.Enabled = False   End Sub

Private Sub tf_Click()    main_tf.Show  Main.Enabled = False  End Sub

Private Sub zscx_Click()   Load main_zscx   main_zscx.Show  Main.Enabled = False  End Sub

Private Sub tfcx_Click()     Load main_tfcx  main_tfcx.Show  Main.Enabled = False  End Sub

Private Sub Adodc1_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

Load main_czysz

 main_czysz.Show

End Sub

Private Sub Adodc2_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

Load main_czysz  main_czysz.Show   End Sub

Private Sub kfcx_Click()   main_kfcx.Show   Main.Enabled = False  End Sub

Private Sub tfdj_Click()  main_tfdj.Show  Main.Enabled = False  End Sub

三、住宿登记模块设计(相当于增加模块)

(一)住宿登记模块概述:在住宿登记模块中能够自动生成住宿登记凭证号码,提供空闲房间供用户选择,实现客人住宿登记,收取客人预交宿费,自动计算折前宿费、实际宿费等等。住宿登记界面如下图:

(二)住宿登记模块实现过程

1、在该系统中添加一个新窗体并命名为main_kfdj,Caption属性设置为“住宿登记”。

2、在窗体中添加两个Adodc控件(用于数据连接)。

3、在窗体中添加TextBox控件数组(主要用于显示客人入住登记信息):添加5个TextBox控件,bh用于显示凭证号码,其他4个文本框用于程序运行是暂存数据。

4、在窗体中添加6个DTPicker控件(分别用来显示住宿日期和时间、退宿日期和时间、提醒日期和时间)

5、在窗体中添加3个ComboBox控件(分别显示证件、付款方式和房间列表)。

6、代码设计如下:

Dim i As Integer  

Dim Fdate As String, Ftime As String

Private Sub Combo3_Click()

  Adodc1.RecordSource = "select * from tb_kf where 房间号='" & Combo3.Text & "'and 房态 = '空房'"

    Adodc1.Refresh

    Adodc2.RecordSource = "select * from tb_djb where 房间号='" & Combo3.Text & "'and 标志='1'"

    Adodc2.Refresh

    If Adodc1.Recordset.RecordCount > 0 Then

        If Adodc2.Recordset.RecordCount = 0 Then  

            ZSDJ(4).Text = Adodc1.Recordset.Fields("房间类型")

            ZSDJ(5).Text = Adodc1.Recordset.Fields("价格") 

        End If

    End If

End Sub

Private Sub Form_Load()

Fdate = Format(Date, "YYYY-MM-DD")

Ftime = Format(Time, "HH:MM:SS")

    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

    Adodc1.RecordSource = "select * from tb_kf "

    Adodc1.Refresh

    Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

    Adodc2.RecordSource = "select * from tb_djb"

    Adodc2.Refresh

    Adodc3.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

    Adodc3.RecordSource = "select * from tb_kf where 房态 = '空房'"

    Adodc3.Refresh

    If Adodc3.Recordset.RecordCount > 0 Then

        For i = 1 To Adodc3.Recordset.RecordCount

            Combo3.AddItem Adodc3.Recordset.Fields("房间号").Value

            Adodc3.Recordset.MoveNext

        Next i

    End If

    Combo3.Enabled = False

    Comok.Enabled = False

End Sub

Private Sub Form_Unload(Cancel As Integer)

    Main.Enabled = True

End Sub

Private Sub Combo2_Click()

    If Combo2.Text = "折扣" Then

        ZSDJ(8).Enabled = True    

        ZSDJ(8).SetFocus   

    End If

    If Combo2.Text = "招待" Then

        ZSDJ(8).Enabled = False   

        ZSDJ(8).Text = 0     

    End If

End Sub

Private Sub ZSDJ_Change(Index As Integer)

    Select Case Index

    Case 6

        ZSDJ(7).Text = Format(Val(ZSDJ(6).Text) * Val(ZSDJ(5).Text), "0.00")     '

        ZSDJ(9).Text = ZSDJ(7).Text  

        ZSDJ(8).Text = 100

        DTP3.Value = DTP1.Value + Val(ZSDJ(6).Text)         

    Case 8   ZSDJ(9).Text = Format(Val(ZSDJ(7).Text) * Val(ZSDJ(8).Text) / 100, "0.00")  

    Case 10

        If ZSDJ(10).Text <> "" Then

            ZSDJ(10).Text = Val(ZSDJ(10).Text)   

            DTP2.Value = DTP1.Value + Int(Val(ZSDJ(10).Text) / Val(ZSDJ(5).Text))  

            If (Val(ZSDJ(10).Text) - Int(Val(ZSDJ(10).Text) / Val(ZSDJ(5).Text))) > 0.5 * Val(ZSDJ(5).Text) Then

                tim2.Value = #6:00:00 PM#  

            Else

                tim2.Value = #12:00:00 AM#

            End If

        End If

    End Select

End Sub

Private Sub comdj_Click()

      '查询空闲房间信息

    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

    Adodc1.RecordSource = "select * from tb_kf where 房态='空房'"  '查询客房数据表

    Adodc1.Refresh

    Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

    Adodc2.RecordSource = "select * from tb_djb order by 凭证号码"  '按凭证号码排序数据

    Adodc2.Refresh

    If Not Adodc2.Recordset.EOF Then Adodc2.Recordset.MoveLast   '移动记录集到最后一条记录

    If lsph.Text = "" Then bh.Text = Fdate & "d" & Format(1, "###000")    '当lsph值为空为凭证号码文本框赋值

    If lsph.Text <> "" Then    '当lsph值不空时

        y1.Text = Month(Fdate)  '把当前月份赋给y1

        y2.Text = Month(Left(lsph.Text, 10))  '把lsph中的月份赋给y2

        If y1.Text = y2.Text Then    '如果y1文本框中内容与y2相同

            bh.Text = Fdate & "d" & Format(Val(Right(lsph.Text, 3)) + 1, "###000")   '为凭证号码文本框赋值

            Text1.Text = Val(Right(lsph.Text, 3)) + 1  'text1中存储lsph文本框中后三位数

        End If

        If y1.Text <> y2.Text Then  '如果y1文本框中内容与y2不同

            bh.Text = Fdate & "d" & Format(1, "###000")  '为凭证号码文本框赋值

        End If

    End If

    '清空数据

    For i = 0 To 6

        ZSDJ(i).Text = ""

        ZSDJ(i).Enabled = True

    Next i

  

    ZSDJ(8).Text = "": ZSDJ(10).Text = "": ZSDJ(11).Text = "": Combo3.Text = ""

    Comok.Enabled = True: Comdj.Enabled = False: Comprint.Enabled = False: ZSDJ(8).Enabled = True

  ZSDJ(10).Enabled = True: ZSDJ(11).Enabled = True: Combo3.Enabled = True: Combo1.Enabled = True

    Combo2.Enabled = True: ZSDJ(0).SetFocus   

     Adodc3.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

    Adodc3.RecordSource = "select * from tb_kf where 房态 = '空房'"

    Adodc3.Refresh

    Combo3.Clear

    If Adodc3.Recordset.RecordCount > 0 Then

        For i = 1 To Adodc3.Recordset.RecordCount

            Combo3.AddItem Adodc3.Recordset.Fields("房间号").Value

            Adodc3.Recordset.MoveNext

        Next i

    End If

End Sub

Private Sub comok_Click()

    If ZSDJ(0) = "" Or Combo3 = "" Then

        MsgBox "请输入完整信息", , "系统提示"

    Else

        Adodc2.RecordSource = "select * from tb_djb where 房间号 = '" & Combo3.Text & "' and 标志 like '1'"

        Adodc2.Refresh

        If Adodc2.Recordset.RecordCount = 0 Then

            Adodc2.Recordset.AddNew

            If bh.Text <> "" Then Adodc2.Recordset.Fields("凭证号码") = bh.Text

            If ZSDJ(0).Text <> "" Then Adodc2.Recordset.Fields("姓名") = ZSDJ(0).Text

            If Combo1.Text <> "" Then Adodc2.Recordset.Fields("证件名称") = Combo1.Text

            If ZSDJ(1).Text <> "" Then Adodc2.Recordset.Fields("证件号码") = ZSDJ(1).Text

            If ZSDJ(2).Text <> "" Then Adodc2.Recordset.Fields("详细地址") = ZSDJ(2).Text

            If ZSDJ(3).Text <> "" Then Adodc2.Recordset.Fields("住宿事由") = ZSDJ(3).Text

            If Combo3.Text <> "" Then Adodc2.Recordset.Fields("房间号") = Val(Combo3.Text)

            If ZSDJ(4).Text <> "" Then Adodc2.Recordset.Fields("客房类型") = ZSDJ(4).Text

            If DTP1.Value <> "" Then Adodc2.Recordset.Fields("住宿日期") = DTP1.Value

            If tim1.Value <> "" Then Adodc2.Recordset.Fields("住宿时间") = tim1.Value

            If ZSDJ(5).Text <> "" Then Adodc2.Recordset.Fields("客房价格") = Val(ZSDJ(5).Text)

            If ZSDJ(6).Text <> "" Then Adodc2.Recordset.Fields("住宿天数") = ZSDJ(6).Text

            If ZSDJ(8).Text <> "" Then Adodc2.Recordset.Fields("折扣") = ZSDJ(8).Text

            If ZSDJ(7).Text <> "" Then Adodc2.Recordset.Fields("宿费") = ZSDJ(7).Text

            If Combo2.Text <> "" Then Adodc2.Recordset.Fields("结款方式") = Combo2.Text

            If ZSDJ(9).Text <> "" Then Adodc2.Recordset.Fields("应收宿费") = ZSDJ(9).Text

            If ZSDJ(10).Text <> "" Then Adodc2.Recordset.Fields("预收金额") = Val(ZSDJ(10).Text)

            If DTP2.Value <> "" Then Adodc2.Recordset.Fields("提醒日期") = DTP2.Value

            If tim2.Value <> "" Then Adodc2.Recordset.Fields("提醒时间") = tim2.Value

            If DTP3.Value <> "" Then Adodc2.Recordset.Fields("退宿日期") = DTP3.Value

            If tim3.Value <> "" Then Adodc2.Recordset.Fields("退宿时间") = tim3.Value

            If ZSDJ(11).Text <> "" Then Adodc2.Recordset.Fields("备注") = ZSDJ(11).Text

            Adodc2.Recordset.Fields("日期") = Fdate 

            Adodc2.Recordset.Fields("时间") = Ftime  

            Adodc2.Recordset.Fields("BZ") = Left(Fdate, 4) & Right(Left(Fdate, 7), 2) & Right(Fdate, 2) & Left(Ftime, 2) & Left(Right(Ftime, 5), 2)  

            Adodc2.Recordset.Fields("标志") = "1" 

            Adodc2.Recordset.Update

            Adodc2.Refresh

          adocon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

            adoRs.Open "select * from tb_djys", adocon, adOpenKeyset, adLockOptimistic   

            adoRs.AddNew

            If bh.Text <> "" Then adoRs.Fields("凭证号码") = bh.Text

            If ZSDJ(0).Text <> "" Then adoRs.Fields("姓名") = ZSDJ(0).Text

            If Combo1.Text <> "" Then adoRs.Fields("证件名称") = Combo1.Text

            If ZSDJ(1).Text <> "" Then adoRs.Fields("证件号码") = ZSDJ(1).Text

            If ZSDJ(2).Text <> "" Then adoRs.Fields("详细地址") = ZSDJ(2).Text

            If ZSDJ(3).Text <> "" Then adoRs.Fields("住宿事由") = ZSDJ(3).Text

            If ZSDJ(4).Text <> "" Then adoRs.Fields("客房类型") = ZSDJ(4).Text

            If Combo3.Text <> "" Then adoRs.Fields("房间号") = Val(Combo3.Text)

            If ZSDJ(5).Text <> "" Then adoRs.Fields("客房价格") = Val(ZSDJ(5).Text)

            If DTP1.Value <> "" Then adoRs.Fields("住宿日期") = DTP1.Value

            If tim1.Value <> "" Then adoRs.Fields("住宿时间") = tim1.Value

            If ZSDJ(6).Text <> "" Then adoRs.Fields("住宿天数") = ZSDJ(6).Text

            If Combo2.Text <> "" Then adoRs.Fields("结款方式") = Combo2.Text

            If ZSDJ(8).Text <> "" Then adoRs.Fields("折扣") = ZSDJ(8).Text

            If ZSDJ(7).Text <> "" Then adoRs.Fields("宿费") = ZSDJ(7).Text

            If ZSDJ(9).Text <> "" Then adoRs.Fields("应收宿费") = ZSDJ(9).Text

            If ZSDJ(10).Text <> "" Then adoRs.Fields("预收金额") = Val(ZSDJ(10).Text)

            If DTP2.Value <> "" Then adoRs.Fields("提醒日期") = DTP2.Value

            If tim2.Value <> "" Then adoRs.Fields("提醒时间") = tim2.Value

            If DTP3.Value <> "" Then adoRs.Fields("退宿日期") = DTP3.Value

            If tim3.Value <> "" Then adoRs.Fields("退宿时间") = tim3.Value

            If ZSDJ(11).Text <> "" Then adoRs.Fields("备注") = ZSDJ(11).Text

            adoRs.Fields("日期") = Fdate

            adoRs.Fields("时间") = Ftime

            adoRs.Fields("BZ") = Left(Fdate, 4) & Right(Left(Fdate, 7), 2) & Right(Fdate, 2) & Left(Ftime, 2) & Left(Right(Ftime, 5), 2)

            adoRs.Fields("标志") = "

            adoRs.Update

            adocon.Close

            Adodc1.RecordSource = "select * from tb_kf where 房间号 like '" + Combo3.Text + "'"

            If Combo3.Text <> "" Then Adodc1.Recordset.Fields("房态") = "入住"

            Adodc1.Recordset.Update

            For i = 0 To 6

                ZSDJ(i).Enabled = False

            Next i

            ZSDJ(8).Enabled = False: ZSDJ(10).Enabled = False: ZSDJ(11).Enabled = False

            Combo3.Enabled = False: Combo1.Enabled = False

        End If

        Comok.Enabled = False: Comprint.Enabled = True: Comdj.Enabled = True

        Comprint.SetFocus

    End If

End Sub

Private Sub comcancel_Click()         '取消操作

    For i = 0 To 11

        ZSDJ(i).Enabled = False

    Next i

    Comprint.Enabled = False: Comok.Enabled = False: Combo3.Enabled = False

    Combo1.Enabled = False: Combo2.Enabled = False: DTP2.Enabled = False: DTP3.Enabled = False

    tim2.Enabled = False: tim3.Enabled = False: Comdj.Enabled = True

End Sub

Private Sub comprint_Click()

    On Error GoTo 1  

    Dim X As Printer

    Printer.Height = 8000: Printer.Width = 8000   

    Printer.CurrentX = 1100: Printer.CurrentY = 300

    Printer.FontSize = 12                           

    Printer.Print "旺隆酒店客房 (住宿证) "          

    Dim A, B, C, d As Integer

A = 100: B = 500: C = 4800: d = 400 

    Printer.FontSize = 10   

    Printer.CurrentX = 100 + A

    Printer.CurrentY = B + 200  

    Printer.Print d & " " & t & "  NO." & bh.Text 

    B = B + d

    Printer.Line (A, B + 100)-(C, B + 100)

    Printer.CurrentX = 100 + A

    Printer.CurrentY = B + 200

    Printer.Print "姓名:" & ZSDJ(0).Text 

    B = B + d

    Printer.CurrentX = 100 + A

    Printer.CurrentY = B + 200

    Printer.Print "房间号:" & Combo3.Text  

    B = B + d

    Printer.CurrentX = 100 + A

    Printer.CurrentY = B + 200

Printer.Print "押金:" & Format(ZSDJ(10).Text, "0.00") 

    B = B + d

    Printer.CurrentX = 100 + A

    Printer.CurrentY = B + 200

Printer.Print Combo2.Text & ":" & ZSDJ(8).Text & "%"

    B = B + d

    Printer.CurrentX = 100 + A

    Printer.CurrentY = B + 200

    Printer.Print "补交日期:    " & Format(DTP2.Value, "YYYY-MM-DD") '

    B = B + d

    Printer.Line (A, B + 100)-(C, B + 100)

    Printer.CurrentX = 100 + A

    Printer.CurrentY = B + 200

Printer.Print "操作员: " & czy.Text & "         欢迎光临"

    Printer.EndDoc 

    Exit Sub

1       If Err.Number = 482 Then

        MsgBox "请连接打印机!", , "系统提示"

        Err.Clear

    End If

End Sub

Private Sub comend_Click()

    Unload Me

    Main.Enabled = True

End Sub

四、调房登记模块设计(相当于修改模块)

(三)调房登记模块概述:该模块主要是实现对客人房间进行调换的过程,“源房间号”下拉列表框是查询登记表中当前所有住宿客人的房间号码,在选择原房间号后,实现自动生成目标房间号。这里使用AddItem方法将房间号加入到Combo2目标房间号下拉列表框中。调房登记界面如下图:

(四)调房登记模块实现过程

1、在该系统中添加一个新窗体并命名为main_tfdj,Caption属性设置为“调房登记”。

2、在窗体中添加3个Adodc控件(用于数据连接)。

3、在窗体中添加3个ComboBox控件(分别用于显示证件类型、目标房间号和源房间号)。Combo1的List属性设置为“身份证”、“军管证”、“学生证”、“身份证”。

4、代码设计如下:

Private Sub Form_Load()

    '自动识别数据库路径

    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

    Adodc1.RecordSource = "select * from tb_djb"

    Adodc1.Refresh

    Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

    Adodc2.RecordSource = "select * from tb_kf"

    Adodc2.Refresh

    Adodc3.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

    Adodc3.RecordSource = "select * from tb_djys"

    Adodc3.Refresh

    End Sub

Private Sub Form_Unload(Cancel As Integer)

  Main.Enabled = True     End Sub

Private Sub Combo2_KeyDown(KeyCode As Integer, Shift As Integer)

    If KeyCode = vbKeyReturn Then Texbz.SetFocus    End Sub

Private Sub Combo3_Click()

Combo2.Clear

If Combo3.Text <> "" Then  

     Adodc1.RecordSource = "select * from tb_djb where 房间号='" + Combo3.Text + "'and 标志='1'"

        Adodc1.Refresh

        If Adodc1.Recordset.RecordCount <= 0 Then '

            MsgBox "请核准住宿房间和住宿人!", , "系统提示"

        Else

       If Adodc1.Recordset.Fields("客房类型") <> "" Then                                    Adodc2.RecordSource = "select * from tb_kf where 房间类型='" + Adodc1.Recordset.Fields("客房类型") + "' and 房态='空房'"                                                    

                Adodc2.Refresh                                  

                If Adodc2.Recordset.RecordCount > 0 Then              

                    For i = 1 To Adodc2.Recordset.RecordCount         

                        Combo2.AddItem Adodc2.Recordset.Fields("房间号").Value    

                        Adodc2.Recordset.MoveNext               

                    Next i

                End If

                 With Adodc1.Recordset

                    If .Fields("凭证号码") <> "" Then bh.Text = .Fields("凭证号码")

                   If .Fields("姓名") <> "" Then Texxmb.Text = .Fields("姓名")

                   If .Fields("证件名称") <> "" Then Combo1.Text = .Fields("证件名称") '

                   If .Fields("证件号码") <> "" Then Texsfz.Text = .Fields("证件号码")

                   If .Fields("客房价格") <> "" Then Texjg.Text = .Fields("客房价格")                    End With  

            End If

        End If

        Combo2.Enabled = True   

    Texbz.Enabled = True

    End If

End Sub

Private Sub Combo3_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = vbKeyReturn Then Combo2.SetFocus   

End Sub

Private Sub texbz_KeyDown(KeyCode As Integer, Shift As Integer)

 If KeyCode = vbKeyReturn Then Comok.SetFocus   

End Sub

Private Sub comdj_Click()  

    Frame1.Enabled = True: Frame2.Enabled = True: Combo3.Enabled = True

    Combo2.Enabled = True: Texjg.Enabled = True: Comok.Enabled = True

    Comcancel.Enabled = True: Comok.Enabled = True: Comdj.Enabled = False

Combo3.SetFocus   

End Sub

Private Sub comok_Click()   

    Dim bh As String     

    Adodc2.RecordSource = "select * from tb_kf where 房间号='" & Combo2.Text & "'and 房态='空房'"

Adodc2.Refresh     If Adodc2.Recordset.RecordCount > 0 Then '

        If Texbz = "" Then

            MsgBox "请输入备注信息",

            Texbz.SetFocus

        Else

            Adodc1.RecordSource = "select * from tb_djb where 房间号='" + Combo3.Text + "' and 标志='1'"             Adodc1.Refresh

            bh = Adodc1.Recordset.Fields("凭证号码")

            adocon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

            Set adoRs = adocon.Execute("update tb_djb set 房间号='" + Combo2.Text + "',备注='" + Texbz.Text + "',标志='1',摘要= '由源房' & '" + Combo3.Text + "' & '调到目标房' &'" + Combo2.Text + "' where 凭证号码='" + Adodc1.Recordset.Fields("凭证号码") + "'")

            Text1.Text = Adodc1.Recordset.Fields("凭证号码")

            adocon.Close

            Adodc3.RecordSource = "select * from tb_djys where 凭证号码='" + Adodc1.Recordset.Fields("凭证号码") + "'"

            Adodc3.Refresh

            If Adodc3.Recordset.EOF = False Then Adodc3.Recordset.MoveLast             If Adodc3.Recordset.BOF = False Then Adodc3.Recordset.MoveFirst

            If Adodc3.Recordset.RecordCount > 0 Then

                adocon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

                Set adoRs = adocon.Execute("update tb_djys set 房间号='" + Combo2.Text + "',备注='" + Texbz.Text + "',标志='1',摘要= '由源房' & '" + Combo3.Text + "' & '调到目标房' & '" + Combo2.Text + "' where 凭证号码='" + Text1.Text + "' "

                adocon.Close

            End If

             Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

            Adodc2.RecordSource = "select * from tb_kf where 房间号= '" & Combo2.Text & "'"

            Adodc2.Refresh

            Adodc2.Recordset.Fields("房态") = "入住"

            Adodc2.Recordset.Update

            Adodc2.RecordSource = "select * from tb_kf where 房间号= '" & Combo3.Text & "'"

            Adodc2.Refresh '刷新记录

            Adodc2.Recordset.Fields("房态") = "空房"

            Adodc2.Recordset.Update

            Adodc3.RecordSource = "select * from tb_kf where 房态='空房'"

            Adodc3.Refresh

            Texxmb.Enabled = False: Texsfz.Enabled = False: Combo2.Enabled = False

            Combo3.Enabled = False: Texbz.Enabled = False: Comok.Enabled = False

            Comcancel.Enabled = False: Comdj.Enabled = True

            '清空数据

            Combo2.Text = "": Combo3.Text = "": Texxmb.Text = ""

            Texsfz.Text = "": Texbz.Text = "": Texjg.Text = ""

            Comdj.SetFocus    

        End If

    Else

        MsgBox "请选择正确房间号,再保存!!!", , "系统提示" 

    End If

End Sub

Private Sub comcancel_Click()    

    Combo3.Enabled = True: Combo2.Enabled = True: Comdj.Enabled = True

    Comok.Enabled = False: Texbz.Enabled = True

    Combo2.Text = "": Combo3.Text = "": Texxmb.Text = ""

    Texsfz.Text = "": Texbz.Text = "": Texjg.Text = ""

End Sub

Private Sub comend_Click()

    Unload Me

    Main.Enabled = True  

End Sub

五、退宿结账模块设计(相当于删除模块)

(五)退宿登记模块概述:该模块能够实现退房客人基本信息的显示和输入,另外可以自动算账,实现快速结账,提高了服务质量。调房登记界面如下图:

(六)退宿登记模块实现过程

2、在该系统中添加一个新窗体并命名为main_tf,Caption属性设置为“退宿结账”。

3、在窗体中添加3个Adodc控件(用于数据连接)。

3、在窗体中添加4个ComboBox控件(分别用于显示凭证号码、证件类型、房间价格和附加费)。

4、代码设计如下:

Public Sub JS()     '定义计算住宿天数的函数

    If DTP2.Value > DTP1.Value Then

             If TIM2.Value > #11:59:00 PM# Then

            If TIM2.Value > #12:00:00 PM# Then

                If TIM2.Value > #6:00:00 PM# Then

                    Texts.Text = DTP2.Value - DTP1.Value + 1

                Else

                    Texts.Text = DTP2.Value - DTP1.Value + 0.5

                End If

            Else

                Texts.Text = DTP2.Value - DTP1.Value

            End If

        Else

            Texts.Text = DTP2.Value - DTP1.Value

        End If

    Else

        If TIM1.Value < #2:00:00 AM# Then

            If TIM2.Value > #2:00:00 AM# Then

                If TIM2.Value > #12:00:00 PM# Then

                    If TIM2.Value > #6:00:00 PM# Then

                        Texts.Text = 1 + 1

                    Else

                        Texts.Text = 1 + 0.5

                    End If

                Else

                    Texts.Text = 1

                End If

            Else

                Texts.Text = 1

            End If

        Else

            Texts.Text = 1

        End If

    End If

End Sub

Public Sub ssje()

    If Combo2.Text = "挂账" Then

        Texssje.Text = Val(Texzhje.Text) + Val(Texzf.Text) + Val(Texdhf.Text) + Val(Texpcf.Text) + Val(Texhyf.Text) + Val(Textcf.Text) - Val(Texyj.Text)

      

    Else

        Texssje.Text = Val(Texzhje.Text) + Val(Texzf.Text) + Val(Texdhf.Text) + Val(Texpcf.Text) + Val(Texhyf.Text) + Val(Textcf.Text)

        Texthje.Text = Val(Texyj.Text) - Val(Texssje.Text)

    End If

End Sub

Private Sub Form_Load()

    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

    Adodc1.RecordSource = "select * from tb_djb"

    Adodc1.Refresh

    Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

    Adodc2.RecordSource = "select * from tb_kf"

    Adodc2.Refresh

    Adodc3.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

    Adodc3.RecordSource = "select * from tb_gzmx"

    Adodc3.Refresh

    Adodc4.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

    Adodc4.RecordSource = "select * from tb_djys"

    Adodc4.Refresh

    Adodc5.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

    Adodc5.RecordSource = "select 凭证号码 from tb_djb where 标志='1'order by 凭证号码"

    Adodc5.Refresh

 If Adodc5.Recordset.RecordCount > 0 Then

        For i = 1 To Adodc5.Recordset.RecordCount

            Combo4.AddItem Adodc5.Recordset.Fields("凭证号码").Value

            Adodc5.Recordset.MoveNext

        Next i

    End If 

End Sub

Private Sub Form_Unload(Cancel As Integer)

    Main.Enabled = True  

End Sub

Private Sub Combo2_Click()

    If Combo2.Text = "折扣" Then

      Texzk.Text = 100     '赋值给Texzk.text

     End If

      If Combo2.Text = "招待" Then

      Texssje.Text = 0: Texthje.Text = Texyj.Text

      End If

    If Combo2.Text = "挂账" Then

        Lab10.Visible = True

        Texgzdw.Visible = True

        Texgzdw.Text = Texxm.Text   

        Lab11.Caption = "欠款金额": Label3.Visible = False: Texthje.Visible = False

         Texzk.Text = 100   

        Texssje.Text = Val(Texzhje.Text) - Val(Texyj.Text) + Val(Texzf.Text) + Val(Texdhf.Text) + Val(Texpcf.Text) + Val(Texhyf.Text) + Val(Textcf.Text)

    Else

     Lab11.Caption = "实收金额": Label3.Visible = True: Texthje.Visible = True

        Lab10.Visible = False

        Texgzdw.Visible = False    

        Texgzdw.Text = ""

    End If

End Sub

Private Sub Combo3_Click()

 Texfjf.SetFocus   

 Texfjf.Text = "0"   

End Sub

Private Sub combo4_Click()

    If Combo4.Text <> "" Then

        Adodc1.RecordSource = "select * from tb_djb where 凭证号码='" + Combo4.Text + "'"

        Adodc1.Refresh

        bh.Text = "T" & Combo4.Text

        If Adodc1.Recordset.RecordCount > 0 Then             

 If Adodc1.Recordset.Fields("姓名") <> "" Then Texxm.Text = Adodc1.Recordset.Fields("姓名")

            If Adodc1.Recordset.Fields("证件名称") <> "" Then Combo1.Text = Adodc1.Recordset.Fields("证件名称")

            If Adodc1.Recordset.Fields("证件号码") <> "" Then Texsfz.Text = Adodc1.Recordset.Fields("证件号码")

            If Adodc1.Recordset.Fields("详细地址") <> "" Then Texdz.Text = Adodc1.Recordset.Fields("详细地址")

            If Adodc1.Recordset.Fields("房间号") <> "" Then DBCombo3.Text = Adodc1.Recordset.Fields("房间号")

            If Adodc1.Recordset.Fields("客房类型") <> "" Then DBCombo1.Text = Adodc1.Recordset.Fields("客房类型")

            If Adodc1.Recordset.Fields("客房价格") <> "" Then DBCombo2.Text = Adodc1.Recordset.Fields("客房价格")

            If Adodc1.Recordset.Fields("住宿日期") <> "" Then DTP1.Value = Adodc1.Recordset.Fields("住宿日期")

            If Adodc1.Recordset.Fields("住宿时间") <> "" Then TIM1.Value = Adodc1.Recordset.Fields("住宿时间")

            If Adodc1.Recordset.Fields("住宿天数") <> "" Then Texts.Text = Adodc1.Recordset.Fields("住宿天数")

            If Adodc1.Recordset.Fields("预收金额") <> "" Then Texyj.Text = Adodc1.Recordset.Fields("预收金额") Else Texyj.Text = "0"

            If Adodc1.Recordset.Fields("结款方式") <> "" Then Combo2.Text = Adodc1.Recordset.Fields("结款方式")

            If Adodc1.Recordset.Fields("折扣") <> "" Then Texzk.Text = Adodc1.Recordset.Fields("折扣")

        End If

        If DTP2.Value > DTP1.Value Then

            If TIM2.Value > #11:59:00 AM# Then

                If TIM2.Value > #6:00:00 PM# Then

                    Texts.Text = DTP2.Value - CDate(DTP1.Value) + 1

                Else

                    Texts.Text = DTP2.Value - CDate(DTP1.Value) + 0.5

                End If

            Else

                Texts.Text = DTP2.Value - CDate(DTP1.Value)

            End If

        Else

            If TIM1.Value < #6:00:00 PM# Then

                If TIM2.Value > #6:00:00 PM# Then Texts.Text = 1 Else Texts.Text = "0.5"

            Else

                Texts.Text = "0.5"

            End If

        End If

        Texxf.Text = Val(Texts.Text) * Val(DBCombo2.Text)  

        Texzhje.Text = Val(Texxf.Text) * Val(Texzk.Text) / 100     '

        Texthje.Text = Val(Texyj.Text) - Val(Texzhje.Text) - Val(Texzf.Text) - Val(Texdhf.Text)           End If   End Sub

Private Sub combo4_KeyDown(KeyCode As Integer, Shift As Integer)

    If KeyCode = vbKeyReturn Then Texzk.SetFocus     '按回车键Texzk获得焦点

End Sub

Private Sub TIM2_Change()

    Call JS     '调用函数

End Sub

Private Sub DTP2_Change()

    Call JS     '调用函数

End Sub

Private Sub texzhje_Change()

    Call ssje     '调用函数

End Sub

Private Sub texzf_Change()

    Call ssje     '调用函数

End Sub

Private Sub texdhf_Change()

    Call ssje     '调用函数

End Sub   

Private Sub texpcf_Change()

    Call ssje     '调用函数

End Sub

Private Sub texhyf_Change()

    Call ssje     '调用函数

End Sub

Private Sub texfjf_Change()

    Texfjf.Text = Val(Texfjf.Text)

    'Val 函数返回包含于字符串内的数字,字符串中是一个适当类型的数值。

    If Combo3.Text = "电话费" Then Texdhf.Text = Val(Texfjf.Text)

    If Combo3.Text = "杂费" Then Texzf.Text = Val(Texfjf.Text)

    If Combo3.Text = "会议费" Then Texhyf.Text = Val(Texfjf.Text)

    If Combo3.Text = "停车费" Then Textcf.Text = Val(Texfjf.Text)

    If Combo3.Text = "赔偿费" Then Texpcf.Text = Val(Texfjf.Text)

End Sub

Private Sub textcf_Change()

 Call ssje     '调用函数

End Sub

Private Sub texts_Change()

    Texxf.Text = Val(Texts.Text) * Val(DBCombo2.Text)     '计算宿费

    Texzhje.Text = Val(Texxf.Text) * Val(Texzk.Text) / 100   '计算折后金额

    '计算退还金额

    Texthje.Text = Val(Texyj.Text) - Val(Texzhje.Text) - Val(Texzf.Text) - Val(Texdhf.Text)

End Sub

Private Sub texts_LostFocus()

    Texts.Text = Format(Val(Texts.Text), "0.0")     '格式化天数

End Sub

Private Sub texzk_Change()

    If Combo2.Text = "折扣" Then

        Texzk.Text = Val(Texzk.Text)

        Texzhje.Text = Val(Texxf.Text) * Val(Texzk.Text) / 100     '计算折后金额

        '计算退还金额

        Texthje.Text = Val(Texyj.Text) - Val(Texzhje.Text) - Val(Texzf.Text) - Val(Texdhf.Text)

    End If

    If Combo2.Text = "挂账" Then

    Texzhje.Text = Val(Texxf.Text) * Val(Texzk.Text) / 100

        Texssje.Text = Val(Texzhje.Text) + Val(Texzf.Text) + Val(Texdhf.Text) + Val(Texpcf.Text) + Val(Texhyf.Text) + Val(Textcf.Text) - Val(Texyj.Text)

    End If

End Sub

Private Sub comdj_Click()      '登记

    Texxm.Text = "": Texsfz.Text = "": Texfjf.Text = "": Texdz.Text = "": Texts.Text = ""

    Texzk.Text = "": Texyj.Text = "": Combo4.Text = "": Texzhje.Text = "": Texthje.Text = ""

    Textcf.Text = "0": Texzf.Text = "0": Texdhf.Text = "0": Texssje.Text = "0": Texpcf.Text = "0"

    Texhyf.Text = "0"

    Comok.Enabled = True: Comcancel.Enabled = True: Comdj.Enabled = False

    Comprint.Enabled = False: Combo4.Enabled = True: Texzk.Enabled = True

    Combo4.SetFocus

    Lab10.Visible = False: Texgzdw.Visible = False

     Lab11.Caption = "实收金额": Label3.Visible = True: Texthje.Visible = True

End Sub

Private Sub comok_Click()        '保存退宿信息

    If Combo2.Text = "挂账" And Texgzdw.Text = "" Then

        MsgBox "挂账单位为空,请填写挂账单位!", , "系统提示"

        Exit Sub

    End If

    If Texxm.Text <> "" And Texts.Text <> "" Then

        adocon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

        adoRs.Open "select * from tb_tfd", adocon, adOpenKeyset, adLockOptimistic

        adoRs.AddNew  '添加退宿记录

        If bh.Text <> "" Then adoRs.Fields("凭证号码") = bh.Text

        If Texxm.Text <> "" Then adoRs.Fields("姓名") = Texxm.Text

        If Combo1.Text <> "" Then adoRs.Fields("证件名称") = Combo1.Text

        If Texsfz.Text <> "" Then adoRs.Fields("证件号码") = Texsfz.Text

        If Texdz.Text <> "" Then adoRs.Fields("详细地址") = Texdz.Text

        If Textcf.Text <> "" Then adoRs.Fields("工作单位") = Textcf.Text

        If DBCombo3.Text <> "" Then adoRs.Fields("房间号") = DBCombo3.Text

        If DBCombo1.Text <> "" Then adoRs.Fields("客房类型") = DBCombo1.Text

        If DBCombo2.Text <> "" Then adoRs.Fields("客房价格") = DBCombo2.Text

        If DTP1.Value <> "" Then adoRs.Fields("住宿日期") = DTP1.Value

        If TIM1.Value <> "" Then adoRs.Fields("住宿时间") = TIM1.Value

        If DTP2.Value <> "" Then adoRs.Fields("退房日期") = DTP2.Value

        If TIM2.Value <> "" Then adoRs.Fields("退房时间") = TIM2.Value

        If Texts.Text <> "" Then adoRs.Fields("住宿天数") = Val(Texts.Text)

        If Texzk.Text <> "" Then adoRs.Fields("折扣") = Val(Texzk.Text)

        If Combo2.Text <> "" Then adoRs.Fields("折扣或招待") = Combo2.Text

        If Texxf.Text <> "" Then adoRs.Fields("宿费") = Format(Texxf.Text, "0.00")

        If Texzhje.Text <> "" Then adoRs.Fields("应收宿费") = Texzhje.Text

        If Texyj.Text <> "" Then adoRs.Fields("预收宿费") = Texyj.Text

        If Texthje.Text <> "" Then adoRs.Fields("退还宿费") = Texthje.Text

       If Texzf.Text <> "" Then adoRs.Fields("杂费") = Val(Texzf.Text) Else adoRs.Fields("杂费") = "0"

 If Texdhf.Text <> "" Then adoRs.Fields("电话费") = Val(Texdhf.Text) Else adoRs.Fields("电话费") = "0"

 If Texhyf.Text <> "" Then adoRs.Fields("会议费") = Val(Texhyf.Text) Else adoRs.Fields("会议费") = "0"

 If Texpcf.Text <> "" Then adoRs.Fields("赔偿费") = Val(Texpcf.Text) Else adoRs.Fields("赔偿费") = "0"

 If Textcf.Text <> "" Then adoRs.Fields("存车费") = Val(Textcf.Text) Else adoRs.Fields("存车费") = "0"

 If Texssje.Text <> "" Then adoRs.Fields("金额总计") = Val(Texssje.Text)

 If Texbz.Text <> "" Then adoRs.Fields("备注") = Texbz.Text

  adoRs.Fields("BZ") = Val(Left(Date, 4) & Right(Left(Date, 7), 2) & Right(Date, 2) & Left(Time, 2) & Left(Right(Time, 5), 2))

             adoRs.Update   

        adocon.Close

        Adodc1.RecordSource = "select * from tb_djb where 凭证号码 ='" + Combo4.Text + "'"

        If Adodc1.Recordset.RecordCount > 0 Then

            Adodc1.Recordset.Fields("标志") = "0"

            Adodc1.Recordset.Update

        End If

        Adodc4.RecordSource = "select * from tb_djys where 凭证号码='" + Combo4.Text + "'"

        Adodc4.Refresh

        If Adodc4.Recordset.RecordCount > 0 Then

            Adodc4.Recordset.Fields("标志") = "0"

            Adodc4.Recordset.Update

        End If

        Adodc2.RecordSource = "select * from tb_kf where 房间号='" + DBCombo3.Text + "'"

        Adodc2.Refresh

        Adodc2.Recordset.Fields("房态") = "空房"

        Adodc2.Recordset.Update

        If Combo2.Text = "挂账" Then

            Adodc3.RecordSource = "select * from tb_gzmx where 挂账单位='" + Texgzdw.Text + "'order by 日期,时间"

            Adodc3.Refresh

            If Adodc3.Recordset.RecordCount > 0 Then

                If Adodc3.Recordset.Fields("金额累计") <> "" Then gzje.Text = Adodc3.Recordset.Fields("金额累计")

            Else

                '添加挂账记录

                Adodc3.Recordset.AddNew

                Adodc3.Recordset.Fields("日期") = Date

                Adodc3.Recordset.Fields("时间") = Time

                Adodc3.Recordset.Fields("票号") = "T" & Combo4.Text

                Adodc3.Recordset.Fields("日期") = Date

                Adodc3.Recordset.Fields("姓名") = Texxm.Text

                Adodc3.Recordset.Fields("证件号码") = Texsfz.Text

                Adodc3.Recordset.Fields("房间标准") = DBCombo1.Text

                Adodc3.Recordset.Fields("房间价格") = DBCombo2.Text

                Adodc3.Recordset.Fields("时间") = Time

                Adodc3.Recordset.Fields("挂账单位") = Texgzdw.Text

                Adodc3.Recordset.Fields("住宿金额") = Texssje.Text

                Adodc3.Recordset.Fields("摘要") = "住宿日期:" & DTP1.Value & " 住宿天数: " & Texts.Text

                Adodc3.Recordset.Fields("欠款金额") = Val(Texssje.Text)

                Adodc3.Recordset.Fields("金额累计") = Val(Texssje.Text) + Val(gzje.Text)

                Adodc3.Recordset.Update     '更新记录

            End If

        End If

    Else

        MsgBox "请录入正确的数据", , "系统提示"

    End If

    Adodc2.RecordSource = "select * from tb_kf where 房态='空房'"

    Adodc2.Refresh

    Adodc1.Refresh

    Comprint.Enabled = True: Comok.Enabled = False: Comcancel.Enabled = False

    Comdj.Enabled = True: Comprint.SetFocus: Combo4.Enabled = False

     If Combo4.ListCount > 0 Then

        Combo4.RemoveItem (Combo4.ListIndex)

    End If

End Sub

Private Sub comcancel_Click()

 Texxm.Text = "": Texsfz.Text = "": Texfjf.Text = "": Texdz.Text = "": Texts.Text = ""

 Texzk.Text = "": Texyj.Text = "": Combo4.Text = "": Texzhje.Text = "": Texthje.Text = ""

 Texxf.Text = "": DBCombo1.Text = "": DBCombo2.Text = "": DBCombo3.Text = "": Texbz.Text = ""

 Textcf.Text = "0": Texzf.Text = "0": Texdhf.Text = "0": Texssje.Text = "0": Texpcf.Text = "0"

 Texhyf.Text = "0"

 Comdj.Enabled = True: Comcancel.Enabled = False: Comok.Enabled = False: Comprint.Enabled = False

  Lab11.Caption = "实收金额": Label3.Visible = True: Texthje.Visible = True

  Lab10.Visible = False: Texgzdw.Visible = False: Combo4.Enabled = False

End Sub

Private Sub comprint_Click()     

    On Error GoTo 1

    Printer.Height = 7000: Printer.Width = 12000

    Printer.CurrentX = 4000: Printer.CurrentY = 800

    Printer.FontSize = 16

    Printer.Print "  旺隆酒店客房退宿结账单 "

    Dim A, B, C, d As Integer

    A = 360: B = 1100: C = 3800: d = 350

    Printer.FontSize = 10

    Printer.CurrentX = 100 + A

    Printer.CurrentY = B + 200

    Printer.Print Date & " " & Time & "  NO." & bh.Text

    B = B + d

    Printer.Line (60 + A, B + 100)-(11000 + A, B + 100)

    Printer.CurrentX = 100 + A

    Printer.CurrentY = B + 200

    Printer.Print "姓名:" & Texxm.Text

    B = B + d

    Printer.CurrentX = 100 + A

    Printer.CurrentY = B + 200

    Printer.Print "房间号:" & DBCombo3.Text

    B = B + d

    Printer.CurrentX = 100 + A

    Printer.CurrentY = B + 200

    Printer.Print "房价:" & Format(DBCombo2.Text, "0.00") & "元" & "    " & "入住天数: " & Texts.Text & "天     " & "宿费 " & Format(Texxf.Text, "0.00") & "元    " & Combo2.Text & ":" & Texzk.Text & "%"

    If Texdhf.Text <> "0" Then

        B = B + d

        Printer.CurrentX = 100 + A

        Printer.CurrentY = B + 200

        Printer.Print "电话费:" & Format(Texdhf.Text, "0.00") & "元"

    End If

    If Texzf.Text <> "0" Then

        B = B + d

        Printer.CurrentX = 100 + A

        Printer.CurrentY = B + 200

        Printer.Print "杂费:" & Format(Texzf.Text, "0.00") & "元"

    End If

    If Texhyf.Text <> "0" Then

        B = B + d

        Printer.CurrentX = 100 + A

        Printer.CurrentY = B + 200

        Printer.Print "会议费:" & Format(Texhyf.Text, "0.00") & "元"

    End If

    If Textcf.Text <> "0" Then

        B = B + d

        Printer.CurrentX = 100 + A

        Printer.CurrentY = B + 200

        Printer.Print "停车费:" & Format(Textcf.Text, "0.00") & "元"

    End If

    If Texpcf.Text <> "0" Then

        B = B + d

        Printer.CurrentX = 100 + A

        Printer.CurrentY = B + 200

        Printer.Print "赔偿费:" & Format(Texpcf.Text, "0.00") & "元"

    End If

    B = B + d

    Printer.CurrentX = 100 + A

    Printer.CurrentY = B + 200

    Printer.Print "实收金额:" & Format(Texssje.Text, "0.00") & "元 " & "押金: " & Format(Texyj.Text, "0.00") & "元 " & "退还金额: " & Format(Texthje.Text, "0.00") & "元"

    B = B + d

    Printer.CurrentX = 100 + A

    Printer.CurrentY = B + 200

    Printer.Print "备注:" & Texbz.Text

    B = B + d

    Printer.Line (60 + A, B + 100)-(11000 + A, B + 100)

    Printer.CurrentX = 400

    Printer.CurrentY = B + 200

    Printer.Print "日期: "; Date & "  " & Time

    Printer.CurrentX = 3000 + A

    Printer.CurrentY = B + 200

    Printer.CurrentX = 6000 + A

    Printer.CurrentY = B + 200

    Printer.Print "顾客签名:                     签章: "

    Printer.EndDoc

    Exit Sub

1   If Err.Number = 482 Then

        MsgBox "请连接打印机", , "系统提示"

        Err.Clear

    End If

End Sub

Private Sub comend_Click()

 Unload Me

 Main.Enabled = True

End Sub

六、住宿查询模块设计(相当于查询模块)

(一)住宿查询模块概述:该模块用于查询正入住酒店的客人信息进行方便快捷地查询。只要输入一个姓名,想要查询的信息就都出来了。住宿查询模块界面如下图:

(七)调房登记模块实现过程

3、在该系统中添加一个新窗体并命名为main_kfcx,Caption属性设置为“住宿查询”。

4、在窗体中添加2个CommandButton控件(作为提交按钮——“查询”和“退出”)。

4、在窗体中添加1个TextBox控件(分别用于输入姓名)。

5、在窗体中添加1个DataGrid控件(用于显示查询的数据库结果)

6、代码设计如下:

Private Sub Command2_Click()  '查询

    Adodc1.RecordSource = "select * from tb_kf where  房间号 like '%" + Text1.Text + "%'"

    Adodc1.Refresh

End Sub

Private Sub DataGrid1_Click()   End Sub

Private Sub Form_Load() 

   Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"

    Adodc1.RecordSource = "select * from tb_kf"

    Adodc1.Refresh

    Set DataGrid1.DataSource = Adodc1

    DataGrid1.Columns(4).Width = 0

End Sub

Private Sub Form_Unload(Cancel As Integer)

    Main.Enabled = True    End Sub

Private Sub Command3_Click()

    Main.Enabled = True     Unload Me    End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)

    If KeyCode = 13 Then Command2.SetFocus  '按回车键Command2获得焦点

End Sub

注:另外还有两个模块——调房登记和客房查询模块的详细设计就不介绍了,调房登记模块和住宿登记模块类似,客房查询模块类似于住宿查询模块。

相关推荐