//增加一条评论信息
        protected void BtnAddComment_Click(object sender, EventArgs e)
        {
            //获取本机IP
            IPHostEntry ipe = Dns.GetHostEntry(Dns.GetHostName());
            IPAddress ipa = ipe.AddressList[0];
            string UserID = ddUserList.SelectedValue.ToString();
            string knowledgeID = ddKnowledgeList.SelectedValue.ToString();
            string commentContent = tbComment.Text.Trim().ToString();
            CTKnowledgePetComment knowledgeComment = new CTKnowledgePetComment();
            knowledgeComment.CommentID = Guid.NewGuid().ToString();
            knowledgeComment.CommentContent = commentContent;
            knowledgeComment.CommentTime = DateTime.Now.ToString();
            knowledgeComment.IsVisible = true;
            knowledgeComment.UserID = UserID;
            knowledgeComment.KnwoledgeID = knowledgeID;
            knowledgeComment.IP = ipa.ToString();

            KnowledgePetComment CknowledgePetCommnet=new KnowledgePetComment();
            int insertStatus = 0;
            insertStatus=CknowledgePetCommnet.InsertComment(knowledgeComment);
            if (insertStatus == 1)
            {
                Response.Write("<script>alert('添加成功!')</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败!')</script>");
            }
        }
 protected void Button3_Click(object sender, EventArgs e)
 {
     //获取本机IP
     IPHostEntry ipe = Dns.GetHostEntry(Dns.GetHostName());
     IPAddress ipa = ipe.AddressList[0];
     string content = tb_Conetent.Text.Trim().ToString();
     string userID = DropDownList2.SelectedValue;
     string knowledgeID = DropDownList1.SelectedValue;
     string commentID=Guid.NewGuid().ToString();
     string ip = ipa.ToString();
     bool visible = true;
     CTKnowledgePetComment comment = new CTKnowledgePetComment();
     comment.IsVisible = visible;
     comment.KnwoledgeID = knowledgeID;
     comment.UserID = userID;
     comment.CommentID = commentID;
     comment.CommentContent = content;
     comment.CommentTime = DateTime.Now.ToString(); ;
     comment.IP = ip;
     KnowledgePetComment knowledgecomment = new KnowledgePetComment();
     int insertStatus=  knowledgecomment.InsertComment(comment);
     if (insertStatus == 1)
     {
         Response.Write("<script>alert('添加成功!')</script>");
     }
     else
     {
         Response.Write("<script>alert('添加失败!')</script>");
     }
 }
 protected void Button1_Click(object sender, EventArgs e)
 {
     string knowledgeID = DropDownList1.SelectedValue.ToString();
     KnowledgePetComment comment = new KnowledgePetComment();
     List<CTKnowledgePetComment> list = new List<CTKnowledgePetComment>();
     list = comment.GetAllCommentByKnowledge(knowledgeID);
     GridView1.DataSource = list;
     GridView1.DataBind();
 }
        protected void BtnDelete_Click(object sender, EventArgs e)
        {
            KnowledgePetComment knowledgePetComment = new KnowledgePetComment();
            for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
            {
                CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox");
                if (cbox.Checked == true)
                {
                    string sqlstr = GridView1.DataKeys[i].Value.ToString();

                }
            }
            string knowledgeID = ddKnowledgeList.SelectedValue.ToString();
            GridViewBind(1, knowledgeID);
        }
 //编辑按钮单机事件
 protected void BtnEdit_Click1(object sender, EventArgs e)
 {
     string commentID = string.Empty;
     for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
     {
         CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox");
         if (cbox.Checked == true)
         {
             commentID = GridView1.DataKeys[i].Value.ToString();
             break;
         }
     }
     KnowledgePetComment petcomment = new KnowledgePetComment();
     CTKnowledgePetComment comment = new CTKnowledgePetComment();
     comment = petcomment.GetKnowledgePetCommentByCommentID(commentID);
     tbKnowledgeID.Text = comment.KnwoledgeID;
     tbCommentID.Text = comment.CommentID;
     tbCommentTime.Text = comment.CommentTime;
     tbContent.Text = comment.CommentContent;
     tbIP.Text = comment.IP;
     tbUserID.Text = comment.UserID;
     cbIsVisible.Checked = comment.IsVisible;
 }
 //保存按钮事件
 protected void BtnSave_Click(object sender, EventArgs e)
 {
     string knowledgeID = tbKnowledgeID.Text.Trim().ToString();
     string commentID = tbCommentID.Text.Trim().ToString();
     string commentTime = tbCommentTime.Text.Trim().ToString();
     string commentIP = tbIP.Text.Trim().ToString();
     string commentContent = tbContent.Text.Trim().ToString();
     string commentUser = tbUserID.Text.Trim().ToString();
     bool isVisible = bool.Parse(cbIsVisible.Checked.ToString());
     CTKnowledgePetComment comment = new CTKnowledgePetComment();
     comment.KnwoledgeID = knowledgeID;
     comment.CommentContent = commentContent;
     comment.CommentID = commentID;
     comment.IP = commentIP;
     comment.UserID = commentUser;
     comment.CommentTime = commentTime;
     comment.IsVisible = isVisible;
     KnowledgePetComment knowledgePetCommnet = new KnowledgePetComment();
     int updateStatus = knowledgePetCommnet.EditKnowledgeComment(comment);
     if (updateStatus == 1)
     {
         Response.Write("<script>alert('保存成功!')</script>");
     }
     else
     {
         Response.Write("<script>alert('保存失败!')</script>");
     }
 }