Exemplo n.º 1
0
    protected void lnkDelFriend_Click(object sender, EventArgs e)
    {
        int id = CommonMethod.ConvertToInt(hidId.Value, 0);

        if (id > 0)
        {
            XiHuan_UserFriendsEntity friend = new XiHuan_UserFriendsEntity();
            friend.Id = id;
            friend.Retrieve();
            if (friend.IsPersistent)
            {
                friend.Delete();
                Alert("恭喜:成功解除好友关系!");
                BindData();
            }
        }
    }
Exemplo n.º 2
0
    private void AddFriend(string fid, string fname)
    {
        if (!IsUserAlreadyLogin)
        {
            CommonMethod.ResponseAjaxContent(this.Page, "needlogin");
            return;
        }
        else
        {
            fname = GlobalObject.unescape(fname);
            if (fname.Equals(CurrentUserName))
            {
                CommonMethod.ResponseAjaxContent(this.Page, "self");
                return;
            }

            else
            {
                RetrieveCriteria rc = new RetrieveCriteria(typeof(XiHuan_UserFriendsEntity));
                Condition        c  = rc.GetNewCondition();
                c.AddEqualTo(XiHuan_UserFriendsEntity.__OWNERID, CurrentUserId);
                c.AddEqualTo(XiHuan_UserFriendsEntity.__FRIENDID, fid);
                rc.AddSelect(XiHuan_UserFriendsEntity.__ID);
                DataTable dt = rc.AsDataTable();
                if (dt != null && dt.Rows.Count > 0)
                {
                    CommonMethod.ResponseAjaxContent(this.Page, "already");
                    return;
                }
                else
                {
                    XiHuan_UserFriendsEntity newfriend = new XiHuan_UserFriendsEntity();
                    newfriend.OwnerId    = CurrentUserId;
                    newfriend.OwnerName  = CurrentUserName;
                    newfriend.FriendId   = CommonMethod.ConvertToInt(fid, 0);
                    newfriend.FriendName = fname;
                    newfriend.AddDate    = DateTime.Now;
                    newfriend.FriendDesc = "";
                    newfriend.Save();
                    CommonMethod.ResponseAjaxContent(this.Page, "ok");
                }
            }
        }
    }