⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmkaifang.frm

📁 用vb编的一个酒店客房管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmKaiFang 
   Caption         =   "开房"
   ClientHeight    =   6675
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9150
   LinkTopic       =   "Form1"
   ScaleHeight     =   6675
   ScaleWidth      =   9150
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   5400
      Top             =   5040
      Visible         =   0   'False
      Width           =   2895
      _ExtentX        =   5106
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.TextBox txtYaJin 
      Height          =   495
      Left            =   2640
      TabIndex        =   15
      Top             =   5760
      Width           =   2535
   End
   Begin VB.TextBox txtXingMing 
      Height          =   495
      Left            =   2640
      TabIndex        =   14
      Top             =   2400
      Width           =   2535
   End
   Begin VB.CommandButton cmdQuXiao 
      Caption         =   "取消"
      Height          =   495
      Left            =   6000
      TabIndex        =   12
      Top             =   2040
      Width           =   1695
   End
   Begin VB.CommandButton cmdQueDing 
      Caption         =   "确定"
      Height          =   495
      Left            =   6000
      TabIndex        =   11
      Top             =   720
      Width           =   1695
   End
   Begin VB.ComboBox combFangJianHao 
      Height          =   300
      Left            =   2640
      TabIndex        =   10
      Text            =   "Combo4"
      Top             =   4920
      Width           =   2535
   End
   Begin VB.ComboBox combFangJianLeiXing 
      Height          =   300
      Left            =   2640
      TabIndex        =   9
      Text            =   "Combo3"
      Top             =   4080
      Width           =   2535
   End
   Begin VB.ComboBox combXingBie 
      Height          =   300
      Left            =   2640
      TabIndex        =   8
      Text            =   "Combo2"
      Top             =   3240
      Width           =   2535
   End
   Begin VB.TextBox txtZhengJianHaoMa 
      Height          =   495
      Left            =   2640
      TabIndex        =   7
      Top             =   1560
      Width           =   2535
   End
   Begin VB.ComboBox combZhengJianLeiXing 
      Height          =   300
      ItemData        =   "frmKaiFang.frx":0000
      Left            =   2640
      List            =   "frmKaiFang.frx":0002
      TabIndex        =   6
      Top             =   600
      Width           =   2535
   End
   Begin VB.Label Label7 
      Caption         =   "押金金额"
      Height          =   495
      Left            =   240
      TabIndex        =   13
      Top             =   5760
      Width           =   1815
   End
   Begin VB.Label Label6 
      Caption         =   "房间号"
      Height          =   495
      Left            =   240
      TabIndex        =   5
      Top             =   4920
      Width           =   1815
   End
   Begin VB.Label Label5 
      Caption         =   "房间类型"
      Height          =   495
      Left            =   360
      TabIndex        =   4
      Top             =   4080
      Width           =   1815
   End
   Begin VB.Label Label4 
      Caption         =   "性别"
      Height          =   495
      Left            =   360
      TabIndex        =   3
      Top             =   3240
      Width           =   1815
   End
   Begin VB.Label Label3 
      Caption         =   "姓名"
      Height          =   495
      Left            =   360
      TabIndex        =   2
      Top             =   2400
      Width           =   1815
   End
   Begin VB.Label Label2 
      Caption         =   "证件号码"
      Height          =   495
      Left            =   360
      TabIndex        =   1
      Top             =   1560
      Width           =   1815
   End
   Begin VB.Label Label1 
      Caption         =   "证件类型"
      Height          =   495
      Left            =   360
      TabIndex        =   0
      Top             =   600
      Width           =   1815
   End
End
Attribute VB_Name = "frmKaiFang"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim objCn As Connection
Dim objRs As Recordset
Dim objCmd As Command
Dim strSql

Private Sub cmdQueDing_Click()

    If combFangJianHao = "" Then
        MsgBox "房间号不能为空!", vbExclamation, "警告"
        Exit Sub
    End If
    
    '向'顾客'表中插入记录
    strSql = "select * from GuKe"
    
    Set objRs = New Recordset
    With objRs
        Set .ActiveConnection = objCn
        .CursorLocation = adUseClient
        .CursorType = adOpenDynamic
        .LockType = adLockOptimistic
        .Open strSql
    End With
    
    objRs.AddNew
    objRs.Fields("zhengJIanLeiBie") = Trim(combZhengJianLeiXing.Text)
    objRs.Fields("zhengJianHaoMa") = Trim(txtZhengJianHaoMa)
    objRs.Fields("xingMing") = Trim(txtXingMing)
    objRs.Fields("xingBie") = Trim(combXingBie.Text)
    objRs.Update
    
    Set objRs = Nothing
    
    Set objCmd = New Command
    Set objCmd.ActiveConnection = objCn
    objCmd.Parameters.Refresh
    
    '查询刚添加的顾客自动生成的编号
    Dim strSqlBianHao As String
    strSqlBianHao = "select bianHao from GuKe where bianHao not in" & _
                    "(select guKeBianHao from KaiFangYuDingFangJian)"
    Dim objBianHao As Recordset
    Set objBianHao = New Recordset
    With objBianHao
        Set .ActiveConnection = objCn
        .CursorLocation = adUseClient
        .CursorType = adOpenDynamic
        .Open strSqlBianHao
    End With
    
    '向'开房预定房间'表中插入记录
    strSql = "select * from KaiFangYuDingFangJian"
    
    Set objRs = New Recordset
    With objRs
        Set .ActiveConnection = objCn
        .CursorLocation = adUseClient
        .CursorType = adOpenDynamic
        .LockType = adLockOptimistic
        .Open strSql
    End With
    
    objRs.AddNew
    objRs.Fields("fangJianHao") = Trim(combFangJianHao.Text)
    objRs.Fields("guKeBianHao") = objBianHao.Fields("bianHao")
    objRs.Fields("kaiFangYuDingFangJian") = 0
    objRs.Fields("yaJin") = Val(Trim(txtYaJin))
    objRs.Update
    
    Set objRs = Nothing
    Set objBianHao = Nothing
    
    MsgBox "开房成功!", vbInformation, "开房"
    
    '询问是否继续开房间
    If MsgBox("是否继续?", vbYesNo + vbQuestion, "开房") = vbYes Then
        combFangJianLeiXing.SetFocus
    Else
        objCn.Close
        Set objCn = Nothing
        
        Unload Me
        frmFangJianGuanLi.Show
    End If

End Sub

Private Sub cmdQuXiao_Click()

    objCn.Close
    Set objCn = Nothing
    
    Unload Me
    frmFangJianGuanLi.Show
    
End Sub

Private Sub combFangJianLeiXing_Click()

    combFangJianHao.Clear
        
    strSql = "select haoMa from FangJian where haoMa not in " & _
           "(select  fangJianHao from KaiFangYuDingFangJian) " & _
           "and leiBie='" & Trim(combFangJianLeiXing.Text) & "'"
           
    Set objRs = New Recordset
    With objRs
        Set .ActiveConnection = objCn
        .CursorLocation = adUseClient
        .CursorType = adOpenDynamic
        .Open strSql
    End With
    
    If objRs.RecordCount < 1 Then
        
    Else
        While Not objRs.EOF
            combFangJianHao.AddItem (objRs.Fields("haoMa"))
            objRs.MoveNext
        Wend
    End If
    
    Set objRs = Nothing
    
End Sub

Private Sub Form_Load()
    
    '向证件类型中添加选项
    combZhengJianLeiXing.AddItem ("身份证")
    combZhengJianLeiXing.AddItem ("学生证")
    combZhengJianLeiXing.AddItem ("军人证")
    combZhengJianLeiXing.Text = combZhengJianLeiXing.List(0)
    
    '向性别类型中添加选项
    combXingBie.AddItem ("男")
    combXingBie.AddItem ("女")
    combXingBie.ListIndex = 0
    
    Set objCn = New Connection
    With objCn
        .Provider = "MSDASQL.1"
        .ConnectionString = "Persist Security Info=False;User ID=da;Data Source=jiudian"
        .Open
    End With
    
    
    Dim strSql As String
    strSql = "select leiBie from FangJianJiaGe"

    Set objRs = New Recordset
    With objRs
        Set .ActiveConnection = objCn
        .CursorLocation = adUseClient
        .CursorType = adOpenDynamic
        .Open strSql
    End With
    
    While Not objRs.EOF
        combFangJianLeiXing.AddItem (objRs.Fields("leiBie"))
        objRs.MoveNext
    Wend
    combFangJianLeiXing.ListIndex = 0
    Set objRs = Nothing
    
    
    strSql = "select haoMa from FangJian where haoMa not in " & _
           "(select  fangJianHao from KaiFangYuDingFangJian) " & _
           "and leiBie='" & Trim(combFangJianLeiXing.Text) & "'"
           
    Set objRs = New Recordset
    With objRs
        Set .ActiveConnection = objCn
        .CursorLocation = adUseClient
        .CursorType = adOpenDynamic
        .Open strSql
    End With
    
    combFangJianHao.Clear
    
    If objRs.RecordCount < 1 Then
    Else
        While Not objRs.EOF
            combFangJianHao.AddItem (objRs.Fields("haoMa"))
            objRs.MoveNext
        Wend
    End If
    
    Set objRs = Nothing
    
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -