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

📄 frmdeviceregister.frm

📁 网路设备资产管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
        
    End With

End Sub

Private Sub mMSFlexGrid1_ValidateEdit(ByVal Row As Long, ByVal col As Long, NewData As Variant, Cancel As Boolean)
    '#############################################################################################################################
    'This Event is fired to validate an Edit before it is accepted. Set Cancel to True
    'to reject the Edit
    '#############################################################################################################################
  
    
        If col = COL_NETCENTER_ID Then
        
         ''''''''''''''''''''''''''''''''''
          If Len(NewData) <> 9 Then
             MsgBox "中心编码必须为9位!", vbOKOnly + vbExclamation, "警告"
             Cancel = True
            Exit Sub
          Else
          
         
          
            Set mrc = ExecuteSQL("select * from tbl_device where netcenter_id = '" & Trim(NewData) & "'", MsgText, HasError)
    
            If mrc.EOF = False Then
                MsgBox "该中心编码的设备已经存在了!", vbOKOnly + vbExclamation, "警告"
                Cancel = True
                Exit Sub
            End If
    
            '到此为止中心编号经认证,还未入库,下面首先自动调出其厂商等属性
            txtTypeId = Mid$(NewData, 1, 1)
            txtManufacturerId = Mid$(NewData, 2, 2)
            txtModelId = Mid$(NewData, 4, 2)
            txtManufacturerName = ""
            txtModelName = ""
            txtTypeName = ""

           For i = LBound(manufacturers, 2) To UBound(manufacturers, 2)
            If manufacturers(0, i) = txtManufacturerId Then
              txtManufacturerName = manufacturers(1, i)
              Exit For
            End If
           Next
   
           For i = LBound(models, 2) To UBound(models, 2)
            If models(0, i) = txtModelId Then
              txtModelName = models(1, i)
              Exit For
            End If
           Next
   
           For i = LBound(devicetypes, 2) To UBound(devicetypes, 2)
            If devicetypes(0, i) = txtTypeId Then
              txtTypeName = devicetypes(1, i)
              Exit For
            End If
           Next
           
            If txtManufacturerName = "" Or txtModelName = "" Or txtTypeName = "" Then
                MsgBox "该中心编码错误!", vbOKOnly + vbExclamation, "警告"
                Cancel = True
                Exit Sub
            End If
            
          End If
            
            ''''''''''''''''''''''''''''''
        

        ElseIf col = 3 Then
        
          'If Trim(NewData) = "" Then
          '   MsgBox "固定资产号不能为空!", vbOKOnly + vbExclamation, "警告"
          '   Cancel = True
          '  Exit Sub
          'End If
        
        ElseIf col = 10 Then
        
          If Trim(NewData) = "" Then
             MsgBox "SN号不能为空!", vbOKOnly + vbExclamation, "警告"
             Cancel = True
            Exit Sub
          End If
          
        End If
        
        
 
    
    Cancel = False
End Sub

Private Sub mMSFlexGrid1_AfterEdit(ByVal Row As Long, ByVal col As Long)
    '#############################################################################################################################
    'This Event is fired after a ValidateEdit Event is accepted
    '#############################################################################################################################

    With MSFlexGrid1
        If col = COL_NETCENTER_ID Then
        

          
          ''''''''''''''''''''''''''''''''''

    
            '到此为止中心编号经认证,还未入库,下面首先自动调出其厂商等属性

            
            .TextMatrix(Row, 4) = txtModelId
            .TextMatrix(Row, 5) = txtModelName
            .TextMatrix(Row, 6) = txtManufacturerId
            .TextMatrix(Row, 7) = txtManufacturerName
            .TextMatrix(Row, 8) = txtTypeId
            .TextMatrix(Row, 9) = txtTypeName
            
 
   
            ''''''''''''''''''''''''''''''

          
        Else
        

        
        End If
        
    End With
End Sub


Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)

    Select Case Button.key
        Case "保存"
'''''''''''''''''''''''''''''''''''''''''
If Trim(txtDesc.Text) = "" Then
         MsgBox "必须输入内容!", vbOKOnly + vbExclamation, "警告"
        txtDesc.SetFocus
        Exit Sub
End If


If Trim(txtApplicant.Text) = "" Then
         MsgBox "必须输入申请人", vbOKOnly + vbExclamation, "警告"
        txtApplicant.SetFocus
        Exit Sub
End If

If Trim(txtTransactor.Text) = "" Then
         MsgBox "必须输入经办人", vbOKOnly + vbExclamation, "警告"
        txtTransactor.SetFocus
        Exit Sub
End If


If MSFlexGrid1.Rows = 1 Then
         MsgBox "必须添加登记的设备", vbOKOnly + vbExclamation, "警告"
        Exit Sub
End If

'对所有的items进行有校检查

For i = 1 To MSFlexGrid1.Rows - 1

If Trim(MSFlexGrid1.TextMatrix(i, 2)) = "" Then
         MsgBox "第" & MSFlexGrid1.TextMatrix(i, 1) & "行的设备必须输入中心编号", vbOKOnly + vbExclamation, "警告"
        Exit Sub
End If

'If Trim(MSFlexGrid1.TextMatrix(i, 3)) = "" Then
'         MsgBox "第" & MSFlexGrid1.TextMatrix(i, 1) & "行的设备必须输入固定资产号", vbOKOnly + vbExclamation, "警告"
'        Exit Sub
'End If

If Trim(MSFlexGrid1.TextMatrix(i, 10)) = "" Then
         MsgBox "第" & MSFlexGrid1.TextMatrix(i, 1) & "行的设备必须输入SN号", vbOKOnly + vbExclamation, "警告"
        Exit Sub
End If

If Trim(MSFlexGrid1.TextMatrix(i, 5)) = "" Or Trim(MSFlexGrid1.TextMatrix(i, 7)) = "" Or Trim(MSFlexGrid1.TextMatrix(i, 9)) = "" Then
         MsgBox "第" & MSFlexGrid1.TextMatrix(i, 1) & "行的设备的中心编号错误", vbOKOnly + vbExclamation, "警告"
        Exit Sub
End If
   
Next


'''''''''''''''''''''''''''''
  '下面开始保存记录
  On Error GoTo ErrorHandler
  BeginTrans
   
   '1 保存入库单
    Set mrc = ExecuteSQL("select top 1 register_id from tbl_device_register order by register_id desc", MsgText, HasError)
    
    If mrc.EOF = False Then
         oldid = Val(mrc.Fields("register_id"))
         oldid = oldid + 1
         snewid = Trim(str(oldid))
         If Len(snewid) = 1 Then snewid = "0000000" & snewid
         If Len(snewid) = 2 Then snewid = "000000" & snewid
         If Len(snewid) = 3 Then snewid = "00000" & snewid
         If Len(snewid) = 4 Then snewid = "0000" & snewid
         If Len(snewid) = 5 Then snewid = "000" & snewid
         If Len(snewid) = 6 Then snewid = "00" & snewid
         If Len(snewid) = 7 Then snewid = "0" & snewid
        newregister_id = snewid
    Else
        newregister_id = "00000001"
    End If
    
    txtSQL = "insert into tbl_device_register values('"
   txtSQL = txtSQL & newregister_id & "','"
   txtSQL = txtSQL & Trim(txtDesc) & "','"
   txtSQL = txtSQL & Trim(txtApplicant) & "','"
   txtSQL = txtSQL & Trim(txtTransactor) & "','"
   txtSQL = txtSQL & Trim(ymdDjrq.FormatDate) & "','"
   txtSQL = txtSQL & Trim(txtBuyrq) & "'"
   txtSQL = txtSQL & ")"
    
    Set mrc = ExecuteSQL(txtSQL, MsgText, HasError)
    
    
    
For i = 1 To MSFlexGrid1.Rows - 1

    
   
   '1 保存设备
   
    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 & newdevice_id & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 2)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 3)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 4)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 5)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 6)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 7)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 8)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 9)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 10)) & "',"
   txtSQL = txtSQL & "0,'',0,'',0,'','"
   txtSQL = txtSQL & Trim("在库") & "','','" & txtBuyrq & "'"
   txtSQL = txtSQL & ",'')"
    
    Set mrc = ExecuteSQL(txtSQL, MsgText, HasError)
    

   '2 保存设备日志
    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("登记入库,登记单号:" & newregister_id) & "','"
   txtSQL = txtSQL & Trim(txtApplicant) & "','"
   txtSQL = txtSQL & Trim(txtTransactor) & "','"
   txtSQL = txtSQL & Trim(ymdDjrq.FormatDate) & "'"
   txtSQL = txtSQL & ")"
    
    Set mrc = ExecuteSQL(txtSQL, MsgText, HasError)

   '3 保存items
     txtSQL = "insert into tbl_device_register_items values('"
   txtSQL = txtSQL & newregister_id & "','"
   txtSQL = txtSQL & i & "','"
   txtSQL = txtSQL & newdevice_id & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 2)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 3)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 4)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 5)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 6)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 7)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 8)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 9)) & "','"
   txtSQL = txtSQL & Trim(MSFlexGrid1.TextMatrix(i, 10)) & "'"
   txtSQL = txtSQL & ")"
    
    Set mrc = ExecuteSQL(txtSQL, MsgText, HasError)
  
 Next
 
  
  CommitTrans

ErrorHandler:

'Handle Error
If Err.Number <> 0 Or HasError Then
  RollbackTrans
  If vbOK = MsgBox("保存过程中发生错误,您是否要查看错误的详细信息?", vbOKCancel + vbExclamation + vbDefaultButton2, "警告") Then
     FrmError.error = Err.Description
     FrmError.sql = txtSQL
     FrmError.msg = MsgText
     FrmError.Show
  End If
Else
  
  FrmDeviceRegisterList.Grid_Fill
  
  Unload Me
  
End If
'''''''''''''''''''''''''''''''''''''''
        Case "添加设备"
        
        
        
        MSFlexGrid1.AddItem vbTab _
        & MSFlexGrid1.Rows & vbTab _
        & "" & vbTab _
        & "" & vbTab _
        & "" & vbTab _
        & "" & vbTab _
        & "" & vbTab _
        & "" & vbTab _
        & "" & vbTab _
        & "" & vbTab _
        & ""
            
        Case "删除设备"

        If MSFlexGrid1.Rows > 2 Then
          
          MSFlexGrid1.RemoveItem (MSFlexGrid1.Row)


          For i = 1 To MSFlexGrid1.Rows - 1

            MSFlexGrid1.TextMatrix(i, 1) = i

          Next
        
        ElseIf MSFlexGrid1.Rows = 2 Then
           MSFlexGrid1.Rows = 1
        End If
            
        Case "关闭"
          Unload Me
          
    End Select
    
End Sub


⌨️ 快捷键说明

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