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