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

📄 frmadd.frm

📁 使用vb编写的人员基本系信息管理
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmadd 
   BackColor       =   &H00FF7722&
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "添加用户"
   ClientHeight    =   2580
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3945
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   172
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   263
   StartUpPosition =   2  '屏幕中心
   Begin VB.TextBox txtque 
      Appearance      =   0  'Flat
      BackColor       =   &H00FF7722&
      ForeColor       =   &H00FFFFFF&
      Height          =   270
      Left            =   1702
      TabIndex        =   3
      Top             =   1200
      Width           =   1500
   End
   Begin VB.TextBox txtpwd 
      Appearance      =   0  'Flat
      BackColor       =   &H00FF7722&
      ForeColor       =   &H00FFFFFF&
      Height          =   270
      IMEMode         =   3  'DISABLE
      Left            =   1702
      PasswordChar    =   "*"
      TabIndex        =   1
      Top             =   480
      Width           =   1500
   End
   Begin VB.TextBox txtans 
      Appearance      =   0  'Flat
      BackColor       =   &H00FF7722&
      ForeColor       =   &H00FFFFFF&
      Height          =   270
      Left            =   1702
      TabIndex        =   4
      Top             =   1560
      Width           =   1500
   End
   Begin VB.TextBox txtrepwd 
      Appearance      =   0  'Flat
      BackColor       =   &H00FF7722&
      ForeColor       =   &H00FFFFFF&
      Height          =   270
      IMEMode         =   3  'DISABLE
      Left            =   1702
      PasswordChar    =   "*"
      TabIndex        =   2
      Top             =   840
      Width           =   1500
   End
   Begin VB.TextBox txtid 
      Appearance      =   0  'Flat
      BackColor       =   &H00FF7722&
      ForeColor       =   &H00FFFFFF&
      Height          =   270
      Left            =   1702
      TabIndex        =   0
      Top             =   120
      Width           =   1500
   End
   Begin VB.CommandButton cmdend 
      Caption         =   "退出"
      Height          =   300
      Left            =   2430
      TabIndex        =   6
      Top             =   2040
      Width           =   750
   End
   Begin VB.CommandButton cmdok 
      Caption         =   "确定"
      Default         =   -1  'True
      Height          =   300
      Left            =   720
      TabIndex        =   5
      Top             =   2040
      Width           =   750
   End
   Begin VB.Label Label5 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H00FF7722&
      Caption         =   "答    案"
      ForeColor       =   &H00FFFFFF&
      Height          =   180
      Left            =   742
      TabIndex        =   11
      Top             =   1605
      Width           =   720
   End
   Begin VB.Label Label4 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H00FF7722&
      Caption         =   "提示问题"
      ForeColor       =   &H00FFFFFF&
      Height          =   180
      Left            =   742
      TabIndex        =   10
      Top             =   1245
      Width           =   720
   End
   Begin VB.Label Label3 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H00FF7722&
      Caption         =   "再填一次"
      ForeColor       =   &H00FFFFFF&
      Height          =   180
      Left            =   742
      TabIndex        =   9
      Top             =   885
      Width           =   720
   End
   Begin VB.Label Label2 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H00FF7722&
      Caption         =   "密    码"
      ForeColor       =   &H00FFFFFF&
      Height          =   180
      Left            =   742
      TabIndex        =   8
      Top             =   525
      Width           =   720
   End
   Begin VB.Label Label1 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H00FF7722&
      Caption         =   "用 户 名"
      ForeColor       =   &H00FFFFFF&
      Height          =   180
      Left            =   742
      TabIndex        =   7
      Top             =   165
      Width           =   720
   End
End
Attribute VB_Name = "frmadd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mycn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim cnstr As String

Private Sub cmdend_Click()
Unload Me
End Sub

Private Sub cmdok_Click()
txtid.SetFocus
If txtid = "" Or txtpwd = "" Or txtrepwd = "" Or txtque = "" Or txtans = "" Then
  MsgBox "请填写全部项目!", vbOKOnly + vbExclamation, "提示"
  txtpwd = ""
  txtrepwd = ""
  Exit Sub
End If
If txtpwd <> txtrepwd Then
  MsgBox "两次填写的密码不同!", vbOKOnly + vbExclamation, "提示"
  txtpwd = ""
  txtrepwd = ""
  Exit Sub
End If
Do While Not rs.EOF
  If Trim(rs!Id) <> txtid Then
    rs.MoveNext
  Else
    MsgBox "该用户名已经存在!", vbOKOnly + vbExclamation, "提示"
    clsall
    Exit Sub
  End If
Loop
rs.AddNew
rs!Id = txtid.Text
rs!pwd = txtpwd.Text
rs!que = txtque.Text
rs!ans = txtans.Text
If MsgBox("要添加新记录吗?", vbYesNo + vbExclamation + vbDefaultButton2, "提示") = vbYes Then
  rs.Update
  clsall
  MsgBox "用户添加成功!请登录!", vbOKOnly + vbExclamation, "成功"
  Unload frmadd
Else
  rs.CancelUpdate
End If
End Sub

Private Sub Form_Load()
cnstr = "provider=microsoft.jet.oledb.4.0;" _
        & "data source=" & App.Path & "\data\data.mdb"
Set mycn = New ADODB.Connection
mycn.Open cnstr
Set rs = New ADODB.Recordset
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseClient
rs.Open "pass", mycn, , , adCmdTable
End Sub

Private Sub Form_Unload(Cancel As Integer)
rs.Close
mycn.Close
Set mycn = Nothing
Set rs = Nothing
End Sub
Private Sub clsall()
txtid = ""
txtpwd = ""
txtrepwd = ""
txtque = ""
txtans = ""
End Sub

⌨️ 快捷键说明

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