www.pudn.com > 西南医院.rar > FrmAdminUpdate.frm


VERSION 5.00 
Begin VB.Form FrmAdminUpdate  
   Caption         =   "修改密码" 
   ClientHeight    =   2790 
   ClientLeft      =   60 
   ClientTop       =   345 
   ClientWidth     =   4320 
   LinkTopic       =   "Form1" 
   MaxButton       =   0   'False 
   MDIChild        =   -1  'True 
   ScaleHeight     =   2790 
   ScaleWidth      =   4320 
   Begin VB.Data Data1  
      Caption         =   "Data1" 
      Connect         =   "Access 2000;" 
      DatabaseName    =   "" 
      DefaultCursorType=   0  'DefaultCursor 
      DefaultType     =   2  'UseODBC 
      Exclusive       =   0   'False 
      Height          =   345 
      Left            =   1440 
      Options         =   0 
      ReadOnly        =   0   'False 
      RecordsetType   =   1  'Dynaset 
      RecordSource    =   "" 
      Top             =   1920 
      Visible         =   0   'False 
      Width           =   1215 
   End 
   Begin VB.CommandButton Command2  
      Caption         =   "关闭" 
      BeginProperty Font  
         Name            =   "MS Sans Serif" 
         Size            =   9.75 
         Charset         =   0 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   495 
      Left            =   2280 
      TabIndex        =   9 
      Top             =   2250 
      Width           =   1215 
   End 
   Begin VB.CommandButton Command1  
      Caption         =   "修改" 
      BeginProperty Font  
         Name            =   "MS Sans Serif" 
         Size            =   9.75 
         Charset         =   0 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   495 
      Left            =   480 
      TabIndex        =   8 
      Top             =   2250 
      Width           =   1215 
   End 
   Begin VB.TextBox Text4  
      Height          =   400 
      IMEMode         =   3  'DISABLE 
      Left            =   1680 
      PasswordChar    =   "*" 
      TabIndex        =   7 
      Top             =   1680 
      Width           =   1815 
   End 
   Begin VB.TextBox Text3  
      Height          =   400 
      IMEMode         =   3  'DISABLE 
      Left            =   1680 
      PasswordChar    =   "*" 
      TabIndex        =   6 
      Top             =   1160 
      Width           =   1815 
   End 
   Begin VB.TextBox Text2  
      Height          =   400 
      IMEMode         =   3  'DISABLE 
      Left            =   1680 
      PasswordChar    =   "*" 
      TabIndex        =   5 
      Top             =   640 
      Width           =   1815 
   End 
   Begin VB.TextBox Text1  
      Height          =   400 
      Left            =   1680 
      TabIndex        =   4 
      Top             =   120 
      Width           =   1815 
   End 
   Begin VB.Label Label4  
      Caption         =   "确认密码" 
      BeginProperty Font  
         Name            =   "MS Sans Serif" 
         Size            =   9.75 
         Charset         =   0 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   255 
      Left            =   360 
      TabIndex        =   3 
      Top             =   1680 
      Width           =   855 
   End 
   Begin VB.Label Label3  
      Caption         =   "修改密码" 
      BeginProperty Font  
         Name            =   "MS Sans Serif" 
         Size            =   9.75 
         Charset         =   0 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   255 
      Left            =   360 
      TabIndex        =   2 
      Top             =   1155 
      Width           =   855 
   End 
   Begin VB.Label Label2  
      Caption         =   "原密码" 
      BeginProperty Font  
         Name            =   "MS Sans Serif" 
         Size            =   9.75 
         Charset         =   0 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   255 
      Left            =   360 
      TabIndex        =   1 
      Top             =   645 
      Width           =   855 
   End 
   Begin VB.Label Label1  
      Caption         =   "用户名" 
      BeginProperty Font  
         Name            =   "MS Sans Serif" 
         Size            =   9.75 
         Charset         =   0 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   255 
      Left            =   360 
      TabIndex        =   0 
      Top             =   120 
      Width           =   855 
   End 
End 
Attribute VB_Name = "FrmAdminUpdate" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Private Sub Command1_Click() 
If Text1.Text = "" Then 
   MsgBox "用户名不能为空", vbOKOnly + vbCritical, "系统提示" 
   Text1.SetFocus 
   Exit Sub 
End If 
If Text2.Text = "" Then 
   MsgBox "密码不能为空", vbOKOnly + vbCritical, "系统提示" 
   Text2.SetFocus 
   Exit Sub 
End If 
If Text3.Text = "" Then 
   MsgBox "请输入新密码", vbOKOnly + vbCritical, "系统提示" 
   Text3.SetFocus 
   Exit Sub 
End If 
If Text3.Text <> Text4.Text Then 
   MsgBox "两次输入的密码不一样", vbOKOnly + vbCritical, "系统提示" 
   Text3.Text = "" 
   Text4.Text = "" 
   Text3.SetFocus 
   Exit Sub 
End If 
'检测数据 
If Data1.Recordset.RecordCount < 1 Then 
   MsgBox "数据库中没有数据", vbOKOnly + vbCritical, "系统提示" 
   Exit Sub 
End If 
'数据库中是否有这个用户 
Data1.Recordset.FindFirst "id='" & Text1.Text & "'" 
If Data1.Recordset.NoMatch Then 
    MsgBox "没有这个用户", vbOKOnly + vbQuestion, "系统信息" 
    Text1.Text = "" 
    Text2.Text = "" 
    Text3.Text = "" 
    Text4.Text = "" 
    Text1.SetFocus 
    Exit Sub 
End If 
'检测密码 
If Text2.Text <> Data1.Recordset.Fields("pwd") Then 
    MsgBox "密码错误", vbOKOnly + vbQuestion, "系统信息" 
    Text2.Text = "" 
    Text2.SetFocus 
    Exit Sub 
End If 
addnew 
MsgBox "修改成功", vbOKOnly + vbInformation, "系统信息" 
Unload Me 
FrmMdi.mnuuserupdate.Checked = False 
End Sub 
 
Private Sub Command2_Click() 
Unload Me 
FrmMdi.mnuuserupdate.Checked = False 
End Sub 
 
Private Sub Form_Load() 
Me.Width = 4440 
Me.Height = 3195 
Data1.DatabaseName = App.Path & "\message.mdb" 
Data1.RecordSource = "admin" 
Data1.Refresh 
End Sub 
 
Private Sub Form_Unload(Cancel As Integer) 
FrmMdi.mnuuserupdate.Checked = False 
End Sub 
 
Private Sub Text1_KeyPress(KeyAscii As Integer) 
If KeyAscii = 13 Then 
   Text2.SetFocus 
End If 
End Sub 
 
Private Sub Text2_KeyPress(KeyAscii As Integer) 
If KeyAscii = 13 Then 
   Text3.SetFocus 
End If 
End Sub 
 
Private Sub Text3_KeyPress(KeyAscii As Integer) 
If KeyAscii = 13 Then 
   Text4.SetFocus 
End If 
End Sub 
 
 
Private Sub Text4_KeyPress(KeyAscii As Integer) 
If KeyAscii = 13 Then 
   Command1.SetFocus 
End If 
End Sub 
 
Sub addnew() '添加数据 
On Error GoTo err '错误检测 
    Data1.Recordset.Edit 
    Data1.Recordset.Fields("id") = Text1.Text 
    Data1.Recordset.Fields("pwd") = Text3.Text 
    Data1.Recordset.Update 
    Data1.Refresh 
err: 
If err.Number = 3022 Then 
    MsgBox "数据重复", vbOKCancel + vbCritical, "系统提示" 
    Text1.Text = "" 
    Text2.Text = "" 
    Text3.Text = "" 
    Text4.Text = "" 
    Text1.SetFocus 
Exit Sub 
End If 
End Sub