private void bt_news_Click(object sender, EventArgs e) { //发送请求消息的请求 string str_msg = "getnews"; Frm_login.send_data(str_msg); }
private void bt_modify_Click(object sender, EventArgs e) { //获取用户输入的信息 string str_pass = tb_pass.Text; string str_name = tb_name.Text; //检测密码、昵称的长度 if (str_pass.Length < 6) { MessageBox.Show("密码不能少于6位"); return; } if (str_name.Length < 1) { MessageBox.Show("昵称不能为空"); return; } //如果用户资料发生了变化,则发送用户的新数据给服务器 Frm_main frm_main = (Frm_main)(this.Owner); if (str_pass != frm_main.self_pass || str_name != frm_main.self_name || head_index != frm_main.self_head) { string str_msg = "modify&" + str_pass + "&" + str_name + "&" + head_index; Frm_login.send_data(str_msg); } Close(); }
private void bt_refuse_Click(object sender, EventArgs e) { //拒绝好友申请、加群申请 string str_msg = String.Format(@"operatenews&0&{0}&{1}&{2}", news_type, with_userid, with_groupid); Frm_login.send_data(str_msg); Close(); }
//加群按钮的点击处理 private void bt_add_Click(object sender, EventArgs e) { if (find_groupid.Length > 0) { //发送查找请求给服务器 string str_msg = String.Format("addgroup&{0}", find_groupid); Frm_login.send_data(str_msg); } }
//加好友按钮的点击处理 private void bt_add_Click(object sender, EventArgs e) { if (find_userid.Length > 0) { //发送添加好友请求给服务器 string str_msg = String.Format("addfriend&{0}", find_userid); Frm_login.send_data(str_msg); } }
private void bt_find_Click(object sender, EventArgs e) { //获取用户输入的信息 string str_input = tb_input.Text; if (str_input.Length < 8) { return; } //发送查找请求给服务器 string str_msg = "findgroup&" + str_input; Frm_login.send_data(str_msg); }
//发送聊天信息 private void bt_send_Click(object sender, EventArgs e) { string str_chat = rtxt_chat.Text; if (str_chat.Length < 1) { //如果输入框没有内容,则不发送 return; } //清空输入框 rtxt_chat.Clear(); //将本人发送的信息显示到聊天框 string str_self_chat = self_name + " " + DateTime.Now.ToString() + "\n " + str_chat + "\n\n"; rtxt_msg.AppendText(str_self_chat); rtxt_msg.Focus(); string str_msg = "sendchat&" + friend_userid + "&" + str_chat; Frm_login.send_data(str_msg); }
//注册按钮点击处理 private void bt_register_Click(object sender, EventArgs e) { //获取用户输入的信息 string str_account = tb_account.Text; string str_pass = tb_pass.Text; string str_name = tb_name.Text; string str_sex = "2"; //性别 1-男 2-女 if (rb_man.Checked) { str_sex = "1"; } string str_head = head_index.ToString(); //检测账号、密码、昵称的长度 if (str_account.Length < 8) { MessageBox.Show("账号不能少于8位"); return; } if (str_pass.Length < 6) { MessageBox.Show("密码不能少于6位"); return; } if (str_name.Length < 1) { MessageBox.Show("昵称不能为空"); return; } //发送用户的注册信息给服务器 string str_msg = "register&" + str_account + "&" + str_pass + "&" + str_name + "&" + str_sex + "&" + str_head; Frm_login.send_data(str_msg); }
//向服务端请求好友列表 public void get_friendlist() { string str_msg = "getfriends"; Frm_login.send_data(str_msg); }