User2144323856 posted
Let's say i got a data of employee id, employee name and department id, and the IT department id is 10. Only department id which is 10 can goes to admin page, other department id goes to user page. Can anyone help me thanks.
What I have tried:
string strCom = "SELECT * FROM EmployeeView";
SqlCommand comm = new SqlCommand(strCom, dbITAsset);
SqlDataAdapter sda = new SqlDataAdapter("select * from EmployeeView where EMPLOYEEID='" + txtIDNO.Text + "'", cons);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count > 0)
{
Session["UserID"] = dt.Rows[0][0];
Session["Username"] = dt.Rows[0][1];
Session["DepartmentID"] = dt.Rows[0][2];
string username = Session["Username"].ToString();
string dpid = Session["DepartmentID"].ToString(); // get department id from database
Response.Write("alert('You are logged in as " + dt.Rows[0][1] + "')");
if (dpid == "10")
{
Server.Transfer("Admin.aspx ? dpid=" + dpid);
}
else {
Server.Transfer("User.aspx ? dpid=" + dpid);
}
}
else
{
Response.Write("alert('Invalid ID No')");
}
}