📄 frmuserman.vb
字号:
If updateflag = 0 Then
cmd_save.Enabled = False
cmd_add.Enabled = True
cmd_Del.Enabled = True
cmd_modify.Enabled = True
txt_name.Enabled = False
txt_pwd.Enabled = False
txt_chkpwd.Enabled = False
comb_usertype.Enabled = False
Exit Sub
End If
If updateflag = 1 Then
txt_name.Text = ""
txt_pwd.Text = ""
txt_chkpwd.Text = ""
comb_usertype.SelectedText = ""
cmd_save.Enabled = True
cmd_add.Enabled = False
cmd_Del.Enabled = False
cmd_modify.Enabled = False
txt_name.Enabled = True
txt_pwd.Enabled = True
txt_chkpwd.Enabled = True
comb_usertype.Enabled = True
Exit Sub
End If
If updateflag = 2 Then
txt_name.Enabled = True
txt_pwd.Enabled = True
txt_chkpwd.Enabled = True
comb_usertype.Enabled = True
cmd_save.Enabled = True
cmd_add.Enabled = False
cmd_Del.Enabled = False
cmd_modify.Enabled = False
Exit Sub
End If
End Sub
Public Sub ShowData(ByVal tmpuser As CUsers)
txt_name.Text = tmpuser.UserName
txt_pwd.Text = tmpuser.UserPassWord
txt_chkpwd.Text = tmpuser.UserPassWord
comb_usertype.SelectedText = tmpuser.UserType
End Sub
Private Sub cmd_add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_add.Click
IsUpdated = 1 '添加
IsUpdate(IsUpdated)
MyUser.Initials()
cmd_cancel.Text = "取 消"
End Sub
Private Sub cmd_save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_save.Click
If IsUpdated = 0 Then
Exit Sub
End If
Dim tmpuser As New CUsers
tmpuser.Equal(MyUser)
If IsUpdated = 1 Then
If Trim(txt_name.Text) = "" Then
MsgBox("用户名称不能为空", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
txt_name.Focus()
Exit Sub
End If
tmpuser.UserName = MakeStr(txt_name.Text)
If Trim(txt_pwd.Text) = "" Then
MsgBox("密码不能为空", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
txt_pwd.Focus()
Exit Sub
End If
If Trim(txt_chkpwd.Text) = "" Then
MsgBox("确认密码不能为空", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
txt_chkpwd.Focus()
Exit Sub
End If
If Trim(txt_chkpwd.Text) <> Trim(txt_pwd.Text) Then
MsgBox("两次输入的密码不相同。", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
txt_pwd.Text = ""
txt_chkpwd.Text = ""
txt_pwd.Focus()
Exit Sub
End If
tmpuser.UserPassWord = MakeStr(txt_pwd.Text)
If Trim(comb_usertype.Text) = "" Then
MsgBox("请选择用户类型", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
txt_name.Focus()
Exit Sub
End If
tmpuser.UserType = MakeStr(comb_usertype.Text)
If tmpuser.IsInDB(tmpuser.UserName) = True Then
MsgBox("用户名称" & tmpuser.UserName & "已存在", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
txt_name.Focus()
Exit Sub
End If
tmpuser.UserID = tmpuser.GetNewID()
tmpuser.InsertDB()
Dim dbset As DataSet
dbset = tmpuser.LoadUserByAdm()
If Not dbset Is Nothing Then
dg_userman.DataSource = dbset.Tables(0).DefaultView
dg_userman.CurrentRowIndex = GetRowIndex(dbset, tmpuser.GetMyRow(dbset))
dg_userman.Select(dg_userman.CurrentRowIndex)
End If
IsUpdated = 0
ShowData(tmpuser)
IsUpdate(IsUpdated)
MyUser.Equal(tmpuser)
End If
If IsUpdated = 2 Then
If Trim(txt_name.Text) = "" Then
MsgBox("用户名称不能为空", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
txt_name.Focus()
Exit Sub
End If
tmpuser.UserName = MakeStr(txt_name.Text)
If Trim(txt_pwd.Text) = "" Then
MsgBox("密码不能为空", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
txt_pwd.Focus()
Exit Sub
End If
If Trim(txt_chkpwd.Text) = "" Then
MsgBox("确认密码不能为空", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
txt_chkpwd.Focus()
Exit Sub
End If
If Trim(txt_chkpwd.Text) <> Trim(txt_pwd.Text) Then
MsgBox("两次输入的密码不相同。", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
txt_pwd.Text = ""
txt_chkpwd.Text = ""
txt_pwd.Focus()
Exit Sub
End If
tmpuser.UserPassWord = MakeStr(txt_pwd.Text)
If Trim(comb_usertype.Text) = "" Then
MsgBox("请选择用户类型", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
txt_name.Focus()
Exit Sub
End If
tmpuser.UserType = MakeStr(comb_usertype.Text)
If tmpuser.UserName <> MyUser.UserName Then
If tmpuser.IsInDB(tmpuser.UserName) = True Then
MsgBox("用户名称" & tmpuser.UserName & "已存在", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
txt_name.Focus()
Exit Sub
End If
End If
tmpuser.UserID = MyUser.UserID
If tmpuser.Modify() Then
MyUser.Equal(tmpuser)
Dim dbset As DataSet
dbset = tmpuser.LoadUserByAdm()
If Not dbset Is Nothing Then
dg_userman.DataSource = dbset.Tables(0).DefaultView
dg_userman.CurrentRowIndex = GetRowIndex(dbset, tmpuser.GetMyRow(dbset))
dg_userman.Select(dg_userman.CurrentRowIndex)
End If
Else
tmpuser.Initials()
End If
IsUpdated = 0
ShowData(MyUser)
IsUpdate(IsUpdated)
End If
End Sub
Private Sub frmUserman_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
IsUpdated = 0
IsUpdate(IsUpdated)
'tmpuser.Initials()
Dim dbset As DataSet
If IsAdmin(CurUser) = True Then
dbset = MyUser.LoadUserByAdm()
Else
dbset = MyUser.GetInfoByName(CurUser.UserName)
End If
If Not dbset Is Nothing Then
dg_userman.DataSource = dbset.Tables(0).DefaultView
End If
End Sub
Private Sub dg_userman_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dg_userman.CurrentCellChanged
IsUpdate(0)
If dg_userman.Item(dg_userman.CurrentRowIndex, 0) Is Nothing Then
Exit Sub
End If
txt_name.Text = dg_userman.Item(dg_userman.CurrentRowIndex, 1)
comb_usertype.Text = dg_userman.Item(dg_userman.CurrentRowIndex, 2)
txt_pwd.Text = dg_userman.Item(dg_userman.CurrentRowIndex, 3)
txt_chkpwd.Text = txt_pwd.Text
MyUser.GetInfoByName(MakeStr(txt_name.Text))
End Sub
Private Sub cmd_Del_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_Del.Click
If MyUser.UserName = "" Then
MsgBox("请选择一个元素", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
Exit Sub
End If
If MyUser.UserName = CurUser.UserName Then
MsgBox("用户[" & CurUser.UserName & "]为当前登陆用户,不能删除", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
Exit Sub
End If
If MsgBox("是否删除用户名称" & MyUser.UserName, MsgBoxStyle.YesNo + MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0") = MsgBoxResult.Yes Then
MyUser.Delete()
Dim dbset As DataSet
dbset = MyUser.LoadUserByAdm()
If Not dbset Is Nothing Then
dg_userman.DataSource = dbset.Tables(0).DefaultView
'dg_userman.CurrentRowIndex = GetRowIndex(dbset, MyUser.GetMyRow(dbset))
'dg_userman.Select(dg_userman.CurrentRowIndex)
End If
IsUpdated = 0
ShowData(MyUser)
IsUpdate(IsUpdated)
End If
End Sub
Private Sub cmd_modify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_modify.Click
If CurUser.UserID <= 0 Then
MsgBox("请选择一个元素", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
Exit Sub
End If
IsUpdated = 2 '修改
IsUpdate(IsUpdated)
cmd_cancel.Text = "取 消"
End Sub
Private Sub cmd_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_cancel.Click
If cmd_cancel.Text = "返 回" Then
Me.Close()
Exit Sub
End If
If cmd_cancel.Text = "取 消" Then
cmd_cancel.Text = "返 回"
IsUpdated = 0
IsUpdate(IsUpdated)
MyUser.Initials()
Exit Sub
End If
End Sub
Private Sub dg_userman_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dg_userman.Click
If dg_userman.CurrentRowIndex < 0 Then
Exit Sub
End If
txt_name.Text = dg_userman.Item(dg_userman.CurrentRowIndex, 1)
comb_usertype.Text = dg_userman.Item(dg_userman.CurrentRowIndex, 2)
txt_pwd.Text = dg_userman.Item(dg_userman.CurrentRowIndex, 3)
txt_chkpwd.Text = txt_pwd.Text
MyUser.GetInfoByName(MakeStr(txt_name.Text))
If cmd_cancel.Text = "取 消" Then
cmd_cancel.Text = "返 回"
IsUpdated = 0
IsUpdate(IsUpdated)
MyUser.Initials()
Exit Sub
End If
End Sub
Private Sub cmd_refresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_refresh.Click
IsUpdated = 0
IsUpdate(IsUpdated)
Dim dbset As DataSet
If IsAdmin(CurUser) = True Then
dbset = MyUser.LoadUserByAdm()
Else
dbset = MyUser.GetInfoByName(CurUser.UserName)
End If
If Not dbset Is Nothing Then
dg_userman.DataSource = dbset.Tables(0).DefaultView
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -