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

📄 frmcheckin.frm

📁 数据库课程设计
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmCheckIn 
   Caption         =   "房间入住"
   ClientHeight    =   4980
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8055
   LinkTopic       =   "Form1"
   ScaleHeight     =   4980
   ScaleWidth      =   8055
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdSave 
      Caption         =   "保存 (&S)"
      Height          =   375
      Left            =   2280
      TabIndex        =   20
      Top             =   4440
      Width           =   1215
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "返回 (&X)"
      Height          =   375
      Left            =   4080
      TabIndex        =   19
      Top             =   4440
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      Caption         =   "客房信息"
      Height          =   1935
      Left            =   240
      TabIndex        =   12
      Top             =   240
      Width           =   7575
      Begin VB.TextBox txtType 
         Height          =   375
         Left            =   4800
         TabIndex        =   22
         Top             =   480
         Width           =   2175
      End
      Begin VB.TextBox txtPrice 
         Height          =   375
         Left            =   4800
         TabIndex        =   21
         Top             =   960
         Width           =   2175
      End
      Begin VB.ComboBox cboRoom 
         Height          =   315
         Left            =   1320
         Style           =   2  'Dropdown List
         TabIndex        =   14
         Top             =   480
         Width           =   2175
      End
      Begin VB.TextBox txtMemo 
         Height          =   720
         Left            =   1320
         MaxLength       =   5
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   13
         Top             =   960
         Width           =   2175
      End
      Begin VB.Label Label2 
         Caption         =   "备注信息:"
         Height          =   255
         Index           =   2
         Left            =   240
         TabIndex        =   18
         Top             =   1080
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "房间种类:"
         Height          =   255
         Index           =   1
         Left            =   3720
         TabIndex        =   17
         Top             =   480
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "房间编号:"
         Height          =   255
         Index           =   0
         Left            =   240
         TabIndex        =   16
         Top             =   480
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "房间单价:"
         Height          =   255
         Index           =   3
         Left            =   3720
         TabIndex        =   15
         Top             =   960
         Width           =   975
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "顾客信息"
      Height          =   1935
      Left            =   240
      TabIndex        =   0
      Top             =   2280
      Width           =   7575
      Begin VB.TextBox txtDiscount 
         Height          =   270
         Left            =   1320
         MaxLength       =   3
         TabIndex        =   5
         Top             =   1440
         Width           =   1572
      End
      Begin VB.TextBox txtDateIn 
         Height          =   270
         Left            =   1320
         MaxLength       =   10
         TabIndex        =   4
         Top             =   1080
         Width           =   2172
      End
      Begin VB.TextBox txtID 
         Height          =   270
         Left            =   1320
         MaxLength       =   18
         TabIndex        =   3
         Top             =   720
         Width           =   2175
      End
      Begin VB.TextBox txtName 
         Height          =   270
         Left            =   1320
         MaxLength       =   5
         TabIndex        =   2
         Top             =   360
         Width           =   2175
      End
      Begin VB.TextBox txtCusMemo 
         Height          =   1320
         Left            =   4800
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   1
         Top             =   360
         Width           =   2175
      End
      Begin VB.Label Label2 
         Caption         =   "顾 客  姓 名:"
         Height          =   255
         Index           =   4
         Left            =   240
         TabIndex        =   11
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "身份证号码:"
         Height          =   255
         Index           =   5
         Left            =   240
         TabIndex        =   10
         Top             =   720
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "折            扣:"
         Height          =   255
         Index           =   6
         Left            =   240
         TabIndex        =   9
         Top             =   1440
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "入 住 时 间:"
         Height          =   255
         Index           =   11
         Left            =   240
         TabIndex        =   8
         Top             =   1080
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "备 注 信 息:"
         Height          =   255
         Index           =   7
         Left            =   3720
         TabIndex        =   7
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "%"
         Height          =   255
         Index           =   8
         Left            =   3000
         TabIndex        =   6
         Top             =   1440
         Width           =   495
      End
   End
End
Attribute VB_Name = "frmCheckIn"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public sqlStr As String
Public msgText As String

Private Sub init_rooms()
    Dim rstRoom As ADODB.Recordset
    
    '初始化房间信息
    '查询所有空闲的房间并显示在列表框中
    sqlStr = "select roomNo from roomInfo where hasBooked='否'"
    Set rstRoom = ExecuteSQL(sqlStr, msgText)
    
    If Not rstRoom.EOF Then
        
            Do While Not rstRoom.EOF
                cboRoom.AddItem Trim(rstRoom.Fields(0))
                rstRoom.MoveNext
            Loop
            cboRoom.ListIndex = 0
        
    Else
        MsgBox "没有任何房间信息!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    rstRoom.Close
    
    txtName = ""
    txtID = ""
    txtDiscount = ""
    txtCusMemo = ""
    txtDateIn.Text = Format(Date, "yyyy-mm-dd")

End Sub

Private Sub cboRoom_Click()
    Dim rstRoom As ADODB.Recordset
 
    sqlStr = "select * from roomInfo where roomNO='" & Trim(cboRoom.Text) & "'"
    Set rstRoom = ExecuteSQL(sqlStr, msgText)
    
    If Not rstRoom.EOF Then
        txtPrice = rstRoom!roomPrice
        txtType.Text = rstRoom!roomType
        txtMemo.Text = rstRoom!roomMemo
    Else
        MsgBox "没有找到相关数据!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    rstRoom.Close

End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub cmdSave_Click()
    Dim rstCheckIn As ADODB.Recordset
    Dim rstRoom As ADODB.Recordset
    
    Dim customerName As String
    Dim customerID As String
    Dim discount As String
    Dim roomNo As String
    Dim custMemo As String
    Dim dateIn As String
    
    roomNo = cboRoom.Text
    customerName = txtName.Text
    customerID = txtID.Text
    discount = txtDiscount.Text
    custMemo = txtCusMemo.Text
    
    '进行信息验证
    
    '得到入住日期

    dateIn = Format(Date, "yyyy-mm-dd")
  
    '添加新记录
    sqlStr = "select * from checkIn"
    Set rstCheckIn = ExecuteSQL(sqlStr, msgText)
    rstCheckIn.AddNew
    rstCheckIn.Fields("roomNO") = roomNo
    rstCheckIn.Fields("customerName") = customerName
    rstCheckIn.Fields("customerID") = customerID
    rstCheckIn.Fields("discount") = discount
    rstCheckIn.Fields("memo") = custMemo
    rstCheckIn.Fields("date_in") = dateIn
    
    rstCheckIn.Update
    rstCheckIn.Close
    
    '修改房间的入住信息
    '将hasBooked字段的值更改为“是”
    
    sqlStr = "select * from roomInfo where roomNO='" & roomNo & "'"
    Set rstRoom = ExecuteSQL(sqlStr, msgText)
    If Not rstRoom.EOF Then
       rstRoom.Fields("hasbooked") = "是"
       rstRoom.Update
    End If
    rstRoom.Close
         
    MsgBox "房间添加完成!", vbOKOnly + vbExclamation, "警告"
    
    '将输入框进行初始化
    init_rooms

End Sub

Private Sub Form_Load()

'窗体居中显示
Me.Top = (Screen.Height - Me.Height) \ 2
Me.Left = (Screen.Width - Me.Width) \ 2

init_rooms

End Sub

⌨️ 快捷键说明

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