以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]窗口登录权限判断修改(已解决)  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=86804)

--  作者:cd_tdh
--  发布时间:2016/6/26 20:49:00
--  [求助]窗口登录权限判断修改(已解决)


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20160626204259.png
图片点击可在新窗口打开查看


图片点击可在新窗口打开查看此主题相关图片如下:22.png
图片点击可在新窗口打开查看
问题1、我登录窗口如图,一个部门或机构有多个用户,登录时需要判断用户是否属于注册表中的那个部门,这个代码怎么修改啊?

问题2、我有多个表,登录的用户只允许看自己部门内容,这个又怎么改?

Dim bm As WinForm.TextBox = e.Form.Controls("部门")
Dim zh As WinForm.TextBox = e.Form.Controls("账号")
Dim mm As WinForm.TextBox = e.Form.Controls("密码")

If bm.Value ="" Then
    MessageBox.Show ("请输入机构或部门!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
    Return
End If
If zh.Value ="" Then
    MessageBox.Show ("请输入账号!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
    Return
End If
If mm.value = "" Then
    MessageBox.Show ("密码不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
    Return
End If

Dim fdr As DataRow = DataTables("账号密码").Find("账号 = \'" & zh.text & "\'")
If fdr IsNot Nothing Then
Dim mms As String = fdr("密码")
    If  mm.value= mms  Then
        vars("当前用户") = fdr
        DataTables("分公司管理").LoadFilter = "所属机构 = \'" & vars("当前用户")("部门") & "\'"
        DataTables("分公司管理").load
        For Each tb As Table In Tables
            tb.Visible = True
        Next     
e.Form.close
    Else
        MessageBox.Show ("账号不存在,或者密码错误!","提示",MessageBoxButtons.OK)
        zh.value=""
        mm.value=""
    End If
End If

[此贴子已经被作者于2016/6/29 22:36:41编辑过]

--  作者:大红袍
--  发布时间:2016/6/27 0:09:00
--  

1、直接判断啊

 

http://www.foxtable.com/help/topics/0396.htm

 

2、直接加载啊

 

DataTables("分公司管理").LoadFilter = "所属机构 = \'" & vars("当前用户")("部门") & "\'"
DataTables("分公司管理").load


--  作者:cd_tdh
--  发布时间:2016/6/27 10:32:00
--  
大红袍老师,我分公司管理是单独的一张表,我现在有很多张表啊?
--  作者:大红袍
--  发布时间:2016/6/27 10:34:00
--  
 多张表,就拷贝写多行
--  作者:大红袍
--  发布时间:2016/6/27 10:35:00
--  

或者这样写

 

Dim tbs() As String = {"表1", "表2", "表2"}
For Each tb As String In tbs
    DataTables(tb).LoadFilter = "所属机构 = \'" & vars("当前用户")("部门") & "\'"
    DataTables(tb).load
Next


--  作者:cd_tdh
--  发布时间:2016/6/27 13:20:00
--  

大红袍老师,登录按钮代码如下,提示错误,怎么修改?


图片点击可在新窗口打开查看此主题相关图片如下:11.jpg
图片点击可在新窗口打开查看
 

Dim bm  As WinForm.TextBox = e.Form.Controls("部门")

Dim zh  As WinForm.ComboBox = e.Form.Controls("账号")

Dim mm As WinForm.TextBox = e.Form.Controls("密码")

 

If zh.Value ="" Then

    MessageBox.Show ("请选择账号!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)

    Return

End If

If mm.value = "" Then

    MessageBox.Show ("密码不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)

    Return

End If

 

Dim tbs() As String = { "分公司管理", "外经证管理", "保证金管理" }

If tbs IsNot Nothing Then

For Each tb As String In tbs

        DataTables(tb).LoadFilter = "所属机构 = \'" & vars("当前用户")("部门") & "\'"

        DataTables(tb).load

        Next

 

e.Form.close

    Else

        MessageBox.Show ("账号不存在,或者密码错误!","提示",MessageBoxButtons.OK)

        zh.value=""

        mm.value=""

 End If


--  作者:大红袍
--  发布时间:2016/6/27 14:38:00
--  
 去看登陆按钮的代码啊,用find函数找到对应的用户那一行。
--  作者:cd_tdh
--  发布时间:2016/6/27 15:02:00
--  

不知道怎么调啊,代码贴出,请老师直接修改,感谢感谢。


--  作者:大红袍
--  发布时间:2016/6/27 15:38:00
--  

查找对应的行,得到数据啊

 

Dim fdr As DataRow = DataTables("账号密码").Find("账号 = \'" & zh.text & "\'")


--  作者:大红袍
--  发布时间:2016/6/27 15:41:00
--  

Dim bm As WinForm.TextBox = e.Form.Controls("部门")
Dim zh As WinForm.TextBox = e.Form.Controls("账号")
Dim mm As WinForm.TextBox = e.Form.Controls("密码")

If bm.Value ="" Then
    MessageBox.Show ("请输入机构或部门!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
    Return
End If
If zh.Value ="" Then
    MessageBox.Show ("请输入账号!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
    Return
End If
If mm.value = "" Then
    MessageBox.Show ("密码不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
    Return
End If

Dim fdr As DataRow = DataTables("账号密码").Find("账号 = \'" & zh.text & "\'")
If fdr IsNot Nothing Then
    Dim mms As String = fdr("密码")
    If  mm.value= mms  Then
        vars("当前用户") = fdr
        Dim tbs() As String = { "分公司管理", "外经证管理", "保证金管理" }
       
        If tbs IsNot Nothing Then
            For Each tb As String In tbs
                DataTables(tb).LoadFilter = "所属机构 = \'" & vars("当前用户")("部门") & "\'"
                DataTables(tb).load
            Next
            e.Form.close
        End If
    Else
        MessageBox.Show ("密码错误!","提示",MessageBoxButtons.OK)
    End If
Else
    MessageBox.Show ("账号不存在","提示",MessageBoxButtons.OK)
End If