mardi 6 décembre 2016

if else condition not met but still running the code inside

This is a really unusual issue I am having, my if else if condition is not working: 1) I am reading values from web.config

string validuserlist = ConfigurationManager.AppSettings["Quality"].ToString();
string safetylist = ConfigurationManager.AppSettings["Safety"].ToString();
string supervisorlist = ConfigurationManager.AppSettings["Supervisors"].ToString();

2) I am checking to see if current user is in the above list and if the workorder type = the type from the gridview:

if (validuserlist.ToLower().Trim().IndexOf(username.ToLower().Trim()) != -1 && TextBox102.Text == "Quality")
{
then perform something
}
else
{
error your user id does not have permissions
}
else if(safetylist.ToLower().Trim().IndexOf(username.ToLower().Trim()) != -1 && TextBox102.Text == "Safety") 
{
do something
}
else
{
error your user id does not have permissions
}
**else if (supervisorlist.ToLower().Trim().IndexOf(username.ToLower().Trim()) != -1 && TextBox102.Text == "Safety" || TextBox102.Text == "Quality" || TextBox102.Text == "General")**
{
do something 
}
else
{
error your user id does not have permissions
}

The condition is not met at the third condition where it checks for supervisorlist I removed my user id from the web.config and I run the application it still runs the third condition. it is suppose to say you don't have permissions.

enter image description here

enter image description here

as you can see the above condition fails but it still runs that code:

enter image description here

please help if you need any code or logic understanding please ask before marking this question down.

Aucun commentaire:

Enregistrer un commentaire