以下为我在系统的自定义的登陆窗口的确定按钮的代码:
Dim r As String =e.Form.Controls("ComboBox1").Value
Dim mm As String =e.Form.Controls("TextBox1").Value
dim kj as string=e.Form.Controls("TextBox2").Value
Dim dr As DataRow
'在用户表查找所输入用户名与密码的行
dr = DataTables("用户").Find("[用户] = '" & r & "' And [密码] = '" & mm & "'")
If dr IsNot Nothing Then '如果找到
if dr("暂停登录")=False then
Vars("_UserGroup ") = dr("组")
Tables("登陆")(0)("用户名") = r '与入当前表第一行用户名列为输入用户名
Tables("登陆")(0)("会计期间") = kj
Vars("_UserName ") = r '写入全局变量
e.Form.Close() '关闭窗口
For Each t As Table In Tables
t.Visible = True
t.AllowEdit = true
t.AllowLockRow = true
t.AllowUnlockRow=true
For Each c As Col In t.Cols
c.Visible = True
c.AllowEdit = True
Next
Next
Tables("登陆").Visible = (Vars("_UserGroup ") = "程序开发")
Tables("提示").Visible = (Vars("_UserGroup ") = "程序开发")
Tables("用户").Visible = (Vars("_UserGroup ") = "程序开发")
Tables("授权表").Visible = (Vars("_UserGroup ") = "程序开发")
If Vars("_UserGroup ") <> "程序开发" Then
For Each dr1 As DataRow In DataTables("授权表").Select("用户名 = '" & Vars("_UserName ") & "'" )
If dr1.IsNull("列名") Then
Tables(dr1("表名")).Visible = Not dr1("不可见")
Tables(dr1("表名")).AllowEdit = Not dr1("不可编辑")
Else
Tables(dr1("表名")).Cols(dr1("列名")).Visible = Not dr1("不可见")
Tables(dr1("表名")).Cols(dr1("列名")).AllowEdit = Not dr1("不可编辑")
End If
if dr1("可审核")=true then
Tables(dr1("表名")).AllowLockRow = true
else
Tables(dr1("表名")).AllowLockRow = False
end if
if dr1("可反审核")=true then
Tables(dr1("表名")).AllowUnlockRow = true
else
Tables(dr1("表名")).AllowUnlockRow = false
end if
if dr1("只能编辑个人数据")=true then
?????(我想在这个地方一次性地设计代码,不用到每个表的相关事件中再去设计代码,不知可否,想不明白啊)
else
?????(我想在这个地方一次性地设计代码,不用到每个表的相关事件中再去设计代码,不知可否,想不明白啊)
end if
Next
End If
'for each rb as RibbonMenu.Tab in RibbonTabs 'RibbonTabs是一个菜单集合,可以用for each遍历的
'rb.Visible = True '显示菜单
'Next
'按用户组显示或隐藏菜单项目
'If Vars("用户组") <> "管理员" Then
' RibbonTabs("DIY")("管理员操作").Visible = False
' RibbonTabs("DIY")("设计员操作").Visible = False
'Else
' RibbonTabs("DIY")("管理员操作").Visible = True
'RibbonTabs("DIY")("设计员操作").Visible = True
'End If
maintable=tables("工资录入表") '登陆成功
Else
MessageBox.Show("用户已被暂停使用!,请与管理员联系", "提示", MessageBoxButtons.ok, MessageBoxIcon.Error)
e.Form.Controls("TextBox1").Select() '将输入焦点移到密码文本框中.
end if
else
MessageBox.Show("用户名或密码错误!", "提示", MessageBoxButtons.ok, MessageBoxIcon.Error)
e.Form.Controls("TextBox1").Select() '将输入焦点移到密码文本框中.
End If