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

📄 changepswd.frm

📁 this code is hospital system visualbasic
💻 FRM
字号:
VERSION 5.00
Begin VB.Form changepswd 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "修改密码"
   ClientHeight    =   2520
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4980
   Icon            =   "changepswd.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2520
   ScaleWidth      =   4980
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  '所有者中心
   Begin VB.PictureBox Picture1 
      BackColor       =   &H00C0C0C0&
      Height          =   2265
      Left            =   120
      ScaleHeight     =   2205
      ScaleWidth      =   4665
      TabIndex        =   0
      Top             =   90
      Width           =   4725
      Begin VB.ComboBox Combo1 
         BackColor       =   &H00C0FFFF&
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1560
         TabIndex        =   6
         Top             =   180
         Width           =   1635
      End
      Begin VB.TextBox txtold 
         BackColor       =   &H00C0FFFF&
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   300
         IMEMode         =   3  'DISABLE
         Left            =   1560
         PasswordChar    =   "*"
         TabIndex        =   5
         Top             =   660
         Width           =   1635
      End
      Begin VB.TextBox txtnew 
         BackColor       =   &H00C0FFFF&
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   300
         IMEMode         =   3  'DISABLE
         Left            =   1560
         PasswordChar    =   "*"
         TabIndex        =   4
         Top             =   1140
         Width           =   1635
      End
      Begin VB.TextBox txtsec 
         BackColor       =   &H00C0FFFF&
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   300
         IMEMode         =   3  'DISABLE
         Left            =   1560
         PasswordChar    =   "*"
         TabIndex        =   3
         Top             =   1590
         Width           =   1635
      End
      Begin VB.CommandButton Command1 
         Caption         =   "确定"
         Default         =   -1  'True
         Height          =   435
         Left            =   3480
         TabIndex        =   2
         Top             =   930
         Width           =   945
      End
      Begin VB.CommandButton Command2 
         Cancel          =   -1  'True
         Caption         =   "退出"
         Height          =   435
         Left            =   3510
         TabIndex        =   1
         Top             =   1470
         Width           =   945
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "用户名称"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   10.5
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   210
         Left            =   120
         TabIndex        =   10
         Top             =   180
         Width           =   900
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "旧 密 码"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   10.5
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   210
         Left            =   120
         TabIndex        =   9
         Top             =   660
         Width           =   915
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "新 密 码"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   10.5
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   210
         Left            =   150
         TabIndex        =   8
         Top             =   1170
         Width           =   915
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "确定密码"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   10.5
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   210
         Left            =   120
         TabIndex        =   7
         Top             =   1620
         Width           =   900
      End
   End
End
Attribute VB_Name = "changepswd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Dim rs As ADODB.Recordset
Dim oldpassword As String       '该变量用来存放获取的密码
Dim cn As ADODB.Connection
Dim oldflag As String

Private Sub Combo1_Click()
    txtold.SetFocus
End Sub

                    '*********修改密码*********
Private Sub Command1_Click()
Dim name As String
Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Set rs.ActiveConnection = cn
    rs.LockType = adLockOptimistic
    rs.CursorType = adOpenKeyset
    strsql = "select * from user_load where user_name=" & CheckString(Combo1.Text)
    rs.Open strsql
    'Set rs = cn.Execute(strsql)
    'txtold.SetFocus
    oldpassword = rs.Fields("password") '获取密码'核对密码
    name = rs.Fields("user_name")
'If Combo1.Text = name Then
  If txtold.Text = oldpassword Then
   If txtnew.Text = txtsec.Text Then
       If txtnew.Text = "" Or txtsec.Text = "" Then
          t = MsgBox("请输入密码!", 48, "WARNING")
       Else                             '如满足条件,则更新密码
          
           rs.Fields("password") = Trim(txtsec.Text) '是否有问题 ??
           rs.Update
           t = MsgBox("密码修改成功!", vbOKOnly, "SURE")
            
           txtold.Text = ""
           txtnew.Text = ""
           txtsec.Text = ""
       End If
    Else
        t = MsgBox("密码输入不同!", 48, "warning")
        txtnew.Text = ""
        txtsec.Text = ""
    End If
Else
    t = MsgBox("原密码错误!", 48, "warning")
    txtold.Text = ""
    txtnew.Text = ""
    txtsec.Text = ""
End If
'End If
'If cn.State = 1 Then
'   cn.Close
'End If
End Sub

Private Sub Command2_Click()
If cn.State = 1 Then cn.Close
Unload Me
End Sub

Private Sub Form_Load()
MyMenu = GetSystemMenu(Me.hwnd, 0)       '得到系统菜单的句柄,Me.hwnd表示当前窗体的句柄
RemoveMenu MyMenu, &HF060, MF_BYCOMMAND  '移去“关闭”菜单项,&HF060“关闭”菜单项的命令ID

Set cn = New ADODB.Connection
    cn.Provider = "sqloledb"
    cn.Properties("Data Source").Value = "(local)"       '建立与本地数据库的连接
    cn.Properties("Initial Catalog").Value = "YAOFEI"   '数据库的名称
    cn.Properties("Integrated Security").Value = "SSPI"
    cn.Open

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "select user_name from user_load ", cn, adOpenStatic, adLockPessimistic
Combo1.Clear
Do Until rs.EOF
         Combo1.AddItem rs.Fields("user_name")
         rs.MoveNext
Loop
rs.MoveFirst
   
End Sub
Function CheckString(s) As String    '检验是否有单引号的输入
pos = InStr(s, "'")
While pos > 0
s = Mid(s, 1, pos) & "'" & Mid(s, pos + 1)
pos = InStr(pos + 2, s, "'")
Wend
CheckString = "'" & s & "'"
End Function

Private Sub Form_Unload(Cancel As Integer)
mainform.StatusBar1.Panels(1).Text = "状态: 无"
End Sub

⌨️ 快捷键说明

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