我知道有一些关于如何根据用户的访问级别将用户重定向到特定页面的资源。
我的问题是My有一些缺陷阻止它正常工作。
非常感谢您的帮助。
这是我们正在努力做的。
我们有心怀不满的员工。为这些员工提供了访问和提交申诉的链接。
一旦员工提出了他/她的申诉,那么员工的经理将登录并将被重定向到一个页面,该页面显示了所有提出申诉的员工,以便他们审查他们的申诉,并决定员工是否被批准与董事会会面以审查他们的案件,这就是我被卡住的地方。
有两个表不是我设计的。所以,我正在努力充分利用我所拥有的一切。
一个名为Employee的表,包含员工用户名(employeeID)和密码(ssn)。
另一个名为Details的表有employeeID(与Employee表相关)和ManagerID也通过employeeID
与Employee表相关一旦用户提交他/她的申诉,他/她的经理的ID (EmployeeID)被保存为ManagerID到详细信息表中。
这个想法是,一旦经理登录到系统,他/她的ID (ManageID)出现在详细信息表中,他/她将被重定向到一个名为Decision.aspx的页面。
当我尝试编码时,每个人,包括管理人员都被重定向到同一个名为LetterOfIntent.aspx的页面。
你知道我做错了什么吗?
代码如下:
StrSQL = "Select Dept, division, divisionManager, EmployeeName,Employee.EmpID, Email, SSN,Category FROM Employee e,Details d Where e.empID = d.managerID OR e.empID = @empid and SSN=@Password"
' Initialize Database Connection
Dim connStr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Dim conn As New SqlConnection(connStr)
Dim cmd As New SqlCommand(StrSQL, conn)
'We use parametized query to prevent sql injection attack
Dim p1 As New SqlParameter("@enpid", StrUser)
Dim p2 As New SqlParameter("@Password", StrPass)
cmd.Parameters.Add(p1)
cmd.Parameters.Add(p2)
While dr.Read()
If dr("empid") <> "" And dr("ssn") <> "" Then
Session("fullname") = dr("empName")
Session("dept") = dr("Dept")
Session("password") = dr("SSN")
Session("Email") = dr("Email")
Session("division") = dr("division")
Session("empid") = dr("empid")
Session("managerID") = dr("managerId")
Session("Cat") = dr("Category")
BValid = True
Else
End If
End While
' This handles all response per validation
If BValid = True Then
If Session("Cat") = "Pending" Then
Response.Redirect("~/pending.aspx")
ElseIf Session("Cat") = "In Progress" Then
Response.Redirect("~/inprogress.aspx")
ElseIf Session("managerID") <> "" And Session("empid") = Session("managerID") Then '***This is a manager, send him/her to Decision page
Response.Redirect("~/Decision.aspx")
Else '***Ok, this is an employee trying to file grievance, send him to LetterofInternt page.
Response.Redirect("~/LetterOfIntent.aspx?myname= " & Session("empid") & "")
End If
'If all else fails, then reject their athentication attempt and let them know.
ElseIf BValid = False Then
lblMsg.ForeColor = Color.Red
lblMsg.Text = "Login failed. "
End If
我怀疑您需要ToString您放入会话中的每个值,像这样:
Session("Cat") = dr("Category").ToString()
你需要把一些空检查周围的每一个,但鉴于信息,它似乎可能是你的问题。