Hi micah,
I have created sample. Please refer the below code.
Code
protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Session["UserName"].ToString()))
{
string username = Session["UserName"].ToString();
GetUserStatus(username);
}
}
public void GetUserStatus(string userName)
{
string status = string.Empty;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CONN"].ConnectionString);
SqlCommand cmd = new SqlCommand("GetManager", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserName", userName);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
status = dr["FollowStatus"].ToString();
}
if (dr.HasRows)
{
if (status == "1")
{
btnInvite.Visible = false;
btnCancel.Visible = true;
}
else if (status == "0")
{
btnInvite.Visible = true;
btnCancel.Visible = false;
}
}
else
{
btnInvite.Visible = true;
btnCancel.Visible = false;
}
con.Close();
}
SQL
CREATE PROCEDURE [dbo].[GetManager]
@UserName VARCHAR(20)
AS
BEGIN
DECLARE @USERFollow AS TABLE([Id] INT,[UserName] VARCHAR(20),[ManagerUserName] VARCHAR(20),
[FollowStatus] CHAR(1),[SendDate] DATETIME)
INSERT INTO @USERFollow VALUES(1,'Micah22','Micah22','0','2016-02-10 14:51:07.887')
INSERT INTO @USERFollow VALUES(2,'ClassLady','Micah22','1','2016-02-10 14:51:07.887')
INSERT INTO @USERFollow VALUES(3,'Micah22','Vivian67','1','2016-02-10 14:51:07.887')
INSERT INTO @USERFollow VALUES(6,'Kelvinkn','ClassLady','1','2016-02-14 18:31:26.393')
INSERT INTO @USERFollow VALUES(8,'Kaynt6','Micah22','1','2016-02-14 19:17:42.640')
INSERT INTO @USERFollow VALUES(9,'KenTal','ClassLady','1','2016-02-14 19:18:27.150')
INSERT INTO @USERFollow VALUES(10,'KenTal','KenTal','1','2016-02-14 23:58:37.000')
SELECT * FROM @USERFollow
WHERE ManagerUserName = @UserName AND UserName = @UserName
END
Screenshot
As you can see from the above screenshot
UserName micah22 is same as ManagerUserName and the FollowStatus is 0 so Invite button is visible.
UserName KenTal is same as ManagerUserName and the FollowStatus is 1 so Cancel button is visible.
UserName Kelvinkn has ManagerUserName as "ClassLady" so UserName not equal to ManagerUserName. So Invite button is visible.