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

📄 frmconfig.frm

📁 一个vb编的计算机机房管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmconfig 
   BorderStyle     =   4  'Fixed ToolWindow
   Caption         =   "配置设置"
   ClientHeight    =   4305
   ClientLeft      =   45
   ClientTop       =   315
   ClientWidth     =   6915
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4305
   ScaleWidth      =   6915
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton cmdadditem 
      Appearance      =   0  'Flat
      Caption         =   "添加配置项"
      Height          =   735
      Left            =   5760
      TabIndex        =   8
      Top             =   240
      Width           =   1095
   End
   Begin VB.CommandButton cmdquery 
      Caption         =   "查询"
      Height          =   375
      Left            =   5760
      TabIndex        =   2
      Top             =   2400
      Width           =   1095
   End
   Begin VB.CommandButton cmdback 
      Caption         =   "返回"
      Height          =   375
      Left            =   5760
      TabIndex        =   4
      Top             =   3840
      Width           =   1095
   End
   Begin VB.CommandButton cmdmodify 
      Caption         =   "修改"
      Height          =   375
      Left            =   5760
      TabIndex        =   3
      Top             =   3120
      Width           =   1095
   End
   Begin VB.CommandButton cmdadd 
      Caption         =   "添加"
      Height          =   375
      Left            =   5760
      TabIndex        =   1
      Top             =   1680
      Width           =   1095
   End
   Begin VB.Frame FrameConfig 
      Caption         =   "配置"
      Height          =   4215
      Left            =   120
      TabIndex        =   0
      Top             =   0
      Width           =   5535
      Begin VB.VScrollBar VScroll 
         Height          =   4095
         Left            =   5280
         TabIndex        =   7
         Top             =   120
         Width           =   255
      End
      Begin VB.TextBox txt 
         Height          =   270
         Index           =   0
         Left            =   1320
         TabIndex        =   6
         Top             =   240
         Width           =   3855
      End
      Begin VB.Label lb 
         AutoSize        =   -1  'True
         Caption         =   "编号:"
         Height          =   180
         Index           =   0
         Left            =   240
         TabIndex        =   5
         Top             =   280
         Width           =   450
      End
   End
End
Attribute VB_Name = "frmconfig"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim i, VScrollValue, ublb, MinConfigid

Private Sub cmdAdd_Click()
 If cmdAdd.Caption = "添加" Then
    Me.cmdmodify.Enabled = False
    Me.cmdquery.Enabled = False
    Me.cmdadditem.Visible = True
    Me.cmdAdd.Caption = "提交"
    Me.txt(1).SetFocus
    FrameConfig.Caption = "编号:" & MinConfigid
    Form_Init
 Else
  Me.cmdmodify.Enabled = True
  Me.cmdadditem.Visible = False
  Me.cmdquery.Enabled = True
  Me.cmdAdd.Caption = "添加"
  Connect "w"
  sqlstr = "select configid from config where configid='" & MinConfigid & "'"
  rs.Open sqlstr
  If rs.EOF = False Then
   sqlstr = "update config set "
   For i = 1 To ublb - 1
    sqlstr = sqlstr & lb(i).Caption & " = '" & txt(i).Text & "',"
   Next
   sqlstr = Left(sqlstr, Len(sqlstr) - 1)
   sqlstr = sqlstr & " where configid='" & MinConfigid & "'"
  Else
   sqlstr = "insert into config values(" & MinConfigid & ","
   For i = 1 To ublb - 1
    sqlstr = sqlstr & "'" & Trim(txt(i).Text) & "',"
   Next
   sqlstr = Left(sqlstr, Len(sqlstr) - 1)
   sqlstr = sqlstr & ")"
  End If
  Connect "w"
  com.CommandText = sqlstr
  com.Execute
  Disconnect
  MsgBox "提交成功"
 End If
End Sub

Private Sub cmdadditem_Click()
Dim configitem As String
configitem = InputBox("添加配置项")
If configitem <> "" Then
 sqlstr = "alter table config add " & configitem & " varchar(30)"
 Connect "w"
 com.CommandText = sqlstr
 com.Execute
 Disconnect
 Load lb(ublb)
 Load txt(ublb)
 lb(ublb).Caption = configitem
 lb(ublb).Top = lb(ublb - 1).Top + 500
 lb(ublb).Left = lb(ublb - 1).Left
 txt(ublb).Top = txt(ublb - 1).Top + 500
 txt(ublb).Left = txt(ublb - 1).Left
 lb(ublb).Visible = True
 txt(ublb).Visible = True
 ublb = ublb + 1
 frmconfig.FrameConfig.Refresh
End If
End Sub

Private Sub cmdback_Click()
 If Me.cmdAdd.Caption = "提交" Then
  Me.cmdmodify.Enabled = True
  Me.cmdquery.Enabled = True
  Me.cmdAdd.Caption = "添加"
 ElseIf Me.cmdmodify.Caption = "提交" Then
  Me.cmdAdd.Enabled = True
  Me.cmdmodify.Caption = "修改"
  Me.cmdquery.Enabled = True
 Else
  Unload Me
 End If
End Sub

Private Sub cmdmodify_Click()
If cmdmodify.Caption = "修改" Then
 Me.cmdAdd.Enabled = False
 Me.cmdquery.Enabled = False
 Me.txt(1).SetFocus
 Me.cmdmodify.Caption = "提交"
Else
 Me.cmdAdd.Enabled = True
 Me.cmdmodify.Caption = "修改"
 Me.cmdquery.Enabled = True
 '提交修改数据
 MinConfigid = CInt(Right(Me.FrameConfig.Caption, 1))
 sqlstr = "select * from config where configid=" & MinConfigid
 Connect "w"
 rs.Open sqlstr
 If rs.EOF Then
  com.CommandText = "insert into config values(" & MinConfigid & ","
  For i = 1 To ublb - 1
   com.CommandText = com.CommandText & "'" & txt(i).Text & "',"
  Next
  com.CommandText = Left(com.CommandText, Len(com.CommandText) - 1)
  com.CommandText = com.CommandText & ")"
 Else
  com.CommandText = "update config set "
  For i = 1 To ublb - 1
   com.CommandText = com.CommandText & lb(i).Caption & "='" & txt(i).Text & "',"
  Next
  com.CommandText = Left(com.CommandText, Len(com.CommandText) - 1)
  com.CommandText = com.CommandText & " where configid=" & MinConfigid
 End If
 com.Execute
 Disconnect
 MsgBox "修改成功"
End If
End Sub

Private Sub cmdquery_Click()
frmConfigInfo.Show
End Sub

Private Sub Form_Load()
 Me.cmdadditem.Visible = False
 Dim IsEmpty As String
'-------------------取得最小空编号值---------------------
 Connect "r"
  sqlstr = "config"
  rs.Open sqlstr
  If rs.EOF Then
   MinConfigid = 1
  Else
   MinConfigid = rs.Fields("configid")
   Do While Not rs.EOF
    IsEmpty = ""
    For i = 1 To rs.Fields.Count - 1
     If (rs.Fields(i).value <> Null) Or rs.Fields(i).value <> "" Then
      IsEmpty = IsEmpty + CStr(rs.Fields(i).value)
     End If
    Next
    If IsEmpty = "" Then
     MinConfigid = rs.Fields("configid") - 1
     Exit Do
    End If
    If rs.Fields("configid") > MinConfigid Then
     MinConfigid = rs.Fields("configid")
    End If
    rs.MoveNext
   Loop
   MinConfigid = MinConfigid + 1
  End If
  Disconnect

Connect "r"
sqlstr = "config"
rs.Open sqlstr
'控件数组第0个的位置
lb(0).Visible = False
txt(0).Visible = False
lb(0).Top = -200
lb(0).Left = 240
If rs.EOF = False Then
 FrameConfig.Caption = "编号:" & MinConfigid
Else
 FrameConfig.Caption = "编号:无纪录"
End If
For i = 1 To rs.Fields.Count - 1
 Load lb(i)
 Load txt(i)
 lb(i).Visible = True
 txt(i).Visible = True
 lb(i).Caption = rs.Fields(i).name
 '设置位置
 lb(i).Top = lb(i - 1).Top + 500
 lb(i).Left = 200
 txt(i).Top = lb(i).Top - 40
 txt(i).Left = lb(i).Left + 800
Next
ublb = i
Disconnect
'滚动条设置
VScroll.Min = 0
VScroll.Max = 500 * (ublb - 1)
VScroll.LargeChange = 500
VScroll.SmallChange = 500
VScrollValue = VScroll.value
End Sub


Private Sub Form_Unload(Cancel As Integer)
  Unload frmConfigInfo
End Sub

Private Sub VScroll_Change()
For i = 1 To ublb - 1
 lb(i).Top = lb(i).Top + (VScrollValue - VScroll.value)
 txt(i).Top = txt(i).Top + (VScrollValue - VScroll.value)
Next
VScrollValue = VScroll.value
End Sub


Private Sub Form_Init()
 For i = 1 To ublb - 1
  txt(i).Text = ""
 Next
 txt(1).SetFocus
End Sub

⌨️ 快捷键说明

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