📄 fmroominfo.frm
字号:
Top = 600
Width = 1815
End
Begin VB.ComboBox CombRType
DataField = "RoomTypeName"
DataSource = "Adodc1"
Height = 300
ItemData = "FMRoomInfo.frx":004A
Left = 2040
List = "FMRoomInfo.frx":005A
TabIndex = 6
Top = 1080
Width = 1815
End
Begin VB.ComboBox CombMoney
DataField = "RoomPrice"
DataSource = "Adodc1"
Height = 300
ItemData = "FMRoomInfo.frx":0077
Left = 6240
List = "FMRoomInfo.frx":0087
TabIndex = 5
Top = 1080
Width = 1815
End
Begin VB.Label Label2
Caption = "房台名称:"
Height = 375
Left = 4800
TabIndex = 13
Top = 600
Width = 1335
End
Begin VB.Label Label1
Caption = "房台编号:"
Height = 375
Left = 840
TabIndex = 12
Top = 600
Width = 975
End
Begin VB.Label Label3
Caption = "房台类型:"
Height = 375
Left = 840
TabIndex = 9
Top = 1140
Width = 975
End
Begin VB.Label Label5
Caption = "房态:"
Height = 375
Left = 840
TabIndex = 8
Top = 1680
Width = 975
End
Begin VB.Label Label4
Caption = "价格:"
Height = 375
Left = 4800
TabIndex = 7
Top = 1200
Width = 1095
End
End
End
Attribute VB_Name = "FMRoomInfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'Private Sub CombRType_Change()
'Dim rsRooType As New ADODB.Recordset
'Dim strSQL As String
'Dim strType As String
'Dim i As Integer
'strSQL = "select RoomTypeID from RoomType "
'rsRoomType.Open strSQL, g_DBConn, adOpenForwardOnly, adLockOptimistic
'Set rsRoomType = g_DBConn.Execute(strSQL)
'i = rsRoomType.RecordCount
'
'rsRoomType.MoveFirst
'For i = 1 To rsRoomType.RecordCount
'strType = rsRoomType.Field("RoomTypeID").Value
'Me.CombRType.AddItem strType
'rsRoomType.MoveNext
'Next i
'End Sub
Private Sub Command1_Click()
Dim AddInfo As New ADODB.Recordset
Dim SqlStr As String
Dim DBStr As String
Dim sRoomID As String
Dim sRoomName As String
Dim sRoomTypeName As String
Dim dRoomPrice As Double
Dim sRoomState As String
If Me.TextRID.Text = "" Then
MsgBox "清输入房台编号!"
Exit Sub
End If
sRoomID = Replace(Trim(Me.TextRID.Text), "'", "''")
sRoomName = Replace(Trim(Me.TextRName.Text), "'", ",,")
sRoomTypeName = Trim(Me.CombRType.Text)
dRoomPrice = Trim(Me.CombMoney.Text)
If Me.CombRState.Text = "" Then
MsgBox "请输入房间状态!"
Exit Sub
End If
sRoomState = Trim(Me.CombRState.Text)
DBStr = "select * from RoomInfo where RoomID='" & sRoomID & "'"
AddInfo.Open DBStr, g_DBConn, adOpenForwardOnly, adLockOptimistic
If Not AddInfo.BOF Then
MsgBox "该房间编号已存在!"
AddInfo.Close
Exit Sub
End If
AddInfo.Close
DBStr = "select * from RoomInfo where " & "RoomName='" & Replace(sRoomName, "'", "''") & "'"
AddInfo.Open DBStr, g_DBConn, adOpenForwardOnly, adLockOptimistic
If Not AddInfo.BOF Then
MsgBox "该房间名称已存在!"
AddInfo.Close
Exit Sub
End If
AddInfo.Close
SqlStr = "insert into RoomInfo(RoomID,RoomName,RoomTypeName," & "RoomPrice,RoomState) values('" & sRoomID & "'," & "'" & sRoomName & "','" & sRoomTypeName & "'," & "'" & dRoomPrice & "','" & sRoomState & "');"
g_DBConn.Execute SqlStr
MsgBox "添加成功!"
Me.TextRID.Text = ""
Me.TextRName.Text = ""
Adodc1.Refresh
End Sub
Private Sub Command2_Click()
Dim ModRInfo As New ADODB.Recordset
Dim DBStr As String
Dim sRoomID As String
Dim sRoomName As String
Dim sRoomTypeName As String
Dim dRoomPrice As Double
Dim sRoomState As String
Dim SqlStr As String
sRoomID = Trim(Me.TextRID.Text)
If Me.TextRID.Text = "" Then
MsgBox "为空!"
Exit Sub
End If
sRoomName = Trim(Me.TextRName.Text)
If Me.CombRType.Text = "" Then
MsgBox "为空!"
Exit Sub
End If
sRoomTypeName = Trim(Me.CombRType.Text)
If Me.CombMoney.Text = "" Then
MsgBox "为空!"
Exit Sub
End If
dRoomPrice = Trim(Me.CombMoney.Text)
If Me.CombRState.Text = "" Then
MsgBox "为空!"
Exit Sub
End If
sRoomState = Trim(Me.CombRState.Text)
DBStr = "select * from RoomInfo where RoomID='" & sRoomID & "'"
ModRInfo.Open DBStr, g_DBConn, adOpenStatic, adLockOptimistic
If ModRInfo.RecordCount = 0 Then
MsgBox "该房间不存在!"
ModRInfo.Close
Exit Sub
End If
ModRInfo.Close
SqlStr = "update RoomInfo set RoomName='" & sRoomName & "'" & ",RoomTypeName='" & sRoomTypeName & "'" & ",RoomPrice='" & dRoomPrice & "'" & ",RoomState='" & sRoomState & "'" & "where RoomID='" & sRoomID & "'"
g_DBConn.Execute SqlStr
MsgBox "修改成功!"
Adodc1.Refresh
End Sub
Private Sub Command3_Click()
If Me.DataGrid1.Row = 0 Then
DLCancelRoom.Show
Else
Me.Adodc1.Recordset.Delete
MsgBox "删除成功!"
Adodc1.Refresh
End If
End Sub
Private Sub Command5_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.Top = (Screen.Height - Me.Height) / 2 '垂直方向居中
Me.Left = (Screen.Width - Me.Height) / 2 '水平方向居中
If g_LoginedUser.Type = Role_User Then
Me.Command1.Enabled = False
Me.Command2.Enabled = False
Me.Command3.Enabled = False
End If
'设置Adodc连接字符串
Adodc1.ConnectionString = g_ConnStr
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "RoomInfo"
'设置Grid 与 Adodc1关联
Set DataGrid1.DataSource = Adodc1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -