📄 frmroom1.frm
字号:
VERSION 5.00
Begin VB.Form frmRoom1
BorderStyle = 3 'Fixed Dialog
Caption = "客房信息"
ClientHeight = 4764
ClientLeft = 48
ClientTop = 336
ClientWidth = 4344
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4764
ScaleWidth = 4344
ShowInTaskbar = 0 'False
StartUpPosition = 1 'CenterOwner
Begin VB.Frame Frame3
Caption = "备注信息"
Height = 1215
Left = 240
TabIndex = 8
Top = 2760
Width = 3732
Begin VB.TextBox txtItem
Height = 840
Index = 3
Left = 120
MaxLength = 5
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 13
Top = 240
Width = 3492
End
End
Begin VB.Frame Frame1
Caption = "客房信息"
Height = 2412
Left = 240
TabIndex = 3
Top = 240
Width = 3735
Begin VB.TextBox txtItem
Enabled = 0 'False
Height = 270
Index = 2
Left = 1200
MaxLength = 10
TabIndex = 11
Top = 1920
Width = 1692
End
Begin VB.TextBox txtItem
Height = 270
Index = 1
Left = 1200
MaxLength = 8
TabIndex = 10
Top = 1440
Width = 2175
End
Begin VB.TextBox txtItem
Height = 270
Index = 0
Left = 1200
MaxLength = 5
TabIndex = 9
Top = 480
Width = 2175
End
Begin VB.ComboBox cboItem
Height = 288
Index = 0
Left = 1200
Style = 2 'Dropdown List
TabIndex = 0
Top = 960
Width = 2175
End
Begin VB.Label Label2
Caption = "/每天"
Height = 252
Index = 4
Left = 3000
TabIndex = 12
Top = 1920
Width = 372
End
Begin VB.Label Label2
Caption = "客房单价:"
Height = 255
Index = 3
Left = 240
TabIndex = 7
Top = 1920
Width = 975
End
Begin VB.Label Label2
Caption = "客房编号:"
Height = 255
Index = 0
Left = 240
TabIndex = 6
Top = 480
Width = 975
End
Begin VB.Label Label2
Caption = "客房类型:"
Height = 255
Index = 1
Left = 240
TabIndex = 5
Top = 960
Width = 975
End
Begin VB.Label Label2
Caption = "客房位置:"
Height = 255
Index = 16
Left = 240
TabIndex = 4
Top = 1440
Width = 975
End
End
Begin VB.CommandButton cmdExit
Caption = "返回 (&X)"
Height = 375
Left = 2400
TabIndex = 2
Top = 4200
Width = 1215
End
Begin VB.CommandButton cmdSave
Caption = "保存 (&S)"
Height = 375
Left = 600
TabIndex = 1
Top = 4200
Width = 1215
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(Index As Integer)
'有变化设置gblchange
mblChange = True
End Sub
Private Sub cboItem_Click(Index As Integer)
Dim sSql As String
Dim MsgText As String
Dim mrcc As ADODB.Recordset
'初始化员工名称和ID
If Index = 0 Then
txtSQL = "select typename,price from roomtype where typename='" & Trim(cboItem(0)) & "'"
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(Index As Integer, 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 mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
MsgBox "已经存在此客房编号的记录!", vbOKOnly + vbExclamation, "警告"
txtItem(0).SetFocus
Exit Sub
End If
mrc.Close
End If
If gintRmode = 2 Then
'先删除已有记录
txtSQL = "delete from rooms where roomNO='" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
End If
'再加入新记录
txtSQL = "select * from rooms"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.AddNew
mrc.Fields(0) = Trim(txtItem(0))
mrc.Fields(1) = Trim(cboItem(0))
For intCount = 1 To 2
If Trim(txtItem(intCount) & " ") = "" Then
mrc.Fields(intCount + 1) = Null
Else
mrc.Fields(intCount + 1) = Trim(txtItem(intCount))
End If
Next intCount
mrc.Fields(4) = " "
mrc.Fields(5) = Trim(txtItem(3))
mrc.Update
mrc.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 sSql 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(0).AddItem Trim(mrc.Fields(0))
mrc.MoveNext
Loop
cboItem(0).ListIndex = 0
Else
MsgBox "请先进行客房标准设置!", vbOKOnly + vbExclamation, "警告"
cmdSave.Enabled = False
Exit Sub
End If
mrc.Close
ElseIf gintRmode = 2 Then
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(0).AddItem Trim(mrc.Fields(0))
mrc.MoveNext
Loop
cboItem(0).ListIndex = 0
Else
MsgBox "请先进行客房标准设置!", vbOKOnly + vbExclamation, "警告"
cmdSave.Enabled = False
Exit Sub
End If
mrc.Close
End With
End If
mrcc.Close
Me.Caption = Me.Caption & "修改"
End If
mblChange = False
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 + -