protected void AddToFriend_Click(object sender, EventArgs e) { if (!object.Equals(Session["UserId"], null)) { if (Session["UserId"].ToString() !="") { lblError.Text = "Your own profile"; lblError.Visible = true; } else { string chkfriendRequest = "SELECT * FROM Friend WHERE (myid='" + Session["UserId"].ToString() + "' and frandid='" + Convert.ToInt32(Request.QueryString["id"])+ "') OR (myid='" + Convert.ToInt32(Request.QueryString["id"]) + "' and frandid='" + Session["UserId"].ToString() + "')"; DataTable dt1 = new DataTable(); dt1 = dbClass.ConnectDataBaseReturnDT(chkfriendRequest); if (dt1.Rows.Count > 0) { if (dt1.Rows[0]["FriendStatus"].ToString() == "1") { lblError.Text = "Already in friend list"; lblError.Visible = true; } if (dt1.Rows[0]["FriendStatus"].ToString() == "0") { lblError.Text = "Friend Request Pending"; lblError.Visible = true; } if (dt1.Rows[0]["FriendStatus"].ToString() == "2") { lblError.Text = "Friend Request deny"; lblError.Visible = true; } } else { string friendRequest = "Insert INTO Friend (myid,frandid) VALUES('" + Session["UserId"].ToString() + "','" + Convert.ToInt32(Request.QueryString["id"]) + "')"; dbClass.ConnectDataBaseToInsert(friendRequest); lblError.Text = "Friend Request Send"; lblError.Visible = true; } } } else { Response.Redirect("~/Login.aspx"); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)