예제 #1
0
        private void picadd_Click(object sender, EventArgs e)
        {
            BLL.friendInfo          bllFriend = new BLL.friendInfo();
            List <Model.friendInfo> myFriends = bllFriend.GetModelList("userID =" + id);

            if (myFriends.Count == 0)
            {
                FrmAddMsg frm = new FrmAddMsg(id, UserID, HeadImage, UserName, SameFriend);
                frm.Show();
            }
            else
            {
                foreach (Model.friendInfo f in myFriends)
                {
                    if (f.friendID == UserID)
                    {
                        i++;
                    }
                }
                if (i == 0)
                {
                    FrmAddMsg frm = new FrmAddMsg(id, UserID, HeadImage, UserName, SameFriend);
                    frm.Show();
                }
                else
                {
                    MessageBox.Show("已是您的好友,请勿重复添加!");
                }
            }
        }
예제 #2
0
        private void getrecentfriend()
        {
            FileStream   fs    = new FileStream(Application.StartupPath + "\\" + "friend.txt", FileMode.Open, FileAccess.Read);
            StreamReader sr    = new StreamReader(fs);
            int          index = 0;

            while (sr.Peek() > -1)
            {
                string   tmp = sr.ReadLine();
                string[] res = tmp.Split(' ');

                foreach (Model.friendInfo fri in myFriends)
                {
                    if (this._user.userID == Convert.ToInt32(res[0]) && res[1] == fri.friendID.ToString())
                    {
                        BLL.friendInfo          bllfrq         = new BLL.friendInfo();
                        List <Model.friendInfo> bllfq          = bllfrq.GetModelList("userid=" + _user.userID + "and friendid=" + Convert.ToInt32(res[1]) + "");
                        UCFriendInfo            ucRecentfriend = new UCFriendInfo(_user, this);
                        BLL.userInfo            frueser        = new BLL.userInfo();
                        Model.userInfo          u = frueser.GetModel(bllfq[0].friendID);
                        ucRecentfriend.Top = ucRecentfriend.Height * index;

                        ucRecentfriend.UserName     = bllfq[0].friendName;
                        ucRecentfriend.NickName     = bllfq[0].friendName;
                        ucRecentfriend.UserShuoshuo = u.userShuoshuo;
                        ucRecentfriend.FriendInfo   = u;
                        ucRecentfriend.HeadImage    = this.imageList1.Images[Convert.ToInt32(u.userHeadImage)];
                        this.pnrecentfriend.Controls.Add(ucRecentfriend);
                        ucRecentfriend.MouseClick += new MouseEventHandler(ucf_MouseClick);
                        //ucRecentfriend.MouseLeave += new EventHandler(ucf_MouseLeave);
                        //ucRecentfriend.myDBClick += new UCFriendInfo.delDBClick(ucf_myDBClick);
                        //ucRecentfriend.MouseEnter += new EventHandler(ucf_MouseEnter);

                        index++;
                    }
                }
            }
            sr.Close();
            fs.Close();
        }
예제 #3
0
        public void getFriendList()
        {
            BLL.friendInfo bllFriend = new BLL.friendInfo();
            myFriends = bllFriend.GetModelList("userID =" + this._user.userID.ToString());
            int index = 0;

            ucflFriend.Clear();
            foreach (Model.friendInfo f in myFriends)
            {
                UCFriendInfo ucF = new UCFriendInfo();

                RelFriendToFrmTalk ft          = new RelFriendToFrmTalk();
                BLL.userInfo       bllUserInfo = new BLL.userInfo();
                Model.userInfo     friend      = bllUserInfo.GetModel(f.friendID);
                if (friend.userState != 2 && friend.userState != 3)
                {
                    ucF.Top          = ucF.Height * index;
                    ucF.HeadImage    = this.imageList1.Images[Convert.ToInt32(friend.userHeadImage)];
                    ucF.UserName     = f.friendName;
                    ucF.myDBClick   += new UCFriendInfo.delDBClick(ucF_myDBClick);
                    ucF.MouseClick  += new MouseEventHandler(ucF_MouseClick);
                    ucF.FriendInfo   = friend;
                    ucF.NickName     = f.friendName;
                    ucF.UserShuoshuo = friend.userShuoshuo;
                    ucF.FID          = f.ID;
                    if (ucF.UserShuoshuo.Length >= 10)
                    {
                        ucF.UserShuoshuo = ucF.UserShuoshuo.Substring(0, 10) + "...";
                    }
                    this.panel1.Controls.Add(ucF);
                    index++;

                    ft.FriendId       = f.friendID;
                    ft.IsOpenTalkForm = false;
                    ft.Frm            = null;
                    tbFriendTalkInfo.Add(ft);
                    ucF.UserID = f.friendID;
                    ucflFriend.Add(ucF);
                }
            }
            foreach (Model.friendInfo f in myFriends)
            {
                UCFriendInfo       ucF         = new UCFriendInfo();
                RelFriendToFrmTalk ft          = new RelFriendToFrmTalk();
                BLL.userInfo       bllUserInfo = new BLL.userInfo();
                Model.userInfo     friend      = bllUserInfo.GetModel(f.friendID);
                if (friend.userState == 2 || friend.userState == 3)
                {
                    ucF.Top          = ucF.Height * index;
                    ucF.HeadImage    = this.imageList1.Images[Convert.ToInt32(friend.userHeadImage) + 110];
                    ucF.UserName     = f.friendName;
                    ucF.myDBClick   += new UCFriendInfo.delDBClick(ucF_myDBClick);
                    ucF.MouseClick  += new MouseEventHandler(ucF_MouseClick);
                    ucF.FriendInfo   = friend;
                    ucF.NickName     = f.friendName;
                    ucF.UserShuoshuo = friend.userShuoshuo;
                    ucF.FID          = f.ID;
                    if (ucF.UserShuoshuo.Length >= 10)
                    {
                        ucF.UserShuoshuo = ucF.UserShuoshuo.Substring(0, 10) + "...";
                    }
                    this.panel1.Controls.Add(ucF);
                    index++;

                    ft.FriendId       = f.friendID;
                    ft.IsOpenTalkForm = false;
                    ft.Frm            = null;
                    tbFriendTalkInfo.Add(ft);
                    ucF.UserID = f.friendID;
                    ucflFriend.Add(ucF);
                }
            }
        }
예제 #4
0
        private void btnSearch_Click_1(object sender, EventArgs e)
        {
            this.panFriend.Controls.Clear();

            if (cmbFriend.Text == "按用户ID查询")
            {
                BLL.userInfo          blluser = new BLL.userInfo();
                List <Model.userInfo> alluser = blluser.GetModelList("userID like'%" + this.txtID.Text + "%'");
                int index = 0;


                for (int j = 0; j < alluser.Count; j++)
                {
                    int                     i          = 0;
                    BLL.friendInfo          bll        = new BLL.friendInfo();
                    List <Model.friendInfo> userfriend = bll.GetModelList(" userID= " + this._user.userID);
                    List <Model.friendInfo> friend     = bll.GetModelList(" userID= " + alluser[j].userID);
                    foreach (Model.friendInfo uf in userfriend)
                    {
                        foreach (Model.friendInfo f in friend)
                        {
                            if (uf.friendID == f.friendID)
                            {
                                i++;
                            }
                        }
                    }

                    UCFriendSearchList uc = new UCFriendSearchList();
                    uc.MouseEnter   += new EventHandler(uc_MouseEnter);
                    uc.Top           = j / 3 * uc.Height;
                    uc.Left          = j % 3 * uc.Width;
                    uc.HeadImage     = this._frm.imageList1.Images[Convert.ToInt16(alluser[j].userHeadImage)];
                    uc.UserID        = alluser[j].userID;
                    uc.UserName      = alluser[j].userName;
                    uc.Iname         = this._user.userName;
                    uc.Id            = this._user.userID;
                    uc.SameFriend    = i;
                    uc.Iimage        = this._frm.imageList1.Images[Convert.ToInt16(this._user.userHeadImage)];
                    uc.FrmtalkIsOpen = false;
                    ucflFriend.Add(uc);
                    ;
                    this.panFriend.Controls.Add(uc);
                    index++;
                }
            }
            if (cmbFriend.Text == "按用户NAME查询")
            {
                BLL.userInfo          blluser = new BLL.userInfo();
                List <Model.userInfo> alluser = blluser.GetModelList("userName like'%" + this.txtID.Text + "%'");
                int index = 0;

                for (int j = 0; j < alluser.Count; j++)
                {
                    int                     i          = 0;
                    BLL.friendInfo          bll        = new BLL.friendInfo();
                    List <Model.friendInfo> userfriend = bll.GetModelList(" userID= " + this._user.userID);
                    List <Model.friendInfo> friend     = bll.GetModelList(" userID= " + alluser[j].userID);
                    foreach (Model.friendInfo uf in userfriend)
                    {
                        foreach (Model.friendInfo f in friend)
                        {
                            if (uf.friendID == f.friendID)
                            {
                                i++;
                            }
                        }
                    }

                    UCFriendSearchList uc = new UCFriendSearchList();
                    uc.MouseEnter   += new EventHandler(uc_MouseEnter);
                    uc.Top           = j / 3 * uc.Height;
                    uc.Left          = j % 3 * uc.Width;
                    uc.HeadImage     = this._frm.imageList1.Images[Convert.ToInt16(alluser[j].userHeadImage)];
                    uc.UserID        = alluser[j].userID;
                    uc.UserName      = alluser[j].userName;
                    uc.Id            = this._user.userID;
                    uc.Iname         = this._user.userName;
                    uc.SameFriend    = i;
                    uc.Iimage        = this._frm.imageList1.Images[Convert.ToInt16(this._user.userHeadImage)];
                    uc.FrmtalkIsOpen = false;
                    ucflFriend.Add(uc);
                    this.panFriend.Controls.Add(uc);
                    index++;
                }
            }
        }