📄 user.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form user
Caption = "用户管理"
ClientHeight = 3285
ClientLeft = 60
ClientTop = 420
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3285
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 2880
Top = 1560
Visible = 0 'False
Width = 1680
_ExtentX = 2963
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSDataGridLib.DataGrid DataGrid1
Bindings = "user.frx":0000
Height = 735
Left = 360
TabIndex = 9
Top = 3240
Visible = 0 'False
Width = 3975
_ExtentX = 7011
_ExtentY = 1296
_Version = 393216
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin VB.CommandButton Command4
Caption = "退出"
Height = 495
Left = 3600
TabIndex = 8
Top = 2280
Width = 975
End
Begin VB.OptionButton Option1
Caption = "是否为管理员"
Height = 375
Left = 1080
TabIndex = 7
Top = 1680
Width = 1815
End
Begin VB.TextBox Text1
Height = 375
Left = 1440
TabIndex = 4
Top = 360
Width = 2055
End
Begin VB.TextBox Text2
BackColor = &H00FFFFFF&
Height = 375
Left = 1440
TabIndex = 3
Top = 1080
Width = 2055
End
Begin VB.CommandButton Command1
Caption = "添加用户"
Height = 495
Left = 120
TabIndex = 2
Top = 2280
Width = 975
End
Begin VB.CommandButton Command2
Caption = "删除用户"
Height = 495
Left = 1200
TabIndex = 1
Top = 2280
Width = 975
End
Begin VB.CommandButton Command3
Caption = "用户查询"
Height = 495
Left = 2520
TabIndex = 0
Top = 2280
Width = 975
End
Begin VB.Label Label1
Caption = "用户名:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 600
TabIndex = 6
Top = 480
Width = 975
End
Begin VB.Label Label2
Caption = "密 码:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 600
TabIndex = 5
Top = 1080
Width = 1095
End
End
Attribute VB_Name = "user"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
Dim ret As ADODB.Recordset
Dim strcnn As String
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim dQuery As DAO.QueryDef
'添加用户
Private Sub Command1_Click()
Dim isguanliyuan As Long '定义一个变量,判断添加的用户是否是管理员
If Option1.Value = False Then
isguanliyuan = 0
Else
isguanliyuan = 1
End If
strcnn = "User ID=Admin;Password=;Data Source=" & App.Path & "\db.mdb;Provider=Microsoft.Jet.OLEDB.3.51"
Set cnn = New ADODB.Connection
cnn.Open strcnn
Set cmd = New ADODB.Command
cmd.ActiveConnection = cnn
'此处需要修改
cmd.CommandText = "insert into login values('" + Text1.Text + "','" + Text2.Text + "',0)"
cmd.Execute
cnn.Close
MsgBox ("添加用户成功!!")
End Sub
'删除用户
Private Sub Command2_Click()
Dim isdelete As Integer
isdelete = MsgBox("确实要删除吗?", vbExclamation + vbDefaultButton1 + vbYesNo, "提示信息")
If isdelete Then
strcnn = "User ID=Admin;Password=;Data Source=" & App.Path & "\db.mdb;Provider=Microsoft.Jet.OLEDB.3.51"
Set cnn = New ADODB.Connection
cnn.Open strcnn
Set cmd = New ADODB.Command
cmd.ActiveConnection = cnn
cmd.CommandText = "delete from login where ID='" + Text1.Text + "' "
cmd.Execute
cnn.Close
MsgBox ("删除成功!!")
End If
End Sub
'查询用户信息
Private Sub Command3_Click()
Set db = OpenDatabase(App.Path & "\db.mdb")
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from login"
Adodc1.Refresh
user.Height = 8000
DataGrid1.Visible = True
DataGrid1.Height = 4000
DataGrid1.Columns(0).Width = 1000
DataGrid1.Columns(1).Width = 1000
DataGrid1.Columns(2).Width = 1000
End Sub
'退出
Private Sub Command4_Click()
Me.Hide
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -