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

📄 modifyuser.frm

📁 这是一个我帮师妹做的软件的大作业
💻 FRM
字号:
VERSION 5.00
Begin VB.Form modifyUser 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "修改密码"
   ClientHeight    =   2820
   ClientLeft      =   5565
   ClientTop       =   4920
   ClientWidth     =   4305
   Icon            =   "modifyUser.frx":0000
   LinkTopic       =   "Form3"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2820
   ScaleWidth      =   4305
   ShowInTaskbar   =   0   'False
   Begin VB.Frame Frame1 
      Height          =   2775
      Left            =   120
      TabIndex        =   0
      Top             =   0
      Width           =   4095
      Begin VB.CommandButton nextCommand 
         Caption         =   "下一条记录"
         Height          =   375
         Index           =   2
         Left            =   2040
         TabIndex        =   16
         Top             =   1920
         Width           =   1215
      End
      Begin VB.CommandButton previousCommand 
         Caption         =   "上一条记录"
         Height          =   375
         Index           =   3
         Left            =   840
         TabIndex        =   15
         Top             =   1920
         Width           =   1215
      End
      Begin VB.CommandButton editCommand 
         Caption         =   "修改记录"
         Height          =   375
         Index           =   4
         Left            =   120
         TabIndex        =   14
         Top             =   2280
         Width           =   975
      End
      Begin VB.CommandButton updateCommand 
         Caption         =   "更新数据"
         Height          =   375
         Index           =   5
         Left            =   1080
         TabIndex        =   13
         Top             =   2280
         Width           =   975
      End
      Begin VB.CommandButton cancelCommand 
         Caption         =   "取消修改"
         Height          =   375
         Index           =   6
         Left            =   2040
         TabIndex        =   12
         Top             =   2280
         Width           =   975
      End
      Begin VB.CommandButton deletCommand 
         Caption         =   "删除记录"
         Height          =   375
         Index           =   7
         Left            =   3000
         TabIndex        =   11
         Top             =   2280
         Width           =   975
      End
      Begin VB.Frame Frame2 
         Height          =   1815
         Left            =   0
         TabIndex        =   4
         Top             =   0
         Width           =   2535
         Begin VB.TextBox Text1 
            Appearance      =   0  'Flat
            BackColor       =   &H80000018&
            Enabled         =   0   'False
            Height          =   350
            Index           =   0
            Left            =   1080
            MaxLength       =   20
            TabIndex        =   7
            Top             =   240
            Width           =   1215
         End
         Begin VB.TextBox Text1 
            Appearance      =   0  'Flat
            BackColor       =   &H80000018&
            Enabled         =   0   'False
            Height          =   350
            IMEMode         =   3  'DISABLE
            Index           =   1
            Left            =   1080
            MaxLength       =   20
            TabIndex        =   6
            Top             =   720
            Width           =   1215
         End
         Begin VB.TextBox Text1 
            Appearance      =   0  'Flat
            BackColor       =   &H80000018&
            Enabled         =   0   'False
            Height          =   350
            IMEMode         =   3  'DISABLE
            Index           =   2
            Left            =   1080
            MaxLength       =   20
            TabIndex        =   5
            Top             =   1200
            Width           =   1215
         End
         Begin VB.Label Label1 
            Caption         =   "用户名:"
            Height          =   375
            Index           =   0
            Left            =   300
            TabIndex        =   10
            Top             =   360
            Width           =   735
         End
         Begin VB.Label Label1 
            Caption         =   "密码:"
            Height          =   375
            Index           =   1
            Left            =   480
            TabIndex        =   9
            Top             =   840
            Width           =   615
         End
         Begin VB.Label Label1 
            Caption         =   "确认密码:"
            Height          =   375
            Index           =   2
            Left            =   120
            TabIndex        =   8
            Top             =   1320
            Width           =   975
         End
      End
      Begin VB.Frame Frame3 
         Height          =   1815
         Left            =   2400
         TabIndex        =   1
         Top             =   0
         Width           =   1695
         Begin VB.OptionButton Option1 
            Caption         =   "管理员"
            Enabled         =   0   'False
            Height          =   255
            Index           =   0
            Left            =   240
            TabIndex        =   3
            Top             =   600
            Width           =   855
         End
         Begin VB.OptionButton Option1 
            Caption         =   "普通用户"
            Enabled         =   0   'False
            Height          =   255
            Index           =   1
            Left            =   240
            TabIndex        =   2
            Top             =   1080
            Width           =   1095
         End
      End
   End
End
Attribute VB_Name = "modifyUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim mrc As ADODB.Recordset
'记录当前记录的位置
Dim mybookmark As Variant
'判断是否修改记录
Dim mcclean As Boolean

Private Sub cancelCommand_Click(Index As Integer)

previousCommand(3).Enabled = True
nextCommand(2).Enabled = True

Text1(0).Enabled = False
Text1(1).Enabled = False
Text1(2).Enabled = False
Option1(0).Enabled = False
Option1(1).Enabled = False
mrc.Bookmark = mybookmark
Call viewData

End Sub

Private Sub deletCommand_Click(Index As Integer)
mybookmark = mrc.Bookmark
    str2$ = MsgBox("是否删除当前记录?", vbOKCancel, "删除当前记录")
    If str2$ = vbOK Then
            mrc.MoveNext
            If mrc.EOF Then
                mrc.MoveFirst
                mybookmark = mrc.Bookmark
                mrc.MoveLast
                mrc.Delete
                mrc.Bookmark = mybookmark
                Call viewData
            Else
                mybookmark = mrc.Bookmark
                mrc.MovePrevious
                mrc.Delete
                mrc.Bookmark = mybookmark
                Call viewData
            End If
    Else
        mrc.Bookmark = mybookmark
        Call viewData
    End If
End Sub
Public Sub viewData()
Text1(0).Text = mrc.Fields(0)
Text1(1).Text = mrc.Fields(1)
Text1(2).Text = mrc.Fields(1)
Select Case mrc.Fields(2)
Case "管理员"
Option1(0).Value = True
Option1(1).Value = False
Case "普通用户"
Option1(1).Value = True
Option1(0).Value = False
End Select

End Sub

Private Sub editCommand_Click(Index As Integer)
 mcclean = False
previousCommand(3).Enabled = False
nextCommand(2).Enabled = False
Text1(0).Enabled = True
Text1(1).Enabled = True
Text1(2).Enabled = True
Option1(0).Enabled = True
Option1(1).Enabled = True
mybookmark = mrc.Bookmark
End Sub

Private Sub Form_Load()

Dim txtSQL As String
   
    txtSQL1 = "select * from use"
    Set mrc = ExecuteSQL(txtSQL1)

   mrc.MoveFirst
    '显示数据
    Call viewData
    mcbookmark = mrc.Bookmark
    mcclean = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
frmMain.Enabled = True
End Sub

Private Sub nextCommand_Click(Index As Integer)
mrc.MoveNext
If mrc.EOF Then
mrc.MoveFirst
End If
Call viewData
End Sub

Private Sub previousCommand_Click(Index As Integer)
mrc.MovePrevious
If mrc.BOF Then
mrc.MoveLast
End If
Call viewData
End Sub

Private Sub updateCommand_Click(Index As Integer)
Dim txtSQL As String
    
    Dim mrcc As ADODB.Recordset
    
    If mcclean Then
        MsgBox "请先修改用户信息", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    
    If Not Testtxt(Text1(0)) Then
        MsgBox "请输入用户名!", vbOKOnly + vbExclamation, "警告"
        Text1(0).SetFocus
        Exit Sub
    End If
    
    If Not Testtxt(Text1(1)) Then
        MsgBox "请输入密码!", vbOKOnly + vbExclamation, "警告"
        Text1(1).SetFocus
      Exit Sub
     End If
    
   
    If Not Testtxt(Text1(2).Text) Then
        MsgBox "请输确认密码!", vbOKOnly + vbExclamation, "警告"
       Text1(2).SetFocus
        Exit Sub
    End If
    
   If Trim(Text1(1).Text) <> Trim(Text1(2).Text) Then
       MsgBox "两次输入的密码不一致!", vbOKOnly + vbExclamation, "警告"
       Text1(1).Text = ""
       Text1(2).Text = ""
        Text1(1).SetFocus
        Exit Sub
   End If
        
mrc.Delete
mrc.AddNew
mrc.Fields(0) = Trim(Text1(0).Text)
mrc.Fields(1) = Trim(Text1(1).Text)
If Option1(0).Value Then
mrc.Fields(2) = Trim(Option1(0).Caption)
Else
mrc.Fields(2) = Trim(Option1(1).Caption)
End If
mrc.Update
MsgBox "修改信息成功!", vbOKOnly + vbExclamation, "警告"
Call viewData

previousCommand(3).Enabled = True
nextCommand(2).Enabled = True
Text1(0).Enabled = False
Text1(1).Enabled = False
Text1(2).Enabled = False
Option1(0).Enabled = False
Option1(1).Enabled = False
mcclean = True
End Sub

⌨️ 快捷键说明

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