Ejemplo n.º 1
0
        //根据commentID编辑对应的评论信息
        public int EditKnowledgePetComment(CTKnowledgePetComment knowledgeComment)
        {
            int editStatus = 0;
               SqlParameter[] parms = null;
               parms = new SqlParameter[]
                            {
                                new SqlParameter("@CommentID",SqlDbType.NVarChar,20),
                                new SqlParameter("@CommentContent",SqlDbType.NVarChar,100),
                                new SqlParameter("@IsVisible",SqlDbType.Bit),
                            };

               parms[0].Value = knowledgeComment.CommentID;
               parms[1].Value = knowledgeComment.CommentContent;
               parms[2].Value = knowledgeComment.IsVisible;

               try
               {
               using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringOrderDistributedTransaction))
               {
                   editStatus = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, SQL_UPDATE_KnowledgeComment, parms);
               }
               }
               catch (Exception ex)
               {
               }

               return editStatus;
        }
        //增加一条评论信息
        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>");
            }
        }
Ejemplo n.º 3
0
 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 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>");
     }
 }
Ejemplo n.º 6
0
        //根据commentID 获取相应的comment信息
        public CTKnowledgePetComment GetKnowledgePetCommentByCommentID(string commentID)
        {
            CTKnowledgePetComment knowledgeComment = new CTKnowledgePetComment();

               SqlParameter parm = new SqlParameter();
               parm.Value = commentID;
               parm.ParameterName=PARM_KNOWLEDGECOMMENT_ID;
               parm.SqlDbType=SqlDbType.NVarChar;

               try
               {
               using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_KnowledgeComment_BY_COMMENTID, parm))
               {
                   while (rdr.Read())
                   {
                       knowledgeComment.UserID = rdr["UserID"].ToString();
                       knowledgeComment.CommentID = rdr["CommentID"].ToString();
                       knowledgeComment.CommentTime = rdr["CommentTime"].ToString();
                       knowledgeComment.CommentContent = rdr["CommentContent"].ToString();
                       knowledgeComment.IP = rdr["IP"].ToString();
                       knowledgeComment.IsVisible = bool.Parse(rdr["IsVisible"].ToString());
                       knowledgeComment.KnwoledgeID = rdr["KnowledgeID"].ToString();

                   }
               }
               }
               catch (Exception ex)
               {
               }
               return knowledgeComment;
        }
Ejemplo n.º 7
0
        //插入一条评论信息
        public int InsertKnowledgePetComment(CTKnowledgePetComment knowledgeComment)
        {
            int insertStatus = 0;
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                            {
                                new SqlParameter("@CommentID",SqlDbType.NVarChar,20),
                                new SqlParameter("@UserID",SqlDbType.NVarChar,20),
                                new SqlParameter("@KnowledgeID",SqlDbType.NVarChar,20),
                                new SqlParameter("@CommentTime",SqlDbType.DateTime ),
                                new SqlParameter("@IP",SqlDbType.NVarChar,20),
                                new SqlParameter("@CommentContent",SqlDbType.NVarChar,100),
                                new SqlParameter("@IsVisible",SqlDbType.Bit),
                            };

            parms[0].Value = knowledgeComment.CommentID;
            parms[1].Value = knowledgeComment.UserID;
            parms[2].Value = knowledgeComment.KnwoledgeID;
            parms[3].Value = knowledgeComment.CommentTime;
            parms[4].Value = knowledgeComment.IP;
            parms[5].Value = knowledgeComment.CommentContent;
            parms[6].Value = knowledgeComment.IsVisible;
            try
            {
                using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringOrderDistributedTransaction))
                {
                    insertStatus = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, SQL_INSERT_KnowledgeComment, parms);
                }
            }
            catch (Exception ex)
            {
            }
            return insertStatus;
        }
Ejemplo n.º 8
0
        public List<CTKnowledgePetComment> GetKnowledgePetCommentListByUserID(string UserID)
        {
            List<CTKnowledgePetComment> list = new List<CTKnowledgePetComment>();
            SqlParameter parm = new SqlParameter(PARM_USER_ID, SqlDbType.NVarChar);
            parm.Value = UserID;

            //execute the query
            using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_KnowledgeComment_BY_USERID, parm))
            {
                while (rdr.Read())
                {
                    CTKnowledgePetComment petComment = new CTKnowledgePetComment();
                    petComment.UserID = rdr["UserID"].ToString();
                    petComment.CommentID = rdr["CommentID"].ToString();
                    petComment.CommentTime = rdr["CommentTime"].ToString();
                    petComment.CommentContent = rdr["CommentContent"].ToString();
                    petComment.IP = rdr["IP"].ToString();
                    petComment.IsVisible = bool.Parse(rdr["IsVisible"].ToString());
                    list.Add(petComment);
                }
            }

            return list;
        }
Ejemplo n.º 9
0
 //插入Comment信息
 public int InsertComment(CTKnowledgePetComment knowledgeComment)
 {
     return dal.InsertKnowledgePetComment(knowledgeComment);
 }
Ejemplo n.º 10
0
 //编辑comment的信息
 public int EditKnowledgeComment(CTKnowledgePetComment knowledgeComment)
 {
     return dal.EditKnowledgePetComment(knowledgeComment);
 }