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

📄 frmmodel.frm

📁 网路设备资产管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form FrmModel 
   Caption         =   "型号"
   ClientHeight    =   5460
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   6390
   Icon            =   "FrmModel.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   5460
   ScaleWidth      =   6390
   StartUpPosition =   2  '屏幕中心
   Begin VB.Frame Frame1 
      Height          =   2175
      Left            =   120
      TabIndex        =   1
      Top             =   3240
      Width           =   6135
      Begin VB.ComboBox cboDevicetype 
         Height          =   300
         Left            =   960
         Style           =   2  'Dropdown List
         TabIndex        =   9
         Top             =   1680
         Width           =   2175
      End
      Begin VB.ComboBox cboManufacturer 
         Height          =   300
         Left            =   960
         Style           =   2  'Dropdown List
         TabIndex        =   8
         Top             =   1200
         Width           =   2175
      End
      Begin VB.TextBox txtId 
         BackColor       =   &H80000011&
         Enabled         =   0   'False
         Height          =   390
         Left            =   960
         TabIndex        =   3
         Top             =   240
         Width           =   2175
      End
      Begin VB.TextBox txtName 
         Height          =   390
         Left            =   960
         TabIndex        =   2
         Top             =   720
         Width           =   2175
      End
      Begin VB.Label Label5 
         Caption         =   "类型:"
         Height          =   255
         Left            =   240
         TabIndex        =   7
         Top             =   1800
         Width           =   855
      End
      Begin VB.Label Label4 
         Caption         =   "厂商:"
         Height          =   255
         Left            =   240
         TabIndex        =   6
         Top             =   1320
         Width           =   855
      End
      Begin VB.Label Label1 
         Caption         =   "ID:"
         Height          =   255
         Left            =   240
         TabIndex        =   5
         Top             =   360
         Width           =   375
      End
      Begin VB.Label Label3 
         Caption         =   "名称:"
         Height          =   255
         Left            =   240
         TabIndex        =   4
         Top             =   840
         Width           =   855
      End
   End
   Begin MSComctlLib.Toolbar Toolbar1 
      Align           =   1  'Align Top
      Height          =   810
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   6390
      _ExtentX        =   11271
      _ExtentY        =   1429
      ButtonWidth     =   1032
      ButtonHeight    =   1376
      Appearance      =   1
      Style           =   1
      ImageList       =   "ImageList1"
      _Version        =   393216
      BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
         NumButtons      =   5
         BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "新建"
            Key             =   "新建"
            ImageIndex      =   1
         EndProperty
         BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "保存"
            Key             =   "保存"
            ImageIndex      =   2
         EndProperty
         BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "删除"
            Key             =   "删除"
            ImageIndex      =   3
         EndProperty
         BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "关闭"
            Key             =   "关闭"
            ImageIndex      =   4
         EndProperty
      EndProperty
      BorderStyle     =   1
      Begin MSComctlLib.ImageList ImageList1 
         Left            =   4680
         Top             =   120
         _ExtentX        =   1005
         _ExtentY        =   1005
         BackColor       =   -2147483643
         ImageWidth      =   32
         ImageHeight     =   32
         MaskColor       =   12632256
         _Version        =   393216
         BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
            NumListImages   =   4
            BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "FrmModel.frx":08CA
               Key             =   ""
            EndProperty
            BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "FrmModel.frx":11A4
               Key             =   ""
            EndProperty
            BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "FrmModel.frx":1A7E
               Key             =   ""
            EndProperty
            BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "FrmModel.frx":2358
               Key             =   ""
            EndProperty
         EndProperty
      End
   End
   Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
      Height          =   2415
      Left            =   0
      TabIndex        =   10
      Top             =   840
      Width           =   6375
      _ExtentX        =   11245
      _ExtentY        =   4260
      _Version        =   393216
      RowHeightMin    =   315
      WordWrap        =   -1  'True
      HighLight       =   0
      FillStyle       =   1
   End
End
Attribute VB_Name = "FrmModel"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'****************************************************************************
'人人为我,我为人人
'枕善居收藏整理
'发布日期:2007/09/25
'描    述:江苏大学网络信息中心网络管理系统 - v1.0 Beta
'网    站:http://www.Mndsoft.com/  (VB6源码博客)
'网    站:http://www.VbDnet.com/   (VB.NET源码博客,主要基于.NET2005)
'e-mail  :Mndsoft@163.com
'e-mail  :Mndsoft@126.com
'OICQ    :88382850
'          如果您有新的好的代码别忘记给枕善居哦!
'****************************************************************************

Dim txtSQL As String
Dim MsgText As String
Dim HasError As Boolean

Private WithEvents mMSFlexGrid1 As cFlexGridBinder
Attribute mMSFlexGrid1.VB_VarHelpID = -1






Private Sub Form_Load()




Grid_Init
Grid_Fill

    For i = LBound(manufacturers, 2) To UBound(manufacturers, 2)
        cboManufacturer.AddItem manufacturers(0, i) & manufacturers(1, i)
    Next

    For i = LBound(manufacturers, 2) To UBound(manufacturers, 2)
        cboManufacturer.AddItem manufacturers(0, i) & manufacturers(1, i)
    Next


    
    For i = LBound(devicetypes, 2) To UBound(devicetypes, 2)
        cboDevicetype.AddItem devicetypes(0, i) & devicetypes(1, i)
    Next

End Sub

Sub Grid_Init()

    With MSFlexGrid1
        .FormatString = "|<编号|<名称|<厂商|<型号"
        .ColWidth(0) = 0
        .ColWidth(1) = 1000
        .ColWidth(2) = 2000
        .ColWidth(3) = 1500
        .ColWidth(4) = 1500
        .Rows = 1

    End With
    
    Set mMSFlexGrid1 = New cFlexGridBinder
    With mMSFlexGrid1
        Set .Grid = MSFlexGrid1
        
        .Editable = True
        .EditOnMouse = emeNone

        .FullRowSelect = True
        
    End With
    

  

End Sub


Sub Grid_Fill()

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
txtSQL = "select * from tbl_model"

Set rst = ExecuteSQL(txtSQL, MsgText, HasError)

   
   MSFlexGrid1.Rows = 1
    
    Do While Not rst.EOF
        MSFlexGrid1.AddItem vbTab & rst.Fields("model_id") & vbTab & rst.Fields("model_name") & vbTab & rst.Fields("manufacturer_name") & vbTab & rst.Fields("type_name")
    rst.MoveNext
    Loop



    
End Sub



Private Sub MSFlexGrid1_Click()

If mMSFlexGrid1.HighlightedRow = 0 Then
Exit Sub
End If


  txtId.Text = MSFlexGrid1.TextMatrix(mMSFlexGrid1.HighlightedRow, 1)
  txtName.Text = MSFlexGrid1.TextMatrix(mMSFlexGrid1.HighlightedRow, 2)

  For i = 0 To cboManufacturer.ListCount
    If manufacturers(1, i) = MSFlexGrid1.TextMatrix(mMSFlexGrid1.HighlightedRow, 3) Then
      cboManufacturer.ListIndex = i
      Exit For
    End If
  Next
  
  For i = 0 To cboDevicetype.ListCount
    If devicetypes(1, i) = MSFlexGrid1.TextMatrix(mMSFlexGrid1.HighlightedRow, 4) Then
      cboDevicetype.ListIndex = i
      Exit For
    End If
  Next




End Sub





Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    On Error Resume Next
    Select Case Button.key
    
        Case "新建"
          txtId.Text = ""
          txtBh.Text = ""
          txtName.Text = ""
          cboManufacturer.ListIndex = -1
          cboDevicetype.ListIndex = -1
        
        Case "保存"
          If txtId.Text = "" Then
            Set mrc = ExecuteSQL("select top 1 model_id from tbl_model order by model_id desc", MsgText, HasError)
    
            If mrc.EOF = False Then
              newid = CInt(mrc.Fields("model_id")) + 1
              snewid = CStr(newid)
              If Len(snewid) = 1 Then snewid = "0" & snewid
              newid = snewid
            End If
    
            txtSQL = "insert into tbl_model values("
            txtSQL = txtSQL & Quote(newid) & ", "
            txtSQL = txtSQL & Quote(txtName.Text) & ", "
            txtSQL = txtSQL & Quote(manufacturers(0, cboManufacturer.ListIndex)) & ", "
            txtSQL = txtSQL & Quote(manufacturers(1, cboManufacturer.ListIndex)) & ", "
            txtSQL = txtSQL & Quote(devicetypes(0, cboDevicetype.ListIndex)) & ", "
            txtSQL = txtSQL & Quote(devicetypes(1, cboDevicetype.ListIndex))
            txtSQL = txtSQL & ")"
    
             Set mrc = ExecuteSQL(txtSQL, MsgText, HasError)
          Else
            txtSQL = "update tbl_model set "
            txtSQL = txtSQL & " model_name=" & Quote(txtName.Text) & ", "
            txtSQL = txtSQL & " manufacturer_id=" & Quote(manufacturers(0, cboManufacturer.ListIndex)) & ", "
            txtSQL = txtSQL & " manufacturer_name=" & Quote(manufacturers(1, cboManufacturer.ListIndex)) & ", "
            txtSQL = txtSQL & " type_id=" & Quote(devicetypes(0, cboDevicetype.ListIndex)) & ", "
            txtSQL = txtSQL & " type_name=" & Quote(devicetypes(1, cboDevicetype.ListIndex))
            txtSQL = txtSQL & " where model_id =" & Quote(txtId)
    
            Set mrc = ExecuteSQL(txtSQL, MsgText, HasError)
          End If
          
          Grid_Fill
        
        Case "删除"
        
            Set mrc = ExecuteSQL("select top 1 * from tbl_device where model_id = " & Quote(txtId), MsgText, HasError)
    
            If mrc.EOF = False Then
              MsgBox "该型号尚有设备使用,无法删除!", vbOKOnly + vbExclamation, "警告"
              Exit Sub
            End If
            
            
            txtSQL = "delete from tbl_model "
            txtSQL = txtSQL & " where model_id =" & txtId
    
            Set mrc = ExecuteSQL(txtSQL, MsgText, HasError)
            
            Grid_Fill
            
            mMSFlexGrid1.HighlightedRow = 0
            
        Case "关闭"
          Unload Me
          
    End Select
    
End Sub





⌨️ 快捷键说明

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