?? frmadduser.frm
字號:
Height = 2415
Left = 1680
TabIndex = 21
Top = 120
Width = 1935
Begin VB.ListBox List1
BackColor = &H00E7DFE7&
Height = 2160
ItemData = "FrmAddUser.frx":1982
Left = 120
List = "FrmAddUser.frx":19A4
Style = 1 'Checkbox
TabIndex = 22
Top = 120
Width = 1695
End
End
Begin VB.Frame Frame4
BackColor = &H00E7DFE7&
Caption = "用戶操作級別"
Height = 1935
Left = 120
TabIndex = 17
ToolTipText = "請選擇一個操作級別"
Top = 360
Width = 1575
Begin VB.OptionButton Option1
BackColor = &H00E7DFE7&
Caption = "普通用戶"
Height = 375
Index = 2
Left = 120
TabIndex = 20
ToolTipText = "請選擇一個操作級別"
Top = 1320
Width = 1215
End
Begin VB.OptionButton Option1
BackColor = &H00E7DFE7&
Caption = "超級用戶"
Height = 375
Index = 1
Left = 120
TabIndex = 19
ToolTipText = "請選擇一個操作級別"
Top = 840
Width = 1215
End
Begin VB.OptionButton Option1
BackColor = &H00E7DFE7&
Caption = "系統管理員"
Height = 375
Index = 0
Left = 120
TabIndex = 18
ToolTipText = "請選擇一個操作級別"
Top = 360
Width = 1215
End
End
End
End
Attribute VB_Name = "FrmAddUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim MyAddUser As OpenRs
Dim Choose As Boolean
Dim Level As Integer
Private Sub Cmdcancel_Click()
Unload Me
End Sub
Private Sub cmdComp_Click() '完成按鈕
If Choose = False Then
MsgBox "請選擇一個操作級別!", vbOKOnly + vbInformation, "添加新用戶"
Exit Sub
End If
MyAddUser.rs1.AddNew
MyAddUser.rs1!user_id = Trim(txtUserid.Text)
MyAddUser.rs1!user_name = Trim(txtUsername)
MyAddUser.rs1!user_des = Trim(txtUserdes.Text)
MyAddUser.rs1!user_pwd = Trim(txtPwd1.Text)
MyAddUser.rs1!user_level = Level
MyAddUser.rs1.Update
If MsgBox("添加用戶成功!" & vbCrLf & vbCrLf & "是否繼續添加用戶?", vbYesNo + vbQuestion, "添加用戶") = vbYes Then
Frame3.Visible = False
cmdComp.Visible = False
Frame1.Visible = True
cmdNext.Visible = True
txtUserid.SetFocus
Call ClearText
Else
Unload Me
End If
End Sub
Private Sub cmdNext_Click()
Choose = False
Dim txtUseridSQL As String
If Trim(txtUserid.Text) = "" Then
MsgBox "用戶編號不能為空!", vbOKOnly + vbInformation, "提示"
txtUserid.SetFocus
Exit Sub
Else
txtUseridSQL = "select * from User_Info" '校驗用戶編號是否重復
MyAddUser.rsDK1 txtUseridSQL
While (MyAddUser.rs1.EOF = False)
If Trim(MyAddUser.rs1!user_id) = Trim(txtUserid.Text) Then
MsgBox "用戶編號已存在,請重新輸入用戶編號!", vbOKOnly + vbExclamation, "警告"
txtUserid.Text = ""
txtUsername.Text = ""
txtUserdes.Text = ""
txtUserid.SetFocus
Exit Sub
Else
MyAddUser.rs1.MoveNext
End If
Wend
End If
'***校驗用戶名是否為空
If txtUsername.Text = "" Then
MsgBox "用戶名不能為空!", vbOKOnly + vbInformation, "提示"
txtUsername.SetFocus
Exit Sub
End If
Frame1.Visible = False
Frame2.Visible = True
txtPwd1.SetFocus
cmdNext.Visible = False
cmdNext1.Visible = True
End Sub
Private Sub cmdNext1_Click()
Dim i As Integer
If txtPwd1.Text = "" Then
MsgBox "請輸入密碼!", vbOKOnly + vbInformation, "提示"
txtPwd1.SetFocus
Exit Sub
End If
If txtPwd2.Text = "" Then
MsgBox "請輸入確認密碼!", vbOKOnly + vbInformation, "提示"
txtPwd2.SetFocus
Exit Sub
End If
If txtPwd1.Text <> txtPwd2.Text Then
MsgBox "兩次輸入的密碼不一致!!!" & vbCrLf & vbCrLf & "請重新輸入!", vbOKOnly + vbInformation, "提示"
txtPwd1.Text = ""
txtPwd2.Text = ""
txtPwd1.SetFocus
Exit Sub
End If
Frame2.Visible = False
Frame3.Visible = True
cmdNext1.Visible = False
cmdComp.Visible = True
For i = 0 To 2 '取消選項按鈕選擇
Option1(i).Value = False
Next i
List1.ListIndex = -1
End Sub
Private Sub Choose_level()
Dim i As Integer
If Option1(0).Value = True Then
Level = 1
For i = 0 To 9 '全選
List1.Selected(i) = True
Next i
List1.ListIndex = -1
ElseIf Option1(1).Value = True Then
Level = 2
For i = 0 To 6
List1.Selected(i) = True
Next i
List1.Selected(7) = False
List1.Selected(8) = False
List1.Selected(9) = False
List1.ListIndex = -1
ElseIf Option1(2).Value = True Then
Level = 3
List1.Selected(0) = True
List1.Selected(1) = True
For i = 2 To 9
List1.Selected(i) = False
Next i
List1.ListIndex = -1
End If
End Sub
Private Sub Form_Load()
Set MyAddUser = New OpenRs
End Sub
Private Sub Option1_Click(Index As Integer)
Choose = True
Call Choose_level
End Sub
Private Sub ClearText()
Dim i As Integer
txtUserid.Text = ""
txtUsername.Text = ""
txtUserdes.Text = ""
txtPwd1.Text = ""
txtPwd2.Text = ""
For i = 0 To 2 '取消選項按鈕選擇
Option1(i).Value = False
Next i
Choose = False
For i = 0 To 9
List1.Selected(i) = False
List1.ListIndex = -1
Next i
End Sub
Private Sub txtPwd1_KeyPress(KeyAscii As Integer)
If KeyAscii = 39 Then
KeyAscii = 0
ElseIf KeyAscii = 13 Then
txtPwd2.SetFocus
End If
End Sub
Private Sub txtPwd2_KeyPress(KeyAscii As Integer)
If KeyAscii = 39 Then
KeyAscii = 0
ElseIf KeyAscii = 13 Then
Call cmdNext1_Click
End If
End Sub
Private Sub txtUserdes_KeyPress(KeyAscii As Integer)
If KeyAscii = 39 Then
KeyAscii = 0
ElseIf KeyAscii = 13 Then
Call cmdNext_Click
End If
End Sub
Private Sub txtUserId_KeyPress(KeyAscii As Integer)
If KeyAscii = 39 Then
KeyAscii = 0
ElseIf KeyAscii = 13 Then
txtUsername.SetFocus
End If
End Sub
Private Sub txtUsername_KeyPress(KeyAscii As Integer)
If KeyAscii = 39 Then
KeyAscii = 0
ElseIf KeyAscii = 13 Then
txtUserdes.SetFocus
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -