setuser1.frm

来自「考务管理是学校考务管理的重要部分」· FRM 代码 · 共 186 行

FRM
186 行
字号
VERSION 5.00
Begin VB.Form setuser1 
   Caption         =   "编辑系统用户"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   StartUpPosition =   2  '屏幕中心
   Begin VB.ComboBox Combo1 
      Height          =   300
      ItemData        =   "setuser1.frx":0000
      Left            =   1920
      List            =   "setuser1.frx":000A
      TabIndex        =   6
      Top             =   1680
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      Caption         =   "用户编辑"
      Height          =   2535
      Left            =   480
      TabIndex        =   0
      Top             =   240
      Width           =   3735
      Begin VB.CommandButton Comm2 
         Caption         =   "取消"
         Height          =   375
         Left            =   2040
         TabIndex        =   8
         Top             =   1920
         Width           =   735
      End
      Begin VB.CommandButton Comm1 
         Caption         =   "确定"
         Height          =   375
         Left            =   840
         TabIndex        =   7
         Top             =   1920
         Width           =   735
      End
      Begin VB.TextBox Text1 
         Height          =   270
         Index           =   1
         Left            =   1440
         TabIndex        =   5
         Top             =   960
         Width           =   1215
      End
      Begin VB.TextBox Text1 
         Height          =   270
         Index           =   0
         Left            =   1440
         TabIndex        =   4
         Top             =   480
         Width           =   1215
      End
      Begin VB.Label Label3 
         Caption         =   "用户级别"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   480
         TabIndex        =   3
         Top             =   1440
         Width           =   855
      End
      Begin VB.Label Label2 
         Caption         =   "口    令"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   480
         TabIndex        =   2
         Top             =   960
         Width           =   855
      End
      Begin VB.Label Label1 
         Caption         =   "用 户 名"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   480
         TabIndex        =   1
         Top             =   480
         Width           =   855
      End
   End
End
Attribute VB_Name = "setuser1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim cond As String


Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        SendKeys "{TAB}"
    End If
End Sub
Private Sub Form_Load()
    If flag = 2 Then
        Text1(0).Text = setuser.Adodc1.Recordset.Fields("用户名")
        Text1(1).Text = setuser.Adodc1.Recordset.Fields("口令")
        Combo1.Text = setuser.Adodc1.Recordset.Fields("级别")
    End If
End Sub
Private Sub Comm1_Click()
    If Trim(Text1(0).Text) = "" Or Trim(Text1(1).Text) = "" Or Trim(Combo1.Text) = "" Then
        MsgBox "数据项不全,请重新设置", vbOKOnly, "信息提示"
        Text1(0).SetFocus
        Exit Sub
    End If
    If flag = 1 Then    '添加操作
        If setuser.Adodc1.Recordset.RecordCount > 0 Then    '原记录个数大于0
            cond = "级别='" + Trim(Text1(0).Text) + "'"
            setuser.Adodc1.Recordset.MoveFirst              '每次从头开始查找
            setuser.Adodc1.Recordset.Find (cond)
            If Not setuser.Adodc1.Recordset.EOF() Then
                MsgBox "存在完全相同的记录", vbOKOnly, "信息提示"
                Text1(0).SetFocus
                Exit Sub
            End If
        End If
        setuser.Adodc1.Recordset.AddNew
        setuser.Adodc1.Recordset.Fields("用户名") = Trim(Text1(0).Text)
        setuser.Adodc1.Recordset.Fields("口令") = Trim(Text1(1).Text)
        setuser.Adodc1.Recordset.Fields("级别") = Trim(Combo1.Text)
        setuser.Adodc1.Recordset.Update
        recs = recs + 1
        Else
        n = setuser.Adodc1.Recordset.AbsolutePosition
        cond = "级别='" + Trim(Text1(0).Text) + "'"
        setuser.Adodc1.Recordset.MoveFirst          '每次从头开始查找
        setuser.Adodc1.Recordset.Find (cond)
        If Not setuser.Adodc1.Recordset.EOF() And _
                setuser.Adodc1.Recordset.AbsolutePosition <> n Then
            MsgBox "存在完全相同的记录", vbOKOnly, "信息提示"
            setuser.Adodc1.Recordset.MoveFirst      '这两个语句恢复原记录位置
            setuser.Adodc1.Recordset.Move (n - 1)
            Text1(0).SetFocus
            Exit Sub
        End If
        setuser.Adodc1.Recordset.MoveFirst          '这两个语句恢复原记录位置
        setuser.Adodc1.Recordset.Move (n - 1)
        setuser.Adodc1.Recordset.Fields("用户名") = Trim(Text1(0).Text)
        setuser.Adodc1.Recordset.Fields("口令") = Trim(Text1(1).Text)
        setuser.Adodc1.Recordset.Fields("级别") = Trim(Combo1.Text)
        setuser.Adodc1.Recordset.Update
    End If
    Unload Me
End Sub
Private Sub Comm2_Click()
    Unload Me
End Sub
Private Sub text1_KeyPress(Index As Integer, KeyAscii As Integer)
    Call endata(KeyAscii)
End Sub

⌨️ 快捷键说明

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