📄 frmroom.frm
字号:
VERSION 5.00
Begin VB.Form frmRoom
BorderStyle = 1 'Fixed Single
Caption = "机房维护"
ClientHeight = 3915
ClientLeft = 45
ClientTop = 330
ClientWidth = 6765
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 3915
ScaleWidth = 6765
Begin VB.CommandButton cmdSearch
Caption = "查询"
Height = 495
Left = 4320
TabIndex = 9
Top = 2880
Width = 975
End
Begin VB.CommandButton cmdModi
Caption = "修改"
Height = 495
Left = 1680
TabIndex = 8
Top = 2880
Width = 975
End
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 495
Left = 5520
TabIndex = 7
Top = 2880
Width = 975
End
Begin VB.CommandButton cmdDel
Caption = "删除"
Height = 495
Left = 3000
TabIndex = 6
Top = 2880
Width = 975
End
Begin VB.CommandButton cmdAdd
Caption = "添加"
Height = 495
Left = 360
TabIndex = 5
Top = 2880
Width = 975
End
Begin VB.Frame Frame1
Height = 2535
Left = 360
TabIndex = 0
Top = 120
Width = 6015
Begin VB.ComboBox cmbRoom
Height = 315
Left = 1680
Style = 2 'Dropdown List
TabIndex = 4
Top = 720
Width = 735
End
Begin VB.TextBox txtOperator
Appearance = 0 'Flat
Height = 375
Left = 1680
MaxLength = 10
TabIndex = 1
Top = 1440
Width = 1575
End
Begin VB.Label Label1
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "编 号:"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 285
Left = 120
TabIndex = 3
Top = 720
Width = 1275
End
Begin VB.Label Label2
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "管理员:"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 285
Left = 120
TabIndex = 2
Top = 1560
Width = 1260
End
End
End
Attribute VB_Name = "frmRoom"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'为了方便起见,该处的数据库操作均只根据机房号进行查询
Private Sub cmdAdd_Click()
Dim strOperator As String
Dim strName As String
Dim strState As String
strOperator = Trim(Me.txtOperator.Text)
strName = Trim(Me.cmbRoom.Text)
strState = "E"
If Trim(strOperator) = "" Then
MsgBox "请填写机房管理员!"
Me.txtOperator.SetFocus
Exit Sub
End If
If objDBOpt.IsRecordExist("CRoom", "name='" & strName & "'") Then
If MsgBox("机房信息已经存在,覆盖吗?", vbOKCancel) = vbOK Then
If objDBOpt.ModiRecord("CRoom", "Operator", "'" & strOperator & "'", "name='" & strName & "'") Then
MsgBox "数据修改成功!"
Me.txtOperator.Text = ""
Exit Sub
Else
MsgBox "数据修改失败!"
Exit Sub
End If
Else
Exit Sub
End If
Else
If objDBOpt.AddRecord("CRoom", "Name,State,Operator", "'" & strName & "','" & strState & "','" & strOperator & "'") Then
MsgBox "数据添加成功!"
Me.txtOperator.Text = ""
Exit Sub
Else
MsgBox "数据添加失败!"
Exit Sub
End If
End If
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdDel_Click()
Dim strName As String
Dim strCondition As String
If MsgBox("确认删除该数据吗?", vbOKCancel) = vbCancel Then
Exit Sub
End If
strName = Trim(Me.cmbRoom.Text)
strCondition = "Name = '" & strName & "'"
If objDBOpt.DelRecord("CRoom", strCondition) Then
MsgBox "数据删除成功!"
Else
MsgBox "数据删除失败!"
End If
End Sub
Private Sub cmdModi_Click()
Dim strName As String
Dim strOperator As String
strName = Trim(Me.cmbRoom.Text)
strOperator = Trim(Me.txtOperator.Text)
If strOperator = "" Then
MsgBox "请填写机房管理员!"
Me.txtOperator.SetFocus
Exit Sub
End If
If objDBOpt.ModiRecord("CRoom", "Operator", "'" & strOperator & "'", "Name='" & strName & "'") Then
MsgBox "数据修改成功!"
Exit Sub
Else
MsgBox "数据修改失败!"
Exit Sub
End If
End Sub
Private Sub cmdSearch_Click()
Dim rsTmp As ADODB.Recordset
Dim strName As String
Dim strOperator As String
strName = Me.cmbRoom.Text
Set rsTmp = objDBOpt.getRecord("CRoom", "*", "name='" & strName & "'")
If rsTmp Is Nothing Then
MsgBox "数据查询失败"
Exit Sub
Else
If rsTmp.EOF And rsTmp.BOF Then
MsgBox "没有找到符合条件的信息!"
Exit Sub
Else
strOperator = rsTmp.Fields("operator").Value
rsTmp.Close
Me.txtOperator.Text = strOperator
End If
End If
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 65 To 90
Me.cmbRoom.AddItem Chr(i)
Next
Me.cmbRoom.ListIndex = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -