tablename Friends Id int MyId int FriendId int Message text FriendStatus bit //this datatype creates the table allow nulls FriendShipDate datetime ImageName varchar(500)
DataBaseClass dbClass = new DataBaseClass(); public DataTable dt; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { GetUserFriendsRequest(int.Parse(Request.QueryString["Id"].ToString())); } } public void GetUserFriendsRequest(int Id) { string getFriendRequestQuery = "Select * FROM [User] where Id IN (SELECT MyId as Id FROM Friends WHERE FriendId='" + Id + "' AND FriendStatus=0)";//this query does not work when freind request is send FriendStatus column is null and UserFriendRequest control is not display FriendStatus datatype is bit which store null or 1 0r 0 i use logic Friendid=id and Friend status=0 FriendId is updated but i not understand about FriendStatus the i use the logic when userfriend request control appears When user accepts friendstatus is updated to 1 and when deny friendstatus is 2 i use the right logic? dt = dbClass.ConnectDataBaseReturnDT(getFriendRequestQuery); if (dt.Rows.Count > 0) { FreindRequestList.DataSource = dt; FreindRequestList.DataBind(); } } public string getHREF(object sURL) { DataRowView dRView = (DataRowView)sURL; string Id = dRView["Id"].ToString(); return ResolveUrl("~/UserDetails.aspx?Id=" + Id); } public string getSRC(object imgSRC) { DataRowView dRView = (DataRowView)imgSRC; string ImageName = dRView["ImageName"].ToString(); if (ImageName == "NoImage") { return ResolveUrl(@"~/UserImage/missing.jpg"); } else { return ResolveUrl("~/UserImage/" + dRView["ImageName"].ToString()); } } protected void FreindRequestList_ItemCommand(object source, DataListCommandEventArgs e) { if (!object.Equals(Session["UserId"], null)) { if (e.CommandName == "Accept") { string SenderFriendId = ((HtmlInputHidden)e.Item.FindControl("hiddenId")).Value; string MyID = Session["UserId"].ToString(); string AcceptFriendQuery = "Update Friends set FriendStatus=1 where MyId='" + SenderFriendId + "' AND FriendId='" + MyID + "'"; dbClass.ConnectDataBaseToInsert(AcceptFriendQuery); Response.Redirect("UserDetails.aspx?Id=" + Request.QueryString["Id"].ToString()); } if (e.CommandName == "Deny") { string SenderFriendId = ((HtmlInputHidden)e.Item.FindControl("hiddenId")).Value; string MyID = Session["UserId"].ToString(); string AcceptFriendQuery = "Update Friends set FriendStatus=0 where MyId='" + SenderFriendId + "' AND FriendId='" + MyID + "'"; dbClass.ConnectDataBaseToInsert(AcceptFriendQuery); Response.Redirect("UserDetails.aspx?Id=" + Request.QueryString["Id"].ToString()); } } }
foreach (Bacon slice in Fridge.getBacon() { slice.addSeasoning(new LiquideNitrogen()); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)