示例#1
0
 private void  除分组ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (Group_Users.Count == 1)
     {
         MessageBox.Show("您只有一个分组!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (MessageBox.Show("确认删除此分组以及该分组下的好友吗?", "询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
     {
         string  groupname = friendsTree.SelectedNode.Text;
         JObject param     = new JObject();
         param.Add("id", GlobalClass.CurrentUser.Id);
         param.Add("groupname", groupname);
         string result = HTTPUtil.SendPostRequest(Util.GetHttpUrl() + "/deletegroup", param.ToString());
         if (result == "删除成功!")
         {
             friendsTree.Nodes.Remove(friendsTree.SelectedNode);
             Group_Users.Remove(groupname);
         }
         else
         {
             MessageBox.Show(result, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
示例#2
0
        private void 添加分组ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddGroupForm af = new AddGroupForm();

            af.ShowDialog();
            if (af.IsOk)
            {
                if (Group_Users.ContainsKey(af.groupname))
                {
                    MessageBox.Show("已存在该分组!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                JObject param = new JObject();
                param.Add("id", GlobalClass.CurrentUser.Id);
                param.Add("groupname", af.groupname);
                string result = HTTPUtil.SendPostRequest(Util.GetHttpUrl() + "/addgroup", param.ToString());
                if (result == "添加成功!")
                {
                    friendsTree.Nodes.Add(af.groupname);
                    Group_Users.Add(af.groupname, new List <User>());
                    GlobalClass.Groups.Add(af.groupname);
                }
                else
                {
                    MessageBox.Show(result, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#3
0
 private void okBtn_Click(object sender, EventArgs e)
 {
     if (operationType == 1) //添加好友
     {
         MessageType msg = new MessageType(GlobalClass.CurrentUser.Id, destid, groupComBox.Text, 2);
         TCPUtil.socketSend.Send(msg.ToJsonBytes()); //发送好友请求
         MessageBox.Show("发送成功,请等待对方验证!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else if (operationType == 2) //被添加好友
     {
         JObject obj = new JObject();
         obj.Add("id", GlobalClass.CurrentUser.Id);
         obj.Add("destid", destid);
         obj.Add("thisgroup", groupComBox.Text);
         obj.Add("thatgroup", group);
         string result = HTTPUtil.SendPostRequest(Util.GetHttpUrl() + "/addfriends", obj.ToString());
         if (result == "添加成功!")
         {
             MessageBox.Show(result, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             issuccess = true;
         }
         else
         {
             MessageBox.Show(result, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
             issuccess = false;
         }
     }
     Close();
 }
示例#4
0
        private void searchBtn_Click(object sender, EventArgs e)
        {
            string searchStr;

            if (searchTB.ForeColor == Color.LightGray)
            {
                searchStr = "";
            }
            else
            {
                searchStr = searchTB.Text;
            }
            string sex    = sexCB.Text;
            string age    = ageCB.Text;
            bool   online = onlineCheckBox.Checked;

            JObject obj = new JObject();

            obj.Add("searchStr", searchStr);
            obj.Add("sex", sex);
            obj.Add("age", age);
            obj.Add("online", online);
            obj.Add("id", GlobalClass.CurrentUser.Id.ToString());
            obj.Add("notids", Util.GetIdInFriends());
            string usersStr = HTTPUtil.SendPostRequest(Util.GetHttpUrl() + "/searchusers", obj.ToString());

            FillDataGrid(usersStr);
        }
示例#5
0
        private void friendsTree_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            friendsTree.LabelEdit = false;
            string oldName = e.Node.Text;
            string newName = e.Label;

            if (newName == null) //没改
            {
                return;
            }
            if (string.IsNullOrEmpty(newName))
            {
                MessageBox.Show("组名不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                e.CancelEdit = true;
                return;
            }
            if (!Util.CheckChar(newName))
            {
                MessageBox.Show("组名不能包含标点符号!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                e.CancelEdit = true;
                return;
            }
            JObject obj = new JObject();

            obj.Add("id", GlobalClass.CurrentUser.Id);
            obj.Add("newname", newName);
            obj.Add("oldname", oldName);
            string result = HTTPUtil.SendPostRequest(Util.GetHttpUrl() + "/updategroup", obj.ToString());

            if (result == "修改成功!")
            {
                List <string> list = Group_Users.Keys.ToList();
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i] == oldName)
                    {
                        list[i] = newName;
                        break;
                    }
                }
                List <List <User> > userList = Group_Users.Values.ToList();
                Group_Users.Clear();
                for (int k = 0; k < list.Count; k++)
                {
                    Group_Users.Add(list[k], userList[k]);
                }
            }
            else
            {
                MessageBox.Show(result, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#6
0
 private void OkBtn_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(imageStr))
     {
         JObject obj = new JObject();
         obj.Add("id", GlobalClass.CurrentUser.Id);
         obj.Add("image", imageStr);
         string result = HTTPUtil.SendPostRequest(Util.GetHttpUrl() + "/updateimage", obj.ToString());
         if (result == "修改失败!")
         {
             MessageBox.Show(result, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         IsSuccess = true;
         GlobalClass.CurrentUser.Headimage = imageStr;
     }
     Close();
 }
示例#7
0
        private void okBtn_Click(object sender, EventArgs e)
        {
            string account = accTB.Text;

            string pwd = pwdTB.Text;

            string conPwd = conTB.Text;

            string name = nameTB.Text;

            DateTime birth = birthTP.Value;

            bool maleChecked = male.Checked;

            bool famaleChecked = famale.Checked;

            string fileName = pathTB.Text;

            if (string.IsNullOrEmpty(account))
            {
                MessageBox.Show("请输入账号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (string.IsNullOrEmpty(pwd))
            {
                MessageBox.Show("请输入密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (pwd.Length < 6)
            {
                MessageBox.Show("密码应不低于6位", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (string.IsNullOrEmpty(conPwd))
            {
                MessageBox.Show("请输入确认密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (conPwd != pwd)
            {
                MessageBox.Show("两次密码不一致", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (string.IsNullOrEmpty(account))
            {
                MessageBox.Show("请输入昵称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (!famaleChecked && !maleChecked)
            {
                MessageBox.Show("请选择性别", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            string headimage = "";

            if (!string.IsNullOrEmpty(fileName))
            {
                bool isExistFile = File.Exists(fileName);
                if (!isExistFile)
                {
                    MessageBox.Show("头像文件格式不正确或文件不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                Tuple <bool, string> tuple = Util.GetBase64StrByImage(fileName);
                if (tuple.Item1)
                {
                    MessageBox.Show("文件超过大小的限制", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                headimage = tuple.Item2;
            }
            char sex = maleChecked ? '男' : '女';

            JObject obj = new JObject();

            obj.Add("account", account);
            obj.Add("password", pwd);
            obj.Add("name", name);
            obj.Add("sex", sex);
            obj.Add("birthday", birth);
            obj.Add("headimage", headimage);
            JArray  jArray  = new JArray();
            JObject jObject = new JObject();

            jObject.Add("name", "我的好友");
            jObject.Add("members", "");
            jArray.Add(jObject);
            obj.Add("friends", jArray.ToString());
            string result = HTTPUtil.SendPostRequest(Util.GetHttpUrl() + "/regist", obj.ToString());

            if (result != "注册失败!")
            {
                MessageBox.Show("注册成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                StyleConfig sc = new StyleConfig()
                {
                    UserId     = int.Parse(result),
                    Color      = 0,
                    Size       = 12.0f,
                    FontFamily = "楷体",
                    FontStyle  = 1
                };
                StyleConfigManager.AddConfig(sc);
                this.Close();
            }
            else
            {
                MessageBox.Show("result", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }