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

📄 adduser.frm

📁 学生信息管理系统2.0,增加了数据库的恢复和备份
💻 FRM
字号:
VERSION 5.00
Object = "{CE671F01-259E-40DA-92FE-95803E2ECBB5}#1.0#0"; "SmartXPButton.ocx"
Begin VB.Form adduser 
   BackColor       =   &H00E7DFE7&
   Caption         =   "添加用户"
   ClientHeight    =   3870
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   5430
   Icon            =   "adduser.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   3870
   ScaleWidth      =   5430
   StartUpPosition =   2  '屏幕中心
   Begin SmartXPButton.XpButton cmdcancel 
      Height          =   495
      Left            =   3000
      TabIndex        =   4
      Top             =   3120
      Width           =   1815
      _ExtentX        =   3201
      _ExtentY        =   873
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "取消(&C)"
      PictureSmoothBackColor=   15460844
      ButtonPicture   =   "adduser.frx":0A02
   End
   Begin SmartXPButton.XpButton cmdok 
      Height          =   495
      Left            =   720
      TabIndex        =   3
      Top             =   3120
      Width           =   1695
      _ExtentX        =   2990
      _ExtentY        =   873
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "添加(&O)"
      PictureSmoothBackColor=   15460844
      ButtonPicture   =   "adduser.frx":1414
   End
   Begin VB.TextBox Text3 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   2760
      PasswordChar    =   "*"
      TabIndex        =   2
      Top             =   2400
      Width           =   1575
   End
   Begin VB.TextBox Text2 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   2760
      PasswordChar    =   "*"
      TabIndex        =   1
      Top             =   1680
      Width           =   1575
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   2760
      TabIndex        =   0
      Top             =   960
      Width           =   1575
   End
   Begin VB.Image Image1 
      Height          =   1740
      Left            =   240
      Picture         =   "adduser.frx":1E26
      Top             =   960
      Width           =   1380
   End
   Begin VB.Label Label4 
      BackStyle       =   0  'Transparent
      Caption         =   "确认密码:"
      Height          =   375
      Left            =   1850
      TabIndex        =   8
      Top             =   2520
      Width           =   975
   End
   Begin VB.Label Label3 
      BackStyle       =   0  'Transparent
      Caption         =   "密码(&P):"
      Height          =   255
      Left            =   1965
      TabIndex        =   7
      Top             =   1800
      Width           =   735
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "用户名:"
      Height          =   495
      Left            =   2040
      TabIndex        =   6
      Top             =   1080
      Width           =   735
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "用户设置"
      BeginProperty Font 
         Name            =   "隶书"
         Size            =   21.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000002&
      Height          =   495
      Left            =   1680
      TabIndex        =   5
      Top             =   240
      Width           =   1935
   End
End
Attribute VB_Name = "adduser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim myconn As New ADODB.Connection
Dim str As String
Dim MyStr As String
Dim myrs1 As ADODB.Recordset
Dim MyRs As New ADODB.Recordset
Private Sub cmdcancel_Click()
MyRs.Close
myconn.Close
Unload Me
End Sub
Private Sub cmdok_Click()
If Len(Trim(Text1.Text)) > 10 Or Len(Trim(Text2.Text)) > 15 Then
    MsgBox "用户名或密码太长!", vbOKOnly + vbExclamation, "错误信息"
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text1.SetFocus
    Exit Sub
End If

    
str = "select username from manager where username='" + Trim(Text1.Text) + "'"
Set myrs1 = myconn.Execute(str)
If myrs1.EOF Then
  If Len(Trim(Text1.Text)) <> 0 And Len(Trim(Text2.Text)) <> 0 And Len(Trim(Text3.Text)) <> 0 Then
    If Trim(Text2.Text) = Trim(Text3.Text) Then
      With MyRs
      .AddNew
      .Fields("username") = Trim(Text1.Text)
      .Fields("password") = Trim(Text2.Text)
      .Update
      End With
      MsgBox "用户信息已添加成功!", vbOKOnly + vbInformation, "提示信息"
      Text1.Text = ""
      Text2.Text = ""
      Text3.Text = ""
      Text1.SetFocus
   Else
      MsgBox "两次输入的密码不一致,请重新输入密码!", vbOKOnly + vbExclamation, "错误提示"
      Text2.Text = ""
      Text3.Text = ""
      Text2.SetFocus
   End If
 Else
   MsgBox "用户名和密码不能为空!", vbOKOnly + vbExclamation, "错误提示"
End If
Else
  MsgBox "用户信息已经存在!", vbOKOnly + vbExclamation, "错误提示"
  Text1.Text = ""
  Text2.Text = ""
  Text3.Text = ""
  Text1.SetFocus
End If
End Sub
 
Private Sub Form_Load()
Set myconn = New ADODB.Connection
myconn.ConnectionString = "driver={SQL Server};" & _
      "server=(local);uid=sa;pwd=;database=student_info"
myconn.Open
'***** 使用Recordset对象的Open方法创建记录集 *****
'MyRs.Open "manager", MyConn, adOpenStatic, adLockOptimistic, adCmdTable
 Set MyRs = New ADODB.Recordset
    With MyRs
    .Source = "manager"
    .ActiveConnection = myconn
    .CursorType = adOpenKeyset
    .LockType = adLockOptimistic
    .Open , , , , adCmdTable
    End With
End Sub

⌨️ 快捷键说明

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