📄 frmcomputeradd.frm
字号:
VERSION 5.00
Begin VB.Form frmAddComputer
BorderStyle = 3 'Fixed Dialog
Caption = "添加计算机信息"
ClientHeight = 4440
ClientLeft = 6345
ClientTop = 2880
ClientWidth = 3735
Icon = "frmComputerAdd.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4440
ScaleWidth = 3735
ShowInTaskbar = 0 'False
Begin VB.Frame FraComputer
Caption = "计算机信息"
Height = 3255
Left = 360
TabIndex = 6
Top = 360
Width = 3015
Begin VB.TextBox txtCPT_ID
Height = 270
Left = 1200
MaxLength = 5
TabIndex = 1
Top = 480
Width = 1455
End
Begin VB.TextBox txtRow
Height = 270
Left = 1200
MaxLength = 2
TabIndex = 2
Top = 960
Width = 1455
End
Begin VB.TextBox txtCPT_Memo
Height = 855
Left = 240
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 4
Top = 2160
Width = 2415
End
Begin VB.TextBox txtTier
Height = 270
Left = 1200
MaxLength = 2
TabIndex = 3
Top = 1440
Width = 1455
End
Begin VB.Label lblCPT_ID
AutoSize = -1 'True
Caption = "计算机ID:"
Height = 180
Left = 240
TabIndex = 10
Top = 480
Width = 900
End
Begin VB.Label lblRow
AutoSize = -1 'True
Caption = "行号:"
Height = 180
Left = 240
TabIndex = 9
Top = 960
Width = 540
End
Begin VB.Label lblTier
AutoSize = -1 'True
Caption = "列号:"
Height = 180
Left = 240
TabIndex = 8
Top = 1440
Width = 540
End
Begin VB.Label lblCPT_Memo
AutoSize = -1 'True
Caption = "计算机描述:"
Height = 180
Left = 240
TabIndex = 7
Top = 1920
Width = 1080
End
End
Begin VB.CommandButton cmdSave
Caption = "保 存"
Height = 375
Left = 1440
TabIndex = 5
Top = 3840
Width = 855
End
Begin VB.CommandButton cmdExit
Caption = "退 出"
Height = 375
Left = 2520
TabIndex = 0
Top = 3840
Width = 855
End
End
Attribute VB_Name = "frmAddComputer"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' ''
''Filename frmAddComputer.frm ''
'' ''
''Created On 2004.2.20 ''
'' ''
''Description 添加计算机信息窗体 ''
'' ''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim rsComputer As Recordset
Dim rsOperateLog As Recordset
Dim rsLog As Recordset
Dim rsCPT_ID As Recordset
Dim rsCPTrow As Recordset
Public strCPT_ID As String
Dim row As Integer, tier As Integer
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdSave_Click()
If Judge = True Then
row = CInt(txtRow.Text)
tier = CInt(txtTier.Text)
Set rsCPTrow = New Recordset
rsCPTrow.Open "select * from tbComputer where Row=" & row & " and Tier=" & tier & "", Modmain.conn, 3, 2
If rsCPTrow.RecordCount <> 0 Then
MsgBox "该位置的计算机已经存在,请重新编写!", vbOKOnly + vbCritical, "机房管理"
txtRow.Text = ""
txtTier.Text = ""
txtRow.SetFocus
ElseIf MsgBox("确实要保存吗?", vbYesNo + vbQuestion, "机房管理") = vbYes Then
SaveInfo
txtCPT_ID.Text = ""
txtRow.Text = ""
txtTier.Text = ""
txtCPT_Memo.Text = ""
txtCPT_ID.SetFocus
End If
End If
End Sub
Private Sub Form_Load()
Set rsComputer = New Recordset
rsComputer.Open "select * from TbComputer", Modmain.conn, 3, 2
End Sub
Private Sub txtCPT_ID_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
End If
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''验证输入的计算机ID是否已经存在,若存在则清空重新编写 ''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub txtCPT_ID_LostFocus()
Set rsCPT_ID = New Recordset
rsCPT_ID.Open "select * from TbComputer where CPT_ID='" & txtCPT_ID.Text & "'", Modmain.conn, 3, 2
If rsCPT_ID.RecordCount <> 0 Then
MsgBox "该计算机ID已存在,请重新编写!", vbOKOnly + vbCritical, "机房管理"
txtCPT_ID.Text = ""
txtCPT_ID.SetFocus
End If
rsCPT_ID.Close
Set rsCPT_ID = Nothing
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''保存新添加的计算机信息 ''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub SaveInfo()
rsComputer.AddNew
strCPT_ID = txtCPT_ID.Text
rsComputer.Fields("CPT_ID") = txtCPT_ID.Text
rsComputer.Fields("ROW") = txtRow.Text
rsComputer.Fields("Tier") = txtTier.Text
rsComputer.Fields("State") = "正常"
If Trim(txtCPT_Memo.Text) <> "" Then
rsComputer.Fields("CPT_Memo") = Trim(txtCPT_Memo.Text)
Else
rsComputer.Fields("CPT_Memo") = ""
End If
rsComputer.Update
AddLog
MsgBox "保存成功", vbOKOnly + vbInformation, "机房管理" '保存完毕并提醒
frmmain.ItgSum = frmmain.ItgSum + 1
frmmain.SbaMain.Panels(3) = "共" & frmmain.ItgSum & "台计算机," & frmmain.ItgUse & "台使用," & CStr(frmmain.ItgSum - frmmain.ItgUse) & "台空闲"
frmComputer.AddItem
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''验证输入的计算机ID、行号,列号是否为空,该位置的计算机是否已经存在,若为空则重新添加 ''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function Judge() As Boolean
If Trim(txtCPT_ID) = "" Then
MsgBox "计算机ID不能为空", vbOKOnly + vbExclamation, "机房管理"
txtCPT_ID.SetFocus
ElseIf Trim(txtRow) = "" Then
MsgBox "行号不能为空", vbOKOnly + vbExclamation, "机房管理"
txtRow.SetFocus
ElseIf Trim(txtTier) = "" Then
MsgBox "列号不能为空", vbOKOnly + vbExclamation, "机房管理"
txtTier.SetFocus
Else
Judge = True
End If
End Function
Private Sub txtRow_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
End If
Dim L As Boolean
L = Chr(KeyAscii) Like "[0-9]" Or KeyAscii = 8
If L = False Then
KeyAscii = 0
End If
End Sub
Private Sub txtTier_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
End If
Dim L As Boolean
L = Chr(KeyAscii) Like "[0-9]" Or KeyAscii = 8
If L = False Then
KeyAscii = 0
End If
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''将用户添加计算机的信息记入操作日志 ''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub AddLog()
Dim strEvents As String
Dim strTemp As String
strTemp = "'"
Set rsOperateLog = New Recordset
rsOperateLog.Open "select * from tbOperateLog", Modmain.conn, 3, 2
Set rsLog = New Recordset
rsLog.Open "select * from tblog where L_ID='L04'", Modmain.conn, 3, 2
strEvents = rsLog.Fields!Events
rsOperateLog.AddNew
rsOperateLog.Fields!U_ID = frmLoad.StrU_ID
rsOperateLog.Fields!Time = Time
rsOperateLog.Fields!Date = Date
rsOperateLog.Fields!Events = strEvents
rsOperateLog.Fields!Description = strEvents & strTemp & txtCPT_ID.Text & strTemp
rsOperateLog.Update
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -