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

📄 form1.frm

📁 图书管理系统阿
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command3 
      Caption         =   "注册"
      Height          =   375
      Left            =   2160
      TabIndex        =   6
      Top             =   2280
      Width           =   1215
   End
   Begin VB.CommandButton Command2 
      Caption         =   "取消"
      Height          =   375
      Left            =   3600
      TabIndex        =   5
      Top             =   2280
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "登录"
      Height          =   375
      Left            =   720
      TabIndex        =   4
      Top             =   2280
      Width           =   1215
   End
   Begin VB.TextBox Text2 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   1560
      PasswordChar    =   "*"
      TabIndex        =   3
      Top             =   1440
      Width           =   1335
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   1560
      TabIndex        =   2
      Top             =   720
      Width           =   1335
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "密码"
      Height          =   180
      Left            =   960
      TabIndex        =   1
      Top             =   1560
      Width           =   360
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "用户名"
      Height          =   180
      Left            =   960
      TabIndex        =   0
      Top             =   840
      Width           =   540
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset

Private Sub Command1_Click()
 Dim rststr As String
 If Trim(Text1.Text) = "" Then
 MsgBox "用户名不能为空!", vbExclamation + vbOKOnly, "警告"
 Text1.SetFocus
 Exit Sub
End If
If Trim(Text2.Text) = "" Then
 MsgBox "密码不能为空!", vbExclamation + vbOKOnly, "警告"
 Text2.SetFocus
 Exit Sub
End If
    rststr = "select * from user where  [name]='" & Text1.Text & "' and [Password]='" & Text2.Text & "' "
    rst.Open rststr, cnn, adOpenKeyset, adLockOptimistic, adCmdText
    If rst.RecordCount >= 1 Then
       Unload Me
       frmMain.Show
       rst.Close
       Exit Sub
    Else
         MsgBox "未注册,请先注册", 32, "信息"
    End If
End Sub



Private Sub Command2_Click()
End
End Sub

Private Sub Command3_Click()
 Dim rststr As String
 Dim pstr As String
    rststr = "select * from user where ( user.name='" & Text1.Text & "') and (user.Password='" & Text2.Text & "')"
    rst.Open rststr, cnn, adOpenKeyset, adLockOptimistic, adCmdText
    If rst.RecordCount >= 1 Then
       MsgBox "该用户已经存在", , "信息"
       rst.Close
       Exit Sub
     Else
     rst.Close
    End If
    pstr = "insert into user([name],[password]) values('" & Text1.Text & "', '" & Text2.Text & "')"
    cnn.Execute pstr
    MsgBox "用户注册成功!!!!", , "信息"
End Sub

Private Sub Form_Load()
Dim strcnn As String
    strcnn = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & App.Path & "\BookManage.mdb"
    cnn.Open (strcnn)
End Sub

Private Sub Label3_Click()

End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = 13 Then Text2.SetFocus
End Sub

Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Command1_Click
End Sub

⌨️ 快捷键说明

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