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("已是您的好友,请勿重复添加!"); } } }
private void btnOK_Click(object sender, EventArgs e) { if (rbok.Checked == true) { BLL.friendRequest bll = new BLL.friendRequest(); Model.friendRequest mf = new Model.friendRequest(); mf.ID = this._frmr.ID; mf.NickName = this._frmr.NickName; mf.NumOfSameFriend = this._frmr.NumOfSameFriend; mf.receiveID = this._frmr.receiveID; mf.senderID = this._frmr.senderID; mf.ValidationInfo = this._frmr.ValidationInfo; mf.ValidationTime = this._frmr.ValidationTime; mf.Station = 2; bll.Update(mf); BLL.friendInfo bff = new BLL.friendInfo(); Model.friendInfo m = new Model.friendInfo(); m.friendID = this._frmr.senderID; m.userID = this._frmr.receiveID; m.friendName = this._user.userName; bff.Add(m); m.friendID = this._frmr.receiveID; m.userID = this._frmr.senderID; m.friendName = this._frmr.NickName; bff.Add(m); this.Close(); } if (rbno.Checked == true) { BLL.friendRequest bll = new BLL.friendRequest(); Model.friendRequest mf = new Model.friendRequest(); mf.ID = this._frmr.ID; mf.NickName = this._frmr.NickName; mf.NumOfSameFriend = this._frmr.NumOfSameFriend; mf.receiveID = this._frmr.receiveID; mf.senderID = this._frmr.senderID; mf.ValidationInfo = this._frmr.ValidationInfo; mf.ValidationTime = this._frmr.ValidationTime; mf.Station = 3; bll.Update(mf); this.Close(); } if (rbhulue.Checked == true) { BLL.friendRequest bll = new BLL.friendRequest(); Model.friendRequest mf = new Model.friendRequest(); mf.ID = this._frmr.ID; mf.NickName = this._frmr.NickName; mf.NumOfSameFriend = this._frmr.NumOfSameFriend; mf.receiveID = this._frmr.receiveID; mf.senderID = this._frmr.senderID; mf.ValidationInfo = this._frmr.ValidationInfo; mf.ValidationTime = this._frmr.ValidationTime; mf.Station = 4; bll.Update(mf); this.Close(); } }
private void 除好友ToolStripMenuItem_Click(object sender, EventArgs e) { UCFriendInfo ucf = (UCFriendInfo)currentRight; BLL.friendInfo bllfriend = new BLL.friendInfo(); int mf = ucf.FID; bllfriend.Delete(mf); this.panel1.Controls.Clear(); getFriendList(); }
private void btnOK_Click(object sender, EventArgs e) { BLL.friendInfo bff = new BLL.friendInfo(); Model.friendInfo mff = new Model.friendInfo(); mff.ID = this._fID; mff.friendName = this.txtName.Text; mff.userID = this._userID; mff.friendID = this._friendID; bff.Update(mff); this.Close(); this._frm.panel1.Controls.Clear(); this._frm.getFriendList(); }
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(); }
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); } } }
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++; } } }