private void headpicture_Click(object sender, EventArgs e) { UserBLL udb = new UserBLL(); bool bSuccess = false; OpenFileDialog openfile = new OpenFileDialog(); openfile.Filter = "图片文件(*.jpg,*.gif,*.bmp)|*.jpg|*.gif|*.bmp"; openfile.InitialDirectory = "C:\\"; if (openfile.ShowDialog() == DialogResult.OK) { FileInfo pic = new FileInfo(openfile.FileName); string dz = s + "//" + pic.Name; pic.CopyTo(dz, true); bSuccess = udb.ChangeHeadPicture(dz, udb.user.UserID.ToString()); } if (bSuccess) { MessageBox.Show("更换头像成功!"); main_Load(sender, e); } else { MessageBox.Show("更换头像失败!"); } }
private void DeleteGroup_Load(object sender, EventArgs e) { UserBLL udb=new UserBLL (); DataTable dt = new DataTable(); dt = udb.DB.GetData(string.Format("select * from FriendGroup where UserID={0}", udb.user.UserID)); for (int i = 0; i < dt.Rows.Count; i++) { Group_skinComboBox.Items.AddRange(new object[] { dt.Rows[i]["GrouName"] }); } }
private void button_ok_Click(object sender, EventArgs e) { bool bSuccess = false; UserBLL udb = new UserBLL(); bSuccess=udb.ChangeAlternateName(UserID, AlternateName_TextBox.Text); if (bSuccess == false) { MessageBox.Show("修改备注名失败!"); } else { MessageBox.Show("修改备注名成功!"); this.Hide(); } }
private void OK_Click(object sender, EventArgs e) { bool bSuccess = false; UserBLL udb = new UserBLL(); bSuccess = udb.AddGroup(udb.user.UserID.ToString(),GroupName_TextBox.Text); if (bSuccess) { MessageBox.Show("添加分组成功!"); this.Hide(); } else { MessageBox.Show("删除分组失败!"); } }
private void button1_Click(object sender, EventArgs e) { bool bSuccess = false; UserBLL udb = new UserBLL(); string sGroupName = string.Empty; sGroupName = Group_skinComboBox.Text; bSuccess = udb.DeletedGroup(sGroupName,udb.user.UserID.ToString()); if (bSuccess) { MessageBox.Show("删除好友成功!"); this.Hide(); } else { MessageBox.Show("删除好友失败!"); } }
/// <summary> /// 添加好友 /// </summary> /// <param name="sNickName">好友昵称</param> private void add_friend(string sNickName) { UserBLL udb=new UserBLL (); string sReSql = string.Empty; string SorT = string.Empty; DataTable dt = new DataTable(); string FriendId=string.Empty; FriendId = udb.GetFriendID(sNickName); SorT = udb.GetSorT(sNickName); bool bSuccess = udb.AddFriend(udb.user.UserID.ToString(), FriendId,SorT); if (bSuccess) { MessageBox.Show("添加好友成功!"); } else { MessageBox.Show("该好友已存在!"); } }
private void button1_Click(object sender, EventArgs e) { string UserId = string.Empty; error_username .Text= ""; error_password .Text= ""; error_password2.Text = ""; error_identity.Text = ""; UserBLL udb = new UserBLL(); bool bSuccess = false; string[] sMessage = { "", "", "", "", "", "" }; udb.user.UserName = username_textBox.Text; udb.user.PassWord1 = passwd_textbox.Text; udb.user.PassWord2 = passwd_textbox2.Text; udb.user.PhoneNumber = phonenum_textbox.Text; udb.user.Identity = Identity_comboBox.Text; udb.user.Email = email_textbox.Text; udb.user.BirthDay = birthday_textbox.Text; udb.user.Sex = sex_comboBox.Text; bSuccess = udb.AddUserInfo(udb.user.UserName, udb.user.PassWord1, udb.user.PassWord2, udb.user.Email, udb.user.PhoneNumber, udb.user.BirthDay, udb.user.Identity, udb.user.Sex, ref sMessage); if (bSuccess) { MessageBox.Show("注册成功!"); Close(); } else { //显示错误信息 if (string.IsNullOrEmpty(sMessage[2])) error_password2.Text = sMessage[4]; else error_password2.Text = sMessage[2]; error_password.Text = sMessage[1]; error_identity.Text = sMessage[3]; if (string.IsNullOrEmpty(sMessage[0])) error_username.Text = sMessage[5]; else error_username.Text = sMessage[0]; } }
private void button2_Click(object sender, EventArgs e) { picture_head1.Image = null; item_name1.Text = null; introduction1.Text = null; picture_head2.Image = null; item_name2.Text = null; introduction2.Text = null; UserBLL udb = new UserBLL(); string sName = string.Empty; sName = search_textBox1.Text; DataTable dt = new DataTable(); dt = udb.SearchUser(search_textBox1.Text, "0"); if (dt.Rows.Count == 1) { picture_head1.Image = IM.Properties.Resources.search_teacher; item_name1.Text = dt.Rows[0]["UserNickName"].ToString(); introduction1.Text = dt.Rows[0]["UserPersonalMessage"].ToString(); add_button1.Visible = true; picture_head2.Image = null; item_name2.Text = null; introduction2.Text = null; add_button2.Visible = false; } if (dt.Rows.Count == 2) { picture_head1.Image = IM.Properties.Resources.search_teacher; item_name1.Text = dt.Rows[0]["UserNickName"].ToString(); introduction1.Text = dt.Rows[0]["UserPersonalMessage"].ToString(); add_button1.Visible = true; picture_head2.Image = IM.Properties.Resources.search_teacher; item_name2.Text = dt.Rows[1]["UserNickName"].ToString(); introduction2.Text = dt.Rows[1]["UserPersonalMessage"].ToString(); add_button2.Visible = false; } if (dt.Rows.Count == 0) { add_button1.Visible = false; add_button2.Visible = false; MessageBox.Show("未找到该用户!"); } }
private void frmChat_Load(object sender, EventArgs e) { UserBLL udb = new UserBLL(); //聊天对象信息表 DataTable dt = new DataTable(); //用户好友列表 DataTable dt1 = new DataTable(); //用户信息表 DataTable dt2 = new DataTable(); dt = udb.Userinfo(ChatUserID); dt1 = udb.GetFriendShipInfo(udb.user.UserID.ToString(), ChatUserID.ToString()); dt2 = udb.Userinfo(udb.user.UserID); Text = "与" + dt1.Rows[0]["AlternateName"] + "聊天中"; FriendName.Text = dt1.Rows[0]["AlternateName"].ToString(); UserName.Text = dt2.Rows[0]["UserNickName"].ToString(); if (string.IsNullOrEmpty(dt.Rows[0]["HeadPicture"].ToString())) { FriendHead.ImageLocation = s + "\\search_teacher.jpg"; } else { FriendHead.ImageLocation = dt.Rows[0]["HeadPicture"].ToString(); } if (string.IsNullOrEmpty(dt2.Rows[0]["HeadPicture"].ToString())) { UserHead.ImageLocation = s + "\\search_teacher.jpg"; } else { UserHead.ImageLocation = dt2.Rows[0]["HeadPicture"].ToString(); } hostname = Dns.GetHostName(); IPAddress[] ip = Dns.GetHostAddresses(hostname); RegisterMsg registmsg = new RegisterMsg(); ClassMsg msg = new ClassMsg(); registmsg.UserName = "******"; registmsg.PassWord = "******"; byte[] registdata = new ClassSerializers().SerializeBinary(registmsg).ToArray(); msg.sendKind = SendKind.SendCommand; msg.msgCommand = MsgCommand.Registering; msg.Data = registdata; serID = "192.168.1.187"; udpSocket1.Send(IPAddress.Parse(serID), 11000, new ClassSerializers().SerializeBinary(msg).ToArray()); }
private void 移动联系人至ToolStripMenuItem_MouseEnter(object sender, EventArgs e) { 移动联系人至ToolStripMenuItem.DropDownItems.Clear(); UserBLL udb = new UserBLL(); DataTable dt = new DataTable(); dt = udb.DB.GetData(string.Format("select * from friendgroup where userID={0}", udb.user.UserID)); for (int i = 0; i < dt.Rows.Count; i++) { ToolStripMenuItem groupitem = new ToolStripMenuItem(); groupitem.Name = "Group" + i.ToString(); groupitem.Size = new System.Drawing.Size(152, 24); groupitem.Text = dt.Rows[i]["GrouName"].ToString(); groupitem.Tag = dt.Rows[i]["GrouID"]; 移动联系人至ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { groupitem}); } }
private void 移动联系人至ToolStripMenuItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { bool bSuccess = false; UserBLL udb = new UserBLL(); string sItemID = string.Empty; sItemID = chatListBox1.SelectSubItem.ID.ToString(); bSuccess = udb.ChangeGroup(e.ClickedItem.Tag.ToString(), sItemID); if (bSuccess) { MessageBox.Show("移动分组成功!"); main_Load(sender, e); } else { MessageBox.Show("移动分组失败!"); } }
private void 删除此好友ToolStripMenuItem_Click(object sender, EventArgs e) { bool bSuccess = false; UserBLL udb = new UserBLL(); string sItemID = string.Empty; sItemID = chatListBox1.SelectSubItem.ID.ToString(); bSuccess = udb.DeleteFriend(sItemID); if (bSuccess) { MessageBox.Show("删除好友成功!"); main_Load(sender, e); } else { MessageBox.Show("删除好友失败!"); } }
private void main_Load(object sender, EventArgs e) { UserBLL udb = new UserBLL(); ClassMsg msg = new ClassMsg(); LoginMsg loginmsg = new LoginMsg(); msg.sendKind = SendKind.SendCommand; msg.msgCommand = MsgCommand.GetFriendList; msg.SID = udb.user.UserID.ToString(); loginmsg.UserName = udb.user.UserName; byte[] loginbyte = new ClassSerializers().SerializeBinary(loginmsg).ToArray(); msg.Data = loginbyte; udpSocket1.Send(IPAddress.Parse(serIP),10001,new ClassSerializers().SerializeBinary(msg).ToArray()); ////用户信息表 //DataTable dt = new DataTable(); ////好友表 //DataTable dt1 = new DataTable(); ////分组信息表 //DataTable dt2 = new DataTable(); ////好友详细信息表 //DataTable dt3 = new DataTable(); //dt = udb.Userinfo(udb.user.UserID); //Name_skinLable.Text = udb.user.UserNickName; //PersonalMessage.Text = udb.user.UserPersonalMessage; //chatListBox1.Items.Clear(); //dt2 = udb.DB.GetData(string.Format("select * from friendgroup where userID={0}", udb.user.UserID)); //if (string.IsNullOrEmpty(dt.Rows[0]["HeadPicture"].ToString())) //{ // headpicture.ImageLocation = s + "\\search_teacher.jpg"; //} //else //{ // headpicture.ImageLocation = dt.Rows[0]["HeadPicture"].ToString(); //} //for (int i = 0; i < dt2.Rows.Count; i++) //{ // ChatListItem chatlist1 = new ChatListItem(); // chatlist1.Bounds = new System.Drawing.Rectangle(0, 53, 363, 25); // chatlist1.IsTwinkleHide = false; // chatlist1.OwnerChatListBox = this.chatListBox1; // chatlist1.Text = dt2.Rows[i]["GrouName"].ToString(); // chatlist1.TwinkleSubItemNumber = 0; // chatListBox1.Items.AddRange(new ChatListItem[] { chatlist1 }); // dt1 = udb.GetFriendList(udb.user.UserName, dt2.Rows[i]["GrouID"].ToString()); // for (int l = 0; l < dt1.Rows.Count; l++) // { // dt3 = udb.DB.GetData(string.Format("select * from user where UserID={0}", dt1.Rows[l]["Use_UserID"])); // ChatListSubItem chatListSubItem1 = new ChatListSubItem(); // chatListSubItem1.Bounds = new System.Drawing.Rectangle(0, 0, 0, 0); // chatListSubItem1.DisplayName = dt1.Rows[l]["Alternatename"].ToString(); // chatListSubItem1.HeadImage = null; // chatListSubItem1.HeadRect = new System.Drawing.Rectangle(0, 0, 0, 0); // chatListSubItem1.ID = Convert.ToInt32(dt1.Rows[l]["Use_UserID"]); // chatListSubItem1.IpAddress = null; // chatListSubItem1.IsTwinkle = false; // chatListSubItem1.IsTwinkleHide = false; // chatListSubItem1.NicName = dt3.Rows[0]["UserNickName"].ToString(); // chatListSubItem1.OwnerListItem = chatlist1; // chatListSubItem1.PersonalMsg = dt3.Rows[0]["UserPersonalMessage"].ToString(); // chatListSubItem1.Status = ChatListSubItem.UserStatus.Online; // chatListSubItem1.Tag = null; // chatListSubItem1.TcpPort = 0; // chatListSubItem1.UpdPort = 0; // chatlist1.SubItems.AddRange(new ChatListSubItem[] {chatListSubItem1}); // } //} }