📄 form2.frm
字号:
VERSION 5.00
Object = "{CFA7AFF4-3242-4269-9172-7389D695AE01}#1.0#0"; "StoneXP.ocx"
Object = "{DAAC6951-59A4-4C08-9D6E-FE3919B64861}#1.0#0"; "FlexCell.ocx"
Begin VB.Form Form2
BorderStyle = 3 'Fixed Dialog
Caption = "用户管理"
ClientHeight = 5025
ClientLeft = 45
ClientTop = 375
ClientWidth = 5565
LinkTopic = "Form2"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 5025
ScaleWidth = 5565
ShowInTaskbar = 0 'False
Begin StoneXP.XPButton XPButton5
Height = 375
Left = 4200
TabIndex = 5
Top = 4560
Width = 975
_ExtentX = 1720
_ExtentY = 661
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 = "退 出"
MouseIcon = "Form2.frx":0000
MousePointer = 99
End
Begin StoneXP.XPButton XPButton4
Height = 375
Left = 3240
TabIndex = 4
Top = 4560
Width = 975
_ExtentX = 1720
_ExtentY = 661
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 = "删 除"
MouseIcon = "Form2.frx":031A
MousePointer = 99
End
Begin StoneXP.XPButton XPButton3
Height = 375
Left = 2280
TabIndex = 3
Top = 4560
Width = 975
_ExtentX = 1720
_ExtentY = 661
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 = "修 改"
MouseIcon = "Form2.frx":0634
MousePointer = 99
End
Begin StoneXP.XPButton XPButton2
Height = 375
Left = 1320
TabIndex = 2
Top = 4560
Width = 975
_ExtentX = 1720
_ExtentY = 661
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 = "保 存"
MouseIcon = "Form2.frx":094E
MousePointer = 99
End
Begin StoneXP.XPButton XPButton1
Height = 375
Left = 360
TabIndex = 1
Top = 4560
Width = 975
_ExtentX = 1720
_ExtentY = 661
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 = "添 加"
MouseIcon = "Form2.frx":0C68
MousePointer = 99
End
Begin FlexCell.Grid Grid1
Height = 4335
Left = 0
TabIndex = 0
Top = 120
Width = 5535
_ExtentX = 9763
_ExtentY = 7646
Cols = 5
Rows = 30
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim gridsave As Boolean
Dim gridedit As Boolean
Dim griddelete As Boolean
Private Sub Form_Load()
On Error GoTo finish
Grid1.SetRegisterInformation "CNwinndy", "W]vyY-nonvk-u\nty-Zbl_e-`hms^" '进行注册
With Grid1
.AllowUserResizing = True
.DisplayFocusRect = False
.ExtendLastCol = True
.Appearance = Flat
.FixedRowColStyle = Flat
.ScrollBarStyle = Flat
.DefaultFont.Name = "Tahoma"
.DefaultFont.Size = 8
.BackColorFixed = RGB(90, 158, 214)
.BackColorFixedSel = RGB(110, 180, 230)
.BackColorBkg = RGB(90, 158, 214)
.BackColorScrollBar = RGB(231, 235, 247)
.BackColor1 = RGB(231, 235, 247)
.BackColor2 = RGB(239, 243, 255)
.GridColor = RGB(148, 190, 231)
.AllowUserResizing = True
.DisplayFocusRect = False
.ExtendLastCol = True
.Appearance = Flat
.FixedRowColStyle = Flat
.ScrollBarStyle = Flat
.GridColor = RGB(148, 190, 231)
.DefaultFont.Name = "Tahoma"
.DefaultFont.Size = 8
.Column(0).Width = 0
.Column(1).Width = 100
.Column(2).Width = 100
.Column(3).Width = 100
.Column(3).CellType = cellComboBox
.ComboBox(3).Clear
.ComboBox(3).AddItem "经理"
.ComboBox(3).AddItem "管理员"
.ComboBox(3).AddItem "客户"
End With
Call callmain
Grid1.Column(1).Locked = True
gridsave = False
gridedit = True
griddelete = True
mdi = False
Exit Sub
finish:
MsgBox Err.Description
End Sub
Private Sub callmain()
On Error GoTo finish
gridsave = False
gridedit = True
griddelete = True
Set mdbrs = mdbconn.Execute("select * from 登陆")
Grid1.Rows = 1
i = 3
Grid1.Cols = i + 1
For i = 0 To 2
Grid1.Cell(0, i + 1).Text = mdbrs.Fields(i).Name
Next
i = 1
Do While Not mdbrs.EOF
Grid1.Rows = Grid1.Rows + 1
For j = 1 To 3 '设定读取列
If mdbrs.Fields(j - 1) = Null Then '空值的处理
Grid1.Cell(i, j).Text = ""
Else
Grid1.Cell(i, j).Text = mdbrs.Fields(j - 1)
End If
Next
i = i + 1
mdbrs.MoveNext '读取下一记录
Loop
Grid1.Column(1).Locked = True
Exit Sub
finish:
MsgBox Err.Description
End Sub
Private Sub Form_LostFocus()
Form2.Show
End Sub
Private Sub Form_Unload(Cancel As Integer)
mdi = True
End Sub
Private Sub XPButton1_Click()
On Error GoTo finish
gridsave = True
gridedit = False
griddelete = False
Set mdbrs = mdbconn.Execute("select * from 登陆")
Grid1.Rows = 1
Grid1.Rows = 2
Grid1.Column(1).Locked = False
Grid1.Cell(1, 1).SetFocus
Exit Sub
finish:
MsgBox Err.Description
End Sub
Private Sub XPButton2_Click()
On Error GoTo finish
If gridsave = False Then
MsgBox "不支持保存操作!", vbInformation, "当前不支持"
Exit Sub
End If
If Grid1.Cell(1, 3).Text = "经理" Then
If chair = False Then
MsgBox "对不起,您不是经理,不能添加经理!!"
Exit Sub
End If
End If
If Grid1.Cell(1, 3).Text = "管理员" Then
If chair = False Then
MsgBox "对不起,只有经理可以添加管理员,管理员只能添加客户!!"
Exit Sub
End If
End If
If Grid1.Cell(1, 1).Text <> "" And Grid1.Cell(1, 2).Text <> "" Then
Set mdbrs = mdbconn.Execute("select * from 登陆 where 用户名='" & Grid1.Cell(1, 1).Text & "'")
If mdbrs.EOF = True Then
Set mdbrs = mdbconn.Execute("insert into 登陆 values('" & Grid1.Cell(1, 1).Text & "','" & Grid1.Cell(1, 2).Text & "','" & Grid1.Cell(1, 3).Text & "')")
MsgBox "提交成功!", vbInformation, ""
Call callmain
Else
MsgBox "该管理员己存在!", vbInformation, "不可重名"
Exit Sub
End If
Else
MsgBox "用户名和密码都不可以是空格!", vbInformation, "错误提示"
End If
Exit Sub
finish:
MsgBox Err.Description
End Sub
Private Sub XPButton3_Click()
On Error GoTo finish
If gridedit = False Then
MsgBox "当前修改操作不被允许!", vbInformation, "非使用对象"
Exit Sub
End If
'If Grid1.Cell(hang, 3).Text = "经理" Then
' If chair = False Then
' MsgBox "你不是经理,不能修改经理的数据!!"
' Exit Sub
' End If
'End If
For i = 1 To Grid1.Rows - 1
Set mdbrs = mdbconn.Execute("update 登陆 set 密码='" & Grid1.Cell(i, 2).Text & "',权限='" & Grid1.Cell(i, 3).Text & "' where 用户名='" & Grid1.Cell(i, 1).Text & "'")
Next
MsgBox "修改的数据己经完成", vbInformation, "完成操作"
Call callmain
Exit Sub
finish:
MsgBox Err.Description
End Sub
Private Sub XPButton4_Click()
On Error GoTo finish
If griddelete = False Then
MsgBox "当前删除操作不被允许!", vbInformation, "非使用对象"
Exit Sub
End If
If chair = False Then
MsgBox "对不起,只有经理有权利删除!!"
Exit Sub
End If
If hang = 0 Then
MsgBox "没有选择用户或者没有用户可以删除!", vbInformation, "非使用对象"
Exit Sub
End If
Set mdbrs = mdbconn.Execute("delete from 登陆 where 用户名='" & Grid1.Cell(hang, 1).Text & "'")
MsgBox "目标己删除,请刷新数据!", vbInformation, "删除成功"
Call callmain
Exit Sub
finish:
MsgBox Err.Description
End Sub
Private Sub XPButton5_Click()
Unload Me
End Sub
Private Sub Grid1_RowColChange(ByVal Row As Long, ByVal Col As Long)
hang = Row
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -