I have written a separate class that holds the permissions of my website. I make calls to this class in every class I have. I am having trouble bringing back the values from my permissions class. I will show you what I have below:
Permissions Class
public class Permissions
{
public static string selectedNumber = "";
public static string selectedName= "";
public static string selectedLocation= "";
public Info SetInfo(string selectedValue)
{
string selectInfo = "SELECT [Num] AS 'Number', [Name] AS 'Name', CONVERT(nvarchar(50),RTRIM(b.Num])) + ' - ' + CONVERT(nvarchar(50),b.Name) AS 'Location' "
+ "FROM [TBL_Info] a "
+ "left join [TBL_Where] b on (a.[ID] = b.[ID]) "
+ "WHERE a.ID = @ID";
sqlCmd = new SqlCommand(selectInfo, sqlConn);
sqlConn.Open();
sqlCmd.Parameters.AddWithValue("@ID", selectedValue);
SqlDataReader rdrInfo = sqlCmd.ExecuteReader();
if (rdrInfo.HasRows)
{
rdrInfo.Read();
selectedNumber = rdrInfo .GetSqlString(rdrInfo .GetOrdinal("Number")).ToString();
selectedName= rdrInfo .GetSqlString(rdrInfo .GetOrdinal("Name")).ToString();
selectedLocation = rdrInfo .GetSqlString(rdrInfo .GetOrdinal("Location")).ToString();
}
sqlCmd.Connection.Close();
return new Info()
{
number= selectedNumber,
name= selectedName,
location= selectedLocation
};
}
public class Info
{
public String number{ get; set; }
public String name{ get; set; }
public String location{ get; set; }
}
}
And I am currently trying to call it in another class like this:
Classes.Permissions permission = new Classes.Permissions();
permission.SetInfo(selectedUserValue);
The end product is that I set textboxes in the class I am trying to make the call from with the 3 return values from permission.SetInfo()
Currently I am not able to get anything returned.... I know I am doing something wrong, clearly. So can someone please give me some advice on how to achieve this?