我做了一个自来水厂的管理系统,现在要做系统的授权模块,但我对授权没经验,哪位大虾能给小弟指点一下,系统,详细地说一下该如何设计,或给一些相关的源码小弟看看,非常感谢!!!

解决方案 »

  1.   

    在数据库中建两个表
    一个表是授权表,其中有编号、姓名、权限、口令
    另一个是权限表,其中就有一个权限字段,把程序中所有用的权限全部写进去。
      snp.FindFirst "[" + snp.Fields(0).Name + "] = '" + Trim$(TextNumber.Text) + "'"
        If snp.NoMatch Then
            chk = 1
        Else
            If Not IsNull(snp("口令")) Then
                If TextPassWord.Text <> snp("口令") Then
                    chk = 2
                Else
                    If IsNull(snp("WorkAt")) Then
                        chk = 0
                    Else
                        If snp("WorkAt") <> MachineName Then
                            chk = 3
                        Else
                            chk = 0
                        End If
                    End If
                End If
            Else
                If TextPassWord.Text <> "" Then
                    chk = 2
                Else
                    If IsNull(snp("WorkAt")) Then
                        chk = 0
                    Else
                        If snp("WorkAt") <> MachineName Then
                            chk = 3
                        Else
                            chk = 0
                        End If
                    End If
                End If
            End If
        End If
        If chk = 0 Then
            Panel(1).Caption = snp("姓名") + ",您好:" + Chr$(13) + "祝您工作顺利!"
        ElseIf chk = 3 Then
            msg = Chr$(13) + "该用户已在" & snp("WorkAt") & "上工作" + Chr$(13) + "不准再次登录!"
            Panel(1).Caption = msg
        Else
            Counter = Counter - 1
            If Counter = 0 Then
                msg = Chr$(13) + "你不是合法用户!" + Chr$(13) + "对不起,再见!"
            ElseIf Counter = 1 Then
                msg = Chr$(13) + "这是最后一次.请仔细!"
            Else
                msg = Chr$(13) + "别急,想好.请再试一次"
            End If
            TextPassWord.Text = ""
            TextPassWord.Enabled = False
            If chk = 1 Then
                Panel(1).Caption = "无此编号∶" + TextNumber.Text + msg
            ElseIf chk = 2 Then
                Panel(1).Caption = "错误口令" + Chr$(13) + msg
            End If
        End If
    以上是登陆时执行的。以后在程序中用到权限的时候就按下边写就可以了。
        If InStr(Employee.Empower, "保存档案") <= 0 Then Exit Sub
    这句的意思是有保存档案的权限就向下进行,否则就执行Exit Sub
      

  2.   

    谢谢: LCAAA(小小程序员),说得很详细!但小弟要问的是每个操作员如何根据自己的权限进入系统后实行对其权限内的模块的操作!就是如何设定用户的权限?!