📄 frmroomtype1.frm
字号:
VERSION 5.00
Begin VB.Form frmRoomtype1
BackColor = &H00C0C0FF&
BorderStyle = 1 'Fixed Single
Caption = "客房标准"
ClientHeight = 4950
ClientLeft = 45
ClientTop = 330
ClientWidth = 6840
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4950
ScaleWidth = 6840
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdExit
BackColor = &H00C0C0FF&
Caption = "返回(&X)"
Height = 615
Left = 3840
Style = 1 'Graphical
TabIndex = 21
Top = 3960
Width = 1455
End
Begin VB.CommandButton cmdSave
BackColor = &H00C0C0FF&
Caption = "保存(&S)"
Height = 615
Left = 1560
Style = 1 'Graphical
TabIndex = 20
Top = 3960
Width = 1575
End
Begin VB.Frame Frame1
BackColor = &H00C0C0FF&
Caption = "客房标准:"
Height = 3255
Left = 120
TabIndex = 0
Top = 480
Width = 6375
Begin VB.ComboBox combol
Height = 300
Index = 3
Left = 4560
TabIndex = 19
Top = 1920
Width = 1575
End
Begin VB.ComboBox combol
Height = 300
Index = 2
Left = 4560
TabIndex = 18
Top = 1440
Width = 1575
End
Begin VB.ComboBox combol
Height = 300
Index = 1
Left = 4560
TabIndex = 17
Top = 960
Width = 1575
End
Begin VB.ComboBox combol
Height = 300
Index = 0
Left = 4560
TabIndex = 16
Top = 480
Width = 1575
End
Begin VB.TextBox txtItem
Height = 375
Index = 4
Left = 1320
TabIndex = 14
Top = 2640
Width = 1575
End
Begin VB.TextBox txtItem
Height = 375
Index = 3
Left = 1320
TabIndex = 13
Top = 2040
Width = 1575
End
Begin VB.TextBox txtItem
Height = 375
Index = 2
Left = 1320
TabIndex = 12
Top = 1560
Width = 1575
End
Begin VB.TextBox txtItem
Height = 375
Index = 1
Left = 1320
TabIndex = 11
Top = 960
Width = 1575
End
Begin VB.TextBox txtItem
Height = 390
Index = 0
Left = 1320
TabIndex = 10
Top = 360
Width = 1575
End
Begin VB.Label Label10
BackColor = &H00C0C0FF&
Caption = "/每天"
Height = 255
Left = 3000
TabIndex = 15
Top = 2400
Width = 975
End
Begin VB.Label Label9
BackColor = &H00C0C0FF&
Caption = "是否有卫生间:"
Height = 255
Left = 3240
TabIndex = 9
Top = 1920
Width = 1335
End
Begin VB.Label Label8
BackColor = &H00C0C0FF&
Caption = "是否有电视:"
Height = 255
Left = 3240
TabIndex = 8
Top = 1440
Width = 1095
End
Begin VB.Label Label7
BackColor = &H00C0C0FF&
Caption = "是否有电话:"
Height = 255
Left = 3240
TabIndex = 7
Top = 960
Width = 1095
End
Begin VB.Label Label6
BackColor = &H00C0C0FF&
Caption = "是否有空调:"
Height = 255
Left = 3240
TabIndex = 6
Top = 480
Width = 1095
End
Begin VB.Label Label5
BackColor = &H00C0C0FF&
Caption = "住房单价:"
Height = 255
Left = 120
TabIndex = 5
Top = 2640
Width = 975
End
Begin VB.Label Label4
BackColor = &H00C0C0FF&
Caption = "客房数量:"
Height = 255
Left = 120
TabIndex = 4
Top = 2040
Width = 975
End
Begin VB.Label Label3
BackColor = &H00C0C0FF&
Caption = "房间面积:"
Height = 255
Left = 120
TabIndex = 3
Top = 1560
Width = 975
End
Begin VB.Label Label2
BackColor = &H00C0C0FF&
Caption = "标准名称:"
Height = 255
Left = 120
TabIndex = 2
Top = 1080
Width = 975
End
Begin VB.Label Label1
BackColor = &H00C0C0FF&
Caption = "客房标准:"
Height = 255
Index = 0
Left = 120
TabIndex = 1
Top = 480
Width = 975
End
End
End
Attribute VB_Name = "frmRoomtype1"
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 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 MsgText As String
For intCount = 0 To 4
If Trim(txtItem(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "标准编号"
Case 1
sMeg = "标准名称"
Case 2
sMeg = "房间面积"
Case 3
sMeg = "床位数量"
Case 4
sMeg = "床位单价"
End Select
sMeg = sMeg & "不能为空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
For intCount = 2 To 4
If Not IsNumeric(Trim(txtItem(intCount))) Then
Select Case intCount
Case 2
sMeg = "房间面积"
Case 3
sMeg = "床位数量"
Case 4
sMeg = "床位单价"
End Select
sMeg = sMeg & "请输入数字!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
'添加判断是否有相同的ID记录
If gintTmode = 1 Then
txtSQL = "select * from roomtype where typeid='" & Trim(txtItem(0)) & "'"
' cnn.Open connstring
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
MsgBox "已经存在此标准编号的记录!", vbOKOnly + vbExclamation, "警告"
txtItem(0).SetFocus
Exit Sub
End If
mrc.Close
End If
'判断是否有相同内容的记录
txtSQL = "select * from roomtype where typeid<>'" & Trim(txtItem(0)) & "' and typename='" & Trim(txtItem(1)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
MsgBox "已经存在相同物资内容的记录!", vbOKOnly + vbExclamation, "警告"
txtItem(1).SetFocus
Exit Sub
End If
'先删除已有记录
txtSQL = "delete from roomtype where typeid='" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
'再加入新记录
txtSQL = "select * from roomtype"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.AddNew
For intCount = 0 To 3
mrc.Fields(intCount) = Trim(txtItem(intCount))
Next intCount
For intCount = 0 To 3
mrc.Fields(intCount + 4) = Trim(Combol(intCount))
Next intCount
mrc.Fields(8) = Trim(txtItem(4))
mrc.Update
mrc.Close
If gintTmode = 1 Then
MsgBox "添加记录成功!", vbOKOnly + vbExclamation, "添加记录"
For intCount = 0 To 4
txtItem(intCount) = ""
Next intCount
For intCount = 0 To 3
Combol(intCount).ListIndex = 0
Next intCount
mblChange = False
If flagTedit Then
Unload frmRoomtype
frmRoomtype.txtSQL = "select * from roomtype"
frmRoomtype.Show
End If
ElseIf gintTmode = 2 Then
Unload Me
If flagTedit Then
Unload frmRoomtype
End If
frmRoomtype.txtSQL = "select * from roomtype"
frmRoomtype.Show
End If
End Sub
Private Sub Command2_Click()
End Sub
Private Sub Form_Load()
Dim intCount As Integer
Dim MsgText As String
Dim i As Integer
If gintTmode = 1 Then
Me.Caption = Me.Caption & "添加"
For i = 0 To 3
Combol(i).AddItem "是"
Combol(i).AddItem "否"
Combol(i).ListIndex = 0
Next i
ElseIf gintTmode = 2 Then
If flagTedit Then
If frmRoomtype.msgList.Rows > 1 Then
gintTmode = 2
intCount = frmRoomtype.msgList.Row
frmRoomtype1.txtSQL = "select * from roomtype where typeid='" & Trim(frmRoomtype.msgList.TextMatrix(intCount, 1)) & "'"
frmRoomtype1.Show
End If
Else
frmRoomtype.txtSQL = "select * from roomtype"
frmRoomtype.Show
End If
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
With mrc
For intCount = 0 To 3
txtItem(intCount) = .Fields(intCount)
Next intCount
txtItem(4) = .Fields(8)
For i = 0 To 3
Combol(i).AddItem "是"
Combol(i).AddItem "否"
Combol(i).ListIndex = 0
Next i
End With
txtItem(0).Enabled = False
End If
Me.Caption = Me.Caption & "修改"
End If
mblChange = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
gintTmode = 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 + -