📄 frmuser.frm
字号:
VERSION 5.00
Object = "{BA513CF3-1BFD-4976-B2DA-2F1A208D11F9}#1.0#0"; "vkusercontrolsxp.ocx"
Begin VB.Form frmUser
Caption = "用户管理"
ClientHeight = 3990
ClientLeft = 60
ClientTop = 420
ClientWidth = 6975
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "frmUser.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3990
ScaleWidth = 6975
StartUpPosition = 2 '屏幕中心
Begin vkUserContolsXP.vkCommand vkCommand4
Height = 375
Left = 5280
TabIndex = 13
Top = 3480
Width = 1335
_ExtentX = 2355
_ExtentY = 661
BackColorPushed1= 16514043
BackColorPushed2= 14474460
Caption = "关闭"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Picture = "frmUser.frx":038A
End
Begin vkUserContolsXP.vkCommand vkCommand3
Height = 375
Left = 3720
TabIndex = 11
Top = 3480
Width = 1335
_ExtentX = 2355
_ExtentY = 661
BackColorPushed1= 16514043
BackColorPushed2= 14474460
Caption = "删除"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Picture = "frmUser.frx":0724
End
Begin vkUserContolsXP.vkCommand vkCommand2
Height = 375
Left = 2160
TabIndex = 10
Top = 3480
Width = 1335
_ExtentX = 2355
_ExtentY = 661
BackColorPushed1= 16514043
BackColorPushed2= 14474460
Caption = "修改"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Picture = "frmUser.frx":0ABE
End
Begin vkUserContolsXP.vkCommand vkCommand1
Height = 375
Left = 600
TabIndex = 9
Top = 3480
Width = 1335
_ExtentX = 2355
_ExtentY = 661
BackColorPushed1= 16514043
BackColorPushed2= 14474460
Caption = "新增"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Picture = "frmUser.frx":0E58
End
Begin vkUserContolsXP.vkCheck chkItem
Height = 255
Index = 1
Left = 600
TabIndex = 8
Top = 1440
Width = 4815
_ExtentX = 8493
_ExtentY = 450
BackColor = 16777215
BackStyle = 0
Caption = "备份数据库"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin vkUserContolsXP.vkCheck chkItem
Height = 255
Index = 5
Left = 600
TabIndex = 7
Top = 2880
Width = 4815
_ExtentX = 8493
_ExtentY = 450
BackColor = 16777215
BackStyle = 0
Caption = "数据查询-出库单"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin vkUserContolsXP.vkCheck chkItem
Height = 255
Index = 4
Left = 600
TabIndex = 6
Top = 2520
Width = 2415
_ExtentX = 4260
_ExtentY = 450
BackColor = 16777215
BackStyle = 0
Caption = "数据查询-入库单"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin vkUserContolsXP.vkCheck chkItem
Height = 255
Index = 3
Left = 600
TabIndex = 5
Top = 2160
Width = 2175
_ExtentX = 3836
_ExtentY = 450
BackColor = 16777215
BackStyle = 0
Caption = "数据录入-出库单"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin vkUserContolsXP.vkCheck chkItem
Height = 255
Index = 2
Left = 600
TabIndex = 4
Top = 1800
Width = 3855
_ExtentX = 6800
_ExtentY = 450
BackColor = 16777215
BackStyle = 0
Caption = "数据录入-入库单"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin vkUserContolsXP.vkCheck chkItem
Height = 255
Index = 0
Left = 600
TabIndex = 3
Top = 1080
Width = 2655
_ExtentX = 4683
_ExtentY = 450
BackColor = 16777215
BackStyle = 0
Caption = "管理员(所有权限)"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.ComboBox Combo1
Height = 345
Left = 1560
Style = 2 'Dropdown List
TabIndex = 0
Top = 240
Width = 2055
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "新增用户的初始密码为123"
ForeColor = &H80000001&
Height = 225
Left = 4200
TabIndex = 12
Top = 240
Width = 2115
End
Begin VB.Image Image3
Height = 240
Left = 3840
Picture = "frmUser.frx":11F2
Top = 240
Width = 240
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "权限设置"
Height = 225
Left = 600
TabIndex = 2
Top = 720
Width = 720
End
Begin VB.Image Image2
Height = 240
Left = 240
Picture = "frmUser.frx":157C
Top = 720
Width = 240
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "选择用户"
Height = 225
Left = 600
TabIndex = 1
Top = 240
Width = 720
End
Begin VB.Image Image1
Height = 240
Left = 240
Picture = "frmUser.frx":1906
Top = 240
Width = 240
End
End
Attribute VB_Name = "frmUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim StrOP() As String
Private Sub RefreshQX()
Dim A() As String
Dim i As Long
A = Split(StrOP(Combo1.ListIndex + 1), ",")
For i = 0 To 5
If A(i) = "1" Then
chkItem(i).Value = vbChecked
Else
chkItem(i).Value = vbUnchecked
End If
Next
End Sub
Private Sub ShowUser()
On Error GoTo ErrFlag
Dim ConnTemp As New ADODB.Connection
Dim RSTemp As New ADODB.Recordset
Dim StrSQL As String, i As Long
Combo1.Clear
StrSQL = "Select UserName,OP from userlist Order by UserName"
ConnTemp.Open StrConn
RSTemp.Open StrSQL, ConnTemp, adOpenStatic, adLockReadOnly
If RSTemp.RecordCount > 0 Then ReDim StrOP(RSTemp.RecordCount)
For i = 1 To RSTemp.RecordCount
Combo1.AddItem RSTemp(0)
StrOP(i) = RSTemp(1)
RSTemp.MoveNext
Next
RSTemp.Close
ConnTemp.Close
Set RSTemp = Nothing
Set ConnTemp = Nothing
If Combo1.ListCount > 0 Then Combo1.ListIndex = 0
Exit Sub
ErrFlag:
MsgBox "[读取用户列表]" & Err.Description, vbOKOnly + vbCritical
End Sub
Private Sub Combo1_Click()
RefreshQX
End Sub
Private Sub Form_Load()
Call ShowUser
End Sub
Private Sub vkCommand1_Click()
On Error GoTo ErrFlag
Dim UserName As String
UserName = InputBox("请输入用户名")
UserName = Trim(UserName)
If Len(UserName) <= 0 Then Exit Sub
Dim ConnTemp As New ADODB.Connection
Dim RSTemp As New ADODB.Recordset
Dim StrSQL As String, i As Long, OP As String
OP = ""
For i = 0 To 5
If chkItem(i).Value = vbChecked Then
OP = OP & "1" & ","
Else
OP = OP & "0" & ","
End If
Next
OP = Left(OP, Len(OP) - 1)
StrSQL = "Select * from userlist Where UserName='" & UserName & "'"
ConnTemp.Open StrConn
RSTemp.Open StrSQL, StrConn, adOpenStatic, adLockReadOnly
If RSTemp.RecordCount > 0 Then
MsgBox "该用户名[" & UserName & "]已经存在, 请重新输入", vbOKOnly + vbInformation
RSTemp.Close
Else
StrSQL = "Insert into userlist Values('" & UserName & "','123','" & OP & "')"
ConnTemp.Execute StrSQL
End If
ConnTemp.Close
Set RSTemp = Nothing
Set ConnTemp = Nothing
Call ShowUser
Exit Sub
ErrFlag:
MsgBox "[添加用户]" & Err.Description, vbOKOnly + vbCritical
End Sub
Private Sub vkCommand2_Click()
On Error GoTo ErrFlag
If Combo1.Text = "" Then Exit Sub
Dim ConnTemp As New ADODB.Connection
Dim StrSQL As String, i As Long, OP As String
OP = ""
For i = 0 To 5
If chkItem(i).Value = vbChecked Then
OP = OP & "1" & ","
Else
OP = OP & "0" & ","
End If
Next
OP = Left(OP, Len(OP) - 1)
StrSQL = "Update userlist set OP='" & OP & "' Where UserName='" & Combo1.Text & "'"
ConnTemp.Open StrConn
ConnTemp.Execute StrSQL
ConnTemp.Close
Set ConnTemp = Nothing
StrOP(Combo1.ListIndex + 1) = OP
Exit Sub
ErrFlag:
MsgBox "[保存密码]" & Err.Description, vbOKOnly + vbCritical
End Sub
Private Sub vkCommand3_Click()
If MsgBox("确定要删除用户[" & Combo1.Text & "]吗", vbYesNo + vbQuestion) = vbNo Then Exit Sub
On Error GoTo ErrFlag
Dim ConnTemp As New ADODB.Connection
Dim StrSQL As String, i As Long, OP As String
StrSQL = "Delete * from userlist Where UserName='" & Combo1.Text & "'"
ConnTemp.Open StrConn
ConnTemp.Execute StrSQL
ConnTemp.Close
Set ConnTemp = Nothing
Call ShowUser
Exit Sub
ErrFlag:
MsgBox "[删除用户]" & Err.Description, vbOKOnly + vbCritical
End Sub
Private Sub vkCommand4_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -