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

📄 frmroom1.frm

📁 宾馆管理信息系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmRoom1 
   BackColor       =   &H00C0C0FF&
   Caption         =   "客房信息"
   ClientHeight    =   4605
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4215
   LinkTopic       =   "Form2"
   ScaleHeight     =   4605
   ScaleWidth      =   4215
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton cmdExit 
      BackColor       =   &H00C0C0FF&
      Caption         =   "返回(&X)"
      Height          =   375
      Left            =   2280
      Style           =   1  'Graphical
      TabIndex        =   12
      Top             =   4080
      Width           =   1215
   End
   Begin VB.CommandButton cmdSave 
      BackColor       =   &H00C0C0FF&
      Caption         =   "保存(&S)"
      Height          =   375
      Left            =   720
      Style           =   1  'Graphical
      TabIndex        =   11
      Top             =   4080
      Width           =   1215
   End
   Begin VB.Frame Frame2 
      BackColor       =   &H00C0C0FF&
      Caption         =   "备注信息"
      Height          =   1095
      Left            =   240
      TabIndex        =   10
      Top             =   2760
      Width           =   3855
      Begin VB.TextBox txtItem 
         Height          =   735
         Index           =   3
         Left            =   120
         TabIndex        =   13
         Top             =   240
         Width           =   3615
      End
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00C0C0FF&
      Caption         =   "客房信息"
      Height          =   2295
      Left            =   240
      TabIndex        =   0
      Top             =   240
      Width           =   3855
      Begin VB.TextBox txtItem 
         Height          =   270
         Index           =   2
         Left            =   1200
         TabIndex        =   8
         Top             =   1800
         Width           =   1575
      End
      Begin VB.TextBox txtItem 
         Height          =   270
         Index           =   1
         Left            =   1200
         TabIndex        =   7
         Top             =   1320
         Width           =   2295
      End
      Begin VB.ComboBox cboItem 
         Height          =   300
         Left            =   1200
         TabIndex        =   6
         Top             =   840
         Width           =   2295
      End
      Begin VB.TextBox txtItem 
         Height          =   270
         Index           =   0
         Left            =   1200
         TabIndex        =   5
         Top             =   360
         Width           =   2295
      End
      Begin VB.Label Label5 
         BackColor       =   &H00C0C0FF&
         Caption         =   "/每天"
         Height          =   255
         Left            =   2880
         TabIndex        =   9
         Top             =   1800
         Width           =   615
      End
      Begin VB.Label Label4 
         BackColor       =   &H00C0C0FF&
         Caption         =   "客房单价:"
         Height          =   255
         Left            =   120
         TabIndex        =   4
         Top             =   1800
         Width           =   1095
      End
      Begin VB.Label Label3 
         BackColor       =   &H00C0C0FF&
         Caption         =   "客房位置:"
         Height          =   255
         Left            =   120
         TabIndex        =   3
         Top             =   1320
         Width           =   1095
      End
      Begin VB.Label Label2 
         BackColor       =   &H00C0C0FF&
         Caption         =   "客房类型:"
         Height          =   255
         Left            =   120
         TabIndex        =   2
         Top             =   840
         Width           =   1095
      End
      Begin VB.Label Label1 
         BackColor       =   &H00C0C0FF&
         Caption         =   "客房编号:"
         Height          =   255
         Left            =   120
         TabIndex        =   1
         Top             =   360
         Width           =   975
      End
   End
End
Attribute VB_Name = "frmRoom1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'是否改动过记录,ture为改过
Dim mblChange As Boolean
Dim mrc As ADODB.Recordset
Public txtSQL As String

Private Sub cboItem_Change()
'有变化设置gblchange
    mblChange = True
End Sub

Private Sub cboItem_Click()
    Dim txtSQL As String
    Dim MsgText As String
    Dim mrcc As ADODB.Recordset
    Dim Index As Integer
                 '初始化员工名称和ID
        If Index = 0 Then
                        
            txtSQL = "select typename,price from roomtype where typename='" & Trim(cboItem) & "'"
            Set mrcc = ExecuteSQL(txtSQL, MsgText)
                        If Not mrcc.EOF Then
                txtItem(2) = mrcc!price
                cmdSave.Enabled = True
            Else
                MsgBox "请先建立客房标准!", vbOKOnly + vbExclamation, "警告"
                cmdSave.Enabled = False
                Exit Sub
            End If
            mrcc.Close
                End If
        Exit Sub
End Sub

Private Sub cboItem_KeyDown(KeyCode As Integer, Shift As Integer)
 EnterToTab KeyCode
End Sub

Private Sub cmdExit_Click()
    If mblChange And cmdSave.Enabled Then
        If MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
            '保存
            Call cmdSave_Click
        End If
    End If
    Unload Me
End Sub
Private Sub cmdSave_Click()
    Dim intCount As Integer
    Dim sMeg As String
    Dim mrcc As ADODB.Recordset
    Dim MsgText As String
    For intCount = 0 To 3
        If Trim(txtItem(intCount) & " ") = "" Then
            Select Case intCount
                Case 0
                    sMeg = "客房编号"
                Case 1
                    sMeg = "客房位置"
            End Select
            sMeg = sMeg & "不能为空!"
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
            txtItem(intCount).SetFocus
            Exit Sub
        End If
    Next intCount
    If gintRmode = 1 Then
        txtSQL = "select * from rooms where roomNO='" & Trim(txtItem(0)) & "'"
        Set mrcc = ExecuteSQL(txtSQL, MsgText)
        If mrcc.EOF = False Then
            MsgBox "已经存在此客房编号的记录!", vbOKOnly + vbExclamation, "警告"
            txtItem(0).SetFocus
            Exit Sub
        End If
        mrcc.Close
    End If
    If gintRmode = 2 Then
        '先删除已有记录
        txtSQL = "delete from rooms where roomNO='" & Trim(txtItem(0)) & "'"
        Set mrcc = ExecuteSQL(txtSQL, MsgText)
    End If
    '再加入新记录
    txtSQL = "select * from rooms"
    Set mrcc = ExecuteSQL(txtSQL, MsgText)
    mrcc.AddNew
    mrcc.Fields(0) = Trim(txtItem(0))
    mrcc.Fields(1) = Trim(cboItem)
    For intCount = 1 To 2
        If Trim(txtItem(intCount) & " ") = "" Then
            mrcc.Fields(intCount + 1) = Null
        Else
            mrcc.Fields(intCount + 1) = Trim(txtItem(intCount))
        End If
    Next intCount
    mrcc.Fields(4) = " "
    mrcc.Fields(5) = Trim(txtItem(3))
    mrcc.Update
    MsgBox "添加成功!", vbOKOnly + vbExclamation, "添加客房信息"
    mrcc.Close
    If gintRmode = 1 Then
        For intCount = 0 To 3
            txtItem(intCount) = ""
        Next intCount
        mblChange = False
        If flagRedit Then
            Unload frmRoom
            frmRoom.txtSQL = "select * from rooms"
            frmRoom.Show
        End If
    ElseIf gintRmode = 2 Then
        Unload Me
        If flagRedit Then
            Unload frmRoom
        End If
        frmRoom.txtSQL = "select * from rooms"
        frmRoom.Show
    End If
End Sub
Private Sub Form_Load()
    Dim txtSQL As String
    Dim intCount As Integer
    Dim MsgText As String
    Dim mrcc As ADODB.Recordset
    If gintRmode = 1 Then
        Me.Caption = Me.Caption & "添加"
        '初始化物资名称
        txtSQL = "select DISTINCT typename from roomtype"
        Set mrc = ExecuteSQL(txtSQL, MsgText)
        If Not mrc.EOF Then
               Do While Not mrc.EOF
                    cboItem.AddItem Trim(mrc.Fields(0))
                    mrc.MoveNext
                Loop
                cboItem.ListIndex = 0
        Else
            MsgBox "请先进行客房标准设置!", vbOKOnly + vbExclamation, "警告"
            cmdSave.Enabled = False
            Exit Sub
        End If
        mrc.Close
    ElseIf gintRmode = 2 Then
        If flagRedit Then
        If frmRoom.msgList.Rows > 1 Then
            gintRmode = 2
            intCount = frmRoom.msgList.Row
           txtSQL = "select * from rooms where roomNO ='" & Trim(frmRoom.msgList.TextMatrix(intCount, 1)) & "'"
        Else
        frmRoom.txtSQL = "select * from rooms"
        frmRoom.Show
    End If
    Set mrcc = ExecuteSQL(txtSQL, MsgText)
       If mrcc.EOF = False Then
            With mrcc
               txtItem(0) = .Fields(0)
                For intCount = 1 To 2
                    If Not IsNull(.Fields(intCount + 1)) Then
                        txtItem(intCount) = .Fields(intCount + 1)
                    End If
                Next intCount
                txtItem(3) = .Fields(5)
                txtSQL = "select DISTINCT typename from roomtype"
                Set mrc = ExecuteSQL(txtSQL, MsgText)
                If Not mrc.EOF Then
                        Do While Not mrc.EOF
                            cboItem.AddItem Trim(mrc.Fields(0))
                            mrc.MoveNext
                        Loop
                        cboItem.ListIndex = 0
                Else
                    MsgBox "请先进行客房标准设置!", vbOKOnly + vbExclamation, "警告"
                    cmdSave.Enabled = False
                    Exit Sub
                End If
                mrc.Close
            End With
          txtItem(0).Enabled = False
        End If
        mrcc.Close
        Me.Caption = Me.Caption & "修改"
    End If
        mblChange = False
 End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
    gintRmode = 0
End Sub
Private Sub txtItem_Change(Index As Integer)
    '有变化设置gblchange
    mblChange = True
End Sub
Private Sub txtItem_GotFocus(Index As Integer)
    txtItem(Index).SelStart = 0
    txtItem(Index).SelLength = Len(txtItem(Index))
End Sub
Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
        EnterToTab KeyCode
End Sub





⌨️ 快捷键说明

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