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

📄 frmuseredit.frm

📁 在VB中开发的连接SQL的图书管理系统。
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmUserEdit 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "用户编辑"
   ClientHeight    =   4260
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   5430
   Icon            =   "frmUserEdit.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4260
   ScaleWidth      =   5430
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "取 消"
      Height          =   495
      Left            =   2760
      TabIndex        =   9
      Top             =   2880
      Width           =   1215
   End
   Begin VB.CommandButton cmdOk 
      Caption         =   "确 定"
      Default         =   -1  'True
      Height          =   495
      Left            =   960
      TabIndex        =   8
      Top             =   2880
      Width           =   1215
   End
   Begin VB.ComboBox cboUserType 
      Height          =   300
      Left            =   2160
      Style           =   2  'Dropdown List
      TabIndex        =   3
      Top             =   2040
      Width           =   1815
   End
   Begin VB.TextBox txtConfirm 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   2160
      MaxLength       =   50
      PasswordChar    =   "*"
      TabIndex        =   2
      Top             =   1440
      Width           =   1815
   End
   Begin VB.TextBox txtPasswd 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   2160
      MaxLength       =   50
      PasswordChar    =   "*"
      TabIndex        =   1
      Top             =   960
      Width           =   1815
   End
   Begin VB.TextBox txtUser 
      Height          =   375
      Left            =   2160
      MaxLength       =   20
      TabIndex        =   0
      Top             =   480
      Width           =   1815
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "用户类型:"
      Height          =   180
      Left            =   1080
      TabIndex        =   7
      Top             =   2040
      Width           =   900
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "确认密码:"
      Height          =   180
      Left            =   1080
      TabIndex        =   6
      Top             =   1560
      Width           =   900
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "输入密码:"
      Height          =   180
      Left            =   1080
      TabIndex        =   5
      Top             =   1080
      Width           =   900
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "用户名:"
      Height          =   180
      Left            =   1080
      TabIndex        =   4
      Top             =   600
      Width           =   720
   End
End
Attribute VB_Name = "frmUserEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'窗体装载事件
Private Sub Form_Load()
  '添加用户类型
  cboUserType.AddItem "1 - 超级用户"
  cboUserType.AddItem "2 - 普通用户"
End Sub

'确定按钮
Private Sub cmdOK_Click()
  '================判断文本框的有效性==================
  '密码一致性
  If txtPasswd.Text <> txtConfirm.Text Then
    MsgBox "请确认密码输入是否正确,请重新输入", vbInformation, "密码错误"
    txtPasswd.Text = ""
    txtConfirm.Text = ""
    txtPasswd.SetFocus
    Exit Sub
  End If
  '判断用户类型
  If cboUserType.Text = "" Then
    MsgBox "请选择用户类型", vbInformation, "信息提示"
    cboUserType.SetFocus
    Exit Sub
  End If

  '增加类型的判断
  If IsAdd Then
    '输入用户名是否为空
    If Trim(txtUser.Text) = "" Then
      MsgBox "请输入用户名", vbOKOnly + vbInformation, "信息提示"
      txtUser.SetFocus
      Exit Sub
    End If
    '判断用户是否存在
    ExistUser = objPasswd.IsExistUser(txtUser.Text)
    If ExistUser Then
      MsgBox "此用户名已经存在,请换个密码来注册!", vbExclamation, "重名"
      txtUser.SetFocus
      txtUser.SelStart = 0
      txtUser.SelLength = Len(txtUser.Text)
      txtPasswd.Text = ""
      txtConfirm.Text = ""
      Exit Sub
    End If
  Else
    '若用户名为super,则不能修改
    If Trim(txtUser.Text) = "super" Then
      MsgBox "此用户为默认用户,不能修改", vbInformation, "信息提示"
      Exit Sub
    End If
  End If
  '===============判断文本框有效性结束=================

  '给objPasswd对象的属性赋值
  objPasswd.UserName = Trim(txtUser.Text)
  objPasswd.Passwd = txtPasswd.Text
  objPasswd.UserType = IIf(cboUserType.ListIndex, 2, 1)

  '========增加========
  If IsAdd Then
    '增加用户信息
    objPasswd.Insert
    MsgBox "插入成功!", vbInformation, "信息提示"
  '========修改========
  Else
    '修改用户信息
    objPasswd.Update objPasswd.UserName
    MsgBox "修改成功!", vbInformation, "信息提示"
  End If

  '关闭窗口
  Unload Me
End Sub

'取消按钮
Private Sub cmdCancel_Click()
  Dim IsCancel As Integer
  IsCancel = MsgBox("是否真的退出而不保存任何操作?", vbYesNo + vbQuestion + vbDefaultButton2, "退出")
  If IsCancel = vbYes Then
    Unload Me
  End If
End Sub

⌨️ 快捷键说明

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