?? frm_sys_set.frm
字號:
VERSION 5.00
Begin VB.Form Frm_sys_set
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 0 'None
Caption = "賬號管理"
ClientHeight = 4770
ClientLeft = 4050
ClientTop = 3450
ClientWidth = 6990
Icon = "Frm_sys_set.frx":0000
LinkTopic = "Form8"
ScaleHeight = 318
ScaleMode = 3 'Pixel
ScaleWidth = 466
ShowInTaskbar = 0 'False
Begin 計算機圖書管理系統2008.xp_canvas xp_canvas1
Height = 3495
Left = 0
TabIndex = 0
Top = 720
Width = 7215
_extentx = 12726
_extenty = 6165
Begin 計算機圖書管理系統2008.xpcmdbutton Command4
Height = 375
Left = 5160
TabIndex = 13
Top = 2880
Width = 1335
_extentx = 2355
_extenty = 661
caption = "退 出"
font = "Frm_sys_set.frx":0CCA
End
Begin 計算機圖書管理系統2008.xpcmdbutton Command3
Height = 375
Left = 3600
TabIndex = 12
Top = 2880
Width = 1335
_extentx = 2355
_extenty = 661
caption = "刪除賬號"
font = "Frm_sys_set.frx":0CF2
End
Begin 計算機圖書管理系統2008.xpcmdbutton Command2
Height = 375
Left = 2040
TabIndex = 11
Top = 2880
Width = 1335
_extentx = 2355
_extenty = 661
caption = "修改賬號"
font = "Frm_sys_set.frx":0D1A
End
Begin 計算機圖書管理系統2008.xpcmdbutton Command1
Height = 375
Left = 480
TabIndex = 10
Top = 2880
Width = 1335
_extentx = 2355
_extenty = 661
caption = "增加賬號"
font = "Frm_sys_set.frx":0D42
End
Begin VB.ListBox List1
Appearance = 0 'Flat
BackColor = &H00C0FFFF&
BeginProperty Font
Name = "新宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2190
Left = 4320
TabIndex = 5
Top = 120
Width = 2295
End
Begin VB.Frame Frame1
BackColor = &H00C0FFFF&
BorderStyle = 0 'None
Height = 2655
Left = 0
TabIndex = 1
Top = 0
Width = 4095
Begin VB.TextBox Text3
BeginProperty Font
Name = "新宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1440
TabIndex = 9
Top = 1800
Width = 2175
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "新宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
IMEMode = 3 'DISABLE
Left = 1440
PasswordChar = "*"
TabIndex = 8
Top = 1080
Width = 2175
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "新宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1440
TabIndex = 7
Top = 360
Width = 2175
End
Begin VB.Label Label3
BackColor = &H00C0FFFF&
Caption = "用戶權限級別"
Height = 495
Left = 120
TabIndex = 4
Top = 1920
Width = 1215
End
Begin VB.Label Label2
BackColor = &H00C0FFFF&
Caption = "用戶密碼"
Height = 495
Left = 120
TabIndex = 3
Top = 1080
Width = 1215
End
Begin VB.Label Label1
BackColor = &H00C0FFFF&
Caption = "用戶賬號"
Height = 495
Left = 120
TabIndex = 2
Top = 360
Width = 1215
End
End
Begin VB.Label Label4
Caption = "用戶賬號列表 :"
BeginProperty Font
Name = "新宋體"
Size = 12
Charset = 0
Weight = 400
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00404040&
Height = 375
Left = 4320
TabIndex = 6
Top = 600
Width = 2175
End
End
Begin 計算機圖書管理系統2008.xptopbuttons xptopbuttons2
Height = 315
Left = 6240
Top = 120
Width = 315
_extentx = 556
_extenty = 556
value = 2
End
Begin 計算機圖書管理系統2008.xptopbuttons xptopbuttons1
Height = 315
Left = 6600
Top = 120
Width = 315
_extentx = 556
_extenty = 556
End
Begin VB.Image Image2
Height = 1545
Left = 0
Picture = "Frm_sys_set.frx":0D6A
Top = 4200
Width = 12765
End
Begin VB.Image Image1
Height = 660
Left = 0
Picture = "Frm_sys_set.frx":2BB44
Top = 0
Width = 7275
End
End
Attribute VB_Name = "Frm_sys_set"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public inx As Integer '用戶列表的索引號
Private Sub Command1_Click() '增加賬號
Dim user As userdata
Dim ans As String '用戶選擇
Dim sql, ss As String
ss = CStr(Trim(Text1.Text))
If Trim(Text1.Text) = "" Then
frmMsg.Show
frmMsg.notice.Visible = True
frmMsg.Text1.Text = "用戶名不能為空!"
Text1.SetFocus
Exit Sub
End If
'檢測用戶名是否已經存在
sql = "select * from user_table where [登錄名]='" & ss & " '"
rst.Close
rst.Open sql, con, adOpenDynamic, adLockOptimistic
If rst.RecordCount > 0 Then
Msgbox "用戶賬號" & ss & "已存在!", vbInformation, "提示!"
Exit Sub
End If
'檢測用戶權限數是否在規定值之間
'1:數據瀏覽者;
'2:借書管理員;
'3:還書管理員;
'4:系統管理員
If Not (Trim(Text3.Text) < 5 And Trim(Text3.Text) > 0) Then
frmMsg.Show
frmMsg.notice.Visible = True
frmMsg.Text1.Text = "用戶權限級別必須是1--4之間的整數!"
Exit Sub
End If
'添加新記錄
user.user_id = CStr(LTrim(Text1.Text))
user.pwd = CStr(LTrim(Text2.Text))
user.right = LTrim(Text3.Text)
ans = Msgbox("增加用戶嗎?", vbOKCancel + vbInformation, "提示!")
If ans = vbOK Then
rst.AddNew
rst![登錄名] = user.user_id
rst![密碼] = user.pwd
rst![權限] = user.right
rst.Update
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
List1.AddItem rst![登錄名]
Command3.Enabled = True
Exit Sub
Else
Exit Sub
End If
End Sub
Private Sub Command2_Click() '修改賬號
Dim ss As String
Dim sql As String
ss = CStr(Trim(Text1.Text))
If Trim(Text1.Text) = "" Then
frmMsg.Show
frmMsg.notice.Visible = True
frmMsg.Text1.Text = "你沒有選擇要編輯的信息!"
Text1.SetFocus
Exit Sub
End If
'修改用戶信息
If inx <> -1 Then
sql = "UPDATE" & " user_table " & " SET [登錄名] ='" & Trim(Text1.Text) & "'" & " where [登錄名] = '" & Trim(List1.List(inx)) & "'"
con.BeginTrans '啟動事務
con.Execute sql '執行查詢
con.CommitTrans '保存所有更改并退出事務
sql = "UPDATE" & " user_table " & " SET [密碼] ='" & Trim(Text2.Text) & "'" & " where [登錄名] = '" & Trim(List1.List(inx)) & "'"
con.BeginTrans
con.Execute sql
con.CommitTrans
sql = "UPDATE" & " user_table " & " SET [權限] ='" & Trim(Text3.Text) & "'" & " where [登錄名]= '" & Trim(List1.List(inx)) & "'"
con.BeginTrans
con.Execute sql
con.CommitTrans
List1.AddItem (Trim(Text1.Text))
List1.RemoveItem (inx)
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End If
End Sub
Private Sub Command3_Click() '刪除賬號
Dim ans As String
If inx = -1 Then '沒有選擇要刪除的項
frmMsg.Show
frmMsg.notice.Visible = True
frmMsg.Text1.Text = "請挑選要刪除的項!"
Exit Sub
End If
If Not rst.EOF Then '如果不是最后一個用戶記錄
ans = Msgbox("確實要刪除此用戶嗎?", vbOKCancel + vbInformation, "提示!")
If ans = vbOK Then
List1.RemoveItem (inx) '索引顯示刪除
rst.Delete '刪除表內記錄
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
inx = -1
Else
Exit Sub
End If
Else
Command2.Enabled = False
Command3.Enabled = False
End If
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim i As Integer
inx = -1 '初始值定為-1
Call open_connection("user_table") '打開user_table表
For i = 0 To rst.RecordCount - 1 '顯示用戶列表
List1.AddItem rst![登錄名]
rst.MoveNext
Next i
End Sub
Private Sub Image1_Click()
End Sub
Private Sub List1_Click()
Dim sql As String
'選擇要修改的用戶記錄,根據索引顯示用戶信息
inx = List1.ListIndex
sql = "select * from user_table where [登錄名] ='" & Trim(List1.List(inx)) & "'"
rst.Close
rst.Open sql, con, adOpenDynamic, adLockOptimistic
Text1.Text = rst![登錄名]
Text2.Text = rst![密碼]
Text3.Text = rst![權限]
End Sub
Private Sub xptopbuttons1_Click()
Unload Me
End Sub
Private Sub xptopbuttons2_Click()
Me.WindowState = 1
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -