⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmdevicedetail.frm

📁 网路设备资产管理系统
💻 FRM
📖 第 1 页 / 共 3 页
字号:
    
            Do While Not rst.EOF
             cboRoom.AddItem rst.Fields("room_name")
             rst.MoveNext
            Loop
          End If
          cboRoom.Text = ""
          txtRoomId.Text = ""
End Sub

Private Sub cboRoom_Click()

If cur_priv_sbzlxg = False Then
  Exit Sub
End If

          Set rst = ExecuteSQL("select * from tbl_room where area_id = " & txtAreaId & " and building_id = " & txtBuildingId & " and room_name='" & cboRoom & "'", MsgText, HasError)
          If rst.EOF = False Then
          txtRoomId = rst.Fields("room_id")
          End If
End Sub


Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    On Error Resume Next
    Select Case Button.key
    
        Case "保存"
        
          If Len(txtNetcenterId) <> 9 Then
             MsgBox "中心编码必须为9位!", vbOKOnly + vbExclamation, "警告"
             txtNetcenterId.SetFocus
            Exit Sub
          End If

         If Trim(txtModel) = "" Then
           MsgBox "设备型号不能为空,可能是由于您的中心编号不正确!", vbOKOnly + vbExclamation, "警告"
           txtModel.SetFocus
          Exit Sub
         End If
         
         If Trim(txtManufacturer) = "" Then
           MsgBox "厂商不能为空,可能是由于您的中心编号不正确!", vbOKOnly + vbExclamation, "警告"
           txtManufacturer.SetFocus
          Exit Sub
         End If
         
         If Trim(txtType) = "" Then
           MsgBox "设备类型不能为空,可能是由于您的中心编号不正确!", vbOKOnly + vbExclamation, "警告"
           txtType.SetFocus
          Exit Sub
         End If
         
         If Trim(cboArea) = "" And cboState = "在库" Then
           MsgBox "校区不能为空!", vbOKOnly + vbExclamation, "警告"
           cboArea.SetFocus
          Exit Sub
         End If
         
         If Trim(cboBuilding) = "" And cboState = "在库" Then
           MsgBox "楼栋不能为空!", vbOKOnly + vbExclamation, "警告"
           cboBuilding.SetFocus
          Exit Sub
         End If
         
         If Trim(cboRoom) = "" And cboState = "在库" Then
           MsgBox "房间不能为空!", vbOKOnly + vbExclamation, "警告"
           cboRoom.SetFocus
          Exit Sub
         End If
        
    

'保存
If device_id > 0 Then


            

            txtSQL = "update tbl_device set "
            txtSQL = txtSQL & " netcenter_id=" & Quote(txtNetcenterId.Text)
            txtSQL = txtSQL & ", property_id=" & Quote(txtPropertyId.Text)
            txtSQL = txtSQL & ", model_id=" & Quote(txtModelId.Text)
            txtSQL = txtSQL & ", model_name=" & Quote(txtModel.Text)
            txtSQL = txtSQL & ", manufacturer_id=" & Quote(txtManufacturerId.Text)
            txtSQL = txtSQL & ", manufacturer_name=" & Quote(txtManufacturer.Text)
            txtSQL = txtSQL & ", type_id=" & Quote(txtTypeId.Text)
            txtSQL = txtSQL & ", type_name=" & Quote(txtType.Text)
            txtSQL = txtSQL & ", memo=" & Quote(txtMemo.Text)
            txtSQL = txtSQL & ", state=" & Quote(cboState.Text)
            txtSQL = txtSQL & ", area_id=" & Quote(txtAreaId.Text)
            txtSQL = txtSQL & ", area_name=" & Quote(cboArea.Text)
            txtSQL = txtSQL & ", building_id=" & Quote(txtBuildingId.Text)
            txtSQL = txtSQL & ", building_name=" & Quote(cboBuilding.Text)
            txtSQL = txtSQL & ", room_id=" & Quote(txtRoomId.Text)
            txtSQL = txtSQL & ", room_name=" & Quote(cboRoom.Text)
            txtSQL = txtSQL & ", sn=" & Quote(txtSN.Text)
            txtSQL = txtSQL & ", buyrq=" & Quote(txtBuyrq.Text)
            txtSQL = txtSQL & " where device_id =" & Quote(device_id)
    
            Set mrc = ExecuteSQL(txtSQL, MsgText, HasError)
            
             '记录日志
            Set mrc = ExecuteSQL("select top 1 log_id from tbl_device_log order by log_id desc", MsgText, HasError)
    
            If mrc.EOF = False Then
                newlog_id = mrc.Fields("log_id") + 1
            Else
                newlog_id = 1
            End If
    
           txtSQL = "insert into tbl_device_log values('"
           txtSQL = txtSQL & newlog_id & "','"
           txtSQL = txtSQL & Trim(device_id) & "','"
           txtSQL = txtSQL & Trim("修改设备属性") & "','"
           txtSQL = txtSQL & Trim(cur_truename) & "','"
           txtSQL = txtSQL & Trim("") & "','"
           txtSQL = txtSQL & Trim(Year(Now()) & "-" & Month(Now()) & "-" & Day(Now())) & "'"
           txtSQL = txtSQL & ")"
    
           Set mrc = ExecuteSQL(txtSQL, MsgText, HasError)

           MsgBox "设备属性保存成功!", vbOKOnly + vbInformation, "提示"
            
           Grid_Init
           Grid_Fill
            
'新建
Else

    Set mrc = ExecuteSQL("select top 1 device_id from tbl_device order by device_id desc", MsgText, HasError)
    
    If mrc.EOF = False Then
        newdevice_id = mrc.Fields("device_id") + 1
    Else
        newdevice_id = 1
    End If
    
   txtSQL = "insert into tbl_device values("
   txtSQL = txtSQL & Quote(newdevice_id) & ","
   txtSQL = txtSQL & Quote(txtNetcenterId.Text) & ","
   txtSQL = txtSQL & Quote(txtPropertyId.Text) & ","
   txtSQL = txtSQL & Quote(txtModelId.Text) & ","
   txtSQL = txtSQL & Quote(txtModel.Text) & ","
   txtSQL = txtSQL & Quote(txtManufacturerId.Text) & ","
   txtSQL = txtSQL & Quote(txtManufacturer.Text) & ","
   txtSQL = txtSQL & Quote(txtTypeId.Text) & ","
   txtSQL = txtSQL & Quote(txtType.Text) & ","
   txtSQL = txtSQL & Quote(txtSN.Text) & ","
   
   txtSQL = txtSQL & Quote(txtAreaId.Text) & ","
   txtSQL = txtSQL & Quote(cboArea.Text) & ","
   txtSQL = txtSQL & Quote(txtBuildingId.Text) & ","
   txtSQL = txtSQL & Quote(cboBuilding.Text) & ","
   txtSQL = txtSQL & Quote(txtRoomId.Text) & ","
   txtSQL = txtSQL & Quote(cboRoom.Text) & ","

   txtSQL = txtSQL & Quote(cboState.Text) & ","
   txtSQL = txtSQL & Quote(txtIp.Text) & ","
   txtSQL = txtSQL & Quote(txtBuyrq.Text) & ","
   txtSQL = txtSQL & Quote(txtMemo.Text)
   txtSQL = txtSQL & ")"
    
    Set mrc = ExecuteSQL(txtSQL, MsgText, HasError)
    
    MsgBox "设备添加成功!", vbOKOnly + vbInformation, "提示"
    
              '记录日志
    Set mrc = ExecuteSQL("select top 1 log_id from tbl_device_log order by log_id desc", MsgText, HasError)
    
    If mrc.EOF = False Then
        newlog_id = mrc.Fields("log_id") + 1
    Else
        newlog_id = 1
    End If
    
    txtSQL = "insert into tbl_device_log values('"
   txtSQL = txtSQL & newlog_id & "','"
   txtSQL = txtSQL & Trim(newdevice_id) & "','"
   txtSQL = txtSQL & Trim("添加新设备") & "','"
   txtSQL = txtSQL & Trim(cur_truename) & "','"
   txtSQL = txtSQL & Trim("") & "','"
   txtSQL = txtSQL & Trim(Year(Now()) & "-" & Month(Now()) & "-" & Day(Now())) & "'"
   txtSQL = txtSQL & ")"
    
    Set mrc = ExecuteSQL(txtSQL, MsgText, HasError)


            
    device_id = newdevice_id
    
      Grid_Init
      Grid_Fill
    
End If

        Case "删除"
        
         If device_id > 0 Then
        
            txtSQL = "delete from tbl_device "
            txtSQL = txtSQL & " where device_id =" & device_id
    
            Set mrc = ExecuteSQL(txtSQL, MsgText, HasError)
            
            txtSQL = "delete from tbl_device_log "
            txtSQL = txtSQL & " where device_id =" & device_id
    
            Set mrc = ExecuteSQL(txtSQL, MsgText, HasError)
            
            MsgBox "设备删除成功!", vbOKOnly + vbInformation, "提示"
            Unload Me
            
         End If
            
        Case "关闭"
          Unload Me
          
    End Select
End Sub



Private Sub cmdSaveIP_Click()
  If device_id <= 0 Then
    MsgBox "请先保存设备!", vbOKOnly + vbInformation, "提示"
    Exit Sub
  End If

            txtSQL = "update tbl_device set "
            txtSQL = txtSQL & ", ip=" & Quote(txtIp.Text)
            txtSQL = txtSQL & " where device_id =" & Quote(device_id)
    
            Set mrc = ExecuteSQL(txtSQL, MsgText, HasError)

            MsgBox "IP保存成功!", vbOKOnly + vbInformation, "提示"
End Sub

Private Sub cmdTelnet_Click()
  Shell ("telnet " & txtIp)
End Sub

Private Sub txtNetcenterId_LostFocus()

If cur_priv_sbzlxg = False Then
  Exit Sub
End If


          If Len(txtNetcenterId) <> 9 Then
             MsgBox "中心编码必须为9位!", vbOKOnly + vbExclamation, "警告"
             txtNetcenterId.SetFocus
             
            Exit Sub
          End If
          
          
If device_id > 0 Then

  If txtNetcenterId <> txtOldNetcenterId Then

           

              Set mrc = ExecuteSQL("select * from tbl_device where netcenter_id = '" & Trim(txtNetcenterId.Text) & "'", MsgText, HasError)
    
              If mrc.EOF = False Then
                MsgBox "您修改了中心编号,但该编号的设备已经存在于设备库中,请使用其它的编号!", vbOKOnly + vbExclamation, "警告"
                txtNetcenterId.SetFocus
                Exit Sub
              End If
            
            
  
          
  End If
  
  
Else

              Set mrc = ExecuteSQL("select * from tbl_device where netcenter_id = '" & Trim(txtNetcenterId.Text) & "'", MsgText, HasError)
              If mrc.EOF = False Then
                MsgBox "该编号的设备已经存在于设备库中,请使用其它的编号!", vbOKOnly + vbExclamation, "警告"
                txtNetcenterId.SetFocus
                Exit Sub
              End If


End If

            '到此为止中心编号经认证,还未入库,下面首先自动调出其厂商等属性
            txtTypeId = Mid$(txtNetcenterId, 1, 1)
            txtManufacturerId = Mid$(txtNetcenterId, 2, 2)
            txtModelId = Mid$(txtNetcenterId, 4, 2)
            txtManufacturer = ""
            txtModel = ""
            txtType = ""

           For i = LBound(manufacturers, 2) To UBound(manufacturers, 2)
            If manufacturers(0, i) = txtManufacturerId Then
              txtManufacturer = manufacturers(1, i)
              Exit For
            End If
           Next
   
           For i = LBound(models, 2) To UBound(models, 2)
            If models(0, i) = txtModelId Then
              txtModel = models(1, i)
              Exit For
            End If
           Next
   
           For i = LBound(devicetypes, 2) To UBound(devicetypes, 2)
            If devicetypes(0, i) = txtTypeId Then
              txtType = devicetypes(1, i)
              Exit For
            End If
           Next
           
            If txtManufacturer = "" Or txtModel = "" Or txtType = "" Then
                MsgBox "该中心编码错误!", vbOKOnly + vbExclamation, "警告"
                txtNetcenterId.SetFocus
                Exit Sub
            End If

End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -