?? 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 + -