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

📄 frmroomno.frm

📁 酒店管理系统 (VB版) 简单的酒店管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form Frmroomno 
   Caption         =   "房间"
   ClientHeight    =   9405
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   7005
   LinkTopic       =   "Form2"
   ScaleHeight     =   9405
   ScaleWidth      =   7005
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Cmdchange 
      Caption         =   "房间号码更改"
      Height          =   495
      Left            =   3840
      TabIndex        =   26
      Top             =   240
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      Caption         =   "更改"
      Height          =   3015
      Left            =   3840
      TabIndex        =   15
      Top             =   840
      Width           =   3015
      Begin VB.TextBox Textcode 
         Enabled         =   0   'False
         Height          =   270
         Left            =   1800
         TabIndex        =   23
         Top             =   360
         Width           =   855
      End
      Begin VB.TextBox Textno1 
         Enabled         =   0   'False
         Height          =   270
         Left            =   1800
         TabIndex        =   22
         Top             =   840
         Width           =   855
      End
      Begin VB.TextBox Textno2 
         Height          =   270
         Left            =   1800
         TabIndex        =   21
         Top             =   1320
         Width           =   855
      End
      Begin VB.CommandButton Cmdc 
         Caption         =   "更改"
         Height          =   375
         Left            =   480
         TabIndex        =   20
         Top             =   2400
         Width           =   855
      End
      Begin VB.CommandButton Cmdcancel 
         Caption         =   "取消"
         Height          =   375
         Left            =   1800
         TabIndex        =   19
         Top             =   2400
         Width           =   855
      End
      Begin VB.CheckBox Checktype1 
         Caption         =   "更改类型:"
         Height          =   375
         Left            =   240
         TabIndex        =   17
         Top             =   1800
         Width           =   1335
      End
      Begin VB.CheckBox Checkno 
         Caption         =   "改房间号码为:"
         Height          =   375
         Left            =   240
         TabIndex        =   16
         Top             =   1200
         Width           =   1575
      End
      Begin MSDataListLib.DataCombo Datatype1 
         Height          =   330
         Left            =   1800
         TabIndex        =   18
         Top             =   1800
         Width           =   975
         _ExtentX        =   1720
         _ExtentY        =   582
         _Version        =   393216
         Text            =   ""
      End
      Begin VB.Label Label1 
         Caption         =   "房间号:"
         Height          =   255
         Left            =   840
         TabIndex        =   25
         Top             =   360
         Width           =   735
      End
      Begin VB.Label Label2 
         Caption         =   "房间类型:"
         Height          =   255
         Left            =   720
         TabIndex        =   24
         Top             =   840
         Width           =   975
      End
   End
   Begin VB.CommandButton Command1 
      Caption         =   "刷新"
      Height          =   495
      Left            =   2520
      TabIndex        =   14
      Top             =   8760
      Width           =   975
   End
   Begin VB.Frame Frame2 
      Caption         =   "添加房间"
      Height          =   2175
      Left            =   3840
      TabIndex        =   7
      Top             =   6480
      Width           =   3015
      Begin VB.TextBox Textcodeadd 
         Height          =   390
         Left            =   1440
         TabIndex        =   10
         Top             =   360
         Width           =   1095
      End
      Begin VB.CommandButton Cmdadd2 
         Caption         =   "添加"
         Height          =   375
         Left            =   480
         TabIndex        =   9
         Top             =   1560
         Width           =   855
      End
      Begin VB.CommandButton quxiao 
         Caption         =   "取消"
         Height          =   375
         Left            =   1560
         TabIndex        =   8
         Top             =   1560
         Width           =   855
      End
      Begin MSDataListLib.DataCombo Datatype2 
         Height          =   330
         Left            =   1440
         TabIndex        =   11
         Top             =   960
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   582
         _Version        =   393216
         Text            =   ""
      End
      Begin VB.Label Label4 
         Caption         =   "房间号:"
         Height          =   255
         Left            =   480
         TabIndex        =   13
         Top             =   480
         Width           =   735
      End
      Begin VB.Label Label3 
         Caption         =   "房间类型为:"
         Height          =   255
         Left            =   240
         TabIndex        =   12
         Top             =   1080
         Width           =   1095
      End
   End
   Begin VB.Frame Frame3 
      Caption         =   "删除房间"
      Height          =   1815
      Left            =   3840
      TabIndex        =   2
      Top             =   4560
      Width           =   3015
      Begin VB.TextBox Textdcode 
         Height          =   375
         Left            =   1320
         TabIndex        =   5
         Top             =   360
         Width           =   1215
      End
      Begin VB.CommandButton Cmdd 
         Caption         =   "删除"
         Height          =   495
         Left            =   240
         TabIndex        =   4
         Top             =   960
         Width           =   1095
      End
      Begin VB.CommandButton Cmdq 
         Caption         =   "取消"
         Height          =   495
         Left            =   1560
         TabIndex        =   3
         Top             =   960
         Width           =   1095
      End
      Begin VB.Label Label6 
         Caption         =   "房间号:"
         Height          =   255
         Left            =   360
         TabIndex        =   6
         Top             =   480
         Width           =   735
      End
   End
   Begin VB.CommandButton Cmddelete 
      Caption         =   "删除该房间"
      Height          =   495
      Left            =   3840
      TabIndex        =   1
      Top             =   3960
      Width           =   1215
   End
   Begin VB.CommandButton Command2 
      Caption         =   "关闭"
      Height          =   495
      Left            =   5520
      TabIndex        =   0
      Top             =   8760
      Width           =   1095
   End
   Begin MSDataGridLib.DataGrid Dataroom 
      Height          =   8415
      Left            =   240
      TabIndex        =   27
      Top             =   240
      Width           =   3375
      _ExtentX        =   5953
      _ExtentY        =   14843
      _Version        =   393216
      HeadLines       =   1
      RowHeight       =   15
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
End
Attribute VB_Name = "Frmroomno"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim str, str1 As String
Dim rsroom, rstype, rsroomstate As ADODB.Recordset
Dim rsroom1, rsroom2 As ADODB.Recordset

Private Sub Cmdadd2_Click()
Set cnn = New ADODB.Connection
Dim connectstring As String
connectstring = "DSN=hotelodbc"
cnn.Open connectstring

str = "select roomcode from room where roomcode='" & Textcodeadd.Text & "'"
Set rsroom1 = New ADODB.Recordset
rsroom1.Open str, cnn, adOpenKeyset, adLockOptimistic

If rsroom1.RecordCount > 0 Then
MsgBox "该房间号已存在", vbOKOnly + vbInformation, "提示"
ElseIf Textcodeadd.Text = "" Then
MsgBox "请输入添加的房间号", vbOKOnly + vbInformation, "提示"
Else:
On err GoTo err
cnn.BeginTrans
str = "insert into room values('" & Textcodeadd.Text & "','" & Datatype2.BoundText & "')"
Debug.Print str
cnn.Execute str

str = "insert into roomstate values('" & Textcodeadd.Text & "','r')"
Debug.Print str
cnn.Execute str
MsgBox "添加成功", vbOKOnly + vbInformation, "提示"

cnn.CommitTrans
Textcodeadd.Text = ""
Exit Sub

err:
cnn.RollbackTrans
MsgBox "添加失败", vbOKOnly + vbInformation, "提示"
End If
End Sub

Private Sub Cmdd_Click()
Set cnn = New ADODB.Connection
Dim connectstring As String
connectstring = "DSN=hotelodbc"
cnn.Open connectstring

Dim a As String
Dim X As Integer
X = MsgBox("确定删除?", vbYesNo, "确定删除")

If X = 6 Then
str = "select roomstate from roomstate where roomcode='" & Textdcode.Text & "'"
Set rsroomstate = New ADODB.Recordset
rsroomstate.Open str, cnn, adOpenKeyset, adLockOptimistic
If Textdcode.Text = "" Then
MsgBox "请选择要删除的房间", vbOKOnly + vbInformation, "提示"
Else:
a = rsroomstate.Fields(0)
If a <> "l" Then

On Error GoTo err

cnn.BeginTrans
str = "delete from room where roomcode='" & Textdcode.Text & "' "
Debug.Print str
cnn.Execute str

str = "delete from roomstate where roomcode='" & Textdcode.Text & "'"
Debug.Print str
cnn.Execute str
MsgBox "删除成功", vbOKOnly + vbInformation, "提示"
cnn.CommitTrans
Textdcode.Text = ""
Exit Sub

err:
cnn.RollbackTrans
MsgBox "删除失败", vbOKOnly + vbInformation, "提示"
Else: MsgBox "该房间有客人入住,无法删除", vbOKOnly + vbInformation, "提示"
End If
End If
End If
End Sub

Private Sub Cmddelete_Click()
Textdcode.Text = Dataroom.Columns(0)
End Sub

Private Sub Cmdq_Click()
Textdcode.Text = ""
End Sub

Private Sub Command1_Click()
rsroom.Requery
Dataroom.Refresh
End Sub

Private Sub Cmdc_Click()
Set cnn = New ADODB.Connection
Dim connectstring As String
connectstring = "DSN=hotelodbc"
cnn.Open connectstring

str = "select roomcode from room where roomcode='" & Textno2.Text & "'"
Set rsroom1 = New ADODB.Recordset
rsroom1.Open str, cnn, adOpenKeyset, adLockOptimistic

If rsroom1.RecordCount > 0 Then
MsgBox "该房间号已存在,无法更改", vbOKOnly + vbInformation, "提示"
ElseIf Checkno.Value = 0 And Checktype1.Value = 0 Then
MsgBox "请选择要修改的内容", vbOKOnly + vbInformation, "提示"
ElseIf Checkno.Value = 1 And Textno2.Text = "" Then
MsgBox "请输入更改后的房间号", vbOKOnly + vbInformation, "提示"
Else:
If Checktype1.Value = 1 Then
str = "update room set typeno=(select typeno from roomtype where typename='" & Datatype1.Text & "') where roomcode='" & Textcode.Text & "'"
Debug.Print str
cnn.Execute str
End If
If Checkno.Value = 1 Then
str = "update room set roomcode='" & Textno2.Text & "' where roomcode=(select roomcode from room where roomcode='" & Textcode.Text & "')"
Debug.Print str
cnn.Execute str
End If
MsgBox "更改成功", vbOKOnly + vbInformation, "提示"
Textno2.Text = ""
Checkno.Value = 0
Checktype1.Value = 0
End If
End Sub

Private Sub Cmdcancel_Click()
Textcode.Text = ""
Textno1.Text = ""
Textno2.Text = ""
Datatype1.Text = ""
End Sub

Private Sub Cmdchange_Click()
Set cnn = New ADODB.Connection
Dim connectstring As String
connectstring = "DSN=hotelodbc"
cnn.Open connectstring

Textcode.Text = Dataroom.Columns(0)
Textno1.Text = Dataroom.Columns(1)

str = "select typename,typeno from roomtype "
Set rstype = New ADODB.Recordset
rstype.Open str, cnn, adOpenKeyset, adLockOptimistic
Set Datatype1.RowSource = rstype
Datatype1.BoundColumn = "typeno"
Datatype1.ListField = "typename"
Datatype1.Text = Dataroom.Columns(1)

End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()
Set cnn = New ADODB.Connection
Dim connectstring As String
connectstring = "DSN=hotelodbc"
cnn.Open connectstring

str = "select room.roomcode 房间号,typename 房间类型 from room,roomtype where room.typeno=roomtype.typeno"
Set rsroom = New ADODB.Recordset
rsroom.Open str, cnn, adOpenKeyset, adLockOptimistic
Set Dataroom.DataSource = rsroom

str = "select typename,typeno from roomtype "
Set rstype = New ADODB.Recordset
rstype.Open str, cnn, adOpenKeyset, adLockOptimistic
Set Datatype2.RowSource = rstype
Datatype2.BoundColumn = "typeno"
Datatype2.ListField = "typename"
rstype.MoveFirst
Datatype2.Text = rstype.Fields("typename")
End Sub

Private Sub quxiao_Click()
Textcodeadd.Text = ""
End Sub

⌨️ 快捷键说明

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