//添加评论
        protected void AddComment_Click(object sender, EventArgs e)
        {
            if (Session["UserType"].ToString() != "CommonUser")
            {
                if (this.CommentTextBox.Text != "")
                {
                    CommonUserForInfo.UserService = new CommonUserService();
                    RegistedUser temp = new RegistedUser();
                    temp = (RegistedUser)Session["User"];
                    temp.Userservice = new RegisterUserService();

                    Comment newComment =new Comment();
                    //Message newMessage = new Message();
                    newComment.content = this.CommentTextBox.Text;
                    newComment.ID = System.Guid.NewGuid();
                    newComment.messageType = MessageType.comment;
                    newComment.state = MessageState.Unread;
                    newComment.userFrom = CommonUserForInfo.UserService.GetOtherUserInfo(temp.UserName);
                    //temp.UserName;
                    newComment.userTo = SellerUser;
                    newComment.registedUserID = TheCommodity.UserName;
                    newComment.commodityId = TheCommodity.ID;
                    List<Comment> singleComment = new List<Comment>();
                    singleComment.Add(newComment);
                    //成功插入消息

                   // if (temp.//.PublishMessage(singleMessage))
                    if(temp.Userservice.PublicComments(singleComment))
                    {
                        InitPageInfo();
                        this.AddComment2.Visible = false;
                        this.CommentTextBox.Text = "";
                        this.Label5.Text = "您已经成功插入评论";
                    }
                    else
                    {
                        this.Label5.Text = "评论插入失败";
                    }
                }
                else
                {
                    Response.Write("<script>alert('评论内容不为空')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('请先登录')</script>");

            }
        }
 //的到指定用户的所有 被评论
 public List<Comment> SearchUserAllCommment(string userName)
 {
     List<Comment> commentList = new List<Comment>();
     ISingleResult<getCommentByUserResult>result = dc.getCommentByUser(userName);
     foreach(getCommentByUserResult comment in result)
     {
         Comment newComment = new Comment();
         newComment.commodityId = comment.commodityid.Value;
         newComment.content = comment.content;
         newComment.ID = comment.id;
         newComment.messageType = MessageType.comment;
         newComment.state = (MessageState)comment.state.Value;
         // 获得目的用户信息
         ISingleResult<getUserByUserNameResult> resultTo = dc.getUserByUserName(comment.userto);
         RegistedUser commentToUser = new RegistedUser();
         foreach (getUserByUserNameResult userTo in resultTo)
         {
             commentToUser.Address = userTo.address;
             commentToUser.City = userTo.city;
             commentToUser.Email = userTo.email;
             commentToUser.NickName = userTo.nickname;
             //commentToUser.Password = null;
             commentToUser.Phone = userTo.phone;
             commentToUser.Portrait = userTo.portraitPath;
             //commentToUser.School =
             commentToUser.UserName = userTo.id;
            // UserZoneStyle otherStyle = new UserZoneStyle();
             //otherStyle.ID = null;
            // otherStyle.FileUrl = userTo.zonestyleid;
             //commentToUser.ZoneStyle = otherStyle;
         }
         newComment.userTo = commentToUser;
         ///////////////
         //获取发件人信息
         ISingleResult<getUserByUserNameResult> resultFrom = dc.getUserByUserName(comment.userfrom);
         RegistedUser commentFromUser = new RegistedUser();
         foreach (getUserByUserNameResult userFrom in resultFrom)
         {
             commentFromUser.Address = userFrom.address;
             commentFromUser.City = userFrom.city;
             commentFromUser.Email = userFrom.email;
             commentFromUser.NickName = userFrom.nickname;
             //commentFromUser.Password = null;
             commentFromUser.Phone = userFrom.phone;
             commentFromUser.Portrait = userFrom.portraitPath;
             //commentFromUser.School =
             commentFromUser.UserName = userFrom.id;
             // UserZoneStyle otherStyle = new UserZoneStyle();
             //otherStyle.ID = null;
             // otherStyle.FileUrl = userFrom.zonestyleid;
             //commentFromUser.ZoneStyle = otherStyle;
         }
         newComment.userFrom = commentFromUser;
      //////////////////////
         commentList.Add(newComment);
     }
     return commentList;
 }
        //获得用户的评论6 OK
        public List<Comment> GetUserAllComments(String UserID)
        {
            List<Comment> CommentList = new List<Comment>();
            //数据访存器
            DatabaseAccess.DataClasses1DataContext DBAccessor = new DataClasses1DataContext();

            try
            {
                //调用存储过程,获得未读评论
                ISingleResult<getCommentByUserResult> resultList = DBAccessor.getCommentByUser(UserID);
                foreach (getCommentByUserResult result in resultList)
                {
                    Comment comment = new Comment();
                    comment.ID = result.id;
                    comment.messageType = MessageType.comment;
                    comment.content = result.content;
                    comment.commodityId = (Guid)result.commodityid;//评论的商品
                    comment.registedUserID = UserID;//商品所属商家,即接受评论的商家
                    comment.userFrom = new RegistedUser();
                    comment.userFrom.UserName = result.userfrom;//发表留言的用户

                    //发评论用户的信息
                    ISingleResult<getUserByUserNameResult> UserInfoList = DBAccessor.getUserByUserName(result.userfrom);
                    foreach (getUserByUserNameResult UserInfo in UserInfoList)
                    {
                        comment.userFrom.NickName = UserInfo.nickname;
                        comment.userFrom.Phone = UserInfo.phone;
                        comment.userFrom.Address = UserInfo.address;
                        comment.userFrom.Email = UserInfo.email;
                        comment.userFrom.City = UserInfo.city;
                        comment.userFrom.Portrait = UserInfo.portraitPath;
                    }
                    CommentList.Add(comment);
                }

            }
            catch (Exception e)
            {

            }

            return CommentList;
        }